Support Joomla!

Joomla! 1.5 Documentation

Packages

Package: patTemplate

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 /pattemplate/patTemplate/Dump.php

Documentation is available at Dump.php

  1. <?PHP
  2. /**
  3.  * Base class for patTemplate dumpers
  4.  *
  5.  * $Id: Dump.php 219 2004-05-25 20:38:38Z schst $
  6.  *
  7.  * The dump functionality is separated from the main class
  8.  * for performance reasons.
  9.  *
  10.  * @package        patTemplate
  11.  * @subpackage    Dump
  12.  * @author        Stephan Schmidt <[email protected]>
  13.  */
  14.  
  15. // Check to ensure this file is within the rest of the framework
  16. defined('JPATH_BASE'or die();
  17.  
  18. /**
  19.  * Base class for patTemplate dumpers
  20.  *
  21.  * The dump functionality is separated from the main class
  22.  * for performance reasons.
  23.  *
  24.  * @abstract
  25.  * @package        patTemplate
  26.  * @subpackage    Dump
  27.  * @author        Stephan Schmidt <[email protected]>
  28.  */
  29. {
  30.    /**
  31.     * reference to the patTemplate object that instantiated the module
  32.     *
  33.     * @access    protected
  34.     * @var    object 
  35.     */
  36.     var    $_tmpl;
  37.  
  38.    /**
  39.     * set a reference to the patTemplate object that instantiated the reader
  40.     *
  41.     * @access    public
  42.     * @param    object        patTemplate object
  43.     */
  44.     function setTemplateReference&$tmpl )
  45.     {
  46.         $this->_tmpl        =    &$tmpl;
  47.     }
  48.  
  49.    /**
  50.     * display the header
  51.     *
  52.     * @access    public
  53.     */
  54.     function displayHeader()
  55.     {
  56.     }
  57.  
  58.    /**
  59.     * dump the global variables
  60.     *
  61.     * @access    public
  62.     * @param    array        array containing all global variables
  63.     * @abstract
  64.     */
  65.     function dumpGlobals$globals )
  66.     {
  67.     }
  68.  
  69.    /**
  70.     * dump the templates
  71.     *
  72.     * This method has to be implemented in the dumpers.
  73.     *
  74.     * @access    public
  75.     * @abstract
  76.     * @param    array    templates
  77.     * @param    array    variables
  78.     */
  79.     function dumpTemplates$templates$vars )
  80.     {
  81.     }
  82.  
  83.    /**
  84.     * display the footer
  85.     *
  86.     * @access    public
  87.     */
  88.     function displayFooter()
  89.     {
  90.     }
  91.  
  92.    /**
  93.      * flatten the variables
  94.     *
  95.     * This will convert the variable definitions
  96.     * to a one-dimensional array. If there are
  97.     * rows defined, they will be converted to a string
  98.     * where the values are seperated with commas.
  99.     *
  100.     * @access    private
  101.     * @param    array        variable definitions
  102.     * @return    array        flattened variables
  103.     */
  104.     function _flattenVars$vars )
  105.     {
  106.         $flatten    =    array();
  107.         foreach$vars['scalar'as $var => $value )
  108.         {
  109.             $flatten[$var]    =    $value;
  110.         }
  111.         foreach$vars['rows'as $row )
  112.         {
  113.             foreach$row as $var => $value )
  114.             {
  115.                 if!isset$flatten[$var|| !is_array$flatten[$var) )
  116.                     $flatten[$var]    =    array();
  117.                 array_push$flatten[$var]$value );
  118.             }
  119.         }
  120.  
  121.         foreach$flatten as $var => $value )
  122.         {
  123.             if!is_array$value ) )
  124.                 continue;
  125.  
  126.             $flatten[$var'['.count($value).' rows] ('.implode', '$value ).')';
  127.         }
  128.  
  129.         return $flatten;
  130.     }
  131.  
  132.    /**
  133.     * extract all variables from a template
  134.     *
  135.     * @access    private
  136.     * @param    string        template content
  137.     * @return    array        array containing all variables
  138.     */
  139.     function _extractVars$template )
  140.     {
  141.         $pattern '/'.$this->_tmpl->getStartTag().'([^a-z]+)'.$this->_tmpl->getEndTag().'/U';
  142.  
  143.         $matches array();
  144.  
  145.         $result preg_match_all$pattern$template$matches );
  146.         if$result == false )
  147.             return array();
  148.  
  149.         $vars array();
  150.         foreach$matches[1as $var )
  151.         {
  152.             ifstrncmp$var'TMPL:'=== )
  153.                 continue;
  154.             array_push$vars$var );
  155.         }
  156.         return array_unique$vars );
  157.     }
  158. }
  159. ?>

Documentation generated on Mon, 05 Mar 2007 20:56:54 +0000 by phpDocumentor 1.3.1