From: <gem...@li...> - 2011-12-20 11:42:57
|
Revision: 379 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=379&view=rev Author: mennodekker Date: 2011-12-20 11:42:48 +0000 (Tue, 20 Dec 2011) Log Message: ----------- Added a little documentation + updated code (no functional change) Modified Paths: -------------- trunk/library/classes/Gems/Menu/SubMenuItem.php Modified: trunk/library/classes/Gems/Menu/SubMenuItem.php =================================================================== --- trunk/library/classes/Gems/Menu/SubMenuItem.php 2011-12-20 11:18:39 UTC (rev 378) +++ trunk/library/classes/Gems/Menu/SubMenuItem.php 2011-12-20 11:42:48 UTC (rev 379) @@ -92,18 +92,18 @@ return print_r($this->_itemOptions, true); } + /** + * Return true when then $source does NOT contain all items in the parameterFilter + * + * @param Gems_Menu_ParameterCollector $source + * @param type $raiseConditions + * @param type $condition + * @return boolean + */ private function _applyParameterFilter(Gems_Menu_ParameterCollector $source, $raiseConditions, &$condition) { if ($this->_parameterFilter) { foreach ($this->_parameterFilter as $name => $testValue) { - //Transform single value to array for uniform processing - if (!is_array($testValue)) { - $testArray = array(); - $testArray[] = $testValue; - } else { - $testArray = $testValue; - } - $paramValue = $source->getMenuParameter($name); if ($paramValue instanceof MUtil_Lazy_LazyInterface) { @@ -111,8 +111,11 @@ $paramValue = MUtil_Lazy::rise($paramValue); } else { - $newCondition = new MUtil_Lazy_Call('in_array', array($paramValue, $testArray)); - //$newCondition = MUtil_Lazy::comp($testValue, '==', $paramValue); + if (is_array($testValue)) { + $newCondition = new MUtil_Lazy_Call('in_array', array($paramValue, $testValue)); + } else { + $newCondition = MUtil_Lazy::comp($testValue, '==', $paramValue); + } if ($condition instanceof MUtil_Lazy_LazyInterface) { $condition = $condition->if($newCondition); } else { @@ -123,21 +126,23 @@ } - foreach($testArray as $currentTestValue) { - if ($currentTestValue == $paramValue) { + if (is_array($testValue)) { + if (!in_array($paramValue, $testValue)) { if (Gems_Menu::$verbose) { // Mutil_Echo::backtrace(); - MUtil_Echo::r($name . ' => ' . $currentTestValue . ' == ' . $paramValue, $this->get('label') . ' (' . $this->get('controller') . '/' . $this->get('action') . ')'); + MUtil_Echo::r($name . ' => ' . print_r($testValue,true) . ' !== ' . $paramValue, $this->get('label') . ' (' . $this->get('controller') . '/' . $this->get('action') . ')'); } - return; - } else { + return true; + } + } else { + if ($testValue !== $paramValue) { if (Gems_Menu::$verbose) { // Mutil_Echo::backtrace(); - MUtil_Echo::r($name . ' => ' . $currentTestValue . ' !== ' . $paramValue, $this->get('label') . ' (' . $this->get('controller') . '/' . $this->get('action') . ')'); + MUtil_Echo::r($name . ' => ' . $testValue . ' !== ' . $paramValue, $this->get('label') . ' (' . $this->get('controller') . '/' . $this->get('action') . ')'); } + return true; } } - return true; } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |