| [ Index ] |
PHP Cross Reference of Joomla 1.5.26 DE |
[Summary view] [Print] [Text view]
1 <?PHP 2 /** 3 * Base class for patTemplate dumpers 4 * 5 * $Id: Dump.php 10381 2008-06-01 03:35:53Z pasamio $ 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 <schst@php.net> 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 <schst@php.net> 28 */ 29 class patTemplate_Dump extends patTemplate_Module 30 { 31 /** 32 * reference to the patTemplate object that instantiated the module 33 * 34 * @access protected 35 * @var object 36 */ 37 var $_tmpl; 38 39 /** 40 * set a reference to the patTemplate object that instantiated the reader 41 * 42 * @access public 43 * @param object patTemplate object 44 */ 45 function setTemplateReference( &$tmpl ) 46 { 47 $this->_tmpl = &$tmpl; 48 } 49 50 /** 51 * display the header 52 * 53 * @access public 54 */ 55 function displayHeader() 56 { 57 } 58 59 /** 60 * dump the global variables 61 * 62 * @access public 63 * @param array array containing all global variables 64 * @abstract 65 */ 66 function dumpGlobals( $globals ) 67 { 68 } 69 70 /** 71 * dump the templates 72 * 73 * This method has to be implemented in the dumpers. 74 * 75 * @access public 76 * @abstract 77 * @param array templates 78 * @param array variables 79 */ 80 function dumpTemplates( $templates, $vars ) 81 { 82 } 83 84 /** 85 * display the footer 86 * 87 * @access public 88 */ 89 function displayFooter() 90 { 91 } 92 93 /** 94 * flatten the variables 95 * 96 * This will convert the variable definitions 97 * to a one-dimensional array. If there are 98 * rows defined, they will be converted to a string 99 * where the values are seperated with commas. 100 * 101 * @access private 102 * @param array variable definitions 103 * @return array flattened variables 104 */ 105 function _flattenVars( $vars ) 106 { 107 $flatten = array(); 108 foreach( $vars['scalar'] as $var => $value ) 109 { 110 $flatten[$var] = $value; 111 } 112 foreach( $vars['rows'] as $row ) 113 { 114 foreach( $row as $var => $value ) 115 { 116 if( !isset( $flatten[$var] ) || !is_array( $flatten[$var] ) ) 117 $flatten[$var] = array(); 118 array_push( $flatten[$var], $value ); 119 } 120 } 121 122 foreach( $flatten as $var => $value ) 123 { 124 if( !is_array( $value ) ) 125 continue; 126 127 $flatten[$var] = '['.count($value).' rows] ('.implode( ', ', $value ).')'; 128 } 129 130 return $flatten; 131 } 132 133 /** 134 * extract all variables from a template 135 * 136 * @access private 137 * @param string template content 138 * @return array array containing all variables 139 */ 140 function _extractVars( $template ) 141 { 142 $pattern = '/'.$this->_tmpl->getStartTag().'([^a-z]+)'.$this->_tmpl->getEndTag().'/U'; 143 144 $matches = array(); 145 146 $result = preg_match_all( $pattern, $template, $matches ); 147 if( $result == false ) 148 return array(); 149 150 $vars = array(); 151 foreach( $matches[1] as $var ) 152 { 153 if( strncmp( $var, 'TMPL:', 5 ) === 0 ) 154 continue; 155 array_push( $vars, $var ); 156 } 157 return array_unique( $vars ); 158 } 159 } 160 ?>
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 |