Support Joomla!

Packages

Package: patTemplate

License

Content on this site is copyright © 2005 - 2008 Open Source Matters Inc and can be used in accordance with the Joomla! Electronic Documentation License. Some parts of this website may be subject to other licenses.
Source code for file /pattemplate/patTemplate/Dump/XUL.php

Documentation is available at XUL.php

  1. <?PHP
  2. /**
  3.  * Dumps templates as XUL
  4.  *
  5.  * $Id: XUL.php 10381 2008-06-01 03:35:53Z pasamio $
  6.  *
  7.  * @package        patTemplate
  8.  * @subpackage    Dump
  9.  * @author        Stephan Schmidt <schst@php.net>
  10.  */
  11.  
  12. // Check to ensure this file is within the rest of the framework
  13. defined('JPATH_BASE'or die();
  14.  
  15. require_once 'XML/XUL.php';
  16.  
  17. /**
  18.  * Dumps templates as XUL, using PEAR::XML_XUL
  19.  *
  20.  * @package        patTemplate
  21.  * @subpackage    Dump
  22.  * @author        Stephan Schmidt <schst@php.net>
  23.  *
  24.  * @todo        move this into patTemplate_Dump_Dhtml and keep it free from javascript
  25.  */
  26. {
  27.     var $_doc = null;
  28.  
  29.     var $_root = null;
  30.  
  31.     var $_templates = null;
  32.  
  33.     var $_addedTemplates = array();
  34.     var $_vars = array();
  35.  
  36.     /**
  37.     * display the header
  38.     *
  39.     * @access    public
  40.     */
  41.     function displayHeader()
  42.     {
  43.         $this->_addedTemplates = array();
  44.  
  45.         $this->_doc = &XML_XUL::createDocument);
  46.  
  47.         $this->_doc->addStylesheet('chrome://global/skin/');
  48.  
  49.         $win &$this->_doc->createElement('Window'array('title'=> 'patTemplate Dump'));
  50.         $this->_doc->addRoot($win);
  51.  
  52.         $this->_root = &$this->_doc->createElement'Tabbox'array('flex' => 1) );
  53.         $win->appendChild($this->_root);
  54.  
  55.     }
  56.  
  57.     /**
  58.     * dump the global variables
  59.     *
  60.     * @access    public
  61.     * @param    array        array containing all global variables
  62.     */
  63.     function dumpGlobals$globals )
  64.     {
  65.         $gbox &$this->_doc->createElement('Groupbox'array('orient'=>'vertical''flex' => 1));
  66.         $gbox->setCaption('Global variables');
  67.  
  68.         $grid &$this->_doc->createElement('Grid');
  69.         $grid->setColumns(2array'flex' => )array'flex' => ));
  70.  
  71.         $gbox->appendChild($grid);
  72.  
  73.         $headers array(
  74.                            $this->_doc->createElement'Description'array'style' => 'font-weight:bold;' )'Variable' ),
  75.                            $this->_doc->createElement'Description'array'style' => 'font-weight:bold;' )'Value' ),
  76.                 );
  77.         $grid->addRow($headers);
  78.         foreach ($globals as $var => $value{
  79.             $row array($var$value);
  80.             $grid->addRow($row);
  81.         }
  82.         $this->_root->addTab('Global Variables'$gbox);
  83.  
  84.     }
  85.  
  86.     /**
  87.     * dump the templates
  88.     *
  89.     * @access    public
  90.     * @param    array    templates
  91.     */
  92.     function dumpTemplates$templates$vars )
  93.     {
  94.         $container &$this->_doc->createElement('VBox'array('flex' => 1));
  95.  
  96.         $gbox &$this->_doc->createElement('Groupbox'array('orient'=>'vertical''flex' => '2'));
  97.         $gbox->setCaption('Templates');
  98.         $container->appendChild($gbox);
  99.  
  100.         $this->_templates = $templates;
  101.         $this->_vars = $vars;
  102.  
  103.         $templates array_reverse$templates );
  104.  
  105.         $tree &$this->_doc->createElement'Tree'array'flex' => 1'enableColumnDrag' => 'true''height' => '500' ) );
  106.         $tree->setColumns5,
  107.                         array(
  108.                                 'id'  => 'name',
  109.                                 'label' => 'Name',
  110.                                 'flex'  => 2,
  111.                                 'primary' => 'true',
  112.                               ),
  113.                         array(
  114.                                 'id'  => 'value',
  115.                                 'label' => 'Value',
  116.                                 'flex'  => 1,
  117.                               ),
  118.                         array(
  119.                                 'id'  => 'type',
  120.                                 'label' => 'Type',
  121.                                 'flex'  => 1,
  122.                               ),
  123.                         array(
  124.                                 'id'  => 'visibility',
  125.                                 'label' => 'Visibility',
  126.                                 'flex'  => 1,
  127.                               ),
  128.                         array(
  129.                                 'id'  => 'loaded',
  130.                                 'label' => 'Loaded',
  131.                                 'flex'  => 1,
  132.                               )
  133.                  );
  134.  
  135.         foreach$templates as $name => $tmpl )
  136.         {
  137.             if (in_array($name$this->_addedTemplates)) {
  138.                 continue;
  139.             }
  140.             $this->_addToTree($name$tree);
  141.         }
  142.  
  143.         $gbox->appendChild($tree);
  144.  
  145.         $splitter &$this->_doc->createElement('Splitter');
  146.         $splitter->useGrippy();
  147.  
  148.         $container->appendChild($splitter);
  149.  
  150.         $gbox2 &$this->_doc->createElement('Groupbox'array('orient'=>'vertical''flex' => '2'));
  151.         $gbox2->setCaption('Details');
  152.  
  153.         $container->appendChild($gbox2);
  154.  
  155.         $deck &$this->_doc->createElement('Deck');
  156.  
  157.         $gbox2->appendChild($deck);
  158.  
  159.  
  160.         $this->_root->addTab('Templates'$container);
  161.         return true;
  162.     }
  163.  
  164.     function _addToTree($name&$tree)
  165.     {
  166.         $tmpl    $this->_getTemplate($name);
  167.         $item    array(
  168.                             $name,
  169.                             '',
  170.                             $tmpl['attributes']['type'],
  171.                             $tmpl['attributes']['visibility'],
  172.                             $tmpl['loaded''yes' 'no',
  173.                         );
  174.         $current &$tree->addItem($item);
  175.         array_push($this->_addedTemplates$name);
  176.         if (!empty($tmpl['dependencies'])) {
  177.             $deps &$current->addItem(array'Dependencies' ));
  178.             foreach ($tmpl['dependencies'as $dependency{
  179.                 $this->_addToTree($dependency$deps);
  180.             }
  181.         }
  182.  
  183.         if (!isset($this->_vars[$name])) {
  184.             $this->_vars[$namearray();
  185.         }
  186.         $vars $this->_flattenVars$this->_vars[$name);
  187.  
  188.         if (empty($vars)) {
  189.             return true;
  190.         }
  191.         $varItem &$current->addItem(array'Variables' ));
  192.         foreach ($vars as $key => $value{
  193.             $varItem->addItem(array($key$value));
  194.         }
  195.     }
  196.  
  197.     function _getTemplate($name)
  198.     {
  199.         if (isset($this->_templates[$name])) {
  200.             return $this->_templates[$name];
  201.         }
  202.     }
  203.  
  204.     /**
  205.     * display the footer
  206.     *
  207.     * @access    public
  208.     */
  209.     function displayFooter()
  210.     {
  211.         if ($_GET['mode'== 'debug'{
  212.             require_once 'XML/Beautifier.php';
  213.             $fmt &new XML_Beautifierarray'indent' => '  ' ) );
  214.             echo '<pre>';
  215.             echo htmlspecialchars$fmt->formatString($this->_doc->serialize()) );
  216.             echo '</pre>';
  217.         elseif ($_GET['mode'== 'source'{
  218.             highlight_file__FILE__ );
  219.         elseif ($_GET['mode'== 'debug2'{
  220.             echo '<pre>';
  221.             echo htmlspecialchars$this->_doc->getDebug());
  222.             echo '</pre>';
  223.         elseif ($_GET['mode'== 'source'{        else {
  224.             $this->_doc->send();
  225.         }
  226.     }
  227. }
  228. ?>

Documentation generated on Sat, 14 Nov 2009 11:23:49 +0000 by phpDocumentor 1.3.1