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