Author: Jonathan.Wage
Date: 2010-01-27 00:10:24 +0100 (Wed, 27 Jan 2010)
New Revision: 27215
Modified:
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalMenuPlugin/lib/menu/sfSympalMenuSite.class.php
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalMenuPlugin/lib/menu/sfSympalMenuSiteManager.class.php
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalMenuPlugin/lib/model/doctrine/PluginsfSympalMenuItem.class.php
Log:
[1.4][sfSympalPlugin][1.0] Fixing issue with menu caching, sub menus and
current menu item
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 21:54:22 UTC (rev 27214)
+++
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalMenuPlugin/lib/menu/sfSympalMenuSite.class.php
2010-01-26 23:10:24 UTC (rev 27215)
@@ -18,12 +18,15 @@
public function clearCache()
{
- return
sfSympalConfiguration::getActive()->getCache()->remove($this->_cacheKey);
+ if ($cache = sfSympalConfiguration::getActive()->getCache())
+ {
+ return $cache->remove($this->_cacheKey);
+ }
}
- public function findMenuItem(sfSympalMenuItem $menuItem)
+ public function findMenuItem($menuItem)
{
- if ($this->_menuItem['id'] == $menuItem->id)
+ if ($this->_menuItem['id'] == $menuItem['id'])
{
return $this;
}
@@ -159,16 +162,19 @@
$this->setCredentials(array('ManageContent'));
}
+ $this->setLevel($this->_menuItem['level']);
+ }
+
+ public function isCurrent($bool = null)
+ {
$currentMenuItem = sfSympalContext::getInstance()->getCurrentMenuItem();
if ($currentMenuItem && $currentMenuItem->exists())
{
- $this->isCurrent($this->_menuItem['id'] == $currentMenuItem['id']);
+ return $this->_menuItem['id'] == $currentMenuItem['id'];
} else {
- $this->isCurrent(false);
+ return false;
}
-
- $this->setLevel($this->_menuItem['level']);
}
public function getTopLevelParent()
Modified:
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalMenuPlugin/lib/menu/sfSympalMenuSiteManager.class.php
===================================================================
---
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalMenuPlugin/lib/menu/sfSympalMenuSiteManager.class.php
2010-01-26 21:54:22 UTC (rev 27214)
+++
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalMenuPlugin/lib/menu/sfSympalMenuSiteManager.class.php
2010-01-26 23:10:24 UTC (rev 27215)
@@ -64,10 +64,9 @@
protected function _getMenu($name, $showChildren = null, $class = null)
{
- if ($name instanceof sfSympalMenuItem)
+ if (is_scalar($name) && isset($this->_rootSlugs[$name]))
{
- $menuItem = $name;
- $name = $name['root_id'] && isset($this->_rootSlugs[$name['root_id']]) ?
$this->_rootSlugs[$name['root_id']] : false;
+ $name = $this->_rootSlugs[$name];
}
if (!$name)
@@ -75,7 +74,7 @@
return false;
}
- $cacheKey = 'SYMPAL_MENU_'.md5($name.var_export($showChildren,
true).$class);
+ $cacheKey = 'SYMPAL_MENU_'.md5((string) $name.var_export($showChildren,
true).$class);
if (isset($this->_menus[$cacheKey]))
{
return $this->_menus[$cacheKey];
@@ -111,22 +110,26 @@
protected function _buildMenu($name, $class)
{
- $rootId = array_search($name, (array) $this->_rootSlugs);
+ if ($name instanceof sfSympalMenuItem)
+ {
+ $menuItem = $name;
+ $rootId = $name['root_id'];
+ $name = (string) $name;
+ } else {
+ $rootId = array_search($name, (array) $this->_rootSlugs);
+ }
if (!$rootId)
{
return false;
}
+
$rootMenuItem = $this->_rootMenuItems[$rootId];
$class = $class ? $class:sfSympalConfig::get('menu_class', null,
'sfSympalMenuSite');
$menu = new $class($name);
$menu->setMenuItem($rootMenuItem);
- if (!$rootId)
- {
- return false;
- }
$hierarchy = $this->_hierarchies[$rootId];
$this->_buildMenuHierarchy($hierarchy, $menu);
Modified:
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalMenuPlugin/lib/model/doctrine/PluginsfSympalMenuItem.class.php
===================================================================
---
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalMenuPlugin/lib/model/doctrine/PluginsfSympalMenuItem.class.php
2010-01-26 21:54:22 UTC (rev 27214)
+++
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalMenuPlugin/lib/model/doctrine/PluginsfSympalMenuItem.class.php
2010-01-26 23:10:24 UTC (rev 27215)
@@ -130,7 +130,7 @@
public function getMenu()
{
- return sfSympalMenuSiteManager::getMenu($this);
+ return sfSympalMenuSiteManager::getMenu($this['root_id']);
}
public function getBreadcrumbs($subItem = null)
--
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.