mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 10:24:26 +02:00
removed return statements from _read_cache_file (how did they get in there?)
This commit is contained in:
13
NEWS
13
NEWS
@@ -1,8 +1,9 @@
|
|||||||
- added assign attribute to insert function (Monte)
|
- added custom cache handling function ability (Monte)
|
||||||
- added assign attribute to fetch function (Monte)
|
- added assign attribute to insert function, documented (Monte)
|
||||||
- fixed bug with fetch testing for file with http address (Monte)
|
- added assign attribute to fetch function, documented (Monte)
|
||||||
- added assign attribute to math function (Monte)
|
- fixed bug with fetch testing for local file when http address (Monte)
|
||||||
- added assign attribute to counter function (Monte)
|
- added assign attribute to math function, documented (Monte)
|
||||||
|
- added assign attribute to counter function, documented (Monte)
|
||||||
- fixed bug with counter and skipval setting (Monte)
|
- fixed bug with counter and skipval setting (Monte)
|
||||||
- made {config_load ...} merge globals from each config file only once per
|
- made {config_load ...} merge globals from each config file only once per
|
||||||
scope, thus avoiding several problems. (Andrei)
|
scope, thus avoiding several problems. (Andrei)
|
||||||
@@ -15,7 +16,7 @@
|
|||||||
blocks. (Andrei, Alexander Belonosov)
|
blocks. (Andrei, Alexander Belonosov)
|
||||||
- added 'field_array' attribute to html_select_time function. (Andrei,
|
- added 'field_array' attribute to html_select_time function. (Andrei,
|
||||||
Michael Caplan)
|
Michael Caplan)
|
||||||
- dpcumented {section} "max" attribute. (Monte)
|
- documented {section} "max" attribute. (Monte)
|
||||||
- fixed notice message in Smarty_Compiler.class.php. (Monte)
|
- fixed notice message in Smarty_Compiler.class.php. (Monte)
|
||||||
- fixed bug with clear_cache introduced in 1.4.6, third parameter should
|
- fixed bug with clear_cache introduced in 1.4.6, third parameter should
|
||||||
default to null. (Monte)
|
default to null. (Monte)
|
||||||
|
@@ -500,7 +500,7 @@ class Smarty
|
|||||||
{
|
{
|
||||||
global $HTTP_SERVER_VARS, $QUERY_STRING, $HTTP_COOKIE_VARS;
|
global $HTTP_SERVER_VARS, $QUERY_STRING, $HTTP_COOKIE_VARS;
|
||||||
|
|
||||||
if ($this->debugging_ctrl == 'URL'
|
if (!$this->debugging && $this->debugging_ctrl == 'URL'
|
||||||
&& (!empty($QUERY_STRING) && strstr($QUERY_STRING, $this->_smarty_debug_id))) {
|
&& (!empty($QUERY_STRING) && strstr($QUERY_STRING, $this->_smarty_debug_id))) {
|
||||||
$this->debugging = true;
|
$this->debugging = true;
|
||||||
}
|
}
|
||||||
@@ -1272,13 +1272,13 @@ function _run_insert_handler($args)
|
|||||||
if (!empty($this->cache_handler_func)) {
|
if (!empty($this->cache_handler_func)) {
|
||||||
|
|
||||||
// use cache_read_handler function
|
// use cache_read_handler function
|
||||||
return($$this->cache_handler_func('read', $tpl_file, $cache_id, $compile_id, $results, $this));
|
$$this->cache_handler_func('read', $tpl_file, $cache_id, $compile_id, $results, $this);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// use local file cache
|
// use local file cache
|
||||||
|
|
||||||
$cache_file = $this->_get_auto_filename($this->cache_dir, $tpl_file, $compile_id . $cache_id);
|
$cache_file = $this->_get_auto_filename($this->cache_dir, $tpl_file, $compile_id . $cache_id);
|
||||||
return ($results = $this->_read_file($cache_file));
|
$results = $this->_read_file($cache_file);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
90
docs.sgml
90
docs.sgml
@@ -2192,6 +2192,14 @@ pass=foobar
|
|||||||
<entry><emphasis>n/a</emphasis></entry>
|
<entry><emphasis>n/a</emphasis></entry>
|
||||||
<entry>The name of the insert function (insert_name)</entry>
|
<entry>The name of the insert function (insert_name)</entry>
|
||||||
</row>
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry>assign</entry>
|
||||||
|
<entry>string</entry>
|
||||||
|
<entry>No</entry>
|
||||||
|
<entry><emphasis>n/a</emphasis></entry>
|
||||||
|
<entry>The name of the template variable the output will
|
||||||
|
be assigned to</entry>
|
||||||
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<entry>[var ...]</entry>
|
<entry>[var ...]</entry>
|
||||||
<entry>[var type]</entry>
|
<entry>[var type]</entry>
|
||||||
@@ -2207,7 +2215,11 @@ pass=foobar
|
|||||||
run into the situation where it is impossible to pass data to a template
|
run into the situation where it is impossible to pass data to a template
|
||||||
before the template is executed because there is info in the template
|
before the template is executed because there is info in the template
|
||||||
needed to aquire the data, kind of a catch 22. The insert tag is a way
|
needed to aquire the data, kind of a catch 22. The insert tag is a way
|
||||||
to callback a function in PHP during runtime 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 page. The
|
||||||
@@ -2240,6 +2252,18 @@ pass=foobar
|
|||||||
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
|
||||||
|
insert tag will be assigned to this template variable instead of
|
||||||
|
being output to the template. NOTE: assiging the output to a template
|
||||||
|
variable isn't too useful with caching enabled. (added to Smarty
|
||||||
|
1.5.0)
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
The Smarty object is passed as the second argument. This way you
|
||||||
|
can reference and modify information in the Smarty object from
|
||||||
|
within the insert function. (added in 1.4.5)
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
TECHNICAL NOTE: It is possible to have portions of the template not
|
TECHNICAL NOTE: It is possible to have portions of the template not
|
||||||
cached. If you have <link linkend="section.caching">caching</link>
|
cached. If you have <link linkend="section.caching">caching</link>
|
||||||
turned on, insert tags will not be cached. They will run
|
turned on, insert tags will not be cached. They will run
|
||||||
@@ -2247,11 +2271,6 @@ pass=foobar
|
|||||||
pages. This works good for things like banners, polls, live
|
pages. This works good for things like banners, polls, live
|
||||||
weather, search results, user feedback areas, etc.
|
weather, search results, user feedback areas, etc.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
|
||||||
NOTE: As of Smarty 1.4.5, the Smarty object is passed as the second
|
|
||||||
argument. This way you can reference and modify information in the
|
|
||||||
Smarty object from within the insert function.
|
|
||||||
</para>
|
|
||||||
</sect2>
|
</sect2>
|
||||||
<sect2>
|
<sect2>
|
||||||
<title>if,elseif,else</title>
|
<title>if,elseif,else</title>
|
||||||
@@ -3152,6 +3171,14 @@ The value of $name is Bob.
|
|||||||
<entry><emphasis>true</emphasis></entry>
|
<entry><emphasis>true</emphasis></entry>
|
||||||
<entry>Whether or not to print the value</entry>
|
<entry>Whether or not to print the value</entry>
|
||||||
</row>
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry>assign</entry>
|
||||||
|
<entry>string</entry>
|
||||||
|
<entry>No</entry>
|
||||||
|
<entry><emphasis>n/a</emphasis></entry>
|
||||||
|
<entry>the template variable the output will be assigned
|
||||||
|
to</entry>
|
||||||
|
</row>
|
||||||
</tbody>
|
</tbody>
|
||||||
</tgroup>
|
</tgroup>
|
||||||
</informaltable>
|
</informaltable>
|
||||||
@@ -3163,6 +3190,11 @@ The value of $name is Bob.
|
|||||||
supplying a unique id for each one. If you do not supply an id, the
|
supplying a unique id for each one. If you do not supply an id, the
|
||||||
default id will be used. counter was added to Smarty 1.4.0.
|
default id will be used. counter was added to Smarty 1.4.0.
|
||||||
</para>
|
</para>
|
||||||
|
<para>
|
||||||
|
If you supply the special "assign" attribute, the output of the
|
||||||
|
counter function will be assigned to this template variable instead of
|
||||||
|
being output to the template. (new in Smarty 1.5.0)
|
||||||
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>counter</title>
|
<title>counter</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
@@ -3211,17 +3243,29 @@ OUTPUT:
|
|||||||
<entry><emphasis>n/a</emphasis></entry>
|
<entry><emphasis>n/a</emphasis></entry>
|
||||||
<entry>the file, http or ftp site to fetch</entry>
|
<entry>the file, http or ftp site to fetch</entry>
|
||||||
</row>
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry>assign</entry>
|
||||||
|
<entry>string</entry>
|
||||||
|
<entry>No</entry>
|
||||||
|
<entry><emphasis>n/a</emphasis></entry>
|
||||||
|
<entry>the template variable the output will be assigned
|
||||||
|
to</entry>
|
||||||
|
</row>
|
||||||
</tbody>
|
</tbody>
|
||||||
</tgroup>
|
</tgroup>
|
||||||
</informaltable>
|
</informaltable>
|
||||||
<para>
|
<para>
|
||||||
fetch allows the template designer to fetch files from the local
|
fetch is used to fetch files from the local file system, http, or
|
||||||
file system, http, or ftp and display the contents. If the file
|
ftp and display the contents. If the file name begins with
|
||||||
name begins with "http://", the web site page will be fetched and
|
"http://", the web site page will be fetched and displayed. If the
|
||||||
displayed. If the file name begins with "ftp://", the file will be
|
file name begins with "ftp://", the file will be fetched from the
|
||||||
fetched from the ftp server and displayed. For local files, the full
|
ftp server and displayed. For local files, the full system file
|
||||||
system file path must be given, or a path relative to the executed
|
path must be given, or a path relative to the executed php script.
|
||||||
php script.
|
</para>
|
||||||
|
<para>
|
||||||
|
If you supply the special "assign" attribute, the output of the
|
||||||
|
fetch function will be assigned to this template variable instead of
|
||||||
|
being output to the template. (new in Smarty 1.5.0)
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
TECHNICAL NOTE: This will not support http redirects, be sure to
|
TECHNICAL NOTE: This will not support http redirects, be sure to
|
||||||
@@ -3241,11 +3285,17 @@ OUTPUT:
|
|||||||
{fetch file="/export/httpd/www.domain.com/docs/navbar.js"}
|
{fetch file="/export/httpd/www.domain.com/docs/navbar.js"}
|
||||||
|
|
||||||
{* embed some weather text in your template from another web site *}
|
{* embed some weather text in your template from another web site *}
|
||||||
{fetch file="http://www.myweather.com/cgi-bin/getweather?zipcode=68502"}
|
{fetch file="http://www.myweather.com/68502/"}
|
||||||
|
|
||||||
{* fetch a news headline file via ftp *}
|
{* fetch a news headline file via ftp *}
|
||||||
{fetch file="ftp://user:password@ftp.domain.com/path/to/currentheadlines.txt"}
|
{fetch file="ftp://user:password@ftp.domain.com/path/to/currentheadlines.txt"}
|
||||||
|
|
||||||
|
{* assign the fetched contents to a template variable *}
|
||||||
|
{fetch file="http://www.myweather.com/68502/" assign="weather"}
|
||||||
|
{if $weather ne ""}
|
||||||
|
<b>{$weather}</b>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
@@ -3926,6 +3976,13 @@ OUTPUT:
|
|||||||
<entry><emphasis>n/a</emphasis></entry>
|
<entry><emphasis>n/a</emphasis></entry>
|
||||||
<entry>equation variable value</entry>
|
<entry>equation variable value</entry>
|
||||||
</row>
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry>assign</entry>
|
||||||
|
<entry>string</entry>
|
||||||
|
<entry>No</entry>
|
||||||
|
<entry><emphasis>n/a</emphasis></entry>
|
||||||
|
<entry>template variable the output will be assigned to</entry>
|
||||||
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<entry>[var ...]</entry>
|
<entry>[var ...]</entry>
|
||||||
<entry>numeric</entry>
|
<entry>numeric</entry>
|
||||||
@@ -3946,6 +4003,11 @@ OUTPUT:
|
|||||||
srans and tan are all valid operators. Check the PHP documenation
|
srans and tan are all valid operators. Check the PHP documenation
|
||||||
for further information on these math functions.
|
for further information on these math functions.
|
||||||
</para>
|
</para>
|
||||||
|
<para>
|
||||||
|
If you supply the special "assign" attribute, the output of the
|
||||||
|
math function will be assigned to this template variable instead of
|
||||||
|
being output to the template.
|
||||||
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>math</title>
|
<title>math</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
|
@@ -500,7 +500,7 @@ class Smarty
|
|||||||
{
|
{
|
||||||
global $HTTP_SERVER_VARS, $QUERY_STRING, $HTTP_COOKIE_VARS;
|
global $HTTP_SERVER_VARS, $QUERY_STRING, $HTTP_COOKIE_VARS;
|
||||||
|
|
||||||
if ($this->debugging_ctrl == 'URL'
|
if (!$this->debugging && $this->debugging_ctrl == 'URL'
|
||||||
&& (!empty($QUERY_STRING) && strstr($QUERY_STRING, $this->_smarty_debug_id))) {
|
&& (!empty($QUERY_STRING) && strstr($QUERY_STRING, $this->_smarty_debug_id))) {
|
||||||
$this->debugging = true;
|
$this->debugging = true;
|
||||||
}
|
}
|
||||||
@@ -1272,13 +1272,13 @@ function _run_insert_handler($args)
|
|||||||
if (!empty($this->cache_handler_func)) {
|
if (!empty($this->cache_handler_func)) {
|
||||||
|
|
||||||
// use cache_read_handler function
|
// use cache_read_handler function
|
||||||
return($$this->cache_handler_func('read', $tpl_file, $cache_id, $compile_id, $results, $this));
|
$$this->cache_handler_func('read', $tpl_file, $cache_id, $compile_id, $results, $this);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// use local file cache
|
// use local file cache
|
||||||
|
|
||||||
$cache_file = $this->_get_auto_filename($this->cache_dir, $tpl_file, $compile_id . $cache_id);
|
$cache_file = $this->_get_auto_filename($this->cache_dir, $tpl_file, $compile_id . $cache_id);
|
||||||
return ($results = $this->_read_file($cache_file));
|
$results = $this->_read_file($cache_file);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user