diff --git a/e107_admin/db.php b/e107_admin/db.php index acf13c3ef..a83a323d0 100644 --- a/e107_admin/db.php +++ b/e107_admin/db.php @@ -9,8 +9,8 @@ * Administration - Database Utilities * * $Source: /cvs_backup/e107_0.8/e107_admin/db.php,v $ - * $Revision: 1.15 $ - * $Date: 2009-08-27 12:54:48 $ + * $Revision: 1.16 $ + * $Date: 2009-08-27 14:34:19 $ * $Author: secretr $ * */ @@ -275,28 +275,39 @@ function export_core_prefs() function importCorePrefs() { //TODO - Cameron - move to own class and make generic. - + //SecretR - structure changes / improvements proposal + $dummyXml = " - -1165362615 -e107 Powered Website -/e107_0.8/ -{e_IMAGE}button.png -e107 Website System - -admin -user@yoursite.com - -tag['value']=this value -[tag2][@attribute][name]='something' and [tag2][value] = this text - -myarray['item'][0]['value'] equals this - - - otherArray['otherItem'][0]['value'] equals this - otherArray['otherItem'][1]['value'] equals this - + + 1165362615 + + + {e_IMAGE}button.png + + + admin + user@yoursite.com + + + + + + + + + + + tag['value']=this value + [tag2][@attribute][name]='something' and [tag2][value] = this text + + myarray['item'][0]['value'] equals this + + + otherArray['otherItem'][0]['value'] equals this + otherArray['otherItem'][1]['value'] equals this + + @@ -304,21 +315,32 @@ function importCorePrefs() echo "

Example XML

".htmlentities($dummyXml)."
"; + //$data = $dummyXml; - $data = $dummyXml; + echo '

New Core parsing method - default options


'; + //NOTE - there is nothing wrong if we call e107::getObject (new instance) + $xml = e107::getSingleton('xmlClass')->parseXml($dummyXml, false); //new instance + print_a($xml); + + echo '

New Core parsing method - new options example


'; + echo 'Option _optAddRoot: true
Option _optValueKey: "myVal"
Option _optForceArray: true
'; + e107::getSingleton('xmlClass')->setOptForceArray(true) //force array variable type for simple tags of first level + ->setOptValueKey('myVal') //the default is value + ->setOptAddRoot(true); //include root element in the returned array + $xml = e107::getSingleton('xmlClass')->parseXml($dummyXml, false); //new instance + print_a($xml); // $xml = e107::getSingleton('xmlClass')->loadXMLfile($_FILES['file_userfile']['tmp_name'][0],TRUE); $xml = e107::getSingleton('xmlClass')->parseXml($dummyXml); - echo "

Core XML Class


"; + echo "

Old Core XML Class


"; print_a($xml); // $data = e107::getSingleton('xmlClass')->xmlFileContents; - echo '

3rd Party Class


'; - $array_3rd = e107::getSingleton('xmlClass')->xml2ary($data); - - print_a($array_3rd); + //echo '

3rd Party Class


'; + //$array_3rd = e107::getSingleton('xmlClass')->xml2ary($data); + //print_a($array_3rd); foreach ($xll->corePref as $key=>$val) { diff --git a/e107_handlers/xml_class.php b/e107_handlers/xml_class.php index b0fe504c4..55c75fa93 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.14 $ - * $Date: 2009-08-27 13:58:28 $ + * $Revision: 1.15 $ + * $Date: 2009-08-27 14:34:20 $ * $Author: secretr $ */ @@ -305,7 +305,11 @@ class xmlClass */ function parseXml($xml = '', $simple = true) { - if ($xml == '' && $this->xmlFileContents) + if ($xml) + { + $this->xmlFileContents = $xml; + } + elseif ($this->xmlFileContents) { $xml = $this->xmlFileContents; } @@ -315,10 +319,6 @@ class xmlClass } $xml = simplexml_load_string($xml); - if (is_object($xml)) - { - $xml = (array) $xml; - } $xml = $simple ? $this->xml_convert_to_array($xml, $this->filter, $this->stripComments) : $this->xml2array($xml); return $xml; } @@ -428,6 +428,10 @@ class xmlClass function xml_convert_to_array($xml, $localFilter = FALSE, $stripComments = TRUE) { + if (is_object($xml)) + { + $xml = (array) $xml; + } if (is_array($xml)) { foreach ($xml as $k=>$v)