mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 10:54:27 +02:00
fix parse errors in examples
# using this: for i in $(ls |grep xml); do php -d short_open_tag=off -l $i; done
This commit is contained in:
@@ -55,7 +55,7 @@
|
|||||||
// the object
|
// the object
|
||||||
|
|
||||||
class My_Object {
|
class My_Object {
|
||||||
function meth1($params, &$smarty_obj) {
|
function meth1($params, &$smarty_obj) {
|
||||||
return "this is my meth1";
|
return "this is my meth1";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -110,7 +110,7 @@ the output was {$output}
|
|||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
// put this in your application
|
// put this in your application
|
||||||
function remove_dw_comments($tpl_source, &$smarty)
|
function remove_dw_comments($tpl_source, &$smarty)
|
||||||
{
|
{
|
||||||
return preg_replace("/<!--#.*-->/U","",$tpl_source);
|
return preg_replace("/<!--#.*-->/U","",$tpl_source);
|
||||||
}
|
}
|
||||||
@@ -147,7 +147,7 @@ $smarty->display("index.tpl");
|
|||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
// put this in your application
|
// put this in your application
|
||||||
function add_header_comment($tpl_source, &$smarty)
|
function add_header_comment($tpl_source, &$smarty)
|
||||||
{
|
{
|
||||||
return "<?php echo \"<!-- Created by Smarty! -->;\n\" ?>;\n".$tpl_source;
|
return "<?php echo \"<!-- Created by Smarty! -->;\n\" ?>;\n".$tpl_source;
|
||||||
}
|
}
|
||||||
@@ -191,7 +191,7 @@ $smarty->display("index.tpl");
|
|||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
// put this in your application
|
// put this in your application
|
||||||
function protect_email($tpl_output, &$smarty)
|
function protect_email($tpl_output, &$smarty)
|
||||||
{
|
{
|
||||||
$tpl_output =
|
$tpl_output =
|
||||||
preg_replace('!(\S+)@([a-zA-Z0-9\.\-]+\.([a-zA-Z]{2,3}|[0-9]{1,3}))!',
|
preg_replace('!(\S+)@([a-zA-Z0-9\.\-]+\.([a-zA-Z]{2,3}|[0-9]{1,3}))!',
|
||||||
@@ -265,7 +265,7 @@ CacheContents MEDIUMTEXT NOT NULL
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function mysql_cache_handler($action, &$smarty_obj, &$cache_content, $tpl_file=null, $cache_id=null, $compile_id=null, $exp_time=null)
|
function mysql_cache_handler($action, &$smarty_obj, &$cache_content, $tpl_file=null, $cache_id=null, $compile_id=null, $exp_time=null)
|
||||||
{
|
{
|
||||||
// set db host, user and pass here
|
// set db host, user and pass here
|
||||||
$db_host = 'localhost';
|
$db_host = 'localhost';
|
||||||
@@ -458,7 +458,7 @@ $smarty->display("file:F:/path/to/my/templates/menu.tpl");
|
|||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
// put these function somewhere in your application
|
// put these function somewhere in your application
|
||||||
function db_get_template ($tpl_name, &$tpl_source, &$smarty_obj)
|
function db_get_template ($tpl_name, &$tpl_source, &$smarty_obj)
|
||||||
{
|
{
|
||||||
// do database call here to fetch your template,
|
// do database call here to fetch your template,
|
||||||
// populating $tpl_source
|
// populating $tpl_source
|
||||||
@@ -474,7 +474,7 @@ function db_get_template ($tpl_name, &$tpl_source, &$smarty_obj)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function db_get_timestamp($tpl_name, &$tpl_timestamp, &$smarty_obj)
|
function db_get_timestamp($tpl_name, &$tpl_timestamp, &$smarty_obj)
|
||||||
{
|
{
|
||||||
// do database call here to populate $tpl_timestamp.
|
// do database call here to populate $tpl_timestamp.
|
||||||
$sql = new SQL;
|
$sql = new SQL;
|
||||||
@@ -489,13 +489,13 @@ function db_get_timestamp($tpl_name, &$tpl_timestamp, &$smarty_obj)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function db_get_secure($tpl_name, &$smarty_obj)
|
function db_get_secure($tpl_name, &$smarty_obj)
|
||||||
{
|
{
|
||||||
// assume all templates are secure
|
// assume all templates are secure
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function db_get_trusted($tpl_name, &$smarty_obj)
|
function db_get_trusted($tpl_name, &$smarty_obj)
|
||||||
{
|
{
|
||||||
// not used for templates
|
// not used for templates
|
||||||
}
|
}
|
||||||
@@ -532,7 +532,7 @@ $smarty->display("db:index.tpl");
|
|||||||
<?php
|
<?php
|
||||||
// put this function somewhere in your application
|
// put this function somewhere in your application
|
||||||
|
|
||||||
function make_template ($resource_type, $resource_name, &$template_source, &$template_timestamp, &$smarty_obj)
|
function make_template ($resource_type, $resource_name, &$template_source, &$template_timestamp, &$smarty_obj)
|
||||||
{
|
{
|
||||||
if( $resource_type == 'file' ) {
|
if( $resource_type == 'file' ) {
|
||||||
if ( ! is_readable ( $resource_name )) {
|
if ( ! is_readable ( $resource_name )) {
|
||||||
|
@@ -422,7 +422,7 @@ if(!$smarty->is_cached("index.tpl"))
|
|||||||
$db_data = array(
|
$db_data = array(
|
||||||
"City" => "Lincoln",
|
"City" => "Lincoln",
|
||||||
"State" => "Nebraska",
|
"State" => "Nebraska",
|
||||||
"Zip" = > "68502"
|
"Zip" => "68502"
|
||||||
);
|
);
|
||||||
|
|
||||||
$smarty->assign("Name","Fred");
|
$smarty->assign("Name","Fred");
|
||||||
@@ -511,7 +511,7 @@ if(!$smarty->is_cached("index.tpl"))
|
|||||||
$db_data = array(
|
$db_data = array(
|
||||||
"City" => "Lincoln",
|
"City" => "Lincoln",
|
||||||
"State" => "Nebraska",
|
"State" => "Nebraska",
|
||||||
"Zip" = > "68502"
|
"Zip" => "68502"
|
||||||
);
|
);
|
||||||
|
|
||||||
$smarty->assign("Name","Fred");
|
$smarty->assign("Name","Fred");
|
||||||
@@ -577,10 +577,10 @@ print_r($config_vars);
|
|||||||
<programlisting role="php">
|
<programlisting role="php">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
function smarty_block_foo($params, &$smarty) {
|
function smarty_block_foo($params, &$smarty) {
|
||||||
if (isset[$params['object']]) {
|
if (isset($params['object'])) {
|
||||||
// get reference to registered object
|
// get reference to registered object
|
||||||
$obj_ref = &$smarty->&get_registered_object($params['object']);
|
$obj_ref = &$smarty->get_registered_object($params['object']);
|
||||||
// use $obj_ref is now a reference to the object
|
// use $obj_ref is now a reference to the object
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -735,7 +735,7 @@ $smarty->load_filter('output', 'compress'); // load output filter named 'compres
|
|||||||
<?php
|
<?php
|
||||||
$smarty->register_block("translate", "do_translation");
|
$smarty->register_block("translate", "do_translation");
|
||||||
|
|
||||||
function do_translation ($params, $content, &$smarty, &$repeat) {
|
function do_translation ($params, $content, &$smarty, &$repeat) {
|
||||||
if (isset($content)) {
|
if (isset($content)) {
|
||||||
$lang = $params['lang'];
|
$lang = $params['lang'];
|
||||||
// do some translation with $content
|
// do some translation with $content
|
||||||
@@ -1228,4 +1228,4 @@ End:
|
|||||||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||||
vim: et tw=78 syn=sgml
|
vim: et tw=78 syn=sgml
|
||||||
vi: ts=1 sw=1
|
vi: ts=1 sw=1
|
||||||
-->
|
-->
|
||||||
|
@@ -359,7 +359,7 @@ require('Smarty.class.php');
|
|||||||
$smarty = new Smarty;
|
$smarty = new Smarty;
|
||||||
$smarty->caching = true;
|
$smarty->caching = true;
|
||||||
|
|
||||||
function remaining_seconds($params, &$smarty) {
|
function remaining_seconds($params, &$smarty) {
|
||||||
$remain = $params['endtime'] - time();
|
$remain = $params['endtime'] - time();
|
||||||
if ($remain >=0)
|
if ($remain >=0)
|
||||||
return $remain . " second(s)";
|
return $remain . " second(s)";
|
||||||
@@ -400,7 +400,7 @@ require('Smarty.class.php');
|
|||||||
$smarty = new Smarty;
|
$smarty = new Smarty;
|
||||||
$smarty->caching = true;
|
$smarty->caching = true;
|
||||||
|
|
||||||
function smarty_block_dynamic($param, $content, &$smarty) {
|
function smarty_block_dynamic($param, $content, &$smarty) {
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
$smarty->register_block('dynamic', 'smarty_block_dynamic', false);
|
$smarty->register_block('dynamic', 'smarty_block_dynamic', false);
|
||||||
@@ -448,4 +448,4 @@ End:
|
|||||||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||||
vim: et tw=78 syn=sgml
|
vim: et tw=78 syn=sgml
|
||||||
vi: ts=1 sw=1
|
vi: ts=1 sw=1
|
||||||
-->
|
-->
|
||||||
|
@@ -182,7 +182,7 @@ require_once $smarty->_get_plugin_filepath('function', 'html_options');
|
|||||||
* Purpose: outputs a random magic answer
|
* Purpose: outputs a random magic answer
|
||||||
* -------------------------------------------------------------
|
* -------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
function smarty_function_eightball($params, &$smarty)
|
function smarty_function_eightball($params, &$smarty)
|
||||||
{
|
{
|
||||||
$answers = array('Yes',
|
$answers = array('Yes',
|
||||||
'No',
|
'No',
|
||||||
@@ -221,7 +221,7 @@ Answer: {eightball}.
|
|||||||
* Purpose: assign a value to a template variable
|
* Purpose: assign a value to a template variable
|
||||||
* -------------------------------------------------------------
|
* -------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
function smarty_function_assign($params, &$smarty)
|
function smarty_function_assign($params, &$smarty)
|
||||||
{
|
{
|
||||||
if (empty($params['var'])) {
|
if (empty($params['var'])) {
|
||||||
$smarty->trigger_error("assign: missing 'var' parameter");
|
$smarty->trigger_error("assign: missing 'var' parameter");
|
||||||
@@ -415,7 +415,7 @@ function smarty_modifier_truncate($string, $length = 80, $etc = '...',
|
|||||||
* Purpose: translate a block of text
|
* Purpose: translate a block of text
|
||||||
* -------------------------------------------------------------
|
* -------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
function smarty_block_translate($params, $content, &$smarty)
|
function smarty_block_translate($params, $content, &$smarty)
|
||||||
{
|
{
|
||||||
if (isset($content)) {
|
if (isset($content)) {
|
||||||
$lang = $params['lang'];
|
$lang = $params['lang'];
|
||||||
@@ -470,7 +470,7 @@ function smarty_block_translate($params, $content, &$smarty)
|
|||||||
* the time it was compiled.
|
* the time it was compiled.
|
||||||
* -------------------------------------------------------------
|
* -------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
function smarty_compiler_tplheader($tag_arg, &$smarty)
|
function smarty_compiler_tplheader($tag_arg, &$smarty)
|
||||||
{
|
{
|
||||||
return "\necho '" . $smarty->_current_file . " compiled at " . date('Y-m-d H:M'). "';";
|
return "\necho '" . $smarty->_current_file . " compiled at " . date('Y-m-d H:M'). "';";
|
||||||
}
|
}
|
||||||
@@ -547,7 +547,7 @@ echo 'index.tpl compiled at 2002-02-20 20:02';
|
|||||||
* Purpose: Convert html tags to be lowercase.
|
* Purpose: Convert html tags to be lowercase.
|
||||||
* -------------------------------------------------------------
|
* -------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
function smarty_prefilter_pre01($source, &$smarty)
|
function smarty_prefilter_pre01($source, &$smarty)
|
||||||
{
|
{
|
||||||
return preg_replace('!<(\w+)[^>]+>!e', 'strtolower("$1")', $source);
|
return preg_replace('!<(\w+)[^>]+>!e', 'strtolower("$1")', $source);
|
||||||
}
|
}
|
||||||
@@ -570,7 +570,7 @@ echo 'index.tpl compiled at 2002-02-20 20:02';
|
|||||||
* Purpose: Output code that lists all current template vars.
|
* Purpose: Output code that lists all current template vars.
|
||||||
* -------------------------------------------------------------
|
* -------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
function smarty_postfilter_post01($compiled, &$smarty)
|
function smarty_postfilter_post01($compiled, &$smarty)
|
||||||
{
|
{
|
||||||
$compiled = "<pre>\n<?php print_r(\$this->get_template_vars()); ?>\n</pre>" . $compiled;
|
$compiled = "<pre>\n<?php print_r(\$this->get_template_vars()); ?>\n</pre>" . $compiled;
|
||||||
return $compiled;
|
return $compiled;
|
||||||
@@ -614,7 +614,7 @@ echo 'index.tpl compiled at 2002-02-20 20:02';
|
|||||||
* a simple protection against spambots
|
* a simple protection against spambots
|
||||||
* -------------------------------------------------------------
|
* -------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
function smarty_outputfilter_protect_email($output, &$smarty)
|
function smarty_outputfilter_protect_email($output, &$smarty)
|
||||||
{
|
{
|
||||||
return preg_replace('!(\S+)@([a-zA-Z0-9\.\-]+\.([a-zA-Z]{2,3}|[0-9]{1,3}))!',
|
return preg_replace('!(\S+)@([a-zA-Z0-9\.\-]+\.([a-zA-Z]{2,3}|[0-9]{1,3}))!',
|
||||||
'$1%40$2', $output);
|
'$1%40$2', $output);
|
||||||
@@ -716,7 +716,7 @@ echo 'index.tpl compiled at 2002-02-20 20:02';
|
|||||||
* Purpose: Fetches templates from a database
|
* Purpose: Fetches templates from a database
|
||||||
* -------------------------------------------------------------
|
* -------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
function smarty_resource_db_source($tpl_name, &$tpl_source, &$smarty)
|
function smarty_resource_db_source($tpl_name, &$tpl_source, &$smarty)
|
||||||
{
|
{
|
||||||
// do database call here to fetch your template,
|
// do database call here to fetch your template,
|
||||||
// populating $tpl_source
|
// populating $tpl_source
|
||||||
@@ -732,7 +732,7 @@ function smarty_resource_db_source($tpl_name, &$tpl_source, &$smarty)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function smarty_resource_db_timestamp($tpl_name, &$tpl_timestamp, &$smarty)
|
function smarty_resource_db_timestamp($tpl_name, &$tpl_timestamp, &$smarty)
|
||||||
{
|
{
|
||||||
// do database call here to populate $tpl_timestamp.
|
// do database call here to populate $tpl_timestamp.
|
||||||
$sql = new SQL;
|
$sql = new SQL;
|
||||||
@@ -747,13 +747,13 @@ function smarty_resource_db_timestamp($tpl_name, &$tpl_timestamp, &$smar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function smarty_resource_db_secure($tpl_name, &$smarty)
|
function smarty_resource_db_secure($tpl_name, &$smarty)
|
||||||
{
|
{
|
||||||
// assume all templates are secure
|
// assume all templates are secure
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function smarty_resource_db_trusted($tpl_name, &$smarty)
|
function smarty_resource_db_trusted($tpl_name, &$smarty)
|
||||||
{
|
{
|
||||||
// not used for templates
|
// not used for templates
|
||||||
}
|
}
|
||||||
@@ -799,7 +799,7 @@ function smarty_resource_db_trusted($tpl_name, &$smarty)
|
|||||||
* Purpose: Inserts current date/time according to format
|
* Purpose: Inserts current date/time according to format
|
||||||
* -------------------------------------------------------------
|
* -------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
function smarty_insert_time($params, &$smarty)
|
function smarty_insert_time($params, &$smarty)
|
||||||
{
|
{
|
||||||
if (empty($params['format'])) {
|
if (empty($params['format'])) {
|
||||||
$smarty->trigger_error("insert time: missing 'format' parameter");
|
$smarty->trigger_error("insert time: missing 'format' parameter");
|
||||||
|
Reference in New Issue
Block a user