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.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.     /**
  37.      * Default configuration options.
  38.      * @var    array 
  39.      * @access public
  40.      */
  41.     var $defaultOptions = array(
  42.     );
  43.  
  44.     // {{{ constructor
  45.     /**
  46.      * Class constructor.
  47.      * @param  array  $options Parameters for the rendering.
  48.      * @access public
  49.      */
  50.     function Var_Dump_Renderer_XML($options = array())
  51.     {
  52.         parent::Var_Dump_Renderer($options);
  53.     }
  54.     // }}}
  55.  
  56.     // {{{ toString()
  57.     /**
  58.      * Returns the string representation of a variable
  59.      * @return string The string representation of the variable.
  60.      * @access public
  61.      */
  62.     function toString()
  63.     {
  64.         if (count($this->family== 1{
  65.             return $this->_toString_Single();
  66.         else {
  67.             return $this->_toString_Array();
  68.         }
  69.     }
  70.     // }}}
  71.  
  72.     // {{{ _toString_Single()
  73.     /**
  74.      * Returns the string representation of a single variable
  75.      * @return string The string representation of a single variable.
  76.      * @access public
  77.      */
  78.     function _toString_Single()
  79.     {
  80.         return
  81.             '<element>' .
  82.             '<type>' htmlspecialchars($this->type[0]'</type>' .
  83.             '<value>' htmlspecialchars($this->value[0]'</value>' .
  84.             '</element>';
  85.     }
  86.     // }}}
  87.  
  88.     // {{{ _toString_Array()
  89.     /**
  90.      * Returns the string representation of a multiple variable
  91.      * @return string The string representation of a multiple variable.
  92.      * @access public
  93.      */
  94.     function _toString_Array()
  95.     {
  96.         $txt '';
  97.         $counter count($this->family);
  98.         $depth = 0;
  99.         for ($c = 0 ; $c $counter $c++{
  100.             switch ($this->family[$c]{
  101.                 case VAR_DUMP_START_GROUP :
  102.                     if ($this->depth[$c> 0{
  103.                         $txt .=
  104.                             $this->spacer($depth'<type>group</type>' "\n" .
  105.                             $this->spacer($depth++'<value>' "\n";
  106.                     }
  107.                     $txt .=
  108.                         $this->spacer($depth.
  109.                         '<group caption="' htmlspecialchars($this->value[$c].
  110.                         '">' "\n";
  111.                     break;
  112.                 case VAR_DUMP_FINISH_GROUP :
  113.                     $txt .= $this->spacer($depth'</group>' "\n";
  114.                     if ($this->depth[$c> 0{
  115.                         $txt .=
  116.                             $this->spacer(--$depth'</value>' "\n" .
  117.                             $this->spacer(--$depth'</element>' "\n";
  118.                         $depth--;
  119.                     }
  120.                     break;
  121.                 case VAR_DUMP_START_ELEMENT_NUM :
  122.                 case VAR_DUMP_START_ELEMENT_STR :
  123.                     $txt .=
  124.                         $this->spacer(++$depth'<element>' "\n" .
  125.                         $this->spacer(++$depth'<key>' .
  126.                         htmlspecialchars($this->value[$c].
  127.                         '</key>' "\n";
  128.                     break;
  129.                 case VAR_DUMP_FINISH_ELEMENT :
  130.                 case VAR_DUMP_FINISH_ELEMENT_NL :
  131.                     $txt .=
  132.                         $this->spacer($depth'<type>' .
  133.                         htmlspecialchars($this->type[$c].
  134.                         '</type>' "\n".
  135.                         $this->spacer($depth--'<value>' .
  136.                         htmlspecialchars($this->value[$c].
  137.                         '</value>' "\n" .
  138.                         $this->spacer($depth--'</element>' "\n";
  139.                     break;
  140.             }
  141.         }
  142.         return $txt;
  143.     }
  144.     // }}}
  145.  
  146.     // {{{ spacer()
  147.     /**
  148.      * Returns a spacer string to prefix the line
  149.      * @param  integer $depth Depth level.
  150.      * @return string Spacer string
  151.      * @access public
  152.      */
  153.     function spacer($depth{
  154.         return str_repeat(' '$depth << 1);
  155.     }
  156.     // }}}
  157.  
  158. }
  159.  
  160. ?>

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