[ Index ]
 

Code source de eGroupWare 1.2.106-2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/phpgwapi/inc/savant2/ -> Savant2.php (sommaire)

Error constants.

Poids: 1488 lignes (32 kb)
Inclus ou requis: 1 fois
Référencé: 0 fois
Nécessite: 0 fichiers

Définit 1 class

Savant2:: (30 méthodes):
  Savant2()
  setCompiler()
  setCall()
  setError()
  setRestrict()
  setExtract()
  setReference()
  setTemplate()
  setPath()
  addPath()
  getPath()
  findFile()
  assign()
  assignRef()
  clear()
  getVars()
  loadTemplate()
  findTemplate()
  fetch()
  display()
  loadPlugin()
  unloadPlugin()
  splugin()
  plugin()
  __call()
  loadFilter()
  unloadFilter()
  applyFilters()
  error()
  isError()


Classe: Savant2  - X-Ref

Provides an object-oriented template system.

Savant2 helps you separate model logic from view logic using PHP as
the template language. By default, Savant2 does not compile templates.
However, you may pass an optional compiler object to compile template
source to include-able PHP code.

Please see the documentation at {@link http://phpsavant.com/}, and be
sure to donate! :-)

$Id: Savant2.php 18360 2005-05-26 19:38:09Z mipmip $

Savant2($conf = array()   X-Ref
Constructor.

param: array $conf An associative array of configuration keys for

setCompiler(&$compiler)   X-Ref
Sets a custom compiler/pre-processor for template sources.

By default, Savant2 does not use a compiler; use this to set your
own custom compiler (pre-processor) for template sources.

param: object $compiler The compiler object; it must have a
return: void

setCall($method = 'plugin')   X-Ref
Sets the method that __call() will alias to.

param: string $method The Savant2 method for __call() to alias to,
return: void

setError($error)   X-Ref
Sets the custom error class for Savant2 errors.

param: string $error The name of the custom error class name; if
return: void

setRestrict($flag = false)   X-Ref
Turns path checking on/off.

param: bool $flag True to turn on path checks, false to turn off.
return: void

setExtract($flag = true)   X-Ref
Turns extraction of variables on/off.

param: bool $flag True to turn on extraction, false to turn off.
return: void

setReference($flag = false)   X-Ref
Sets the automated Savant reference for plugins and filters.

param: bool $flag Whether to reference Savant2 or not.
return: void

setTemplate($template)   X-Ref
Sets the default template name.

param: string $template The default template name.
return: void

setPath($type, $new)   X-Ref
Sets an entire array of search paths.

param: string $type The type of path to set, typcially 'template'
param: string|array $new The new set of search paths.  If null or
return: void

addPath($type, $dir)   X-Ref
Adds a search directory for templates.

param: string $dir The directory or stream to search.
return: void

getPath($type = null)   X-Ref
Gets the array of search directories for template sources.

return: array The array of search directories for template sources.

findFile($type, $file)   X-Ref
Searches a series of paths for a given file.

param: array $type The type of paths to search (template, plugin,
param: string $file The file name to look for.
return: string|bool The full path and file name for the target file,

assign()   X-Ref
Sets variables for the template.

This method is overloaded; you can assign all the properties of
an object, an associative array, or a single value by name.

You are not allowed to set variables that begin with an underscore;
these are either private properties for Savant2 or private variables
within the template script itself.

<code>

$Savant2 =& new Savant2();

// assign directly
$Savant2->var1 = 'something';
$Savant2->var2 = 'else';

// assign by name and value
$Savant2->assign('var1', 'something');
$Savant2->assign('var2', 'else');

// assign by assoc-array
$ary = array('var1' => 'something', 'var2' => 'else');
$Savant2->assign($obj);

// assign by object
$obj = new stdClass;
$obj->var1 = 'something';
$obj->var2 = 'else';
$Savant2->assign($obj);

</code>

Greg Beaver came up with the idea of assigning to public class
properties.

return: void

assignRef($key, &$val)   X-Ref
Sets references for the template.

// assign by name and value
$Savant2->assignRef('ref', $reference);

// assign directly
$Savant2->ref =& $reference;

Greg Beaver came up with the idea of assigning to public class
properties.

param: string $key The name for the reference in the template.
param: mixed &$val The referenced variable.
return: void

clear($var = null)   X-Ref
Unsets assigned variables and references.

param: mixed $var If null, clears all variables; if a string, clears
return: void

getVars($key = null)   X-Ref
Gets the current value of one, many, or all assigned variables.

Never returns variables starting with an underscore; these are
reserved for internal Savant2 use.

param: mixed $key If null, returns a copy of all variables and
return: mixed If multiple variables were reqested, returns an

loadTemplate($tpl = null, $setScript = false)   X-Ref
Loads a template script for execution (does not execute the script).

This will optionally compile the template source into a PHP script
if a compiler object has been passed into Savant2.

Also good for including templates from the template paths within
another template, like so:

include $this->loadTemplate('template.tpl.php');

param: string $tpl The template source name to look for.
param: bool $setScript Default false; if true, sets the $this->_script
return: string The full path to the compiled template script.

findTemplate($tpl = null)   X-Ref
This is a an alias to loadTemplate() that cannot set the script.

param: string $tpl The template source name to look for.
return: string The full path to the compiled template script.

fetch($_tpl = null)   X-Ref
Executes a template script and returns the results as a string.

param: string $_tpl The name of the template source file ...
return: string The output of the the template script.

display($tpl = null)   X-Ref
Execute and display a template script.

param: string $tpl The name of the template file to parse;
return: void

loadPlugin($name, $conf = array()   X-Ref
Loads a plugin class and instantiates it within Savant2.

param: string $name The plugin name (not including Savant2_Plugin_
param: array $conf An associative array of plugin configuration
param: bool $savantRef Default false.  When true, sets the $Savant
return: void

unloadPlugin($name = null)   X-Ref
Unloads one or more plugins from Savant2.

param: string|array $name The plugin name (not including Savant2_Plugin_
return: void

splugin($name)   X-Ref
Executes a plugin with arbitrary parameters and returns the
result.

param: string $name The plugin name (not including Savant2_Plugin_
return: mixed The plugin results.

plugin($name)   X-Ref
Executes a plugin with arbitrary parameters and displays the
result.

param: string $name The plugin name (not including Savant2_Plugin_
return: void

__call($func, $args)   X-Ref
PHP5 ONLY: Magic method alias to plugin().

E.g., instead of $this->plugin('form', ...) you would use
$this->form(...).  You can set this to use any other Savant2 method
by issuing, for example, setCall('splugin') to use splugin() ... which
is really the only other sensible choice.

param: string $func The plugin name.
param: array $args Arguments passed to the plugin.
return: void

loadFilter($name, $conf = array()   X-Ref
Loads a filter class and instantiates it within Savant2.

param: string $name The filter name (not including Savant2_Filter_
param: array $conf An associative array of filter configuration
param: bool $savantRef Default false.  When true, sets the $Savant
return: void

unloadFilter($name = null)   X-Ref
Unloads one or more filters from Savant2.

param: string|array $name The filter name (not including Savant2_Filter_
return: void

applyFilters($text = null)   X-Ref
Apply all loaded filters, in order, to text.

param: string $text The text to which filters should be applied.
return: string The text after being passed through all loded

error($code, $info = array()   X-Ref
Returns an error object.

param: int $code A SAVANT2_ERROR_* constant.
param: array $info An array of error-specific information.
return: object An error object of the type specified by

isError(&$obj)   X-Ref
Tests if an object is of the Savant2_Error class.

param: object &$obj The object to be tested.
return: boolean True if $obj is an error object of the type



Généré le : Sun Feb 25 17:20:01 2007 par Balluche grâce à PHPXref 0.7