Loading Please wait...

zTemplate Class Reference
[template]

Inheritance diagram for zTemplate:

Inheritance graph
[legend]
Collaboration diagram for zTemplate:

Collaboration graph
[legend]

Public Member Functions

 numeric ($templateName, $placeHolders=array())
 sysNumeric ($templateName, $placeHolders=array())
 assoc ($templateName, $placeHolders=array())
 sysAssoc ($templateName, $placeHolders=array())

Private Member Functions

 getContents ($src, $flag=false)
 exists ($src, $flag)
 getPath ($src, $flag)
 coreNumeric ()
 coreAssoc ($dict)

Detailed Description

Template Handling Class. It holds several static methods that accepts a template name and arguments to be placed on the templated. and returns the output of the template as a string.

Definition at line 40 of file usr/lib/module/template/template.php.


Member Function Documentation

zTemplate::getContents ( src,
flag = false 
) [private]

get Contents of a Template as string.

For internal use only.

Parameters:
$src string Template name.
$flag boolean optional defaults to false If set to true means you are accessing a global template if turned true it means you are accessing a template of your project.
Returns:
boolean

Definition at line 49 of file usr/lib/module/template/template.php.

References exists(), getPath(), and perror().

Referenced by assoc(), numeric(), sysAssoc(), and sysNumeric().

00049                                          {
00050     if(zTemplate::exists($src, $flag)){
00051       return file_get_contents(zTemplate::getPath($src, $flag));
00052     }else{
00053       perror('<code>zigmoyd.template</code><br />template '.$src.' doesn\'t exist');
00054       return false;
00055     }
00056   }

Here is the call graph for this function:

zTemplate::exists ( src,
flag 
) [private]

Checks whaeather a template exists or not.

For internal use only.

Parameters:
$src string Template name.
$flag boolean optional defaults to false If set to true means you are accessing a global template if turned true it means you are accessing a template of your project.
Returns:
boolean

Definition at line 65 of file usr/lib/module/template/template.php.

References getPath().

Referenced by zigController::forward(), and getContents().

00065                               {
00066     return file_exists(zTemplate::getPath($src, $flag));
00067   }

Here is the call graph for this function:

zTemplate::getPath ( src,
flag 
) [private]

get full path to a template.

For internal use only.

Parameters:
$src string Template name.
$flag boolean optional defaults to false If set to true means you are accessing a global template if turned true it means you are accessing a template of your project.
Returns:
boolean

Definition at line 76 of file usr/lib/module/template/template.php.

References $app_data, and perror().

Referenced by exists(), and getContents().

00076                                {
00077     global $app_data;
00078     $src = explode('.', trim(trim($src), '.'));
00079     if($flag){
00080       $srcPath = ZIGROOT.DRS.Z_DIR_TMPL.DRS.$src[0].'.tmpl.php';
00081     }else{
00082       switch(count($src)){
00083         case 1://Template of Same Project
00084             $srcPath = ZIGROOT.DRS.Z_DIR_PROJECTS.DRS.fstab_getProjectDirByName($app_data['prj']).DRS.Z_DIR_TMPL.DRS.$src[0].'.tmpl.php';
00085           break;
00086         case 2://Template of another project
00087             $srcPath = ZIGROOT.DRS.Z_DIR_PROJECTS.DRS.fstab_getProjectDirByName($src[0]).DRS.Z_DIR_TMPL.DRS.$src[1].'.tmpl.php';
00088           break;
00089         default:
00090           perror("Invalid Template Name $src");
00091       }
00092     }
00093     return $srcPath;
00094   }

Here is the call graph for this function:

zTemplate::coreNumeric (  )  [private]

takes a number of arguments. If some of them are arrays flattern's them and builds a key Pair associative array like $arr['{{0}}'] = "Value"

For internal use only.

Core numaric Template Handler.

Definition at line 102 of file usr/lib/module/template/template.php.

References $val.

00102                         {
00103     $list_args = func_get_args();
00104     $replace = array();
00105     $search = array();
00106     for($i=1;$i<count($list_args);++$i){
00107       $val = $list_args[$i];
00108       if(is_array($val)){
00109         foreach(array_values($val) as $val)array_push($replace, $val);
00110       }else{
00111         array_push($replace, $val);
00112       }
00113     }
00114     foreach($replace as $i => $val){
00115       $search['{{'.$i.'}}'] = $val;
00116     }
00117     return $search;
00118   }

zTemplate::coreAssoc ( dict  )  [private]

takes a number of arguments. If some of them are arrays flattern's them and builds a key Pair associative array like $arr['{{key}}'] = "Value"

For internal use only.

Core associative Template Handler.

Definition at line 126 of file usr/lib/module/template/template.php.

References $val.

00126                            {
00127     $search = array();
00128     foreach($dict as $key => $val){
00129       $search["{{{$key}}}"] = $val;
00130     }
00131     return $search;
00132   }

zTemplate::numeric ( templateName,
placeHolders = array() 
)

parses a numaric template under the current project. e.g. If you have a template like.the following with a name abcd.tmpl.php

Hi! {{0}} I am {{1}}
you can call zTemplate::numaric('abcd', "foo", "bar") or zTemplate::numaric('abcd', array("foo", "bar")) you can pass place holders as arguments as well as array. You can supply any number of arguments. returns the parsed template after all replacements.
Parameters:
$templateName string template Name
$placeHolders mixed plaeHolder's data
Returns:
string

Definition at line 145 of file usr/lib/module/template/template.php.

References getContents().

00145                                                         {
00146     $list_args = func_get_args();
00147     $dict = call_user_func_array(array('zTemplate', 'coreNumeric'), $list_args);
00148     return str_replace(array_keys($dict), array_values($dict), zTemplate::getContents($list_args[0]));
00149   }

Here is the call graph for this function:

zTemplate::sysNumeric ( templateName,
placeHolders = array() 
)

parses a global numaric template. e.g. If you have a template like.the following with a name abcd.tmpl.php

Hi! {{0}} I am {{1}}
you can call zTemplate::sysNumaric('abcd', "foo", "bar") or zTemplate::sysNumaric('abcd', array("foo", "bar")) you can pass place holders as arguments as well as array. You can supply any number of arguments. returns the parsed template after all replacements.
Parameters:
$templateName string template Name
$placeHolders mixed plaeHolder's data
Returns:
string

Definition at line 162 of file usr/lib/module/template/template.php.

References getContents().

Referenced by zigController::attachModel(), zigController::commitViews(), zigController::forward(), zHttpAuth::forward401(), Embed::renderable(), and zigController::renderView().

00162                                                            {
00163     $list_args = func_get_args();
00164     $dict = call_user_func_array(array('zTemplate', 'coreNumeric'), $list_args);
00165     return str_replace(array_keys($dict), array_values($dict), zTemplate::getContents($list_args[0], true));
00166   }

Here is the call graph for this function:

zTemplate::assoc ( templateName,
placeHolders = array() 
)

parses an associative template under the current project. e.g. If you have a template like.the following with a name abcd.tmpl.php

Hi! {{you}} I am {{me}}
you can callzTemplate::assoc('abcd', array('you' => "foo", 'me' => "bar")) you can pass place holders as arguments as well as array. returns the parsed template after all replacements.
Parameters:
$templateName string template Name
$placeHolders array an associative array plaeHolder's data
Returns:
string

Definition at line 178 of file usr/lib/module/template/template.php.

References getContents().

00178                                                       {
00179     $dict = call_user_func_array(array('zTemplate', 'coreAssoc'), array($dict));
00180     return str_replace(array_keys($dict), array_values($dict), zTemplate::getContents($src));
00181   }

Here is the call graph for this function:

zTemplate::sysAssoc ( templateName,
placeHolders = array() 
)

parses a global associative template.. e.g. If you have a template like.the following with a name abcd.tmpl.php

Hi! {{you}} I am {{me}}
you can callzTemplate::sysAssoc('abcd', array('you' => "foo", 'me' => "bar")) you can pass place holders as arguments as well as array. returns the parsed template after all replacements.
Parameters:
$templateName string template Name
$placeHolders array an associative array plaeHolder's data
Returns:
string

Definition at line 193 of file usr/lib/module/template/template.php.

References getContents().

00193                                                          {
00194     $dict = call_user_func_array(array('zTemplate', 'coreAssoc'), array($dict));
00195     return str_replace(array_keys($dict), array_values($dict), zTemplate::getContents($src));
00196   }

Here is the call graph for this function:


The documentation for this class was generated from the following file:

Generated on Mon Oct 27 23:54:34 2008 for zigmoyd.kdevelop by doxygen 1.5.6