Author: Jonathan.Wage
Date: 2010-01-26 21:50:11 +0100 (Tue, 26 Jan 2010)
New Revision: 27212

Modified:
   
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalMenuPlugin/lib/menu/sfSympalMenuSite.class.php
   plugins/sfSympalPlugin/trunk/test/unit/MenuTest.php
Log:
[1.4][sfSympalPlugin][1.0] Fixing i18n for menus and caching


Modified: 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalMenuPlugin/lib/menu/sfSympalMenuSite.class.php
===================================================================
--- 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalMenuPlugin/lib/menu/sfSympalMenuSite.class.php
     2010-01-26 20:23:26 UTC (rev 27211)
+++ 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalMenuPlugin/lib/menu/sfSympalMenuSite.class.php
     2010-01-26 20:50:11 UTC (rev 27212)
@@ -106,11 +106,44 @@
       $array['level'] = $menuItem->getLevel();
       $array['date_published'] = $menuItem->getDatePublished();
       unset($array['__children']);
+
+      if (sfSympalConfig::isI18nEnabled('sfSympalMenuItem'))
+      {
+        $array['Translation'] = $menuItem->Translation->toArray(false);
+      }
+
       return $array;
     }
     return $menuItem;
   }
 
+  public function getLabel()
+  {
+    $label = null;
+    if (sfSympalConfig::isI18nEnabled('sfSympalMenuItem'))
+    {
+      $culture = sfContext::getInstance()->getUser()->getCulture();
+      if (isset($this->_menuItem['Translation'][$culture]['label']))
+      {
+        $label = $this->_menuItem['Translation'][$culture]['label'];
+      }
+      if (!$label && 
isset($this->_menuItem['Translation'][sfConfig::get('sf_default_culture')]['label']))
+      {
+        $label = 
$this->_menuItem['Translation'][sfConfig::get('sf_default_culture')]['label'];
+      }
+    } else {
+      if (isset($this->_menuItem['label']))
+      {
+        $label = $this->_menuItem['label'];
+      }
+    }
+    if (!$label)
+    {
+      $label = parent::getLabel();
+    }
+    return $label;
+  }
+
   public function setMenuItem($menuItem)
   {
     $this->_menuItem = $this->_prepareMenuItem($menuItem);

Modified: plugins/sfSympalPlugin/trunk/test/unit/MenuTest.php
===================================================================
--- plugins/sfSympalPlugin/trunk/test/unit/MenuTest.php 2010-01-26 20:23:26 UTC 
(rev 27211)
+++ plugins/sfSympalPlugin/trunk/test/unit/MenuTest.php 2010-01-26 20:50:11 UTC 
(rev 27212)
@@ -3,7 +3,7 @@
 $app = 'sympal';
 require_once(dirname(__FILE__).'/../bootstrap/unit.php');
 
-$t = new lime_test(52, new lime_output_color());
+$t = new lime_test(53, new lime_output_color());
 
 $configuration->loadHelpers(array('Tag'));
 
@@ -154,8 +154,15 @@
 $t->is($menuItem->getContent()->getHeaderTitle(), 'Home', 'Test 
sfSympalMenuItem::getHeaderTitle()');
 $t->is($menuItem->getLabel(), 'Home', 'Test sfSympalMenuItem::getLabel()');
 $t->is($menuItem->getItemRoute(), '@sympal_content_home', 'Test 
sfSympalMenuItem::getItemRoute()');
-$t->is($menuItem->getBreadcrumbs()->getPathAsString(), 'primary / Home', 'Test 
sfSympalBreadcrumbs::getPathAsString()');
+$t->is($menuItem->getBreadcrumbs()->getPathAsString(), '', 'Test 
sfSympalBreadcrumbs::getPathAsString() returns nothing for home');
 
+$menuItem = $table
+  ->createQuery('m')
+  ->where('m.slug = ?', 'sample-page')
+  ->fetchOne();
+
+$t->is($menuItem->getBreadcrumbs()->getPathAsString(), 'Home / Sample Page', 
'Test sfSympalBreadcrumbs::getPathAsString() returns nothing for home');
+
 $menuManager = sfSympalMenuSiteManager::getInstance();
 $menuManager->clear();
 

-- 
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