Support Joomla!

Joomla! 1.5 Documentation

Packages

Package: Joomla-Framework

Developer Network License

The Joomla! Developer Network content is © copyright 2006 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution- NonCommercial- ShareAlike 2.5
Source code for file /joomla/registry/format/xml.php

Documentation is available at xml.php

  1. <?php
  2. /**
  3.  * @version        $Id: xml.php 6472 2007-02-03 10:47:26Z pasamio $
  4.  * @package        Joomla.Framework
  5.  * @subpackage    Registry
  6.  * @copyright    Copyright (C) 2005 - 2007 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.  * @author         Samuel Moffatt <[email protected]>
  22.  * @package     Joomla.Framework
  23.  * @subpackage        Registry
  24.  * @since        1.5
  25.  */
  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.         $depth 1;
  50.         $retval "<?xml version=\"1.0\" ?>\n<config>\n";
  51.         foreach (get_object_vars$object as $key=>$item{
  52.             if (is_object($item)) {
  53.                 $retval .= "\t<group name=\"".$key."\">\n";
  54.                 $retval .= $this->_buildXMLstringLevel($item$depth+1);
  55.                 $retval .= "\t</group>\n";
  56.             else {
  57.                 $retval .= "\t<entry name=\"".$key."\">".$item."</entry>\n";
  58.             }
  59.         }
  60.         $retval .= '</config>';
  61.         return $retval;
  62.     }
  63.  
  64.     /**
  65.      * Method to build a level of the XML string -- called recursively
  66.      *
  67.      * @access private
  68.      * @param object $object Object that represents a node of the xml document
  69.      * @param int $depth The depth in the XML tree of the $object node
  70.      * @return string XML string
  71.      */
  72.     function _buildXMLstringLevel($object$depth{
  73.         // Initialize variables
  74.         $retval '';
  75.         for($i=1;$i <= $depth$i++{
  76.             $tab .= "\t";
  77.         }
  78.  
  79.         foreach (get_object_vars$object as $key=>$item{
  80.             if (is_object($item)) {
  81.                 $retval .= $tab."<group name=\"".$key."\">\n";
  82.                 $retval .= $this->_buildXMLstringLevel($item$depth+1);
  83.                 $retval .= $tab."</group>\n";
  84.             else {
  85.                 $retval .= $tab."<entry name=\"".$key."\">".$item."</entry>\n";
  86.             }
  87.         }
  88.         return $retval;
  89.     }
  90. }
  91. ?>

Documentation generated on Mon, 05 Mar 2007 21:31:50 +0000 by phpDocumentor 1.3.1