mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 19:04:27 +02:00
Formatting mostly.
This commit is contained in:
@@ -60,8 +60,7 @@ class Smarty
|
|||||||
var $compile_dir = './templates_c'; // name of directory for compiled templates
|
var $compile_dir = './templates_c'; // name of directory for compiled templates
|
||||||
var $config_dir = './configs'; // directory where config files are located
|
var $config_dir = './configs'; // directory where config files are located
|
||||||
|
|
||||||
var $global_assign = array( 'HTTP_SERVER_VARS' =>
|
var $global_assign = array( 'HTTP_SERVER_VARS' => array( 'SCRIPT_NAME' )
|
||||||
array( 'SCRIPT_NAME' )
|
|
||||||
); // variables from the GLOBALS array
|
); // variables from the GLOBALS array
|
||||||
// that are implicitly assigned
|
// that are implicitly assigned
|
||||||
// to all templates
|
// to all templates
|
||||||
@@ -136,7 +135,7 @@ class Smarty
|
|||||||
var $compiler_class = 'Smarty_Compiler'; // the compiler class used by
|
var $compiler_class = 'Smarty_Compiler'; // the compiler class used by
|
||||||
// Smarty to compile templates
|
// Smarty to compile templates
|
||||||
var $resource_funcs = array(); // what functions resource handlers are mapped to
|
var $resource_funcs = array(); // what functions resource handlers are mapped to
|
||||||
var $prefilter_funcs = array(); // what functions templates are prefiltered through
|
var $prefilter_funcs = array(); // what functions templates are prefiltered through
|
||||||
// before being compiled
|
// before being compiled
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
@@ -149,6 +148,7 @@ class Smarty
|
|||||||
var $_tpl_vars = array(); // where assigned template vars are kept
|
var $_tpl_vars = array(); // where assigned template vars are kept
|
||||||
var $_smarty_md5 = 'f8d698aea36fcbead2b9d5359ffca76f'; // md5 checksum of the string 'Smarty'
|
var $_smarty_md5 = 'f8d698aea36fcbead2b9d5359ffca76f'; // md5 checksum of the string 'Smarty'
|
||||||
|
|
||||||
|
|
||||||
/*======================================================================*\
|
/*======================================================================*\
|
||||||
Function: Smarty
|
Function: Smarty
|
||||||
Purpose: Constructor
|
Purpose: Constructor
|
||||||
@@ -411,26 +411,27 @@ class Smarty
|
|||||||
Function: clear_compile_dir()
|
Function: clear_compile_dir()
|
||||||
Purpose: clears compiled version of specified template resource,
|
Purpose: clears compiled version of specified template resource,
|
||||||
or all compiled template files if one is not specified.
|
or all compiled template files if one is not specified.
|
||||||
This function is for advanced use only, not normally needed.
|
This function is for advanced use only, not normally needed.
|
||||||
\*======================================================================*/
|
\*======================================================================*/
|
||||||
function clear_compile_dir($tpl_file=null)
|
function clear_compile_dir($tpl_file = null)
|
||||||
{
|
{
|
||||||
if (!is_dir($this->compile_dir))
|
if (!is_dir($this->compile_dir))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if($tpl_file) {
|
if (isset($tpl_file)) {
|
||||||
// remove compiled template file if it exists
|
// remove compiled template file if it exists
|
||||||
$tpl_file = urlencode($tpl_file).'.php';
|
$tpl_file = urlencode($tpl_file).'.php';
|
||||||
if(file_exists($this->compile_dir.'/'.$tpl_file)) {
|
if (file_exists($this->compile_dir.'/'.$tpl_file)) {
|
||||||
unlink($this->compile_dir.'/'.$tpl_file);
|
unlink($this->compile_dir.'/'.$tpl_file);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// remove everything in $compile_dir
|
// remove everything in $compile_dir
|
||||||
$dir_handle = opendir($this->compile_dir);
|
$dir_handle = opendir($this->compile_dir);
|
||||||
while ($curr_file = readdir($dir_handle)) {
|
while ($curr_file = readdir($dir_handle)) {
|
||||||
if ($curr_file == '.' || $curr_dir == '..' ||
|
if ($curr_file == '.' || $curr_dir == '..' ||
|
||||||
!is_file($this->compile_dir.'/'.$curr_file))
|
!is_file($this->compile_dir.'/'.$curr_file)) {
|
||||||
{ continue; }
|
continue;
|
||||||
|
}
|
||||||
unlink($this->compile_dir.'/'.$curr_file);
|
unlink($this->compile_dir.'/'.$curr_file);
|
||||||
}
|
}
|
||||||
closedir($dir_handle);
|
closedir($dir_handle);
|
||||||
@@ -609,7 +610,6 @@ class Smarty
|
|||||||
\*======================================================================*/
|
\*======================================================================*/
|
||||||
function _fetch_template_source($tpl_path, &$template_source, &$template_timestamp)
|
function _fetch_template_source($tpl_path, &$template_source, &$template_timestamp)
|
||||||
{
|
{
|
||||||
|
|
||||||
// split tpl_path by the first colon
|
// split tpl_path by the first colon
|
||||||
$tpl_path_parts = explode(':', $tpl_path, 2);
|
$tpl_path_parts = explode(':', $tpl_path, 2);
|
||||||
|
|
||||||
@@ -637,16 +637,17 @@ class Smarty
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if(isset($this->resource_funcs[$resource_type])) {
|
if (isset($this->resource_funcs[$resource_type])) {
|
||||||
$funcname = $this->resource_funcs[$resource_type];
|
$funcname = $this->resource_funcs[$resource_type];
|
||||||
if(function_exists($funcname)) {
|
if (function_exists($funcname)) {
|
||||||
// call the function to fetch the template
|
// call the function to fetch the template
|
||||||
$funcname($resource_name,$template_source,$template_timestamp);
|
$funcname($resource_name, $template_source, $template_timestamp);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
$this->_trigger_error_msg("function: \"$funcname\" does not exist for resource type: \"$resource_type\".");
|
$this->_trigger_error_msg("function: resource function \"$funcname\" does not exist for resource type: \"$resource_type\".");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->_trigger_error_msg("unknown resource type: \"$resource_type\". Register this resource first.");
|
$this->_trigger_error_msg("unknown resource type: \"$resource_type\". Register this resource first.");
|
||||||
|
@@ -56,12 +56,12 @@ class Smarty_Compiler extends Smarty {
|
|||||||
{
|
{
|
||||||
|
|
||||||
// run template source through functions registered in prefilter_funcs
|
// run template source through functions registered in prefilter_funcs
|
||||||
if(is_array($this->prefilter_funcs) && count($this->prefilter_funcs) > 0) {
|
if (is_array($this->prefilter_funcs) && count($this->prefilter_funcs) > 0) {
|
||||||
foreach($this->prefilter_funcs as $curr_func) {
|
foreach($this->prefilter_funcs as $prefilter) {
|
||||||
if(function_exists($curr_func)) {
|
if (function_exists($prefilter)) {
|
||||||
$template_source = $curr_func($template_source);
|
$template_source = $prefilter($template_source);
|
||||||
} else {
|
} else {
|
||||||
$this->_trigger_error_msg("prefilter function $curr_func does not exist.");
|
$this->_trigger_error_msg("prefilter function $prefilter does not exist.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -89,8 +89,6 @@ class Smarty_Compiler extends Smarty {
|
|||||||
/* Split content by template tags to obtain non-template content. */
|
/* Split content by template tags to obtain non-template content. */
|
||||||
$text_blocks = preg_split("!{$ldq}.*?{$rdq}!s", $template_source);
|
$text_blocks = preg_split("!{$ldq}.*?{$rdq}!s", $template_source);
|
||||||
|
|
||||||
/* TODO: speed up the following with preg_replace and /F once we require that version of PHP */
|
|
||||||
|
|
||||||
/* loop through text blocks */
|
/* loop through text blocks */
|
||||||
for ($curr_tb = 0; $curr_tb < count($text_blocks); $curr_tb++) {
|
for ($curr_tb = 0; $curr_tb < count($text_blocks); $curr_tb++) {
|
||||||
/* match anything within <? ?> */
|
/* match anything within <? ?> */
|
||||||
|
@@ -292,8 +292,12 @@ chmod 700 cache
|
|||||||
This is a list of variables that are always implicitly assigned
|
This is a list of variables that are always implicitly assigned
|
||||||
to the template engine. This is handy for making global
|
to the template engine. This is handy for making global
|
||||||
variables or server variables available to all templates
|
variables or server variables available to all templates
|
||||||
without having to manually assign them. $SCRIPT_NAME is
|
without having to manually assign them. Each element in the
|
||||||
globally assigned by default.
|
$global_assign should be either a name of the global variable,
|
||||||
|
or a key/value pair, where the key is the name of the global
|
||||||
|
array and the value is the array of variables to be assigned
|
||||||
|
from that global array. $SCRIPT_NAME is globally assigned by
|
||||||
|
default from $HTTP_SERVER_VARS.
|
||||||
</para>
|
</para>
|
||||||
</sect2>
|
</sect2>
|
||||||
<sect2 id="setting.undefined">
|
<sect2 id="setting.undefined">
|
||||||
|
@@ -60,8 +60,7 @@ class Smarty
|
|||||||
var $compile_dir = './templates_c'; // name of directory for compiled templates
|
var $compile_dir = './templates_c'; // name of directory for compiled templates
|
||||||
var $config_dir = './configs'; // directory where config files are located
|
var $config_dir = './configs'; // directory where config files are located
|
||||||
|
|
||||||
var $global_assign = array( 'HTTP_SERVER_VARS' =>
|
var $global_assign = array( 'HTTP_SERVER_VARS' => array( 'SCRIPT_NAME' )
|
||||||
array( 'SCRIPT_NAME' )
|
|
||||||
); // variables from the GLOBALS array
|
); // variables from the GLOBALS array
|
||||||
// that are implicitly assigned
|
// that are implicitly assigned
|
||||||
// to all templates
|
// to all templates
|
||||||
@@ -136,7 +135,7 @@ class Smarty
|
|||||||
var $compiler_class = 'Smarty_Compiler'; // the compiler class used by
|
var $compiler_class = 'Smarty_Compiler'; // the compiler class used by
|
||||||
// Smarty to compile templates
|
// Smarty to compile templates
|
||||||
var $resource_funcs = array(); // what functions resource handlers are mapped to
|
var $resource_funcs = array(); // what functions resource handlers are mapped to
|
||||||
var $prefilter_funcs = array(); // what functions templates are prefiltered through
|
var $prefilter_funcs = array(); // what functions templates are prefiltered through
|
||||||
// before being compiled
|
// before being compiled
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
@@ -149,6 +148,7 @@ class Smarty
|
|||||||
var $_tpl_vars = array(); // where assigned template vars are kept
|
var $_tpl_vars = array(); // where assigned template vars are kept
|
||||||
var $_smarty_md5 = 'f8d698aea36fcbead2b9d5359ffca76f'; // md5 checksum of the string 'Smarty'
|
var $_smarty_md5 = 'f8d698aea36fcbead2b9d5359ffca76f'; // md5 checksum of the string 'Smarty'
|
||||||
|
|
||||||
|
|
||||||
/*======================================================================*\
|
/*======================================================================*\
|
||||||
Function: Smarty
|
Function: Smarty
|
||||||
Purpose: Constructor
|
Purpose: Constructor
|
||||||
@@ -411,26 +411,27 @@ class Smarty
|
|||||||
Function: clear_compile_dir()
|
Function: clear_compile_dir()
|
||||||
Purpose: clears compiled version of specified template resource,
|
Purpose: clears compiled version of specified template resource,
|
||||||
or all compiled template files if one is not specified.
|
or all compiled template files if one is not specified.
|
||||||
This function is for advanced use only, not normally needed.
|
This function is for advanced use only, not normally needed.
|
||||||
\*======================================================================*/
|
\*======================================================================*/
|
||||||
function clear_compile_dir($tpl_file=null)
|
function clear_compile_dir($tpl_file = null)
|
||||||
{
|
{
|
||||||
if (!is_dir($this->compile_dir))
|
if (!is_dir($this->compile_dir))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if($tpl_file) {
|
if (isset($tpl_file)) {
|
||||||
// remove compiled template file if it exists
|
// remove compiled template file if it exists
|
||||||
$tpl_file = urlencode($tpl_file).'.php';
|
$tpl_file = urlencode($tpl_file).'.php';
|
||||||
if(file_exists($this->compile_dir.'/'.$tpl_file)) {
|
if (file_exists($this->compile_dir.'/'.$tpl_file)) {
|
||||||
unlink($this->compile_dir.'/'.$tpl_file);
|
unlink($this->compile_dir.'/'.$tpl_file);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// remove everything in $compile_dir
|
// remove everything in $compile_dir
|
||||||
$dir_handle = opendir($this->compile_dir);
|
$dir_handle = opendir($this->compile_dir);
|
||||||
while ($curr_file = readdir($dir_handle)) {
|
while ($curr_file = readdir($dir_handle)) {
|
||||||
if ($curr_file == '.' || $curr_dir == '..' ||
|
if ($curr_file == '.' || $curr_dir == '..' ||
|
||||||
!is_file($this->compile_dir.'/'.$curr_file))
|
!is_file($this->compile_dir.'/'.$curr_file)) {
|
||||||
{ continue; }
|
continue;
|
||||||
|
}
|
||||||
unlink($this->compile_dir.'/'.$curr_file);
|
unlink($this->compile_dir.'/'.$curr_file);
|
||||||
}
|
}
|
||||||
closedir($dir_handle);
|
closedir($dir_handle);
|
||||||
@@ -609,7 +610,6 @@ class Smarty
|
|||||||
\*======================================================================*/
|
\*======================================================================*/
|
||||||
function _fetch_template_source($tpl_path, &$template_source, &$template_timestamp)
|
function _fetch_template_source($tpl_path, &$template_source, &$template_timestamp)
|
||||||
{
|
{
|
||||||
|
|
||||||
// split tpl_path by the first colon
|
// split tpl_path by the first colon
|
||||||
$tpl_path_parts = explode(':', $tpl_path, 2);
|
$tpl_path_parts = explode(':', $tpl_path, 2);
|
||||||
|
|
||||||
@@ -637,16 +637,17 @@ class Smarty
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if(isset($this->resource_funcs[$resource_type])) {
|
if (isset($this->resource_funcs[$resource_type])) {
|
||||||
$funcname = $this->resource_funcs[$resource_type];
|
$funcname = $this->resource_funcs[$resource_type];
|
||||||
if(function_exists($funcname)) {
|
if (function_exists($funcname)) {
|
||||||
// call the function to fetch the template
|
// call the function to fetch the template
|
||||||
$funcname($resource_name,$template_source,$template_timestamp);
|
$funcname($resource_name, $template_source, $template_timestamp);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
$this->_trigger_error_msg("function: \"$funcname\" does not exist for resource type: \"$resource_type\".");
|
$this->_trigger_error_msg("function: resource function \"$funcname\" does not exist for resource type: \"$resource_type\".");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->_trigger_error_msg("unknown resource type: \"$resource_type\". Register this resource first.");
|
$this->_trigger_error_msg("unknown resource type: \"$resource_type\". Register this resource first.");
|
||||||
|
@@ -56,12 +56,12 @@ class Smarty_Compiler extends Smarty {
|
|||||||
{
|
{
|
||||||
|
|
||||||
// run template source through functions registered in prefilter_funcs
|
// run template source through functions registered in prefilter_funcs
|
||||||
if(is_array($this->prefilter_funcs) && count($this->prefilter_funcs) > 0) {
|
if (is_array($this->prefilter_funcs) && count($this->prefilter_funcs) > 0) {
|
||||||
foreach($this->prefilter_funcs as $curr_func) {
|
foreach($this->prefilter_funcs as $prefilter) {
|
||||||
if(function_exists($curr_func)) {
|
if (function_exists($prefilter)) {
|
||||||
$template_source = $curr_func($template_source);
|
$template_source = $prefilter($template_source);
|
||||||
} else {
|
} else {
|
||||||
$this->_trigger_error_msg("prefilter function $curr_func does not exist.");
|
$this->_trigger_error_msg("prefilter function $prefilter does not exist.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -89,8 +89,6 @@ class Smarty_Compiler extends Smarty {
|
|||||||
/* Split content by template tags to obtain non-template content. */
|
/* Split content by template tags to obtain non-template content. */
|
||||||
$text_blocks = preg_split("!{$ldq}.*?{$rdq}!s", $template_source);
|
$text_blocks = preg_split("!{$ldq}.*?{$rdq}!s", $template_source);
|
||||||
|
|
||||||
/* TODO: speed up the following with preg_replace and /F once we require that version of PHP */
|
|
||||||
|
|
||||||
/* loop through text blocks */
|
/* loop through text blocks */
|
||||||
for ($curr_tb = 0; $curr_tb < count($text_blocks); $curr_tb++) {
|
for ($curr_tb = 0; $curr_tb < count($text_blocks); $curr_tb++) {
|
||||||
/* match anything within <? ?> */
|
/* match anything within <? ?> */
|
||||||
|
Reference in New Issue
Block a user