| [ Index ] |
PHP Cross Reference of Joomla 1.5.26 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @version $Id: xml.php 14401 2010-01-26 14:10:00Z louis $ 4 * @package Joomla.Framework 5 * @subpackage Registry 6 * @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. 7 * @license GNU/GPL, see LICENSE.php 8 * Joomla! is free software. This version may have been modified pursuant 9 * to the GNU General Public License, and as distributed it includes or 10 * is derivative of works licensed under the GNU General Public License or 11 * other free or open source software licenses. 12 * See COPYRIGHT.php for copyright notices and details. 13 */ 14 15 // Check to ensure this file is within the rest of the framework 16 defined('JPATH_BASE') or die(); 17 18 /** 19 * XML Format for JRegistry 20 * 21 * @package Joomla.Framework 22 * @subpackage Registry 23 * @since 1.5 24 */ 25 class JRegistryFormatXML extends JRegistryFormat { 26 27 /** 28 * Converts an XML formatted string into an object 29 * 30 * @access public 31 * @param string XML Formatted String 32 * @return object Data Object 33 */ 34 function stringToObject( $data, $namespace='' ) { 35 return true; 36 } 37 38 /** 39 * Converts an object into an XML formatted string 40 * - If more than two levels of nested groups are necessary, since INI is not 41 * useful, XML or another format should be used. 42 * 43 * @access public 44 * @param object $object Data Source Object 45 * @param array $param Parameters used by the formatter 46 * @return string XML Formatted String 47 */ 48 function objectToString( &$object, $params ) 49 { 50 $depth = 1; 51 $retval = "<?xml version=\"1.0\" ?>\n<config>\n"; 52 foreach (get_object_vars( $object ) as $key=>$item) 53 { 54 if (is_object($item)) 55 { 56 $retval .= "\t<group name=\"".$key."\">\n"; 57 $retval .= $this->_buildXMLstringLevel($item, $depth+1); 58 $retval .= "\t</group>\n"; 59 } else { 60 $retval .= "\t<entry name=\"".$key."\">".$item."</entry>\n"; 61 } 62 } 63 $retval .= '</config>'; 64 return $retval; 65 } 66 67 /** 68 * Method to build a level of the XML string -- called recursively 69 * 70 * @access private 71 * @param object $object Object that represents a node of the xml document 72 * @param int $depth The depth in the XML tree of the $object node 73 * @return string XML string 74 */ 75 function _buildXMLstringLevel($object, $depth) 76 { 77 // Initialize variables 78 $retval = ''; 79 $tab = ''; 80 for($i=1;$i <= $depth; $i++) { 81 $tab .= "\t"; 82 } 83 84 foreach (get_object_vars( $object ) as $key=>$item) 85 { 86 if (is_object($item)) 87 { 88 $retval .= $tab."<group name=\"".$key."\">\n"; 89 $retval .= $this->_buildXMLstringLevel($item, $depth+1); 90 $retval .= $tab."</group>\n"; 91 } else { 92 $retval .= $tab."<entry name=\"".$key."\">".$item."</entry>\n"; 93 } 94 } 95 return $retval; 96 } 97 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Mar 28 15:54:07 2012 | Cross-referenced by PHPXref 0.7.1 |