apidoc
[ class tree: apidoc ] [ index: apidoc ] [ all elements ]

Class: HTML_Template_Flexy

Source Location: /HTML_Template_Flexy-1.3.13/HTML/Template/Flexy.php

Class Overview


A Flexible Template engine - based on simpletemplate


Author(s):

Version:

  • $Id: Flexy.php 335205 2014-11-21 04:23:53Z alan_k $

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 87]
A Flexible Template engine - based on simpletemplate
  • Version: $Id: Flexy.php 335205 2014-11-21 04:23:53Z alan_k $
  • Abstract:

    Long Description Have a look at the package description for details.

    usage: $template = new HTML_Template_Flexy($options); $template->compiler('/name/of/template.html'); $data =new StdClass $data->text = 'xxxx'; $template->outputObject($data,$elements)

    Notes: $options can be blank if so, it is read from PEAR::getStaticProperty('HTML_Template_Flexy','options');

    the first argument to outputObject is an object (which could even be an associateve array cast to an object) - I normally send it the controller class. the seconde argument '$elements' is an array of HTML_Template_Flexy_Elements eg. array('name'=> new HTML_Template_Flexy_Element('',array('value'=>'fred blogs'));



[ Top ]


Class Variables

$activeEngine =  false

[line 233]

The active engine

When outputing elements, we need access to the active engine for translation so before we output, we store the active engine in here.

  • Var: of HTML_Template_Flexy_Elements
  • Access: public

Type:   array


[ Top ]

$compiledTemplate =

[line 187]

The compiled template filename (Full path)
  • Access: public

Type:   string


[ Top ]

$currentTemplate =

[line 196]

The source template filename (Full path)
  • Access: public

Type:   string


[ Top ]

$elements = array()

[line 223]

Array of HTML_elements which is displayed on the template

Technically it's private (eg. only the template uses it..)

  • Var: of HTML_Template_Flexy_Elements
  • Access: public

Type:   array


[ Top ]

$elementsFile =

[line 211]

The serialized elements array file.
  • Access: public

Type:   string


[ Top ]

$getTextStringsFile =

[line 204]

The getTextStrings Filename
  • Access: public

Type:   string


[ Top ]

$options = array(   
        'compileDir'    =>  '',         // where do you want to write to.. (defaults to session.save_path)
        'templateDir'   =>  '',         // where are your templates
        
        // where the template comes from. ------------------------------------------
        'multiSource'   => false,       // Allow same template to exist in multiple places
                                        // So you can have user themes....
        'templateDirOrder' => '',       // set to 'reverse' to assume that first template
        
         
        'debug'         => false,       // prints a few messages
        
        
        // compiling conditions ------------------------------------------
        'compiler'      => 'Flexy',  // which compiler to use. (Flexy,Regex, Raw,Xipe)
        'forceCompile'  =>  false,      // only suggested for debugging
        'dontCompile'   => false,      // never compile - use this if you're manually compiling your templates

        // regex Compiler       ------------------------------------------
        'filters'       => array(),// used by regex compiler.
// standard Compiler    ------------------------------------------
'nonHTML'=>false,// dont parse HTML tags (eg. email templates)
'allowPHP'=>false,// allow PHP in template (use true=allow, 'delete' = remove it.)
'flexyIgnore'=>0,// turn on/off the tag to element code
'numberFormat'=>",2,'.',','",// default number format  {xxx:n} format = eg. 1,200.00 
'url_rewrite'=>'',// url rewriting ability:
// eg. "images/:test1/images/,js/:test1/js"
// changes href="images/xxx" to href="test1/images/xxx"
// and src="js/xxx.js" to src="test1/js/xxx.js"
'compileToString'=>false,// should the compiler return a string 
// rather than writing to a file.
'privates'=>false,// allow access to _variables (eg. suido privates
'globals'=>false,// allow access to _GET/_POST/_REQUEST/GLOBALS/_COOKIES/_SESSION
'globalfunctions'=>false,// allow GLOBALS.date(#d/m/Y#) to have access to all PHP's methods
// warning dont use unless you trust the template authors
// exec() becomes exposed.
'useElementLabels'=>true,// WARNING DO NOT ENABLE THIS UNLESS YOU TRUST THE TEMPLATE AUTHORS
// look for label elements referring to input elements
// you can then set (replace) the label of the corresponding input
// element by $element->label="my new label text";
// get text/transalation suppport ------------------------------------------
//  (flexy compiler only)
'disableTranslate'=>false,// if true, skips the translation functionality completely
'locale'=>'en',// works with gettext or File_Gettext
'textdomain'=>'',// for gettext emulation with File_Gettext
// eg. 'messages' (or you can use the template name.
'textdomainDir'=>'',// eg. /var/www/site.com/locale
// so the french po file is:
// /var/www/site.com/local/fr/LC_MESSAGE/{textdomain}.po
'Translation2'=>false,// to make Translation2 a provider.
// rather than gettext.
// set to:
//  'Translation2' => array(
//         'driver' => 'dataobjectsimple',
//         'CommonPageID' => 'page.id'    
//         'options' => array()
//  );
//
// Note: CommonPageID : to use a single page id for all templates
//
// or the slower way.. 
//   = as it requires loading the code..
//
//  'Translation2' => new Translation2('dataobjectsimple','')
'DB_DataObject_translator'=>false,// a db dataobject that handles translation (optional)
// the dataobject has to have the method translateFlexyString($flexy, $string);
'charset'=>'UTF-8',// charset used with htmlspecialchars to render data.
// experimental
// output options           ------------------------------------------
'strict'=>false,// All elements in the template must be defined - 
// makes php E_NOTICE warnings appear when outputing template.
'fatalError'=>HTML_TEMPLATE_FLEXY_ERROR_DIE,// default behavior is to die on errors in template.
'plugins'=>array(),// load classes to be made available via the plugin method
// eg. = array('Savant') - loads the Savant methods.
// = array('MyClass_Plugins' => 'MyClass/Plugins.php')
//    Class, and where to include it from..
)

[line 93]


Type:   mixed


[ Top ]



Method Detail

HTML_Template_Flexy (Constructor)   [line 244]

HTML_Template_Flexy HTML_Template_Flexy( [array $options = array()])

Constructor

Initializes the Template engine, for each instance, accepts options or reads from PEAR::getStaticProperty('HTML_Template_Flexy','options');

  • Access: public

Parameters:

array   $options   —  (Optional)

[ Top ]

addToBuffer   [line 673]

void addToBuffer( $buffer)

callback for outputObjectToFile

Parameters:

   $buffer   — 

[ Top ]

bufferedOutputObject   [line 630]

string bufferedOutputObject( object object $t, [ $elements = array()])

Outputs an object as $t, buffers the result and returns it.

See outputObject($t) for more details.

  • Return: - result
  • Author: Alan Knowles
  • Version: 01/12/14
  • Access: public

Parameters:

object object   $t   —  to output as $t
   $elements   — 

[ Top ]

compile   [line 317]

boolean compile( string $file)

compile the template
  • Return: true on success. (or string, if compileToString) PEAR_Error on failure..
  • Author: Wolfram Kriesing <wolfram@kriesing.de>
  • Version: 01/12/03
  • Access: public

Parameters:

string   $file   —  relative to the 'templateDir' which you set when calling the constructor

[ Top ]

compileAll   [line 507]

void compileAll( [ $dir = ''], [ $regex = '/.html$/'])

compiles all templates Used for offline batch compilation (eg. if your server doesn't have write access to the filesystem).

Parameters:

   $dir   — 
   $regex   — 

[ Top ]

debug   [line 710]

none debug( string $string)

if debugging is on, print the debug info to the screen

Parameters:

string   $string   —  output to display

[ Top ]

getElements   [line 765]

array getElements( )

Get an array of elements from the template

All <form> elements (eg. <input><textarea) etc.) and anything marked as dynamic (eg. flexy:dynamic="yes") are converted in to elements (simliar to XML_Tree_Node) you can use this to build the default $elements array that is used by outputObject() - or just create them and they will be overlayed when you run outputObject()

  • Return: of HTML_Template_Flexy_Element sDescription
  • Access: public

[ Top ]

initializeTranslator   [line 784]

none initializeTranslator( )

Initilalize the translation methods.

Loads Translation2 if required.

  • Access: public

[ Top ]

mergeElement   [line 736]

void mergeElement( $original, $new)

  • Access: public

Parameters:

   $original   — 
   $new   — 

[ Top ]

output   [line 1093]

mixed output( [optional $object = false])

output / display ? - outputs an object, without copy by references..
  • Return: PEAR_Error or true?
  • See: HTML_Template_Flexy::ouptutObject
  • Access: public

Parameters:

optional   $object   —  mixed object to output

[ Top ]

outputObject   [line 530]

none outputObject( object to &$t, [array $elements = array()])

Outputs an object as $t

for example the using simpletags the object's variable $t->test would map to {test}

  • Author: Alan Knowles
  • Version: 01/12/14
  • Access: public

Parameters:

object to   &$t   —  output
array   $elements   —  HTML_Template_Flexy_Elements (or any object that implements toHtml())

[ Top ]

outputObjectToFile   [line 653]

void outputObjectToFile( object object &$t, [ $elements = array()], $filename)

Outputs result to a file

See outputObject($t) for more details.

  • Author: Alan Knowles
  • Version: 01/12/14
  • Access: public

Parameters:

object object   &$t   —  to output as $t
   $elements   — 
   $filename   — 

[ Top ]

plugin   [line 1073]

mixed plugin( varargs 0)

Plugin (used by templates as $this->plugin(...) or {this.plugin(#...#,#....#)}

read the docs on HTML_Template_Flexy_Plugin()

  • Return: PEAR_Error or true?
  • See: HTML_Template_Flexy_Plugin
  • Access: public

Parameters:

varargs   0   —  ....

[ Top ]

raiseError   [line 975]

object pear raiseError( string $message, [int $type = null], [int $fatal = HTML_TEMPLATE_FLEXY_ERROR_RETURN])

Lazy loading of PEAR, and the error handler..

This should load HTML_Template_Flexy_Error really..

  • Return: error.
  • Access: public

Parameters:

string   $message   —  message
int   $type   —  error type.
int   $fatal   —  an equivalant to pear error return|die etc.

[ Top ]

resolvePath   [line 282]

string|PEAR_Error resolvePath( string $file)

given a file, return the possible templates that will becompiled.

Parameters:

string   $file   —  the template to look for.

[ Top ]

setData   [line 1029]

mixed setData( varargs 0)

Assign API -

read the docs on HTML_Template_Flexy_Assign::assign()

  • Return: PEAR_Error or true?
  • See: HTML_Template_Flexy_Assign::assign()
  • Access: public

Parameters:

varargs   0   —  ....

[ Top ]

setDataByRef   [line 1052]

mixed setDataByRef( key $k, value &$v)

Assign API - by Reference

read the docs on HTML_Template_Flexy_Assign::assign()

  • Return: PEAR_Error or true?
  • See: HTML_Template_Flexy_Assign::assign()
  • Access: public

Parameters:

key   $k   —  string
value   &$v   —  mixed

[ Top ]

staticQuickTemplate   [line 695]

string &staticQuickTemplate( object object $file, filename &$t)

static version which does new, compile and output all in one go.

See outputObject($t) for more details.

  • Return: - result
  • Author: Alan Knowles
  • Version: 01/12/14
  • Access: public

Parameters:

object object   $file   —  to output as $t
filename   &$t   —  of template

[ Top ]

staticRaiseError   [line 1001]

object pear staticRaiseError( string $message, [int $type = null], [int $fatal = HTML_TEMPLATE_FLEXY_ERROR_RETURN])

static version of raiseError
  • Return: error.
  • See: HTML_Template_Flexy::raiseError
  • Access: public

Parameters:

string   $message   —  message
int   $type   —  error type.
int   $fatal   —  an equivalant to pear error return|die etc.

[ Top ]

toString   [line 1109]

mixed toString( [optional $object = false])

render the template with data..
  • Return: PEAR_Error or true?
  • See: HTML_Template_Flexy::ouptutObject
  • Access: public

Parameters:

optional   $object   —  mixed object to output

[ Top ]

translateString   [line 833]

string translateString( string $string)

translateString - a gettextWrapper

tries to do gettext or falls back on File_Gettext This has !!!NO!!! error handling - if it fails you just get english.. no questions asked!!!

  • Return: translated string..
  • Access: public

Parameters:

string   $string   —  string to translate

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:59:57 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.