118        $this->checkblocknameRegExp = 
'@' . $this->blocknameRegExp . 
'@';
 
  119        $this->functionRegExp = 
'@' . $this->functionPrefix . 
'(' .
 
  120                                $this->functionnameRegExp . 
')\s*\(@sm';
 
  122        parent::__construct(
$root);
 
  131        $this->
template = 
'';
 
  162        if (!isset($this->blocklist[$block])) {
 
  164                " does not exist in the template and thus it can't be replaced."));
 
  179        $parents = $this->blockparents[$block];
 
  181        $this->blockparents[$block] = $parents;
 
  244        if ($placeholder == 
'') {
 
  246        } elseif ($blockname == 
'' ||
 
  247                    !preg_match($this->checkblocknameRegExp, $blockname)
 
  252        } elseif (isset($this->blocklist[$blockname])) {
 
  258        if (count($parents) == 0) {
 
  260                " '$placeholder' was not found in the template."));
 
  262        } elseif (count($parents) > 1) {
 
  264            foreach ($parents as $k => $parent) {
 
  267            $msg = substr($parent, -2);
 
  269                " must be unique, found in multiple blocks '$msg'."));
 
  274        if ($this->flagBlocktrouble) {
 
  277        $this->blockinner[$parents[0]][] = $blockname;
 
  278        $this->blocklist[$parents[0]] = preg_replace(
 
  279            '@' . $this->openingDelimiter . $placeholder .
 
  280                    $this->closingDelimiter . 
'@',
 
  281            $this->openingDelimiter . 
'__' . $blockname . 
'__' .
 
  282                    $this->closingDelimiter,
 
  283            $this->blocklist[$parents[0]]
 
  323        if ($placeholder == 
'') {
 
  327        if ($block != 
'' && !isset($this->blocklist[$block])) {
 
  335            if (is_array($variables = $this->blockvariables[$block])) {
 
  338                foreach ($variables as $k => $variable) {
 
  339                    if ($k == $placeholder) {
 
  349            reset($this->blockvariables);
 
  350            foreach ($this->blockvariables as $blockname => $variables) {
 
  351                if (is_array($variables) && isset($variables[$placeholder])) {
 
  369        reset($this->functions);
 
  370        foreach ($this->functions as $func_id => $function) {
 
  371            if (isset($this->callback[$function[
'name']])) {
 
  372                if ($this->callback[$function[
'name']][
'expandParameters']) {
 
  373                    $callFunction = 
'call_user_func_array';
 
  375                    $callFunction = 
'call_user_func';
 
  378                if ($this->callback[$function[
'name']][
'object'] != 
'') {
 
  382                        &
$GLOBALS[$this->callback[$function[
'name']][
'object']],
 
  383                        $this->callback[$function[
'name']][
'function']),
 
  389                           $this->callback[$function[
'name']][
'function'],
 
  393                $this->variableCache[
'__function' . $func_id . 
'__'] = $call;
 
  418        $this->variableCache[
'__function' . $functionID . 
'__'] = $replacement;
 
  468    public function setCallbackFunction($tplfunction, $callbackfunction, $callbackobject = 
'', $expandCallbackParameters = 
false)
 
  470        if ($tplfunction == 
'' || $callbackfunction == 
'') {
 
  472                " and/or no callback function ('$callbackfunction') given."));
 
  474        $this->callback[$tplfunction] = array(
 
  475                                          'function' => $callbackfunction,
 
  476                                          'object' => $callbackobject,
 
  477                                          'expandParameters' => (
boolean) $expandCallbackParameters
 
  507        if (isset($this->blockinner[$block])) {
 
  508            foreach ($this->blockinner[$block] as $k => $inner) {
 
  512            unset($this->blockinner[$block]);
 
  515        unset($this->blocklist[$block]);
 
  516        unset($this->blockdata[$block]);
 
  517        unset($this->blockvariables[$block]);
 
  518        unset($this->touchedBlocks[$block]);
 
  531        foreach ($this->blocklist as $block => $content) {
 
  548        return isset($this->blocklist[$blockname]);
 
  561        if (!isset($this->blockvariables[$block])) {
 
  565        $variables = array();
 
  566        foreach ($this->blockvariables[$block] as $variable => $v) {
 
  567            $variables[$variable] = $variable;
 
  584        return isset($this->blockvariables[$block][$variable]);
 
  593        $this->functions = array();
 
  598        while (preg_match($this->functionRegExp, 
$template, $regs)) {
 
  605            $search = $regs[0] . $head . 
')';
 
  607            $replace = $this->openingDelimiter .
 
  608                       '__function' . $num . 
'__' .
 
  611            $this->
template = str_replace($search, $replace, $this->
template);
 
  614            while ($head != 
'' && $args2 = $this->
getValue($head, 
',')) {
 
  615                $arg2 = trim($args2);
 
  616                $args[] = (
'"' == $arg2[0] || 
"'" == $arg2[0]) ?
 
  617                                    substr($arg2, 1, -1) : $arg2;
 
  618                if ($arg2 == $head) {
 
  621                $head = substr($head, strlen($arg2) + 1);
 
  624            $this->functions[$num++] = array(
 
  651        $len = strlen(
$code);
 
  658            for (
$i = 0; 
$i < $len; ++
$i) {
 
  662                        ($char == 
'"' || $char == 
"'") &&
 
  663                        ($char == $enclosed_by || 
'' == $enclosed_by) &&
 
  667                        $enclosed_by = $char;
 
  671                    $enclosed = !$enclosed;
 
  693        if (!is_array($variables)) {
 
  694            $variables = array($variables => 
true);
 
  697        reset($this->blockvariables[$block]);
 
  698        foreach ($this->blockvariables[$block] as $varname => $val) {
 
  699            if (isset($variables[$varname])) {
 
  700                unset($this->blockvariables[$block][$varname]);
 
  714            $this->variablesRegExp,
 
  715            $this->blocklist[$block],
 
  719        if (count($regs[1]) != 0) {
 
  720            foreach ($regs[1] as $k => $var) {
 
  721                $this->blockvariables[$block][$var] = 
true;
 
  724            $this->blockvariables[$block] = array();
 
  728        if (isset($this->blockinner[$block]) &&
 
  729            is_array($this->blockinner[$block]) &&
 
  730            count($this->blockinner[$block]) > 0
 
  736            foreach ($this->blockinner[$block] as $childBlock) {
 
  753        reset($this->blocklist);
 
  754        foreach ($this->blocklist as $blockname => $content) {
 
  755            reset($this->blockvariables[$blockname]);
 
  756            foreach ($this->blockvariables[$blockname] as $varname => $val) {
 
  757                if ($variable == $varname) {
 
  758                    $parents[] = $blockname;
 
  779            'HTML_Template_ITX Warning: %s [File: %s, Line: %d]',
 
  787        if ($this->printWarning) {
 
  791        if ($this->haltOnWarning) {
 
An exception for terminatinating execution or to throw for unit testing.
setCallbackFuntiontable($functions)
Sets the Callback function lookup table.
removeBlockData($block)
Recursively removes all data assiciated with a block, including all inner blocks.
setFunctioncontent($functionID, $replacement)
Replaces a function call with the given replacement.
setCallbackFunction($tplfunction, $callbackfunction, $callbackobject='', $expandCallbackParameters=false)
Sets a callback function.
updateBlockvariablelist($block)
Updates the variable list of a block.
warning($message, $file='', $line=0)
Handles warnings, saves them to $warn and prints them or calls die() depending on the flags.
getBlockvariables($block)
Returns a list of variables of a block.
findPlaceholderBlocks($variable)
Returns an array of blocknames where the given variable placeholder is used.
addBlockfile($placeholder, $blockname, $filename)
Adds a block taken from a file to the template changing a variable placeholder to a block placeholder...
performCallback()
Checks the list of function calls in the template and calls their callback function.
buildFunctionlist()
Builds a functionlist from the template.
addBlock($placeholder, $blockname, $template)
Adds a block to the template changing a variable placeholder to a block placeholder.
getBlocklist()
Returns a list of blocknames in the template.
replaceBlock($block, $template, $keep_content=false)
Replaces an existing block with new content.
__construct($root='')
Builds some complex regexps and calls the constructor of the parent class.
init()
Clears all datafields of the object and rebuild the internal blocklist.
getFunctioncalls()
Returns a list of all function calls in the current template.
blockExists($blockname)
Checks wheter a block exists.
BlockvariableExists($block, $variable)
Checks wheter a block variable exists.
deleteFromBlockvariablelist($block, $variables)
Deletes one or many variables from the block variable list.
replaceBlockfile($block, $filename, $keep_content=false)
Replaces an existing block with new content from a file.
getValue($code, $delimiter)
Truncates the given code from the first occurence of $delimiter but ignores $delimiter enclosed by " ...
placeholderExists($placeholder, $block='')
Returns the name of the (first) block that contains the specified placeholder.
findBlocks($string)
Recusively builds a list of all blocks within the template.
free()
Clears all datafields of the object.
buildBlockvariablelist()
Build a list of all variables within of a block.
getFile($filename)
Reads a file from disk and returns its content.
catch(Exception $e) $message
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
Integrated Template - IT.