mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 10:24:26 +02:00
update version numbers
This commit is contained in:
@@ -5,7 +5,7 @@ require_once "PEAR.php";
|
|||||||
/**
|
/**
|
||||||
* Config_File class.
|
* Config_File class.
|
||||||
*
|
*
|
||||||
* @version 1.5.1
|
* @version 1.5.2
|
||||||
* @author Andrei Zmievski <andrei@php.net>
|
* @author Andrei Zmievski <andrei@php.net>
|
||||||
* @access public
|
* @access public
|
||||||
*
|
*
|
||||||
|
4
NEWS
4
NEWS
@@ -1,3 +1,7 @@
|
|||||||
|
Version 1.5.2
|
||||||
|
-------------
|
||||||
|
- added Smarty object as fifth argument for template resource functions
|
||||||
|
(Monte)
|
||||||
- fixed a bug with incorrectly combined cache and compile id in
|
- fixed a bug with incorrectly combined cache and compile id in
|
||||||
clear_cache(). (Andrei)
|
clear_cache(). (Andrei)
|
||||||
- fixed bug in smarty_make_timestamp introduced in PHP 4.1.0. (Monte)
|
- fixed bug in smarty_make_timestamp introduced in PHP 4.1.0. (Monte)
|
||||||
|
2
README
2
README
@@ -2,7 +2,7 @@ NAME:
|
|||||||
|
|
||||||
Smarty - the PHP compiling template engine
|
Smarty - the PHP compiling template engine
|
||||||
|
|
||||||
VERSION: 1.5.1
|
VERSION: 1.5.2
|
||||||
|
|
||||||
AUTHORS:
|
AUTHORS:
|
||||||
|
|
||||||
|
@@ -1,3 +1,8 @@
|
|||||||
|
1.5.2
|
||||||
|
-----
|
||||||
|
|
||||||
|
Mostly bug fixes, added a default template resource handler.
|
||||||
|
|
||||||
1.5.1
|
1.5.1
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
* File: Smarty.addons.php
|
* File: Smarty.addons.php
|
||||||
* Author: Monte Ohrt <monte@ispi.net>
|
* Author: Monte Ohrt <monte@ispi.net>
|
||||||
* Andrei Zmievski <andrei@php.net>
|
* Andrei Zmievski <andrei@php.net>
|
||||||
* Version: 1.5.1
|
* Version: 1.5.2
|
||||||
* Copyright: 2001 ispi of Lincoln, Inc.
|
* Copyright: 2001 ispi of Lincoln, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
* Author: Monte Ohrt <monte@ispi.net>
|
* Author: Monte Ohrt <monte@ispi.net>
|
||||||
* Andrei Zmievski <andrei@php.net>
|
* Andrei Zmievski <andrei@php.net>
|
||||||
*
|
*
|
||||||
* Version: 1.5.1
|
* Version: 1.5.2
|
||||||
* Copyright: 2001 ispi of Lincoln, Inc.
|
* Copyright: 2001 ispi of Lincoln, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
@@ -204,7 +204,7 @@ class Smarty
|
|||||||
var $_conf_obj = null; // configuration object
|
var $_conf_obj = null; // configuration object
|
||||||
var $_config = array(); // loaded configuration settings
|
var $_config = array(); // loaded configuration settings
|
||||||
var $_smarty_md5 = 'f8d698aea36fcbead2b9d5359ffca76f'; // md5 checksum of the string 'Smarty'
|
var $_smarty_md5 = 'f8d698aea36fcbead2b9d5359ffca76f'; // md5 checksum of the string 'Smarty'
|
||||||
var $_version = '1.5.1'; // Smarty version number
|
var $_version = '1.5.2'; // Smarty version number
|
||||||
var $_extract = false; // flag for custom functions
|
var $_extract = false; // flag for custom functions
|
||||||
var $_inclusion_depth = 0; // current template inclusion depth
|
var $_inclusion_depth = 0; // current template inclusion depth
|
||||||
var $_compile_id = null; // for different compiled templates
|
var $_compile_id = null; // for different compiled templates
|
||||||
@@ -927,6 +927,7 @@ function _is_trusted($resource_type, $resource_name)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$_return) {
|
if(!$_return) {
|
||||||
// see if we can get a template with the default template handler
|
// see if we can get a template with the default template handler
|
||||||
if(!empty($this->default_template_handler_func)) {
|
if(!empty($this->default_template_handler_func)) {
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
* Author: Monte Ohrt <monte@ispi.net>
|
* Author: Monte Ohrt <monte@ispi.net>
|
||||||
* Andrei Zmievski <andrei@php.net>
|
* Andrei Zmievski <andrei@php.net>
|
||||||
*
|
*
|
||||||
* Version: 1.5.1
|
* Version: 1.5.2
|
||||||
* Copyright: 2001 ispi of Lincoln, Inc.
|
* Copyright: 2001 ispi of Lincoln, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
|
125
docs.sgml
125
docs.sgml
@@ -14,7 +14,7 @@
|
|||||||
<address><email>andrei@php.net</email></address>
|
<address><email>andrei@php.net</email></address>
|
||||||
</affiliation>
|
</affiliation>
|
||||||
</author>
|
</author>
|
||||||
<edition>Version 1.5.0</edition>
|
<edition>Version 1.5.2</edition>
|
||||||
<copyright><year>2001</year><holder>ispi of Lincoln, Inc.</holder></copyright>
|
<copyright><year>2001</year><holder>ispi of Lincoln, Inc.</holder></copyright>
|
||||||
</bookinfo>
|
</bookinfo>
|
||||||
<chapter>
|
<chapter>
|
||||||
@@ -435,18 +435,18 @@ require_once(SMARTY_DIR."Smarty.class.php");
|
|||||||
If $compile_check is enabled, the cached content will be
|
If $compile_check is enabled, the cached content will be
|
||||||
regenerated if any of the involved templates are changed. (new
|
regenerated if any of the involved templates are changed. (new
|
||||||
to 1.4.6). If $force_compile is enabled, the cached content
|
to 1.4.6). If $force_compile is enabled, the cached content
|
||||||
will always be regenerated (new to 1.4.7).
|
will always be regenerated. (added to Smarty 1.4.7)
|
||||||
</para>
|
</para>
|
||||||
</sect2>
|
</sect2>
|
||||||
<sect2 id="setting.cache.dir">
|
<sect2 id="setting.cache.dir">
|
||||||
<title>$cache_dir</title>
|
<title>$cache_dir</title>
|
||||||
<para>
|
<para>
|
||||||
This is the name of the directory where template caches are
|
This is the name of the directory where template caches are
|
||||||
stored. By default this is "./cache", meaning that it will
|
stored. By default this is "./cache", meaning that it will look
|
||||||
look for the cache directory in the same directory as the
|
for the cache directory in the same directory as the executing
|
||||||
executing php script. This was added to Smarty version 1.3.0.
|
php script. You can also use your own custom cache handler
|
||||||
You can also use your own custom cache handler function to
|
function to control cache files, which will ignore this
|
||||||
control cache files, which will ignore this setting.
|
setting. (added to Smarty 1.3.0)
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
TECHNICAL NOTE: This setting must be either a relative or
|
TECHNICAL NOTE: This setting must be either a relative or
|
||||||
@@ -464,8 +464,8 @@ require_once(SMARTY_DIR."Smarty.class.php");
|
|||||||
valid. Once this time has expired, the cache will be
|
valid. Once this time has expired, the cache will be
|
||||||
regenerated. $caching must be set to "true" for this setting to
|
regenerated. $caching must be set to "true" for this setting to
|
||||||
work. You can also force the cache to expire with <link
|
work. You can also force the cache to expire with <link
|
||||||
linkend="api.clear.all.cache">clear_all_cache</link>. This was
|
linkend="api.clear.all.cache">clear_all_cache</link>. (added to
|
||||||
added to Smarty 1.3.0.
|
Smarty 1.3.0)
|
||||||
</para>
|
</para>
|
||||||
</sect2>
|
</sect2>
|
||||||
<sect2 id="setting.insert.tag.check">
|
<sect2 id="setting.insert.tag.check">
|
||||||
@@ -485,6 +485,13 @@ require_once(SMARTY_DIR."Smarty.class.php");
|
|||||||
custom cache handler function section for details.
|
custom cache handler function section for details.
|
||||||
</para>
|
</para>
|
||||||
</sect2>
|
</sect2>
|
||||||
|
<sect2 id="setting.default.template.handler.func">
|
||||||
|
<title>$default_template_handler_func</title>
|
||||||
|
<para>
|
||||||
|
This function is called when a template cannot be obtained from
|
||||||
|
its resource. (added to Smarty 1.5.2)
|
||||||
|
</para>
|
||||||
|
</sect2>
|
||||||
<sect2 id="setting.tpl.file.ext">
|
<sect2 id="setting.tpl.file.ext">
|
||||||
<title>$tpl_file_ext</title>
|
<title>$tpl_file_ext</title>
|
||||||
<para>
|
<para>
|
||||||
@@ -1472,7 +1479,7 @@ $smarty->display("file:/path/to/my/templates/menu.tpl");
|
|||||||
|
|
||||||
// put this function somewhere in your application
|
// put this function somewhere in your application
|
||||||
function get_db_template ($tpl_name, &$tpl_source, &$tpl_timestamp,
|
function get_db_template ($tpl_name, &$tpl_source, &$tpl_timestamp,
|
||||||
$get_source=true) {
|
$get_source=true, &$smarty_obj) {
|
||||||
|
|
||||||
if($get_source) {
|
if($get_source) {
|
||||||
// do database calls (or whatever) here to fetch your template, populating
|
// do database calls (or whatever) here to fetch your template, populating
|
||||||
@@ -1496,6 +1503,47 @@ $smarty->display("db:index.tpl");
|
|||||||
{* using resource from within Smarty template *}
|
{* using resource from within Smarty template *}
|
||||||
{include file="db:/extras/navigation.tpl"}
|
{include file="db:/extras/navigation.tpl"}
|
||||||
|
|
||||||
|
</programlisting>
|
||||||
|
</example>
|
||||||
|
</sect2>
|
||||||
|
<sect2>
|
||||||
|
<title>Default Template Handler Function</title>
|
||||||
|
<para>
|
||||||
|
You can specify a function that is used to retrieve template
|
||||||
|
contents in the event the template cannot be retrieved from its
|
||||||
|
resource. One use of this is to create templates that do not exist
|
||||||
|
on-the-fly. This was added to Smarty 1.5.2.
|
||||||
|
</para>
|
||||||
|
<example>
|
||||||
|
|
||||||
|
<title>using the default template handler function call</title>
|
||||||
|
<programlisting>
|
||||||
|
|
||||||
|
// from PHP script
|
||||||
|
|
||||||
|
// put this function somewhere in your application
|
||||||
|
|
||||||
|
function make_template ($resource_type, $resource_name, &$template_source,
|
||||||
|
&$template_timestamp, &$smarty_obj) {
|
||||||
|
|
||||||
|
if( $resource_type == 'file' ) {
|
||||||
|
if ( ! is_readable ( $resource_name )) {
|
||||||
|
// create the template file, return contents.
|
||||||
|
$template_source = "This is a new template.";
|
||||||
|
$template_timestamp = time();
|
||||||
|
$smarty_obj->_write_file($resource_name,$template_source);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// not a file
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// set the default handler
|
||||||
|
$smarty->default_template_handler_func = 'make_template';
|
||||||
|
|
||||||
|
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
</sect2>
|
</sect2>
|
||||||
@@ -1601,8 +1649,8 @@ $smarty->display("index.tpl");
|
|||||||
variable. Smarty will now use this to handle cached data. The first
|
variable. Smarty will now use this to handle cached data. The first
|
||||||
argument is the action, which will be one of 'read', 'write' and
|
argument is the action, which will be one of 'read', 'write' and
|
||||||
'clear'. The second parameter is the smarty object. The third
|
'clear'. The second parameter is the smarty object. The third
|
||||||
parameter is the cached content. Upon a write, Smarty passed th
|
parameter is the cached content. Upon a write, Smarty passes the
|
||||||
cached content in this parameters. Upon a 'read', Smarty expects
|
cached content in these parameters. Upon a 'read', Smarty expects
|
||||||
your function to pass this by reference and populate it with the
|
your function to pass this by reference and populate it with the
|
||||||
cached data. Upon a 'clear', pass a dummy variable here since it is
|
cached data. Upon a 'clear', pass a dummy variable here since it is
|
||||||
not used. The fourth parameter is the name of the template file
|
not used. The fourth parameter is the name of the template file
|
||||||
@@ -2481,6 +2529,14 @@ index.tpl
|
|||||||
<entry>The name of the template variable the output will
|
<entry>The name of the template variable the output will
|
||||||
be assigned to</entry>
|
be assigned to</entry>
|
||||||
</row>
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry>script</entry>
|
||||||
|
<entry>string</entry>
|
||||||
|
<entry>No</entry>
|
||||||
|
<entry><emphasis>n/a</emphasis></entry>
|
||||||
|
<entry>The name of the php script that is included before
|
||||||
|
the insert function is called</entry>
|
||||||
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<entry>[var ...]</entry>
|
<entry>[var ...]</entry>
|
||||||
<entry>[var type]</entry>
|
<entry>[var type]</entry>
|
||||||
@@ -2492,22 +2548,19 @@ index.tpl
|
|||||||
</tgroup>
|
</tgroup>
|
||||||
</informaltable>
|
</informaltable>
|
||||||
<para>
|
<para>
|
||||||
The insert tag in Smarty serves a special purpose. You may
|
Insert tags work much like include tags, except that insert tags
|
||||||
run into the situation where it is impossible to pass data to a template
|
are not cached when you have template <link
|
||||||
before the template is executed because there is info in the template
|
linkend="section.caching">caching</link> enabled. They will be
|
||||||
needed to aquire the data, kind of a catch 22. The insert tag is a way
|
executed on every invocation of the template.
|
||||||
to callback a function in PHP during runtime of the template. The
|
|
||||||
difference between insert tags and custom functions is that insert
|
|
||||||
tags are not cached when you have template <link
|
|
||||||
linkend="section.caching">caching</link> enabled. They
|
|
||||||
will be executed on every invocation of the template.
|
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Let's say you have a template with a banner slot at the top of the page. The
|
Let's say you have a template with a banner slot at the top of the
|
||||||
banner can contain any mixture of HTML, images, flash, etc. so we can't just
|
page. The banner can contain any mixture of HTML, images, flash,
|
||||||
use a static link here. In comes the insert tag: the template
|
etc. so we can't just use a static link here, and we don't want
|
||||||
knows #banner_location_id# and #site_id# values (gathered from a config file),
|
this contents cached with the page. In comes the insert tag: the
|
||||||
and needs to call a function to get the banner's contents.
|
template knows #banner_location_id# and #site_id# values (gathered
|
||||||
|
from a config file), and needs to call a function to get the banner
|
||||||
|
contents.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>function insert</title>
|
<title>function insert</title>
|
||||||
@@ -2533,11 +2586,19 @@ index.tpl
|
|||||||
and display the returned results in place of the insert tag.
|
and display the returned results in place of the insert tag.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
If you supply the special "assign" attribute, the output of the
|
If you supply the "assign" attribute, the output of the insert tag
|
||||||
insert tag will be assigned to this template variable instead of
|
will be assigned to this template variable instead of being output
|
||||||
being output to the template. NOTE: assiging the output to a template
|
to the template. NOTE: assiging the output to a template variable
|
||||||
variable isn't too useful with caching enabled. (added to Smarty
|
isn't too useful with caching enabled. (added to Smarty 1.5.0)
|
||||||
1.5.0)
|
</para>
|
||||||
|
<para>
|
||||||
|
If you supply the "script" attribute, this php script will be
|
||||||
|
included (only once) before the insert function is executed. This
|
||||||
|
is the case where the insert function may not exist yet, and a php
|
||||||
|
script must be included first to make it work. The path can be
|
||||||
|
either absolute, or relative to $trusted_dir. When security is
|
||||||
|
enabled, the script must reside in $trusted_dir. (added to Smarty
|
||||||
|
1.5.2)
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
The Smarty object is passed as the second argument. This way you
|
The Smarty object is passed as the second argument. This way you
|
||||||
|
@@ -5,7 +5,7 @@ require_once "PEAR.php";
|
|||||||
/**
|
/**
|
||||||
* Config_File class.
|
* Config_File class.
|
||||||
*
|
*
|
||||||
* @version 1.5.1
|
* @version 1.5.2
|
||||||
* @author Andrei Zmievski <andrei@php.net>
|
* @author Andrei Zmievski <andrei@php.net>
|
||||||
* @access public
|
* @access public
|
||||||
*
|
*
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
* Author: Monte Ohrt <monte@ispi.net>
|
* Author: Monte Ohrt <monte@ispi.net>
|
||||||
* Andrei Zmievski <andrei@php.net>
|
* Andrei Zmievski <andrei@php.net>
|
||||||
*
|
*
|
||||||
* Version: 1.5.1
|
* Version: 1.5.2
|
||||||
* Copyright: 2001 ispi of Lincoln, Inc.
|
* Copyright: 2001 ispi of Lincoln, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
@@ -204,7 +204,7 @@ class Smarty
|
|||||||
var $_conf_obj = null; // configuration object
|
var $_conf_obj = null; // configuration object
|
||||||
var $_config = array(); // loaded configuration settings
|
var $_config = array(); // loaded configuration settings
|
||||||
var $_smarty_md5 = 'f8d698aea36fcbead2b9d5359ffca76f'; // md5 checksum of the string 'Smarty'
|
var $_smarty_md5 = 'f8d698aea36fcbead2b9d5359ffca76f'; // md5 checksum of the string 'Smarty'
|
||||||
var $_version = '1.5.1'; // Smarty version number
|
var $_version = '1.5.2'; // Smarty version number
|
||||||
var $_extract = false; // flag for custom functions
|
var $_extract = false; // flag for custom functions
|
||||||
var $_inclusion_depth = 0; // current template inclusion depth
|
var $_inclusion_depth = 0; // current template inclusion depth
|
||||||
var $_compile_id = null; // for different compiled templates
|
var $_compile_id = null; // for different compiled templates
|
||||||
@@ -927,6 +927,7 @@ function _is_trusted($resource_type, $resource_name)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$_return) {
|
if(!$_return) {
|
||||||
// see if we can get a template with the default template handler
|
// see if we can get a template with the default template handler
|
||||||
if(!empty($this->default_template_handler_func)) {
|
if(!empty($this->default_template_handler_func)) {
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
* Author: Monte Ohrt <monte@ispi.net>
|
* Author: Monte Ohrt <monte@ispi.net>
|
||||||
* Andrei Zmievski <andrei@php.net>
|
* Andrei Zmievski <andrei@php.net>
|
||||||
*
|
*
|
||||||
* Version: 1.5.1
|
* Version: 1.5.2
|
||||||
* Copyright: 2001 ispi of Lincoln, Inc.
|
* Copyright: 2001 ispi of Lincoln, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
|
Reference in New Issue
Block a user