template 
[ doc home ] [ class tree: template ] [ index: template ] [ all elements ]

Class: T24FunctionContainer

Source Location: /T24FunctionContainer.php

Class Overview

IsterObject
   |
   --T24FunctionContainer

This class represents a set of buildin functions for T24 template language.


Author(s): Ingo Schramm   

Copyright: Copyright (c) 2005 Ister.ORG Ingo Schramm

Methods


Inherited Constants

Inherited Variables

Inherited Methods

Class: IsterObject

IsterObject::IsterObject()
Constructor
IsterObject::abstractMethodError()
Report attempt to call an abstract method.
IsterObject::addLogger()
Add an IsterLogger to process log messages.
IsterObject::deleteLogger()
Delete an already registered IsterLogger.
IsterObject::getLoggerNames()
Fetch the names of all currently registered IsterLoggers.
IsterObject::getMem()
Return maximum amount of memory an application has allocated at this point.
IsterObject::log()
Trigger a log message.
IsterObject::passPHPmessage()
Catch PHP E_WARNING and E_NOTICE messages.
IsterObject::serialize()
Serialize the object.
IsterObject::setLogLocal()
Set logging local for the current object.
IsterObject::setupLogger()
Setup a logger.
IsterObject::triggerError()
Alias for log();
IsterObject::unserialize()
Unserialize the object.
IsterObject::__sleep()
Executed prior to serialize().
IsterObject::__wakeup()
Executed prior to unserialize().

Class Details

This class represents a set of buildin functions for T24 template language.

General syntax for buildin functions:

  1. <?t24 :<function> <arg1> <arg2> ... ?>
  2.  
  3. strings are possible:
  4. <?t24 :<function> <arg1> "<arg2> <arg2>" '<arg3> <arg3>' ... ?>

It is possible to add more buildin functions e.g. by extending this class. On the other hand, this may not a simple task as it needs knowledge of the internal interaction of the different T24 objects.

Each of the buildin functions will get the parameter buffer from the parser, a reference to the current internal parse tree and the index of the parse tree where this function was called.

The contents of the parameter buffer is as follows:

  1. $parbuf[0] - function name
  2. $parbuf[1..n-1] - function arguments
  3. $parbuf[n] - line number

The builins c_repeat() and c_invoke() expect some registered methods to call. Such a method will receive one single array of arguments.

For a description of buildin functions and how to use them see the links below.




[ Top ]


Class Methods


constructor T24FunctionContainer

T24FunctionContainer T24FunctionContainer( )

Constructor

[ Top ]

method c_else

boolean c_else( array $parbuf, object T24TemplateTree &$tree, integer $idx)

Define an alternative.

  1. <?t24 :if DO == 1 ?>
  2. YES
  3. <?t24 :else ?>
  4. NO
  5. <?t24 :end ?>


Parameters:

array   $parbuf  
object T24TemplateTree   &$tree  
integer   $idx  

[ Top ]

method c_end

boolean c_end( array $parbuf, object T24TemplateTree &$tree, integer $idx)

End the most recent block.

Parameters:

array   $parbuf  
object T24TemplateTree   &$tree  
integer   $idx  

[ Top ]

method c_if

boolean c_if( array $parbuf, object T24TemplateTree &$tree, integer $idx)

Test if a condition is true.

  1. <?t24 :if VAR == 1 ?>Hello World!<?t24 :end ?>
  2.  
  3. <?t24 :if <var> ?> // true if <var> is true
  4. <?t24 :if <var> def ?> // true if <var> not null
  5. <?t24 :if <var> z ?> // true if (string) <var> has zero length
  6. <?t24 :if <var> nz ?> // true if (string) <var> has nonzero length
  7. <?t24 :if <var> eq <string> ?> // true if (string) <var> equals <string>
  8. <?t24 :if <var> neq <string> ?> // true if (string) <var> not equals <string>
  9. <?t24 :if <var> == <integer> ?> // true if <var> equals <integer>
  10. <?t24 :if <var> != <integer> ?> // true if <var> not equals <integer>
  11. <?t24 :if <var> > <integer> ?> // true if <var> is greater than <integer>
  12. <?t24 :if <var> < <integer> ?> // true if <var> is lesser than <integer>
  13. <?t24 :if <var> >= <integer> ?> // true if <var> is greater or equal <integer>
  14. <?t24 :if <var> <= <integer> ?> // true if <var> is lesser or eaqual <integer>


Parameters:

array   $parbuf  
object T24TemplateTree   &$tree  
integer   $idx  

[ Top ]

method c_include

boolean c_include( array $parbuf, object T24TemplateTree &$tree, integer $idx)

Include another template.

  1. <?t24 :include <path> [file] ?>
  2. <?t24 :include <methodname> string [<arg1> [<arg2> [...]]] ?>
For string ressources, the name of the string will be composed of the method name and arguments, concatenated with a single space. This may be usefulf if you want to establish some caching mechanism.
  1. <?t24 :include getString string 23 ?>
  2. ---
  3. Name of included ressource now: "getString 23"


Parameters:

array   $parbuf  
object T24TemplateTree   &$tree  
integer   $idx  

[ Top ]

method c_invoke

boolean c_invoke( array $parbuf, object T24TemplateTree &$tree, integer $idx)

Invoke a registered method.

  1. class test {
  2. function example($array) {
  3. return 'example: '.implode('+',$array);
  4. }
  5. }
  6. $class = new test;
  7. $template->setProperty('/register/method', array('example' => $class);
  8. ---
  9. <?t24 :invoke example arg1 arg2 arg3 ?>
  10. ---
  11. example: arg1+arg2+arg3

Method should return a string, otherwise the empty string will be inserted. You may use explicit type cast to ensure this.


Parameters:

array   $parbuf  
object T24TemplateTree   &$tree  
integer   $idx  

[ Top ]

method c_not

boolean c_not( array $parbuf, object T24TemplateTree &$tree, integer $idx)

Test if a condition is false.

  1. <?t24 :not VAR == 1 ?>Hello World!<?t24 :end ?>


Parameters:

array   $parbuf  
object T24TemplateTree   &$tree  
integer   $idx  

[ Top ]

method c_repeat

boolean c_repeat( array $parbuf, object T24TemplateTree &$tree, integer $idx)

Define a block template.

The registered method should return an array of variable => value pairs. The loop will stop when the method returns null. The variables returned by the method are only visible inside the current block or subsequent blocks.

  1. class test {
  2. function test {
  3. $this->counter = 0;
  4. }
  5.  
  6. function repeater() {
  7. if($this->counter == 3)
  8. return null;
  9. return array('COUNTER' => ++$this->counter);
  10. }
  11. }
  12. $class = new test;
  13. $template->setProperty('/register/method', array('repeater' => $class);
  14. ---
  15. <?t24 :repeat repeater ?>
  16. <?t24 COUNTER ?>
  17. <?t24 :end ?>
  18. ---
  19. 1
  20. 2
  21. 3


Parameters:

array   $parbuf  
object T24TemplateTree   &$tree  
integer   $idx  

[ Top ]

method c_set

boolean c_set( array $parbuf, object T24TemplateTree &$tree, integer $idx)

Assign a value to a variable.

  1. <?t24 :set scalar 1 ?>
  2. <?t24 :set array 1 2 3 4 ?>
  3. <?t24 :set string1 '1 2 "3" 4' ?>
  4. <?t24 :set string2 "1 2 '3' 4" ?>


Parameters:

array   $parbuf  
object T24TemplateTree   &$tree  
integer   $idx  

[ Top ]

method destroy

boolean destroy( )

Explicitly run garbage collection.

[ Top ]

method executeFunction

boolean executeFunction( string $name, array $parbuf, object T24TemplateTree &$tree, integer $idx)

Execute a buildin function

Parameters:

string   $name  
array   $parbuf  
object T24TemplateTree   &$tree  
integer   $idx  

[ Top ]

method setParser

boolean setParser( object T24Parser &$parser)

Set parser this object belongs to.

Parameters:

object T24Parser   &$parser  

[ Top ]


Documentation generated on Tue, 20 Dec 2005 11:21:51 +0100 by phpDocumentor 1.3.0RC4