diff --git a/e107_handlers/plugin_class.php b/e107_handlers/plugin_class.php index f6cdd0504..aa198ba84 100644 --- a/e107_handlers/plugin_class.php +++ b/e107_handlers/plugin_class.php @@ -11,9 +11,9 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_handlers/plugin_class.php,v $ -| $Revision: 1.85 $ -| $Date: 2009-09-15 16:10:32 $ -| $Author: secretr $ +| $Revision: 1.86 $ +| $Date: 2009-09-16 13:01:17 $ +| $Author: e107coders $ +----------------------------------------------------------------------------+ */ @@ -1779,7 +1779,9 @@ class e107plugin // loadLanFiles($plugName, 'admin'); // Look for LAN files on default paths require_once(e_HANDLER.'xml_class.php'); $xml = new xmlClass; + $xml->setOptArrayTags('extendedField,userclass,menuLink'); // always arrays for these tags. $this->plug_vars = $xml->loadXMLfile(e_PLUGIN.$plugName.'/plugin.xml', true, true); + if ($this->plug_vars === FALSE) { require_once(e_HANDLER."message_handler.php"); @@ -1789,29 +1791,11 @@ class e107plugin } $this->plug_vars['category'] = $this->manage_category($this->plug_vars['category']); - $this->plug_vars = $this->cleanXML($this->plug_vars); return TRUE; } - /** - * Return as an array, even when a single xml tag value is found - * @param object $vars - * @return array - */ - private function cleanXml($vars) - { - $array_tags = array("extendedField","userclass","menuLink"); - foreach($array_tags as $vl) - { - if(is_array($vars[$vl]) && !varset($vars[$vl][0])) - { - $vars[$vl] = array($vars[$vl]); - } - } - - return $vars; - } + } diff --git a/e107_handlers/xml_class.php b/e107_handlers/xml_class.php index 3c1f8045f..33dc7d79c 100644 --- a/e107_handlers/xml_class.php +++ b/e107_handlers/xml_class.php @@ -9,8 +9,8 @@ * Simple XML Parser * * $Source: /cvs_backup/e107_0.8/e107_handlers/xml_class.php,v $ - * $Revision: 1.24 $ - * $Date: 2009-09-10 09:49:01 $ + * $Revision: 1.25 $ + * $Date: 2009-09-16 13:01:19 $ * $Author: e107coders $ */ @@ -69,7 +69,7 @@ class xmlClass /** * Log of all paths replaced. * @var - */ + */ public $fileConvertLog = array(); public $convertFilePaths = FALSE; @@ -82,6 +82,7 @@ class xmlClass public $filePathConvKeys = array(); + private $arrayTags = false; /** * Add root element to the result array @@ -189,6 +190,17 @@ class xmlClass return $this; } + /** + * Set Xml tags that should always return arrays. + * @param object $array + * @return + */ + public function setOptArrayTags($string) + { + $this->arrayTags = (array) explode(",",$string); + return $this; + } + /** * Set forceArray option * @@ -403,6 +415,8 @@ class xmlClass $ret[$tag] = $this->xml2array($xml->{$tag}, $tag); } + $ret = $this->parseArrayTags($ret); + return ($this->_optAddRoot ? array($xml->getName() => $ret) : $ret); } @@ -450,11 +464,13 @@ class xmlClass break; } } + return $ret; } //parse value only $ret = trim((string) $xml); + return ($this->_optForceArray ? array($this->_optValueKey => $ret) : $ret); } @@ -503,9 +519,46 @@ class xmlClass $xml = $xml[0]; } } + + + $xml = $this->parseArrayTags($xml); + return $xml; } + + /** + * Return as an array, even when a single xml tag value is found + * Use setArrayTags() to set which tags are affected. + * @param object $vars + * @return array + */ + private function parseArrayTags($vars) + { + + if(!$this->arrayTags) + { + return $vars; + } + + // $array_tags = array("extendedField","userclass","menuLink"); + foreach($this->arrayTags as $vl) + { + + if(is_array($vars[$vl]) && !varset($vars[$vl][0])) + { + + $vars[$vl] = array($vars[$vl]); + } + } + + return $vars; + } + + + + + /** * Load XML file and parse it (optional) *