removed return statements from _read_cache_file (how did they get in there?)

This commit is contained in:
mohrt
2001-11-28 17:16:04 +00:00
parent 580c44ff06
commit ea13304b71
4 changed files with 91 additions and 28 deletions

13
NEWS
View File

@@ -1,8 +1,9 @@
- added assign attribute to insert function (Monte)
- added assign attribute to fetch function (Monte)
- fixed bug with fetch testing for file with http address (Monte)
- added assign attribute to math function (Monte)
- added assign attribute to counter function (Monte)
- added custom cache handling function ability (Monte)
- added assign attribute to insert function, documented (Monte)
- added assign attribute to fetch function, documented (Monte)
- fixed bug with fetch testing for local file when http address (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)
- made {config_load ...} merge globals from each config file only once per
scope, thus avoiding several problems. (Andrei)
@@ -15,7 +16,7 @@
blocks. (Andrei, Alexander Belonosov)
- added 'field_array' attribute to html_select_time function. (Andrei,
Michael Caplan)
- dpcumented {section} "max" attribute. (Monte)
- documented {section} "max" attribute. (Monte)
- fixed notice message in Smarty_Compiler.class.php. (Monte)
- fixed bug with clear_cache introduced in 1.4.6, third parameter should
default to null. (Monte)

View File

@@ -500,11 +500,11 @@ class Smarty
{
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))) {
$this->debugging = true;
}
if ($this->debugging) {
// capture time for debugging info
$debug_start_time = $this->_get_microtime();
@@ -1272,13 +1272,13 @@ function _run_insert_handler($args)
if (!empty($this->cache_handler_func)) {
// 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 {
// use local file cache
$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);
}

View File

@@ -2192,6 +2192,14 @@ pass=foobar
<entry><emphasis>n/a</emphasis></entry>
<entry>The name of the insert function (insert_name)</entry>
</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>
<entry>[var ...]</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
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
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>
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.
</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
cached. If you have <link linkend="section.caching">caching</link>
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
weather, search results, user feedback areas, etc.
</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>
<title>if,elseif,else</title>
@@ -3152,6 +3171,14 @@ The value of $name is Bob.
<entry><emphasis>true</emphasis></entry>
<entry>Whether or not to print the value</entry>
</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>
</tgroup>
</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
default id will be used. counter was added to Smarty 1.4.0.
</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>
<title>counter</title>
<programlisting>
@@ -3211,17 +3243,29 @@ OUTPUT:
<entry><emphasis>n/a</emphasis></entry>
<entry>the file, http or ftp site to fetch</entry>
</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>
</tgroup>
</informaltable>
<para>
fetch allows the template designer to fetch files from the local
file system, http, or ftp and display the contents. If the file
name begins with "http://", the web site page will be fetched and
displayed. If the file name begins with "ftp://", the file will be
fetched from the ftp server and displayed. For local files, the full
system file path must be given, or a path relative to the executed
php script.
fetch is used to fetch files from the local file system, http, or
ftp and display the contents. If the file name begins with
"http://", the web site page will be fetched and displayed. If the
file name begins with "ftp://", the file will be fetched from the
ftp server and displayed. For local files, the full system file
path must be given, or a path relative to the executed 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>
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"}
{* 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 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 ""}
&lt;b&gt;{$weather}&lt;/b&gt;
{/if}
</programlisting>
</example>
@@ -3926,6 +3976,13 @@ OUTPUT:
<entry><emphasis>n/a</emphasis></entry>
<entry>equation variable value</entry>
</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>
<entry>[var ...]</entry>
<entry>numeric</entry>
@@ -3946,6 +4003,11 @@ OUTPUT:
srans and tan are all valid operators. Check the PHP documenation
for further information on these math functions.
</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>
<title>math</title>
<programlisting>

View File

@@ -500,11 +500,11 @@ class Smarty
{
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))) {
$this->debugging = true;
}
if ($this->debugging) {
// capture time for debugging info
$debug_start_time = $this->_get_microtime();
@@ -1272,13 +1272,13 @@ function _run_insert_handler($args)
if (!empty($this->cache_handler_func)) {
// 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 {
// use local file cache
$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);
}