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