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

Class: HTML_Template_Flexy

Source Location: /HTML_Template_Flexy-0.8.0/Flexy.php

Class Overview


A Flexible Template engine - based on simpletemplate


Author(s):

Version:

  • $Id: Flexy.php,v 1.68 2004/04/21 09:02:17 alan_k Exp $

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 68]
A Flexible Template engine - based on simpletemplate
  • Version: $Id: Flexy.php,v 1.68 2004/04/21 09:02:17 alan_k Exp $
  • 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

$compiledTemplate =

[line 156]

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

Type:   string


[ Top ]

$currentTemplate =

[line 165]

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

Type:   string


[ Top ]

$elementsFile =

[line 180]

The serialized elements array file.
  • Access: public

Type:   string


[ Top ]

$emailBoundary =

[line 142]

emailBoundary - to use put {this.emailBoundary} in template
  • Access: public

Type:   string


[ Top ]

$emaildate =

[line 149]

emaildate - to use put {this.emaildate} in template
  • Access: public

Type:   string


[ Top ]

$gettextStringsFile =

[line 173]

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
        
        
        // get text/transalation suppport
        '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',
                                        //         'options' => array()
                                        //  );
                                        // or the slower way.. 
                                        //   = as it requires loading the code..
                                        //
                                        //  'Translation2' => new Translation2('dataobjectsimple','')
                                        
                                        
        'forceCompile'  =>  false,      // only suggested for debugging

        'debug'         => false,       // prints a few messages
        
        
        // compiling conditions.
        'nonHTML'       => false,       // dont parse HTML tags (eg. email templates)
        'allowPHP'      => false,       // allow PHP in template
        'filters'       => array(),// used by regex compiler.                
'flexyIgnore'=>0,// turn on/off the tag to element code
'numberFormat'=>",2,'.',','",// default number format  {xxx:n} format = eg. 1,200.00 
'compiler'=>'Standard',// which compiler to use.
'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.
'strict'=>false,// All elements in the template must be defined - 
// makes php E_NOTICE warnings appear when outputing template.
'fatalError'=>PEAR_ERROR_DIE,// default behavior is to die on errors in template.
)

[line 74]


Type:   mixed


[ Top ]



Method Detail

HTML_Template_Flexy (Constructor)   [line 205]

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 ]

bufferedOutputObject   [line 322]

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 362]

boolean compile( string $file, boolean $fixForMail)

compile the template
  • Return: true on success. 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
boolean   $fixForMail   —  - replace ?>\n with ?>\n\n

[ Top ]

compileAll   [line 520]

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 577]

none debug( string $string)

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

Parameters:

string   $string   —  output to display

[ Top ]

getElements   [line 660]

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 ]

mergeElement   [line 598]

HTML_Template_Flexy_Element mergeElement( HTML_Template_Flexy_Element $original, HTML_Template_Flexy_Element $new)

A general Utility method that merges HTML_Template_Flexy_Elements Static method - no native debug avaiable..
  • Return: the combined/merged data.
  • Access: public

Parameters:

HTML_Template_Flexy_Element   $original   —  (eg. from getElements())
HTML_Template_Flexy_Element   $new   —  (with data to replace/merge)

[ Top ]

outputObject   [line 246]

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 ]

staticQuickTemplate   [line 342]

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 ]


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