Var_Dump
[ class tree: Var_Dump ] [ index: Var_Dump ] [ all elements ]

Source for file XML.php

Documentation is available at XML.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2004 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 3.0 of the PHP license,       |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available through the world-wide-web at the following url:           |
  11. // | http://www.php.net/license/3_0.txt.                                  |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Authors: Frederic Poeydomenge <frederic.poeydomenge@free.fr>         |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id:
  20.  
  21. require_once 'Var_Dump/Renderer/Common.php';
  22.  
  23. /**
  24.  * A concrete renderer for Var_Dump
  25.  *
  26.  * Returns a representation of a variable in XML
  27.  * DTD : $PEARDIR/data/Var_Dump/renderer-xml.dtd
  28.  *
  29.  * @package Var_Dump
  30.  * @category PHP
  31.  * @author Frederic Poeydomenge <frederic.poeydomenge@free.fr>
  32.  */
  33.  
  34. {
  35.  
  36.     // {{{ constructor
  37.     /**
  38.      * Class constructor.
  39.      * @param array $options Parameters for the rendering.
  40.      * @access public
  41.      */
  42.     function Var_Dump_Renderer_XML($options = array())
  43.     {
  44.         $this->setOptions($options);
  45.     }
  46.     // }}}
  47.  
  48.     // {{{ toString()
  49.     /**
  50.      * Returns the string representation of a variable
  51.      * @return string The string representation of the variable.
  52.      * @access public
  53.      */
  54.     function toString()
  55.     {
  56.         if (count($this->family== 1{
  57.             return $this->_toString_Single();
  58.         else {
  59.             return $this->_toString_Array();
  60.         }
  61.     }
  62.     // }}}
  63.  
  64.     // {{{ _toString_Single()
  65.     /**
  66.      * Returns the string representation of a single variable
  67.      * @return string The string representation of a single variable.
  68.      * @access private
  69.      */
  70.     function _toString_Single()
  71.     {
  72.         return
  73.             '<element>' .
  74.             '<type>' htmlspecialchars($this->type[0]'</type>' .
  75.             '<value>' htmlspecialchars($this->value[0]'</value>' .
  76.             '</element>';
  77.     }
  78.     // }}}
  79.  
  80.     // {{{ _toString_Array()
  81.     /**
  82.      * Returns the string representation of a multiple variable
  83.      * @return string The string representation of a multiple variable.
  84.      * @access private
  85.      */
  86.     function _toString_Array()
  87.     {
  88.         $txt '';
  89.         $counter count($this->family);
  90.         $depth = 0;
  91.         for ($c = 0 ; $c $counter $c++{
  92.             switch ($this->family[$c]{
  93.                 case VAR_DUMP_START_GROUP :
  94.                     if ($this->depth[$c> 0{
  95.                         $txt .=
  96.                             $this->_spacer($depth'<type>group</type>' "\n" .
  97.                             $this->_spacer($depth++'<value>' "\n";
  98.                     }
  99.                     $txt .=
  100.                         $this->_spacer($depth.
  101.                         '<group caption="' htmlspecialchars($this->value[$c].
  102.                         '">' "\n";
  103.                     break;
  104.                 case VAR_DUMP_FINISH_GROUP :
  105.                     $txt .= $this->_spacer($depth'</group>' "\n";
  106.                     if ($this->depth[$c> 0{
  107.                         $txt .=
  108.                             $this->_spacer(--$depth'</value>' "\n" .
  109.                             $this->_spacer(--$depth'</element>' "\n";
  110.                         $depth--;
  111.                     }
  112.                     break;
  113.                 case VAR_DUMP_START_ELEMENT_NUM :
  114.                 case VAR_DUMP_START_ELEMENT_STR :
  115.                     $txt .=
  116.                         $this->_spacer(++$depth'<element>' "\n" .
  117.                         $this->_spacer(++$depth'<key>' .
  118.                         htmlspecialchars($this->value[$c].
  119.                         '</key>' "\n";
  120.                     break;
  121.                 case VAR_DUMP_FINISH_ELEMENT :
  122.                 case VAR_DUMP_FINISH_ELEMENT_NL :
  123.                     $txt .=
  124.                         $this->_spacer($depth'<type>' .
  125.                         htmlspecialchars($this->type[$c].
  126.                         '</type>' "\n".
  127.                         $this->_spacer($depth--'<value>' .
  128.                         htmlspecialchars($this->value[$c].
  129.                         '</value>' "\n" .
  130.                         $this->_spacer($depth--'</element>' "\n";
  131.                     break;
  132.             }
  133.         }
  134.         return $txt;
  135.     }
  136.     // }}}
  137.  
  138.     // {{{ _spacer()
  139.     /**
  140.      * Returns a spacer string to prefix the line
  141.      * @param integer $depth Depth level.
  142.      * @return string Spacer string
  143.      * @access private
  144.      */
  145.     function _spacer($depth{
  146.         return str_repeat(' '$depth << 1);
  147.     }
  148.     // }}}
  149.  
  150. }
  151.  
  152. ?>

Documentation generated on Mon, 11 Mar 2019 10:16:32 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.