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/XUL.php

Documentation is available at XUL.php

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

Documentation generated on Mon, 05 Mar 2007 21:33:19 +0000 by phpDocumentor 1.3.1