|
|
| |
File: c:/www/apache/doc2//form/ITX.php
PEAR Integrated Template [Extension] - IT[X], 11.02.2001 -
IntegratedTemplateExtension
IntegratedTemplate | +-- IntegratedTemplateExtension
Integrated Template Extension - ITX
|
public class IntegratedTemplateExtension extends IntegratedTemplate
Integrated Template Extension - ITX
With this class you get the full power of the phplib template class.You may have one file with blocks in it but you have as well one main fileand multiple files one for each block. This is quite usefull when you haveuser configurable websites. Using blocks not in the main template allowsyou to some parts of your layout easily.Note that you can replace an existing block and add new blocks add runtime.Adding new blocks means changing a variable placeholder to a block.
| Authors | Ulf Wendel <uw@netuse.de> |
| Version | $Id: ITX.php,v 1.4 2001/01/24 11:19:28 sbergmann Exp $ |
|
| |
|
Methods inherited from IntegratedTemplate |
| integratedtemplate, show, get, parse, parsecurrentblock, setvariable, setcurrentblock, touchblock, free, settemplate, loadtemplatefile, setroot, buildblockvariablelist, getglobalvariables, findblocks, getfile, halt |
|
|
|
|
|
Fields inherited from IntegratedTemplate |
| $err, $printerror, $haltonerror, $clearcache, $openingdelimiter, $closingdelimiter, $blocknameregexp, $variablenameregexp, $variablesregexp, $removevariablesregexp, $removeunknownvariables, $removeemptyblocks, $blockregexp, $currentblock, $template, $blocklist, $blockdata, $blockvariables, $blockinner, $touchedblocks, $variablecache, $clearcacheonparse, $fileroot, $flagblocktrouble, $flagglobalparsed, $flagcachetemplatefile, $lasttemplatefile |
|
|
|
|
|
Public Method Details |
IntegratedTemplateExtension |
|
public void IntegratedTemplateExtension( string $root )
|
| |
Builds some complex regexps and calls the constructor of the parent class.
Make sure that you call this constructor if you derive you owntemplate class from this one.
|
| Parameter |
|
| string |
$root |
|
|
Warning: documentation is missing. |
|
| Returns |
void |
|
replaceBlock |
|
public boolean replaceBlock( string $block, string $template )
|
| |
Replaces an existing block with new content. Warning: not implemented yet.
The Replacement does not affect previously added variables. All data is cached.In case the new block does contain less or other variable placeholder the previouslypassed data that is no longer referenced will be deleted. The internal listof allowed variables gets updated as well.In case the original block contains other blocks it must eighter have placeholderfor the inner blocks or contain them. If you want to use placeholder the placeholder mustlook like openingDelimiter."__".blockname."__".closingDelimiter .Due to the cache updates replaceBlock() and replaceBlockfile() are "expensive" operationswhich means extensive usage will slow down your script. So try to avoid them and ifyou can't do so try to use them before you pass lots of variables to the block you'rereplacing.
|
| Parameter |
|
|
|
|
| Returns |
boolean |
| See Also |
replaceBlockfile(), addBlock(), addBlockfile() |
|
addBlock |
|
public boolean addBlock( string $placeholder, string $blockname, string $template )
|
| |
Adds a block to the template changing a variable placeholder to a block placeholder.
Add means "replace a variable placeholder by a new block".This is different to PHPLibs templates. The function loads ablock, creates a handle for it and assigns it to a certainvariable placeholder. To to the same with PHPLibs templates you wouldcall set_file() to create the handle and parse() to assign theparsed block to a variable. By this PHPLibs templates assume that you tendto assign a block to more than one one placeholder. To assign a parsed blockto more than only the placeholder you specify in this function you haveto use a combination of getBlock() and setVariable().As no updates to cached data is necessary addBlock() and addBlockfile()are rather "cheap" meaning quick operations.The block content must not start with <!-- BEGIN blockname --> and end with<!-- END blockname --> this would cause overhead and produce an error.
|
| Parameter |
|
| string |
$placeholder |
|
|
of the variable placeholder, the name must be unique within the template. |
|
|
| string |
$blockname |
|
|
of the block to be added |
|
|
| string |
$template |
|
|
of the block |
|
| Returns |
boolean |
| See Also |
addBlockfile() |
|
placeholderExists |
|
public string placeholderExists( string $placeholder, [ string $block ] )
|
| |
Returns the name of the (first) block that contains the specified placeholder.
|
| Parameter |
|
| string |
$placeholder |
|
|
of the placeholder you're searching |
|
|
| string |
$block |
= >>""<< |
|
of the block to scan. If left out (default) all blocks are scanned. |
|
| Returns |
string Name of the (first) block that contains the specified placeholder.
If the placeholder was not found or an error occured an empty string is returned. |
|
performCallback |
|
public void performCallback( )
|
| |
Checks the list of function calls in the template and calls their callback function.
|
| Returns |
void |
|
getFunctioncalls |
|
public array getFunctioncalls( )
|
| |
Returns a list of all function calls in the current template.
|
| Returns |
array |
|
setFunctioncontent |
|
public void setFunctioncontent( int $functionID, string $replacement )
|
| |
Replaces a function call with the given replacement.
|
| Parameter |
|
|
|
|
| Returns |
void |
|
setCallbackFunction |
|
public boolean setCallbackFunction( string $tplfunction, string $callbackfunction, [ string $callbackobject ] )
|
| |
Sets a callback function.
|
| Parameter |
|
| string |
$tplfunction |
|
|
name in the template |
|
|
| string |
$callbackfunction |
|
|
of the callback function |
|
|
| string |
$callbackobject |
= >>""<< |
|
of the callback object |
|
| Returns |
boolean False on failure. |
|
setCallbackFuntiontable |
|
public void setCallbackFuntiontable( array $functions )
|
| |
Sets the Callback function lookup table
|
| Parameter |
|
| array |
$functions |
|
|
table - array[templatefunction] = array( "function" => userfunction, "object" => userobject ) |
|
| Returns |
void |
|
getBlocklist |
|
public array getBlocklist( )
|
| |
Returns a list of blocknames in the template.
|
| Returns |
array [blockname => blockname] |
| See Also |
blockExists() |
|
blockExists |
|
public boolean blockExists( string $blockname )
|
| |
Checks wheter a block exists.
|
| Parameter |
|
|
| Returns |
boolean |
| See Also |
getBlocklist() |
|
getBlockvariables |
|
public array getBlockvariables( string $block )
|
| |
Returns a list of variables of a block.
|
| Parameter |
|
|
| Returns |
array [varname => varname] |
| See Also |
BlockvariableExists() |
|
BlockvariableExists |
|
public boolean BlockvariableExists( string $block, string $variable )
|
| |
Checks wheter a block variable exists.
|
| Parameter |
|
|
|
|
| Returns |
boolean |
| See Also |
getBlockvariables() |
|
|
Private Method Details |
replaceBlockfile |
|
private void replaceBlockfile( string $block, string $filename )
|
| |
Replaces an existing block with new content from a file. Warning: not implemented yet.
The Replacement does not affect previously added variables. All data is cached.In case the new block does contain less or other variable placeholder the previouslypassed data that is no longer referenced will be deleted. The internal listof allowed variables gets updated as well.In case the original block contains other blocks it must eighter have placeholderfor the inner blocks or contain them. If you want to use placeholder the placeholder mustlook like openingDelimiter."__".blockname."__".closingDelimiter .Due to the cache updates replaceBlock() and replaceBlockfile() are "expensive" operationswhich means extensive usage will slow down your script. So try to avoid them and ifyou can't do so try to use them before you pass lots of variables to the block you'rereplacing.
|
| Parameter |
|
|
|
| string |
$filename |
|
|
of the file that contains the blockcontent |
|
| Returns |
void |
| See Also |
replaceBlockfile(), addBlock(), addBlockfile() |
|
addBlockfile |
|
private void addBlockfile( string $placeholder, string $blockname, string $filename )
|
| |
Adds a block taken from a file to the template changing a variable placeholder to a block placeholder.
Add means "replace a variable placeholder by a new block".This is different to PHPLibs templates. The function loads ablock, creates a handle for it and assigns it to a certainvariable placeholder. To to the same with PHPLibs templates you wouldcall set_file() to create the handle and parse() to assign theparsed block to a variable. By this PHPLibs templates assume that you tendto assign a block to more than one one placeholder. To assign a parsed blockto more than only the placeholder you specify in this function you haveto use a combination of getBlock() and setVariable().As no updates to cached data is necessary addBlock() and addBlockfile()are rather "cheap" meaning quick operations.The block content must not start with <!-- BEGIN blockname --> and end with<!-- END blockname --> this would cause overhead and produce an error.
|
| Parameter |
|
| string |
$placeholder |
|
|
of the variable placeholder to be converted |
|
|
| string |
$blockname |
|
|
of the block to be added |
|
|
| string |
$filename |
|
|
that contains the block |
|
| Returns |
void |
| See Also |
addBlockfile() |
|
buildFunctionlist |
|
private void buildFunctionlist( )
|
| |
Builds a functionlist from the template.
|
| Returns |
void |
|
deleteFromBlockvariablelist |
|
private void deleteFromBlockvariablelist( string $block, mixed $variables )
|
| |
Deletes one or many variables from the block variable list.
|
| Parameter |
|
|
|
| mixed |
$variables |
|
|
of one variable or array of variables ( array ( name => true ) ) to be stripped. |
|
| Returns |
void |
|
updateBlockvariablelist |
|
private void updateBlockvariablelist( string $block )
|
| |
Updates the variable list of a block.
|
| Parameter |
|
|
| Returns |
void |
|
findPlaceholderBlocks |
|
private array findPlaceholderBlocks( string $variable )
|
| |
Returns an array of blocknames where the given variable placeholder is used.
|
| Parameter |
|
| string |
$variable |
|
|
placeholder |
|
| Returns |
array $parents parents[0..n] = blockname |
|
warning |
|
private void warning( string $message, [ string $file, integer $line ] )
|
| |
Handles warnings, saves them to $warn and prints them or calls die() depending on the flags
|
| Parameter |
|
|
|
| string |
$file |
= >>""<< |
|
where the warning occured |
|
|
| integer |
$line |
= >>0<< |
|
where the warning occured |
|
| Returns |
void |
| See Also |
$warn, $printWarning, $haltOnWarning |
|
init |
|
private void init( )
|
| |
Clears all datafields of the object and rebuild the internal blocklist
LoadTemplatefile() and setTemplate() automatically call this functionwhen a new template is given. Don't use this functionunless you know what you're doing.
Warning: documentation is missing.
|
| Returns |
void |
| See Also |
free() |
|
getValue |
|
private void getValue( $code, $delimiter )
|
| |
Warning: documentation is missing.
|
| Parameter |
|
|
$code |
|
|
Warning: documentation is missing. |
|
|
|
$delimiter |
|
|
Warning: documentation is missing. |
|
| Returns |
void |
|
|
|
|
Private Field Details |
$checkblocknameRegExp |
|
private string $checkblocknameRegExp
>>""<<
RegExp used to test for a valid blockname.
|
|
$functionPrefix |
|
private string $functionPrefix
>>"func_"<<
Functionnameprefix used when searching function calls in the template.
|
|
$functionnameRegExp |
|
private string $functionnameRegExp
>>"[_a-zA-Z]+[A-Za-z_0-9]*"<<
Functionname RegExp.
|
|
$functionRegExp |
|
private string $functionRegExp
>>""<<
RegExp used to grep function calls in the template.
The variable gets set by the constructor.
|
| See Also |
IntegratedTemplateExtension() |
|
$functions |
|
private array $functions
>>array()<<
List of functions found in the template.
|
|
$callback |
|
private array $callback
>>array()<<
List of callback functions specified by the user.
|
|
|
|
|
|
| PHPDoc 1.0beta |