function to help with debug of IT[X] generated pages
| From: | Moody | Date: | Tue, 28 Aug 2001 15:02:01 +0000 |
| Subject: | function to help with debug of IT[X] generated pages | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-289@lists.php.net to get a copy of this message | ||
I have been coming to grips with the inner workings of IT[X] decided to
write this function to help me see what's happening at various stages of
building the page.
What specifically prompted me to write this function was that I have been
having problems with the addBlockfile method in that it will find all blocks
in a file, but not any of the variables (place holders) in the file. This
seems to point at a bug in the updateBlockvariablelist method of ITX. Before
I dive in there to try and debug it, I was wondering if anyone else has come
across this and fixed it?
Now on to my function:
<?php
function indent($ilevel)
{
$t="";
for($i=0; $i<$ilevel; $i++) { $t .= " "; }
return $t;
} // end function indent
/**
* Recursively prints all details of a block, including all place holders
(variables) and inner blocks
*
* Usage:
* block_show_details($template [, $block])
*
* @param template Instance of IntegratedTemplate[Extension] in your
script.
* @param block Name of the block whose details are to be shown,
defaults to "__global__"
* @param ilevel Indent level of the block. Should not be included when
calling the function.
* @return boolean
*/
function block_show_details($template, $block = "__global__", $ilevel = 0)
{
print indent($ilevel)."Details of <b>".$block."</b>
block:<br>";
$ilevel++;
$block_variables = $template->blockvariables[$block];
if (is_array($block_variables)) {
foreach ( $block_variables as $k=>$v ) {
print indent($ilevel)."Variable:
".$k."->".$v."<br>";
}
} else {
print indent($ilevel)."....no variables....<br>";
}
$inner_blocks = $template->blockinner[$block];
if (is_array($inner_blocks)) {
foreach ( $inner_blocks as $k=>$v ) {
print indent(&$ilevel)."Inner block:
".$k."->".$v."<br>";
block_show_details($template, $v, $ilevel++);
$ilevel--;
}
} else {
print indent($ilevel)."....no inner blocks....<br>";
}
return true;
} //end function block_show_details
?>