mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 10:24:26 +02:00
fix $smarty.const.foo compiling, clean up double quoted strings,
allow full dollar var syntax in quotes again
This commit is contained in:
2
FAQ
2
FAQ
@@ -66,7 +66,7 @@ A: Most other template engines for PHP provide basic variable substitution and
|
||||
functionality as easy as possible to use for both programmers and template
|
||||
designers. Smarty also compiles the templates into PHP scripts, eliminating
|
||||
the need to parse the templates on every invocation, making Smarty extremely
|
||||
scalable and managable for large application needs.
|
||||
scalable and manageable for large application needs.
|
||||
|
||||
Q: What do you mean "Compiled PHP Scripts" ?
|
||||
A: Smarty reads the template files and creates PHP scripts from them. Once
|
||||
|
4
NEWS
4
NEWS
@@ -1,6 +1,7 @@
|
||||
- added nl2br modifier to distribution (Monte)
|
||||
- added html_image to distribution (Monte)
|
||||
- added cat modifier to distribution (Monte)
|
||||
- added html_table to distribution (Monte)
|
||||
- added << >> <> support to if statments (SMK, Monte)
|
||||
- fix _assign_smarty_interface to not overwrite keys
|
||||
other than 'request' (Jerome Poudevigne, Monte)
|
||||
@@ -9,7 +10,8 @@
|
||||
- fixed string_format modifier args (wrong order) (Paul
|
||||
Lockaby, Monte)
|
||||
- use tmp file for file writes, avoid file lock race (Monte)
|
||||
- handle embedded "$smarty.config.foo.tpl" correctly (Monte)
|
||||
- support syntax "$`smarty.config.foo`.tpl" for embedded
|
||||
vars in quotes, and allow full dollar var syntax (Monte)
|
||||
- add $smarty.config.varname variable for accessing config vars (Paul
|
||||
Lockaby, Monte)
|
||||
- silence PHP warnings in function.fetch.php (Eduardo,
|
||||
|
2
README
2
README
@@ -52,7 +52,7 @@ DESCRIPTION:
|
||||
use for both programmers and template designers. Smarty also converts
|
||||
the templates into PHP scripts, eliminating the need to parse the
|
||||
templates on every invocation. This makes Smarty extremely scalable and
|
||||
managable for large application needs.
|
||||
manageable for large application needs.
|
||||
|
||||
Some of Smarty's features:
|
||||
|
||||
|
@@ -515,6 +515,56 @@ OUTPUT:
|
||||
|
||||
Cold Wave Linked to Temperatures.
|
||||
32</programlisting>
|
||||
</example>
|
||||
</sect1>
|
||||
<sect1 id="language.modifier.cat">
|
||||
<title>cat</title>
|
||||
<informaltable frame=all>
|
||||
<tgroup cols=5>
|
||||
<colspec colname=param align=center>
|
||||
<colspec colname=type align=center>
|
||||
<colspec colname=required align=center>
|
||||
<colspec colname=cat align=center>
|
||||
<colspec colname=desc>
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Parameter Position</entry>
|
||||
<entry>Type</entry>
|
||||
<entry>Required</entry>
|
||||
<entry>cat</entry>
|
||||
<entry>Description</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>1</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>empty</emphasis></entry>
|
||||
<entry>This value to catentate to the given variable.</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
This value is catenated to the given variable.
|
||||
</para>
|
||||
<example>
|
||||
<title>cat</title>
|
||||
<programlisting>
|
||||
index.php:
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('articleTitle', 'Psychics predict world didn't end');
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
index.tpl:
|
||||
|
||||
{$articleTitle|cat:" yesterday."}
|
||||
|
||||
OUTPUT:
|
||||
|
||||
Psychics predict world didn't end yesterday.</programlisting>
|
||||
</example>
|
||||
</sect1>
|
||||
<sect1 id="language.modifier.count.paragraphs">
|
||||
@@ -984,6 +1034,30 @@ OUTPUT:
|
||||
|
||||
Two Convicts Evade Noose, Jury Hung.
|
||||
two convicts evade noose, jury hung.</programlisting>
|
||||
</example>
|
||||
</sect1>
|
||||
<sect1 id="language.modifier.nl2br">
|
||||
<title>nl2br</title>
|
||||
<para>
|
||||
All linebreaks will be converted to <br /> tags in the given
|
||||
variable. This is equivalent to the PHP nl2br() function.
|
||||
</para>
|
||||
<example>
|
||||
<title>nl2br</title>
|
||||
<programlisting>
|
||||
index.php:
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('articleTitle', "Sun or rain expected\ntoday, dark tonight");
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
index.tpl:
|
||||
|
||||
{$articleTitle|nl2br}
|
||||
|
||||
OUTPUT:
|
||||
|
||||
Sun or rain expected<br />today, dark tonight</programlisting>
|
||||
</example>
|
||||
</sect1>
|
||||
<sect1 id="language.modifier.regex.replace">
|
||||
@@ -2840,7 +2914,7 @@ e-mail: jane@mydomain.com<p></programlisting>
|
||||
carriage returns affect the output of the rendered HTML (browser
|
||||
"features"), so you must run all your tags together in the template
|
||||
to get the desired results. This usually ends up in unreadable or
|
||||
unmanagable templates.
|
||||
unmanageable templates.
|
||||
</para>
|
||||
<para>
|
||||
Anything within {strip}{/strip} tags in Smarty are stripped of the
|
||||
@@ -3374,6 +3448,219 @@ You must supply a <b>state</b>.
|
||||
{if $weather ne ""}
|
||||
<b>{$weather}</b>
|
||||
{/if}</programlisting>
|
||||
</example>
|
||||
</sect1>
|
||||
<sect1 id="language.function.html.checkboxes">
|
||||
<title>html_checkboxes</title>
|
||||
<informaltable frame=all>
|
||||
<tgroup cols=5>
|
||||
<colspec colname=param align=center>
|
||||
<colspec colname=type align=center>
|
||||
<colspec colname=required align=center>
|
||||
<colspec colname=default align=center>
|
||||
<colspec colname=desc>
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Attribute Name</entry>
|
||||
<entry>Type</entry>
|
||||
<entry>Required</entry>
|
||||
<entry>Default</entry>
|
||||
<entry>Description</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>name</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>checkbox</emphasis></entry>
|
||||
<entry>name of checkbox list</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>values</entry>
|
||||
<entry>array</entry>
|
||||
<entry>Yes, unless using checkboxes attribute</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>an array of values for checkbox buttons</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>output</entry>
|
||||
<entry>array</entry>
|
||||
<entry>Yes, unless using checkboxes attribute</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>an array of output for checkbox buttons</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>checked</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>empty</emphasis></entry>
|
||||
<entry>the checked checkbox element</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>checkboxes</entry>
|
||||
<entry>associative array</entry>
|
||||
<entry>Yes, unless using values and output</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>an associative array of values and output</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>separator</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>empty</emphasis></entry>
|
||||
<entry>string of text to separate each checkbox item</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
html_checkboxes is a custom function that creates an html checkbox
|
||||
group with provided data. It takes care of which item(s) are
|
||||
selected by default as well. Required attributes are values and
|
||||
output, unless you use checkboxes instead. All output is XHTML
|
||||
compatible.
|
||||
</para>
|
||||
<example>
|
||||
<title>html_checkboxes</title>
|
||||
<programlisting>
|
||||
index.php:
|
||||
|
||||
require('Smarty.php.class');
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('cust_ids', array(1000,1001,1002,1003));
|
||||
$smarty->assign('cust_names', array('Joe Schmoe','Jack Smith','Jane
|
||||
Johnson','CHarlie Brown'));
|
||||
$smarty->assign('customer_id', 1001);
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
|
||||
index.tpl:
|
||||
|
||||
{html_checkboxes values=$cust_ids checked=$customer_id output=$cust_names separator="<br />"}
|
||||
|
||||
|
||||
index.php:
|
||||
|
||||
require('Smarty.php.class');
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('cust_checkboxes', array(
|
||||
1001 => 'Joe Schmoe',
|
||||
1002 => 'Jack Smith',
|
||||
1003 => 'Jane Johnson','Carlie Brown'));
|
||||
$smarty->assign('customer_id', 1001);
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
index.tpl:
|
||||
|
||||
{html_checkboxes name="id" checkboxes=$cust_checkboxes checked=$customer_id separator="<br />"}
|
||||
|
||||
|
||||
OUTPUT: (both examples)
|
||||
|
||||
<input type="checkbox" name="id[]" value="1000">Joe Schmoe<br />
|
||||
<input type="checkbox" name="id[]" value="1001" checked="checked"><br />
|
||||
<input type="checkbox" name="id[]" value="1002">Jane Johnson<br />
|
||||
<input type="checkbox" name="id[]" value="1003">Charlie Brown<br /></programlisting>
|
||||
</example>
|
||||
</sect1>
|
||||
<sect1 id="language.function.html.image">
|
||||
<title>html_image</title>
|
||||
<informaltable frame=all>
|
||||
<tgroup cols=5>
|
||||
<colspec colname=param align=center>
|
||||
<colspec colname=type align=center>
|
||||
<colspec colname=required align=center>
|
||||
<colspec colname=default align=center>
|
||||
<colspec colname=desc>
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Attribute Name</entry>
|
||||
<entry>Type</entry>
|
||||
<entry>Required</entry>
|
||||
<entry>Default</entry>
|
||||
<entry>Description</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>name</entry>
|
||||
<entry>string</entry>
|
||||
<entry>Yes</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>name/path to image</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>border</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>0</emphasis></entry>
|
||||
<entry>size of border around image</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>height</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>actual image height</emphasis></entry>
|
||||
<entry>height to display image</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>width</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>actual image width</emphasis></entry>
|
||||
<entry>width to display image</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>basedir</entry>
|
||||
<entry>string</entry>
|
||||
<entry>no</entry>
|
||||
<entry><emphasis>web server doc root</emphasis></entry>
|
||||
<entry>directory to base relative paths from</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
html_image is a custom function that generates an HTML tag for an
|
||||
image. The height and width are automatically calculated from the
|
||||
image file if none are supplied.
|
||||
</para>
|
||||
<para>
|
||||
basedir is the base directory that relative image paths are based
|
||||
from. If not given, the web server document root (env variable
|
||||
DOCUMENT_ROOT) is used as the base. If security is enabled, the
|
||||
path to the image must be within a secure directory.
|
||||
</para>
|
||||
<note>
|
||||
<title>Technical Note</title>
|
||||
<para>
|
||||
html_image requires a hit to the disk to read the image and
|
||||
calculate the height and width. If you don't use template
|
||||
caching, it is generally better to avoid html_image and leave
|
||||
image tags static for optimal performance.
|
||||
</para>
|
||||
</note>
|
||||
<example>
|
||||
<title>html_image</title>
|
||||
<programlisting>
|
||||
index.php:
|
||||
|
||||
require('Smarty.php.class');
|
||||
$smarty = new Smarty;
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
index.tpl:
|
||||
|
||||
{image file="pumpkin.jpg"}
|
||||
{image file="/path/from/docroot/pumpkin.jpg"}
|
||||
{image file="../path/relative/to/currdir/pumpkin.jpg"}
|
||||
|
||||
OUTPUT: (possible)
|
||||
|
||||
<img src="pumpkin.jpg" border="0" width="44" height="68">
|
||||
<img src="/path/under/docroot/pumpkin.jpg" border="0" width="44" height="68">
|
||||
<img src="../path/relative/to/currdir/pumpkin.jpg" border="0" width="44" height="68"></programlisting>
|
||||
</example>
|
||||
</sect1>
|
||||
<sect1 id="language.function.html.options">
|
||||
@@ -3414,7 +3701,7 @@ You must supply a <b>state</b>.
|
||||
<entry>string/array</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>empty</emphasis></entry>
|
||||
<entry>the selected array element(s)</entry>
|
||||
<entry>the selected option element(s)</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>options</entry>
|
||||
@@ -3423,44 +3710,194 @@ You must supply a <b>state</b>.
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>an associative array of values and output</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>name</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>empty</emphasis></entry>
|
||||
<entry>name of select group</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
html_options is a custom function that creates html option lists
|
||||
with provided data. It takes care of which item is selected by
|
||||
html_options is a custom function that creates html option group
|
||||
with provided data. It takes care of which item(s) are selected by
|
||||
default as well. Required attributes are values and output, unless
|
||||
you use options instead. If a given value is an array, it will
|
||||
treat it as an html OPTGROUP, and display the groups. Recursion is
|
||||
supported with OPTGROUP. All output is xhtml compatible.
|
||||
you use options instead.
|
||||
</para>
|
||||
<para>
|
||||
If a given value is an array, it will treat it as an html OPTGROUP,
|
||||
and display the groups. Recursion is supported with OPTGROUP. All
|
||||
output is XHTML compatible.
|
||||
</para>
|
||||
<para>
|
||||
If the optional <emphasis>name</emphasis> attribute is given, the
|
||||
<select name="groupname"></select> tags will enclose
|
||||
the option list. Otherwise only the option list is generated.
|
||||
</para>
|
||||
<example>
|
||||
<title>html_options</title>
|
||||
<programlisting>
|
||||
{* assume that $cust_ids, and $cust_names are arrays of values,
|
||||
and $customer_id may or may not be set to a value *}
|
||||
index.php:
|
||||
|
||||
require('Smarty.php.class');
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('cust_ids', array(1000,1001,1002,1003));
|
||||
$smarty->assign('cust_names', array('Joe Schmoe','Jack Smith','Jane
|
||||
Johnson','Carlie Brown'));
|
||||
$smarty->assign('customer_id', 1001);
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
index.tpl:
|
||||
|
||||
<select name=customer_id>
|
||||
{html_options values=$cust_ids selected=$customer_id output=$cust_names}
|
||||
</select>
|
||||
|
||||
|
||||
{* an alternative method is to pass the values & output as an associative array into
|
||||
options. $customer_options is an associative array in this example. *}
|
||||
index.php:
|
||||
|
||||
require('Smarty.php.class');
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('cust_options', array(
|
||||
1001 => 'Joe Schmoe',
|
||||
1002 => 'Jack Smith',
|
||||
1003 => 'Jane Johnson',
|
||||
1004 => 'Charlie Brown'));
|
||||
$smarty->assign('customer_id', 1001);
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
index.tpl:
|
||||
|
||||
<select name=customer_id>
|
||||
{html_options options=$customer_options selected=$customer_id}
|
||||
{html_options options=$cust_options selected=$customer_id}
|
||||
</select>
|
||||
|
||||
|
||||
OUTPUT:
|
||||
OUTPUT: (both examples)
|
||||
|
||||
<select name=customer_id>
|
||||
<option value="1000">Joe Schmoe</option>
|
||||
<option value="1001" selected="selected">Jack Smith</option>
|
||||
<option value="1002">Jane Johnson</option>
|
||||
<option value="1003">Charlie Brown</option>
|
||||
<option value="1000">Joe Schmoe</option>
|
||||
<option value="1001" selected="selected">Jack Smith</option>
|
||||
<option value="1002">Jane Johnson</option>
|
||||
<option value="1003">Charlie Brown</option>
|
||||
</select></programlisting>
|
||||
</example>
|
||||
</sect1>
|
||||
<sect1 id="language.function.html.radios">
|
||||
<title>html_radios</title>
|
||||
<informaltable frame=all>
|
||||
<tgroup cols=5>
|
||||
<colspec colname=param align=center>
|
||||
<colspec colname=type align=center>
|
||||
<colspec colname=required align=center>
|
||||
<colspec colname=default align=center>
|
||||
<colspec colname=desc>
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Attribute Name</entry>
|
||||
<entry>Type</entry>
|
||||
<entry>Required</entry>
|
||||
<entry>Default</entry>
|
||||
<entry>Description</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>name</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>radio</emphasis></entry>
|
||||
<entry>name of radio list</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>values</entry>
|
||||
<entry>array</entry>
|
||||
<entry>Yes, unless using radios attribute</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>an array of values for radio buttons</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>output</entry>
|
||||
<entry>array</entry>
|
||||
<entry>Yes, unless using radios attribute</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>an array of output for radio buttons</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>checked</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>empty</emphasis></entry>
|
||||
<entry>the checked radio element</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>radios</entry>
|
||||
<entry>associative array</entry>
|
||||
<entry>Yes, unless using values and output</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>an associative array of values and output</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>separator</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>empty</emphasis></entry>
|
||||
<entry>string of text to separate each radio item</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
html_radios is a custom function that creates html radio button
|
||||
group with provided data. It takes care of which item is selected
|
||||
by default as well. Required attributes are values and output,
|
||||
unless you use radios instead. All output is XHTML compatible.
|
||||
</para>
|
||||
<example>
|
||||
<title>html_radios</title>
|
||||
<programlisting>
|
||||
index.php:
|
||||
|
||||
require('Smarty.php.class');
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('cust_ids', array(1000,1001,1002,1003));
|
||||
$smarty->assign('cust_names', array('Joe Schmoe','Jack Smith','Jane
|
||||
Johnson','Carlie Brown'));
|
||||
$smarty->assign('customer_id', 1001);
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
|
||||
index.tpl:
|
||||
|
||||
{html_radios values=$cust_ids checked=$customer_id output=$cust_names separator="<br />"}
|
||||
|
||||
|
||||
index.php:
|
||||
|
||||
require('Smarty.php.class');
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('cust_radios', array(
|
||||
1001 => 'Joe Schmoe',
|
||||
1002 => 'Jack Smith',
|
||||
1003 => 'Jane Johnson',
|
||||
1004 => 'Charlie Brown'));
|
||||
$smarty->assign('customer_id', 1001);
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
|
||||
index.tpl:
|
||||
|
||||
{html_radios name="id" radios=$cust_radios checked=$customer_id separator="<br />"}
|
||||
|
||||
|
||||
OUTPUT: (both examples)
|
||||
|
||||
<input type="radio" name="id[]" value="1000">Joe Schmoe<br />
|
||||
<input type="radio" name="id[]" value="1001" checked="checked"><br />
|
||||
<input type="radio" name="id[]" value="1002">Jane Johnson<br />
|
||||
<input type="radio" name="id[]" value="1003">Charlie Brown<br /></programlisting>
|
||||
</example>
|
||||
</sect1>
|
||||
<sect1 id="language.function.html.select.date">
|
||||
@@ -4056,6 +4493,118 @@ OUTPUT:
|
||||
<option value="am" selected>AM</option>
|
||||
<option value="pm">PM</option>
|
||||
</select></programlisting>
|
||||
</example>
|
||||
</sect1>
|
||||
<sect1 id="language.function.html.table">
|
||||
<title>html_table</title>
|
||||
<informaltable frame=all>
|
||||
<tgroup cols=5>
|
||||
<colspec colname=param align=center>
|
||||
<colspec colname=type align=center>
|
||||
<colspec colname=required align=center>
|
||||
<colspec colname=default align=center>
|
||||
<colspec colname=desc>
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Attribute Name</entry>
|
||||
<entry>Type</entry>
|
||||
<entry>Required</entry>
|
||||
<entry>Default</entry>
|
||||
<entry>Description</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>loop</entry>
|
||||
<entry>array</entry>
|
||||
<entry>Yes</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>array of data to loop through</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>cols</entry>
|
||||
<entry>integer</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>3</emphasis></entry>
|
||||
<entry>number of columns in the table</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>table_attr</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>border="1"</emphasis></entry>
|
||||
<entry>attributes for table tag</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>tr_attr</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>empty</emphasis></entry>
|
||||
<entry>attributes for tr tag (arrays are cycled)</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>td_attr</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>empty</emphasis></entry>
|
||||
<entry>attributes for td tag (arrays are cycled)</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>trailpad</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>&nbsp;</emphasis></entry>
|
||||
<entry>value to pad the trailing cells on last row with
|
||||
(if any)</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
<emphasis>html_table</emphasis> is a custom function that dumps an
|
||||
array of data into an HTML table. The <emphasis>cols</emphasis>
|
||||
attribute determines how many columns will be in the table. The
|
||||
<emphasis>table_attr</emphasis>, <emphasis>tr_attr</emphasis> and
|
||||
<emphasis>td_attr</emphasis> values determine the attributes given
|
||||
to the table, tr and td tags. If <emphasis>tr_attr</emphasis> or
|
||||
<emphasis>td_attr</emphasis> are arrays, they will be cycled through.
|
||||
<emphasis>trailpad</emphasis> is the value put into the trailing
|
||||
cells on the last table row if there are any present.
|
||||
</para>
|
||||
<example>
|
||||
<title>html_table</title>
|
||||
<programlisting>
|
||||
index.php:
|
||||
|
||||
require('Smarty.php.class');
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('data',array(1,2,3,4,5,6,7,8,9));
|
||||
$smarty->assign('tr',array('bgcolor="#eeeeee"','bgcolor="#dddddd"'));
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
index.tpl:
|
||||
|
||||
{html_table loop=$data}
|
||||
{html_table loop=$data cols=4 table_attrs='border="0"'}
|
||||
{html_table loop=$data cols=4 tr_attrs=$tr}
|
||||
|
||||
OUTPUT:
|
||||
|
||||
<table border="1">
|
||||
<tr><td>1</td><td>2</td><td>3</td></tr>
|
||||
<tr><td>4</td><td>5</td><td>6</td></tr>
|
||||
<tr><td>7</td><td>8</td><td>9</td></tr>
|
||||
</table>
|
||||
<table border="0">
|
||||
<tr><td>1</td><td>2</td><td>3</td><td>4</td></tr>
|
||||
<tr><td>5</td><td>6</td><td>7</td><td>8</td></tr>
|
||||
<tr><td>9</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
|
||||
</table>
|
||||
<table border="1">
|
||||
<tr bgcolor="#eeeeee"><td>1</td><td>2</td><td>3</td><td>4</td></tr>
|
||||
<tr bgcolor="#dddddd"><td>5</td><td>6</td><td>7</td><td>8</td></tr>
|
||||
<tr bgcolor="#eeeeee"><td>9</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
|
||||
</table></programlisting>
|
||||
</example>
|
||||
</sect1>
|
||||
<sect1 id="language.function.math">
|
||||
|
@@ -5,7 +5,7 @@
|
||||
<title>What is Smarty?</title>
|
||||
<para>
|
||||
Smarty is a template engine for PHP. More specifically, it facilitates a
|
||||
managable way to separate application logic and content from its
|
||||
manageable way to separate application logic and content from its
|
||||
presentation. This is best described in a situation where the application
|
||||
programmer and the template designer play different roles, or in most cases
|
||||
are not the same person. For example, let's say you are creating a web page
|
||||
@@ -30,7 +30,7 @@
|
||||
logic in your templates under the condition that this logic is strictly for
|
||||
presentation. A word of advice: keep application logic out of the
|
||||
templates, and presentation logic out of the application. This will most
|
||||
definately keep things managable and scalable for the foreseeable future.
|
||||
definately keep things manageable and scalable for the foreseeable future.
|
||||
</para>
|
||||
<para>
|
||||
One of the unique aspects about Smarty is the template compling. This means
|
||||
@@ -81,39 +81,14 @@
|
||||
|
||||
<sect1 id="installing.smarty.basic">
|
||||
<title>Basic Installation</title>
|
||||
<note>
|
||||
<title>Technical Note</title>
|
||||
<para>
|
||||
This installation guide makes the assumption that you are familiar with
|
||||
your web server setup, your PHP setup, and your operating system directory
|
||||
naming conventions. In these examples we use a Unix filesystem, so be sure
|
||||
you make the appropriate adjustments for your environment.
|
||||
</para>
|
||||
<para>
|
||||
The following examples assume that "/php/includes" is in your PHP
|
||||
include_path. See the PHP manual for information on setting this up.
|
||||
</para>
|
||||
</note>
|
||||
<para>
|
||||
First install the Smarty library files. These are the PHP files that you DO
|
||||
NOT edit. They are shared among all applications and they only get updated
|
||||
when you upgrade to a new version of Smarty.
|
||||
</para>
|
||||
<note>
|
||||
<title>Technical Note</title>
|
||||
<para>
|
||||
We recommend that you do not edit the Smarty library files. This makes
|
||||
upgrades much easier for you. You DO NOT need to edit these files to
|
||||
configure your applications! Use an instance of the Smarty class, which
|
||||
we'll get to in the sample setup below.
|
||||
</para>
|
||||
</note>
|
||||
|
||||
<para>
|
||||
This is a list of the required library files that come with Smarty:
|
||||
Install the Smarty library files which are in the /libs/ directory of
|
||||
the distribution. These are the PHP files that you SHOULD NOT edit. They
|
||||
are shared among all applications and they only get updated when you
|
||||
upgrade to a new version of Smarty.
|
||||
</para>
|
||||
<example>
|
||||
<title>Smarty library files list</title>
|
||||
<title>Smarty library files</title>
|
||||
<screen>
|
||||
Smarty.class.php
|
||||
Smarty_Compiler.class.php
|
||||
@@ -123,32 +98,52 @@ debug.tpl
|
||||
</example>
|
||||
|
||||
<para>
|
||||
You can either place these library files within your PHP include_path, or
|
||||
in any directory as long as you define that with the <link
|
||||
linkend="constant.smarty.dir">SMARTY_DIR</link> constant. We'll show an
|
||||
example of both.
|
||||
Smarty uses a PHP constant named <link
|
||||
linkend="constant.smarty.dir">SMARTY_DIR</link> which is the system
|
||||
filepath Smarty library directory. Basically, if your application can find
|
||||
the <emphasis>Smarty.class.php</emphasis> file, you do not need to set
|
||||
SMARTY_DIR, Smarty will figure it out on its own. Therefore, if
|
||||
<emphasis>Smarty.class.php</emphasis> is not in your include_path, or you
|
||||
do not supply an absolute path to it in your application, then you must
|
||||
define SMARTY_DIR manually. SMARTY_DIR <emphasis>must</emphasis> include a
|
||||
trailing slash.
|
||||
</para>
|
||||
<para>
|
||||
Here is how you create an instance of Smarty in your PHP scripts:
|
||||
</para>
|
||||
|
||||
<example>
|
||||
<title>Create Smarty instance from include_path</title>
|
||||
<title>Create Smarty instance of Smarty</title>
|
||||
<screen>
|
||||
require('Smarty.class.php');
|
||||
$smarty = new Smarty;</screen>
|
||||
</example>
|
||||
|
||||
<para>
|
||||
If the library files are outside of your PHP include_path, you must define
|
||||
the absolute path with the <link
|
||||
linkend="constant.smarty.dir">SMARTY_DIR</link> constant. SMARTY_DIR must
|
||||
end with a slash. Lets say we place our Smarty library files in
|
||||
"/usr/local/lib/php/Smarty/".
|
||||
Try running the above script. If you get an error saying the
|
||||
<emphasis>Smarty.class.php</emphasis> file could not be found, you have to
|
||||
do one of the following:
|
||||
</para>
|
||||
|
||||
<example>
|
||||
<title>Create Smarty instance from SMARTY_DIR</title>
|
||||
<title>Supply absolute path to library directory</title>
|
||||
<screen>
|
||||
require('/usr/local/lib/php/Smarty/Smarty.class.php');
|
||||
$smarty = new Smarty;</screen>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<title>Add library directory to php_include path</title>
|
||||
<screen>
|
||||
// Edit your php.ini file, add the Smarty library
|
||||
// directory to the include_path and restart web server.
|
||||
// Then the following should work:
|
||||
require('Smarty.class.php');
|
||||
$smarty = new Smarty;</screen>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<title>Set SMARTY_DIR constant manually</title>
|
||||
<screen>
|
||||
define('SMARTY_DIR','/usr/local/lib/php/Smarty/');
|
||||
require(SMARTY_DIR.'Smarty.class.php');
|
||||
@@ -156,53 +151,44 @@ $smarty = new Smarty;</screen>
|
||||
</example>
|
||||
|
||||
<para>
|
||||
Now the library files are in place, it's time to setup the Smarty
|
||||
directories.
|
||||
Now that the library files are in place, it's time to setup the Smarty
|
||||
directories for your application. Smarty requires four directories which
|
||||
are (by default) named <emphasis>tempalates</emphasis>,
|
||||
<emphasis>templates_c</emphasis>, <emphasis>configs</emphasis> and
|
||||
<emphasis>cache</emphasis>. Each of these are definable by the Smarty class
|
||||
properties <emphasis>$template_dir</emphasis>,
|
||||
<emphasis>$compile_dir</emphasis>, <emphasis>$config_dir</emphasis>, and
|
||||
<emphasis>$cache_dir</emphasis> respectively. It is highly recommended
|
||||
that you setup a separate set of these directories for each application
|
||||
that will use Smarty.
|
||||
</para>
|
||||
<para>
|
||||
Be sure you know the location of your web server document root. In our
|
||||
example, the document root is "/web/www.mydomain.com/docs/". The Smarty
|
||||
directories are only accessed by the Smarty library and never accessed
|
||||
directly by the web browser. Therefore to avoid any security concerns, it
|
||||
is recommended to place these directories in a directory
|
||||
<emphasis>off</emphasis> the document root.
|
||||
</para>
|
||||
<para>
|
||||
For our installation example, we will be setting up the Smarty environment
|
||||
for a guest book application. We picked an application only for the purpose
|
||||
of a directory naming convention. You can use the same environment for any
|
||||
application, just replace "guestbook" with the name of your app.
|
||||
</para>
|
||||
<para>
|
||||
Be sure you know the location of your web server document root. In our
|
||||
example, the document root is "/web/www.mydomain.com/docs/".
|
||||
</para>
|
||||
<para>
|
||||
The Smarty directories are defined in the class variables $template_dir,
|
||||
$compile_dir, $config_dir and $cache_dir, which default to the values
|
||||
"templates", "templates_c", "configs" and "cache" respectively. In our
|
||||
example, we'll place all of these directories under
|
||||
application, just replace "guestbook" with the name of your app. We'll
|
||||
place our Smarty directories under
|
||||
"/web/www.mydomain.com/smarty/guestbook/".
|
||||
</para>
|
||||
|
||||
<note>
|
||||
<title>Technical Note</title>
|
||||
<para>
|
||||
As a rule of thumb, none of these directories should be under the document
|
||||
root of your web server. This is recommended to avoid any possible direct
|
||||
access. You may, for example, have config files with sensitive data.
|
||||
</para>
|
||||
</note>
|
||||
|
||||
<para>
|
||||
You will need as least one file under your document root, and that is the
|
||||
script accessed by the web browser. We will call our script "index.php",
|
||||
and place it in a subdirectory under the document root called "/guestbook/".
|
||||
</para>
|
||||
|
||||
<note>
|
||||
<title>Technical Note</title>
|
||||
<para>
|
||||
It is convenient to setup the web server so that "index.php" can be
|
||||
identified as the default directory index, so if you access
|
||||
and place it in a subdirectory under the document root called
|
||||
"/guestbook/". It is convenient to setup the web server so that "index.php"
|
||||
can be identified as the default directory index, so if you access
|
||||
"http://www.mydomain.com/guestbook/", the index.php script will be executed
|
||||
without "index.php" in the URL. In Apache you can set this up by adding
|
||||
"index.php" onto the end of your DirectoryIndex setting (separate each
|
||||
entry with a space.)
|
||||
</para>
|
||||
</note>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Lets take a look at the file structure so far:
|
||||
@@ -225,21 +211,13 @@ $smarty = new Smarty;</screen>
|
||||
/web/www.mydomain.com/docs/guestbook/index.php</screen>
|
||||
</example>
|
||||
|
||||
<note>
|
||||
<title>Technical Note</title>
|
||||
<para>
|
||||
The $config_dir and $cache_dir are not absolutely necessary if you do not
|
||||
plan on using config files or template caching. It is probably a good idea
|
||||
to set them up anyways, in the case you decide to use them later.
|
||||
</para>
|
||||
</note>
|
||||
|
||||
<para>
|
||||
Smarty will need write access to the $compile_dir and $cache_dir, so be sure
|
||||
the web server user can write to them. This is usually user "nobody" and
|
||||
group "nobody". For OS X users, the default is user "web" and group "web".
|
||||
If you are using Apache, you can look in your httpd.conf file (usually in
|
||||
"/usr/local/apache/conf/") to see what user and group are being used.
|
||||
Smarty will need write access to the <emphasis>$compile_dir</emphasis> and
|
||||
<emphasis>$cache_dir</emphasis>, so be sure the web server user can write
|
||||
to them. This is usually user "nobody" and group "nobody". For OS X users,
|
||||
the default is user "web" and group "web". If you are using Apache, you can
|
||||
look in your httpd.conf file (usually in "/usr/local/apache/conf/") to see
|
||||
what user and group are being used.
|
||||
</para>
|
||||
|
||||
<example>
|
||||
@@ -291,15 +269,16 @@ Hello, {$name}!</screen>
|
||||
|
||||
<para>
|
||||
Now lets edit index.php. We'll create an instance of Smarty, assign a
|
||||
template variable and display the index.tpl file.
|
||||
template variable and display the index.tpl file. In our example
|
||||
environment, "/usr/local/lib/php/Smarty" is in our include_path. Be sure you
|
||||
do the same, or use absolute paths.
|
||||
</para>
|
||||
|
||||
<example>
|
||||
<title>Editing /web/www.mydomain.com/docs/guestbook/index.php</title>
|
||||
<screen>
|
||||
|
||||
define('SMARTY_DIR','/usr/local/lib/php/Smarty/');
|
||||
require(SMARTY_DIR.'Smarty.class.php');
|
||||
// load Smarty library
|
||||
require(Smarty.class.php');
|
||||
|
||||
$smarty = new Smarty;
|
||||
|
||||
@@ -345,19 +324,21 @@ $smarty->display('index.tpl');</screen>
|
||||
A slightly more flexible way to setup Smarty is to extend the class and
|
||||
initialize your Smarty environment. So instead of repeatedly setting
|
||||
directory paths, assigning the same vars, etc., we can do that in one place.
|
||||
Lets create a new directory "/php/includes/guestbook/" and make a new file called
|
||||
"setup.php".
|
||||
Lets create a new directory "/php/includes/guestbook/" and make a new file
|
||||
called "setup.php". In our example environment, "/php/includes" is in our
|
||||
include_path. Be sure you set this up too, or use absolute file paths.
|
||||
</para>
|
||||
|
||||
<example>
|
||||
<title>Editing /php/includes/guestbook/setup.php</title>
|
||||
<screen>
|
||||
|
||||
// load Smarty library files
|
||||
define('SMARTY_DIR','/usr/local/lib/php/Smarty/');
|
||||
require(SMARTY_DIR.'Smarty.class.php');
|
||||
// load Smarty library
|
||||
require(Smarty.class.php');
|
||||
|
||||
// a good place to load application library files, example:
|
||||
// The setup.php file is a good place to load
|
||||
// required application library files, and you
|
||||
// can do that right here. An example:
|
||||
// require('guestbook/guestbook.lib.php');
|
||||
|
||||
class Smarty_GuestBook extends Smarty {
|
||||
@@ -380,18 +361,6 @@ class Smarty_GuestBook extends Smarty {
|
||||
}</screen>
|
||||
</example>
|
||||
|
||||
<note>
|
||||
<title>Technical Note</title>
|
||||
<para>
|
||||
In our example, we keep application libraries (not intended for direct
|
||||
browser access) in a separate directory outside of the document root. These
|
||||
files may contain sensitive data that we don't want any direct access to.
|
||||
We keep all library files for the guest book application under
|
||||
"/php/includes/guestbook/" and load them in the setup script, as you see in
|
||||
the above example.
|
||||
</para>
|
||||
</note>
|
||||
|
||||
<para>
|
||||
Now lets alter the index.php file to use setup.php:
|
||||
</para>
|
||||
|
@@ -1449,16 +1449,20 @@ class Smarty_Compiler extends Smarty {
|
||||
function _expand_quoted_text($var_expr)
|
||||
{
|
||||
// if contains unescaped $, expand it
|
||||
if(preg_match_all('%(?<!\\\\)\$\`?(?:smarty(?:\.\w+)*|\w+(?:' . $this->_var_bracket_regexp . ')*)\`?%', $var_expr, $match)) {
|
||||
rsort($match[0]);
|
||||
reset($match[0]);
|
||||
foreach($match[0] as $var) {
|
||||
$var_expr = str_replace ($var, '".' . $this->_parse_var(str_replace('`','',$var)) . '."', $var_expr);
|
||||
if(preg_match_all('%(?<!\\\\)\$\`?' . $this->_dvar_guts_regexp . '\`?%', $var_expr, $_match)) {
|
||||
$_match = $_match[0];
|
||||
rsort($_match);
|
||||
reset($_match);
|
||||
foreach($_match as $_var) {
|
||||
$var_expr = str_replace ($_var, '".' . $this->_parse_var(str_replace('`','',$_var)) . '."', $var_expr);
|
||||
}
|
||||
return preg_replace('!\.""|""\.!', '', $var_expr);
|
||||
$_return = preg_replace('!\.""|""\.!', '', $var_expr);
|
||||
} else {
|
||||
return $var_expr;
|
||||
$_return = $var_expr;
|
||||
}
|
||||
// replace double quoted string with single quotes
|
||||
$_return = preg_replace('!"([^\$\']+)"!',"'\\1'",$_return);
|
||||
return $_return;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1468,9 +1472,8 @@ class Smarty_Compiler extends Smarty {
|
||||
*/
|
||||
function _parse_var($var_expr)
|
||||
{
|
||||
|
||||
preg_match('!(' . $this->_obj_call_regexp . '|' . $this->_var_regexp . ')(' . $this->_mod_regexp . '*)$!', $var_expr, $match);
|
||||
|
||||
|
||||
$var_ref = substr($match[1],1);
|
||||
$modifiers = $match[2];
|
||||
|
||||
@@ -1481,7 +1484,7 @@ class Smarty_Compiler extends Smarty {
|
||||
|
||||
// get [foo] and .foo and ->foo and (...) pieces
|
||||
preg_match_all('!(?:^\w+)|' . $this->_obj_params_regexp . '|(?:' . $this->_var_bracket_regexp . ')|->\w+|\.\$?\w+|\S+!', $var_ref, $match);
|
||||
|
||||
|
||||
$indexes = $match[0];
|
||||
$var_name = array_shift($indexes);
|
||||
|
||||
@@ -1534,11 +1537,6 @@ class Smarty_Compiler extends Smarty {
|
||||
$output .= $index;
|
||||
}
|
||||
}
|
||||
|
||||
// look for variables imbedded in quoted strings, replace them
|
||||
if(preg_match('|(?<!\\\\)\$|', $output, $match)) {
|
||||
$output = str_replace($match[0], $this->_expand_quoted_text($match[0]), $output);
|
||||
}
|
||||
|
||||
$this->_parse_modifiers($output, $modifiers);
|
||||
|
||||
@@ -1749,7 +1747,7 @@ class Smarty_Compiler extends Smarty {
|
||||
case 'const':
|
||||
array_shift($indexes);
|
||||
$_val = $this->_parse_var_props(substr($indexes[0],1));
|
||||
$compiled_ref = "(defined($_val) ? $_val : null)";
|
||||
$compiled_ref = '(defined(' . $_val . ') ? ' . $this->_dequote($_val) . ' : null)';
|
||||
$_max_index = 1;
|
||||
break;
|
||||
|
||||
|
@@ -11,6 +11,7 @@
|
||||
* Purpose: Prints out a list of checkbox input types
|
||||
* Input: name (optional) - string default "checkbox"
|
||||
* values (required) - array
|
||||
* checkboxes (optional) - associative array
|
||||
* checked (optional) - array default not set
|
||||
* separator (optional) - ie <br> or
|
||||
* output (optional) - without this one the buttons don't have names
|
||||
@@ -21,9 +22,10 @@
|
||||
* {html_checkboxes values=$ids checked=$checked separator='<br>' output=$names}
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
require_once $this->_get_plugin_filepath('shared','escape_special_chars');
|
||||
function smarty_function_html_checkboxes($params, &$smarty)
|
||||
{
|
||||
require_once $smarty->_get_plugin_filepath('shared','escape_special_chars');
|
||||
|
||||
extract($params);
|
||||
|
||||
$_html_result = '';
|
||||
|
@@ -15,8 +15,8 @@
|
||||
* border = border width (optional, default 0)
|
||||
* height = image height (optional, default actual height)
|
||||
* image =image width (optional, default actual width)
|
||||
* basedir= base directory for absolute paths, default
|
||||
* is environment variable DOCUMENT_ROOT
|
||||
* basedir = base directory for absolute paths, default
|
||||
* is environment variable DOCUMENT_ROOT
|
||||
*
|
||||
* Examples: {image name="images/masthead.gif"}
|
||||
* Output: <img src="images/masthead.gif" border=0 width=400 height=23>
|
||||
@@ -80,8 +80,8 @@ function smarty_function_html_image($params, &$smarty)
|
||||
$smarty->trigger_error("html_image: '$_image_path' is not a valid image file", E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
if(!$smarty->security && substr($_image_path,0,strlen($basedir)) != $basedir) {
|
||||
$smarty->trigger_error("html_image: (secure) '$_image_path' not within basedir ($basedir)", E_USER_ERROR);
|
||||
if(!$smarty->security && !$smarty->_is_secure('file', $_image_path)) {
|
||||
$smarty->trigger_error("html_image: (secure) '$_image_path' not in secure directory", E_USER_ERROR);
|
||||
}
|
||||
|
||||
if(!isset($params['width'])) {
|
||||
|
@@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
require('shared.escape_special_chars.php');
|
||||
|
||||
/*
|
||||
* Smarty plugin
|
||||
* -------------------------------------------------------------
|
||||
@@ -13,6 +11,8 @@ require('shared.escape_special_chars.php');
|
||||
*/
|
||||
function smarty_function_html_options($params, &$smarty)
|
||||
{
|
||||
require_once $smarty->_get_plugin_filepath('shared','escape_special_chars');
|
||||
|
||||
extract($params);
|
||||
|
||||
$html_result = '';
|
||||
@@ -35,6 +35,9 @@ function smarty_function_html_options($params, &$smarty)
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($name)) {
|
||||
$html_result = '<select name="' . $name . '">' . "\n" . $html_result . '</select>' . "\n";
|
||||
}
|
||||
return $html_result;
|
||||
}
|
||||
|
||||
|
@@ -11,6 +11,7 @@
|
||||
* Purpose: Prints out a list of radio input types
|
||||
* Input: name (optional) - string default "radio"
|
||||
* values (required) - array
|
||||
* radios (optional) - associative array
|
||||
* checked (optional) - array default not set
|
||||
* separator (optional) - ie <br> or
|
||||
* output (optional) - without this one the buttons don't have names
|
||||
|
@@ -19,10 +19,10 @@
|
||||
* day values (Marcus Bointon)
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
require_once $this->_get_plugin_filepath('shared','make_timestamp');
|
||||
require_once $this->_get_plugin_filepath('function','html_options');
|
||||
function smarty_function_html_select_date($params, &$smarty)
|
||||
{
|
||||
require_once $smarty->_get_plugin_filepath('shared','make_timestamp');
|
||||
require_once $smarty->_get_plugin_filepath('function','html_options');
|
||||
/* Default values. */
|
||||
$prefix = "Date_";
|
||||
$start_year = strftime("%Y");
|
||||
|
@@ -8,10 +8,10 @@
|
||||
* Purpose: Prints the dropdowns for time selection
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
require_once $this->_get_plugin_filepath('shared','make_timestamp');
|
||||
require_once $this->_get_plugin_filepath('function','html_options');
|
||||
function smarty_function_html_select_time($params, &$smarty)
|
||||
{
|
||||
require_once $smarty->_get_plugin_filepath('shared','make_timestamp');
|
||||
require_once $smarty->_get_plugin_filepath('function','html_options');
|
||||
/* Default values. */
|
||||
$prefix = "Time_";
|
||||
$time = time();
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* table_attr = table attributes
|
||||
* tr_attr = table row attributes (arrays are cycled)
|
||||
* td_attr = table cell attributes (arrays are cycled)
|
||||
* cellpad = value to pad trailing cells with
|
||||
* trailpad = value to pad trailing cells with
|
||||
*
|
||||
* Examples: {table loop=$data}
|
||||
* {$table loop=$data cols=4 tr_attr='"bgcolor=red"'}
|
||||
@@ -23,11 +23,11 @@
|
||||
*/
|
||||
function smarty_function_html_table($params, &$smarty)
|
||||
{
|
||||
$table_attr = 'border=1';
|
||||
$table_attr = 'border="1"';
|
||||
$tr_attr = '';
|
||||
$td_attr = '';
|
||||
$cols = 3;
|
||||
$cellpad = ' ';
|
||||
$trailpad = ' ';
|
||||
|
||||
extract($params);
|
||||
|
||||
@@ -50,7 +50,7 @@ function smarty_function_html_table($params, &$smarty)
|
||||
$cells = $cols - $y % $cols;
|
||||
if($cells != $cols) {
|
||||
for($padloop = 0; $padloop < $cells; $padloop++) {
|
||||
$output .= "<td " . smarty_function_html_table_cycle('td', $td_attr) . ">$cellpad</td>\n";
|
||||
$output .= "<td " . smarty_function_html_table_cycle('td', $td_attr) . ">$trailpad</td>\n";
|
||||
}
|
||||
}
|
||||
$output .= "</tr>\n";
|
||||
|
Reference in New Issue
Block a user