From: <gem...@li...> - 2013-01-11 18:29:09
|
Revision: 1097 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=1097&view=rev Author: matijsdejong Date: 2013-01-11 18:28:58 +0000 (Fri, 11 Jan 2013) Log Message: ----------- Check for absolute paths in PluginLoader Modified Paths: -------------- trunk/library/classes/MUtil/Form.php trunk/library/classes/MUtil/Loader/PluginLoader.php Modified: trunk/library/classes/MUtil/Form.php =================================================================== --- trunk/library/classes/MUtil/Form.php 2013-01-11 18:14:20 UTC (rev 1096) +++ trunk/library/classes/MUtil/Form.php 2013-01-11 18:28:58 UTC (rev 1097) @@ -80,9 +80,6 @@ */ public function __construct($options = null) { - $this->addPrefixPath('MUtil_Form_Decorator', 'MUtil/Form/Decorator/', Zend_Form::DECORATOR); - $this->addPrefixPath('MUtil_Form_Element', 'MUtil/Form/Element/', Zend_Form::ELEMENT); - $this->addElementPrefixPath('MUtil_Form_Decorator', 'MUtil/Form/Decorator', Zend_Form_Element::DECORATOR); $this->addElementPrefixPath('MUtil_Validate', 'MUtil/Validate/', Zend_Form_Element::VALIDATE); @@ -238,6 +235,46 @@ } /** + * Retrieve plugin loader for given type + * + * $type may be one of: + * - decorator + * - element + * + * If a plugin loader does not exist for the given type, defaults are + * created. + * + * @param string $type + * @return Zend_Loader_PluginLoader_Interface + */ + public function getPluginLoader($type = null) + { + $type = strtoupper($type); + if (!isset($this->_loaders[$type])) { + switch ($type) { + case self::DECORATOR: + $prefixSegment = 'Form_Decorator'; + $pathSegment = 'Form/Decorator'; + break; + case self::ELEMENT: + $prefixSegment = 'Form_Element'; + $pathSegment = 'Form/Element'; + break; + default: + require_once 'Zend/Form/Exception.php'; + throw new Zend_Form_Exception(sprintf('Invalid type "%s" provided to getPluginLoader()', $type)); + } + + $this->_loaders[$type] = new MUtil_Loader_PluginLoader(array( + 'Zend_' . $prefixSegment . '_' => 'Zend/' . $pathSegment . '/', + 'MUtil_' . $prefixSegment . '_' => 'MUtil/' . $pathSegment . '/', + )); + } + + return $this->_loaders[$type]; + } + + /** * Return true when the form is lazy * * @return boolean Modified: trunk/library/classes/MUtil/Loader/PluginLoader.php =================================================================== --- trunk/library/classes/MUtil/Loader/PluginLoader.php 2013-01-11 18:14:20 UTC (rev 1096) +++ trunk/library/classes/MUtil/Loader/PluginLoader.php 2013-01-11 18:28:58 UTC (rev 1097) @@ -71,10 +71,15 @@ throw new Zend_Loader_PluginLoader_Exception('Zend_Loader_PluginLoader::addPrefixPath() method only takes strings for prefix and path.'); } - // Only add existing directories - if (file_exists(rtrim($path, '/\\'))) { - parent::addPrefixPath($prefix, $path); + if ($path) { + if (('/' == $path[0]) || ('.' == $path[0]) || ((strlen($path) > 1) && (':' == $path[1]))) { + // Only add existing directories + if (! file_exists(rtrim($path, '/\\'))) { + return $this; + } + } } + parent::addPrefixPath($prefix, $path); return $this; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |