Author: ornicar2
Date: 2010-02-10 20:41:05 +0100 (Wed, 10 Feb 2010)
New Revision: 27840

Modified:
   
plugins/diemPlugin/trunk/dmCorePlugin/lib/model/doctrine/PluginDmPageTable.class.php
Log:
[Diem]
- fixed possible issue if trying to create basic pages when service container 
is not loaded

Modified: 
plugins/diemPlugin/trunk/dmCorePlugin/lib/model/doctrine/PluginDmPageTable.class.php
===================================================================
--- 
plugins/diemPlugin/trunk/dmCorePlugin/lib/model/doctrine/PluginDmPageTable.class.php
        2010-02-10 19:40:13 UTC (rev 27839)
+++ 
plugins/diemPlugin/trunk/dmCorePlugin/lib/model/doctrine/PluginDmPageTable.class.php
        2010-02-10 19:41:05 UTC (rev 27840)
@@ -20,8 +20,8 @@
       $root = $this->create(array(
         'module' => 'main',
         'action' => 'root',
-        'name' => $this->getService('i18n')->__('Home'),
-        'title' => $this->getService('i18n')->__('Home'),
+        'name' => $this->tryToTranslate('Home'),
+        'title' => $this->tryToTranslate('Home'),
         'slug' => ''
       ));
 
@@ -40,8 +40,8 @@
       $page404 = $this->create(array(
         'module' => 'main',
         'action' => 'error404',
-        'name' => $this->getService('i18n')->__('Page not found'),
-        'title' => $this->getService('i18n')->__('Page not found'),
+        'name' => $this->tryToTranslate('Page not found'),
+        'title' => $this->tryToTranslate('Page not found'),
         'slug' => 'error404'
       ));
 
@@ -60,20 +60,29 @@
       $signinPage = $this->create(array(
         'module' => 'main',
         'action' => 'signin',
-        'name' => $this->getService('i18n')->__('Signin'),
-        'title' => $this->getService('i18n')->__('Signin'),
+        'name' => $this->tryToTranslate('Signin'),
+        'title' => $this->tryToTranslate('Signin'),
         'slug' => 'signin'
       ));
       
       $signinPage->getNode()->insertAsLastChildOf($root);
 
-      dmDb::table('DmWidget')->create(array(
-        'module' => 'dmUser',
-        'action' => 'signin',
-        'dm_zone_id' => $signinPage->PageView->Area->Zones[0]->id
-      ));
+      dmDb::table('DmWidget')->createInZone(
+        $signinPage->PageView->Area->Zones[0],
+        'dmUser/signin'
+      )->save();
     }
   }
+
+  protected function tryToTranslate($message)
+  {
+    if($i18n = $this->getService('i18n'))
+    {
+      return $i18n->__($message);
+    }
+
+    return $message;
+  }
   
   /**
    * Check that search page exist
@@ -83,13 +92,20 @@
   {
     if (!$this->createQuery('p')->where('p.module = ? AND p.action = ?', 
array('main', 'search'))->exists())
     {
-      $this->create(array(
-        'name' => $this->getService('i18n')->__('Search results'),
-        'title' => $this->getService('i18n')->__('Search results'),
+      $searchResultsPage = $this->create(array(
+        'name' => $this->tryToTranslate('Search results'),
+        'title' => $this->tryToTranslate('Search results'),
         'module' => 'main',
         'action' => 'search',
         'slug' => 'search'
-      ))->getNode()->insertAsLastChildOf($this->getTree()->fetchRoot());
+      ));
+
+      
$searchResultsPage->getNode()->insertAsLastChildOf($this->getTree()->fetchRoot());
+
+      dmDb::table('DmWidget')->createInZone(
+        $searchResultsPage->PageView->Area->Zones[0],
+        'dmWidgetSearch/results'
+      )->save();
     }
   }
   
@@ -329,15 +345,12 @@
 
   public function findOneByModuleAndActionWithI18n($module, $action, $culture 
= null)
   {
-    $timer = 
dmDebug::timerOrNull('dmPageTable::findOneByModuleAndActionWithI18n');
-    $page = $this->createQuery('p')
+    return $this->createQuery('p')
     ->where('p.module = ?', $module)
     ->andWhere('p.action = ?', $action)
     ->withI18n($culture, null, 'p')
     ->dmCache()
     ->fetchOne();
-    $timer && $timer->addTime();
-    return $page;
   }
 
 }
\ No newline at end of file

-- 
You received this message because you are subscribed to the Google Groups 
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/symfony-svn?hl=en.

Reply via email to