Initialer Commit: Kundenverwaltung (PHP/Smarty)
Bestehende Codebasis als Ausgangsstand aufgenommen. - .gitignore: Kundendaten (uploads_*), Smarty-Compile-Cache (templates_c), Laufzeit-Temp und Datenbank-Dumps ausgeschlossen; Verzeichnisstruktur ueber .gitkeep erhalten - .gitattributes: Zeilenenden normalisiert (LF im Repo), Binaerformate markiert - db-backup.php: MySQL-Zugangsdaten kommen jetzt wie im Rest der Anwendung aus der externen Konfiguration statt hartkodiert aus der Datei; Passwort wird ueber eine temporaere Optionsdatei statt per Kommandozeile uebergeben, Fehler von mysqldump/gzip werden gemeldet, Aufraeumen aelterer Backups berechnet Jahr und Monat konsistent Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,326 @@
|
||||
<?php /*%%SmartyHeaderCode:12640292194ede8dc07d9679-56216527%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
|
||||
$_valid = $_smarty_tpl->decodeProperties(array (
|
||||
'file_dependency' =>
|
||||
array (
|
||||
'c0360d049dff10f364dfc53ba2cc3958abf6ee6d' =>
|
||||
array (
|
||||
0 => './templates/index.tpl',
|
||||
1 => 1323208095,
|
||||
2 => 'file',
|
||||
),
|
||||
'dcf64f36a8afd5f887bb61bf9b6a5f77c9e60d5f' =>
|
||||
array (
|
||||
0 => './configs/test.conf',
|
||||
1 => 1323208095,
|
||||
2 => 'file',
|
||||
),
|
||||
'97c13ae6868bbc459509c9f1b968154acd23eecc' =>
|
||||
array (
|
||||
0 => './templates/header.tpl',
|
||||
1 => 1323208095,
|
||||
2 => 'file',
|
||||
),
|
||||
'3a4f6f0d327fc7bc3ea86f63906a1bf934ca50c7' =>
|
||||
array (
|
||||
0 => './templates/footer.tpl',
|
||||
1 => 1323208095,
|
||||
2 => 'file',
|
||||
),
|
||||
),
|
||||
'nocache_hash' => '12640292194ede8dc07d9679-56216527',
|
||||
'variables' =>
|
||||
array (
|
||||
'SCRIPT_NAME' => 0,
|
||||
'Name' => 1,
|
||||
'FirstName' => 0,
|
||||
'LastName' => 0,
|
||||
'contacts' => 0,
|
||||
'option_values' => 0,
|
||||
'option_selected' => 0,
|
||||
'option_output' => 0,
|
||||
),
|
||||
'has_nocache_code' => true,
|
||||
'version' => 'Smarty-3.1.6',
|
||||
'unifunc' => 'content_4ede8dc0ac1cf',
|
||||
'cache_lifetime' => 120,
|
||||
),true); /*/%%SmartyHeaderCode%%*/?>
|
||||
<?php if ($_valid && !is_callable('content_4ede8dc0ac1cf')) {function content_4ede8dc0ac1cf($_smarty_tpl) {?><HTML>
|
||||
<HEAD>
|
||||
<TITLE>foo - <?php echo $_smarty_tpl->tpl_vars['Name']->value;?>
|
||||
</TITLE>
|
||||
</HEAD>
|
||||
<BODY bgcolor="#ffffff">
|
||||
|
||||
|
||||
<PRE>
|
||||
<b>Title: Welcome To Smarty!
|
||||
</b>
|
||||
The current date and time is 2011-12-06 22:48:48
|
||||
|
||||
The value of global assigned variable $SCRIPT_NAME is /kunden/smarty/demo/index.php
|
||||
|
||||
Example of accessing server environment variable SERVER_NAME: localhost
|
||||
|
||||
The value of {$Name} is <b><?php echo $_smarty_tpl->tpl_vars['Name']->value;?>
|
||||
</b>
|
||||
|
||||
variable modifier example of {$Name|upper}
|
||||
|
||||
<b><?php echo mb_strtoupper($_smarty_tpl->tpl_vars['Name']->value,SMARTY_RESOURCE_CHAR_SET);?>
|
||||
</b>
|
||||
|
||||
|
||||
An example of a section loop:
|
||||
|
||||
1 * John Doe
|
||||
2 * Mary Smith
|
||||
3 . James Johnson
|
||||
4 . Henry Case
|
||||
|
||||
An example of section looped key values:
|
||||
|
||||
phone: 1<br>
|
||||
fax: 2<br>
|
||||
cell: 3<br>
|
||||
phone: 555-4444<br>
|
||||
fax: 555-3333<br>
|
||||
cell: 760-1234<br>
|
||||
<p>
|
||||
|
||||
testing strip tags
|
||||
<table border=0><tr><td><A HREF="/kunden/smarty/demo/index.php"><font color="red">This is a test </font></A></td></tr></table>
|
||||
|
||||
</PRE>
|
||||
|
||||
This is an example of the html_select_date function:
|
||||
|
||||
<form>
|
||||
<select name="Date_Month">
|
||||
<option value="01">January</option>
|
||||
<option value="02">February</option>
|
||||
<option value="03">March</option>
|
||||
<option value="04">April</option>
|
||||
<option value="05">May</option>
|
||||
<option value="06">June</option>
|
||||
<option value="07">July</option>
|
||||
<option value="08">August</option>
|
||||
<option value="09">September</option>
|
||||
<option value="10">October</option>
|
||||
<option value="11">November</option>
|
||||
<option value="12" selected="selected">December</option>
|
||||
</select>
|
||||
<select name="Date_Day">
|
||||
<option value="1">01</option>
|
||||
<option value="2">02</option>
|
||||
<option value="3">03</option>
|
||||
<option value="4">04</option>
|
||||
<option value="5">05</option>
|
||||
<option value="6" selected="selected">06</option>
|
||||
<option value="7">07</option>
|
||||
<option value="8">08</option>
|
||||
<option value="9">09</option>
|
||||
<option value="10">10</option>
|
||||
<option value="11">11</option>
|
||||
<option value="12">12</option>
|
||||
<option value="13">13</option>
|
||||
<option value="14">14</option>
|
||||
<option value="15">15</option>
|
||||
<option value="16">16</option>
|
||||
<option value="17">17</option>
|
||||
<option value="18">18</option>
|
||||
<option value="19">19</option>
|
||||
<option value="20">20</option>
|
||||
<option value="21">21</option>
|
||||
<option value="22">22</option>
|
||||
<option value="23">23</option>
|
||||
<option value="24">24</option>
|
||||
<option value="25">25</option>
|
||||
<option value="26">26</option>
|
||||
<option value="27">27</option>
|
||||
<option value="28">28</option>
|
||||
<option value="29">29</option>
|
||||
<option value="30">30</option>
|
||||
<option value="31">31</option>
|
||||
</select>
|
||||
<select name="Date_Year">
|
||||
<option value="1998">1998</option>
|
||||
<option value="1999">1999</option>
|
||||
<option value="2000">2000</option>
|
||||
<option value="2001">2001</option>
|
||||
<option value="2002">2002</option>
|
||||
<option value="2003">2003</option>
|
||||
<option value="2004">2004</option>
|
||||
<option value="2005">2005</option>
|
||||
<option value="2006">2006</option>
|
||||
<option value="2007">2007</option>
|
||||
<option value="2008">2008</option>
|
||||
<option value="2009">2009</option>
|
||||
<option value="2010">2010</option>
|
||||
</select>
|
||||
</form>
|
||||
|
||||
This is an example of the html_select_time function:
|
||||
|
||||
<form>
|
||||
<select name="Time_Hour">
|
||||
<option value="01">01</option>
|
||||
<option value="02">02</option>
|
||||
<option value="03">03</option>
|
||||
<option value="04">04</option>
|
||||
<option value="05">05</option>
|
||||
<option value="06">06</option>
|
||||
<option value="07">07</option>
|
||||
<option value="08">08</option>
|
||||
<option value="09">09</option>
|
||||
<option value="10" selected="selected">10</option>
|
||||
<option value="11">11</option>
|
||||
<option value="12">12</option>
|
||||
</select>
|
||||
<select name="Time_Minute">
|
||||
<option value="00">00</option>
|
||||
<option value="01">01</option>
|
||||
<option value="02">02</option>
|
||||
<option value="03">03</option>
|
||||
<option value="04">04</option>
|
||||
<option value="05">05</option>
|
||||
<option value="06">06</option>
|
||||
<option value="07">07</option>
|
||||
<option value="08">08</option>
|
||||
<option value="09">09</option>
|
||||
<option value="10">10</option>
|
||||
<option value="11">11</option>
|
||||
<option value="12">12</option>
|
||||
<option value="13">13</option>
|
||||
<option value="14">14</option>
|
||||
<option value="15">15</option>
|
||||
<option value="16">16</option>
|
||||
<option value="17">17</option>
|
||||
<option value="18">18</option>
|
||||
<option value="19">19</option>
|
||||
<option value="20">20</option>
|
||||
<option value="21">21</option>
|
||||
<option value="22">22</option>
|
||||
<option value="23">23</option>
|
||||
<option value="24">24</option>
|
||||
<option value="25">25</option>
|
||||
<option value="26">26</option>
|
||||
<option value="27">27</option>
|
||||
<option value="28">28</option>
|
||||
<option value="29">29</option>
|
||||
<option value="30">30</option>
|
||||
<option value="31">31</option>
|
||||
<option value="32">32</option>
|
||||
<option value="33">33</option>
|
||||
<option value="34">34</option>
|
||||
<option value="35">35</option>
|
||||
<option value="36">36</option>
|
||||
<option value="37">37</option>
|
||||
<option value="38">38</option>
|
||||
<option value="39">39</option>
|
||||
<option value="40">40</option>
|
||||
<option value="41">41</option>
|
||||
<option value="42">42</option>
|
||||
<option value="43">43</option>
|
||||
<option value="44">44</option>
|
||||
<option value="45">45</option>
|
||||
<option value="46">46</option>
|
||||
<option value="47">47</option>
|
||||
<option value="48" selected="selected">48</option>
|
||||
<option value="49">49</option>
|
||||
<option value="50">50</option>
|
||||
<option value="51">51</option>
|
||||
<option value="52">52</option>
|
||||
<option value="53">53</option>
|
||||
<option value="54">54</option>
|
||||
<option value="55">55</option>
|
||||
<option value="56">56</option>
|
||||
<option value="57">57</option>
|
||||
<option value="58">58</option>
|
||||
<option value="59">59</option>
|
||||
</select>
|
||||
<select name="Time_Second">
|
||||
<option value="00">00</option>
|
||||
<option value="01">01</option>
|
||||
<option value="02">02</option>
|
||||
<option value="03">03</option>
|
||||
<option value="04">04</option>
|
||||
<option value="05">05</option>
|
||||
<option value="06">06</option>
|
||||
<option value="07">07</option>
|
||||
<option value="08">08</option>
|
||||
<option value="09">09</option>
|
||||
<option value="10">10</option>
|
||||
<option value="11">11</option>
|
||||
<option value="12">12</option>
|
||||
<option value="13">13</option>
|
||||
<option value="14">14</option>
|
||||
<option value="15">15</option>
|
||||
<option value="16">16</option>
|
||||
<option value="17">17</option>
|
||||
<option value="18">18</option>
|
||||
<option value="19">19</option>
|
||||
<option value="20">20</option>
|
||||
<option value="21">21</option>
|
||||
<option value="22">22</option>
|
||||
<option value="23">23</option>
|
||||
<option value="24">24</option>
|
||||
<option value="25">25</option>
|
||||
<option value="26">26</option>
|
||||
<option value="27">27</option>
|
||||
<option value="28">28</option>
|
||||
<option value="29">29</option>
|
||||
<option value="30">30</option>
|
||||
<option value="31">31</option>
|
||||
<option value="32">32</option>
|
||||
<option value="33">33</option>
|
||||
<option value="34">34</option>
|
||||
<option value="35">35</option>
|
||||
<option value="36">36</option>
|
||||
<option value="37">37</option>
|
||||
<option value="38">38</option>
|
||||
<option value="39">39</option>
|
||||
<option value="40">40</option>
|
||||
<option value="41">41</option>
|
||||
<option value="42">42</option>
|
||||
<option value="43">43</option>
|
||||
<option value="44">44</option>
|
||||
<option value="45">45</option>
|
||||
<option value="46">46</option>
|
||||
<option value="47">47</option>
|
||||
<option value="48" selected="selected">48</option>
|
||||
<option value="49">49</option>
|
||||
<option value="50">50</option>
|
||||
<option value="51">51</option>
|
||||
<option value="52">52</option>
|
||||
<option value="53">53</option>
|
||||
<option value="54">54</option>
|
||||
<option value="55">55</option>
|
||||
<option value="56">56</option>
|
||||
<option value="57">57</option>
|
||||
<option value="58">58</option>
|
||||
<option value="59">59</option>
|
||||
</select>
|
||||
<select name="Time_Meridian">
|
||||
<option value="am">AM</option>
|
||||
<option value="pm" selected="selected">PM</option>
|
||||
</select>
|
||||
</form>
|
||||
|
||||
This is an example of the html_options function:
|
||||
|
||||
<form>
|
||||
<select name=states>
|
||||
<option value="NY">New York</option>
|
||||
<option value="NE" selected="selected">Nebraska</option>
|
||||
<option value="KS">Kansas</option>
|
||||
<option value="IA">Iowa</option>
|
||||
<option value="OK">Oklahoma</option>
|
||||
<option value="TX">Texas</option>
|
||||
|
||||
</select>
|
||||
</form>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
|
||||
<?php }} ?>
|
||||
@@ -0,0 +1,5 @@
|
||||
title = Welcome to Smarty!
|
||||
cutoff_size = 40
|
||||
|
||||
[setup]
|
||||
bold = true
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* Example Application
|
||||
|
||||
* @package Example-application
|
||||
*/
|
||||
|
||||
require('../libs/Smarty.class.php');
|
||||
|
||||
$smarty = new Smarty;
|
||||
|
||||
|
||||
|
||||
//$smarty->force_compile = true;
|
||||
$smarty->debugging = true;
|
||||
$smarty->caching = true;
|
||||
$smarty->cache_lifetime = 120;
|
||||
|
||||
$smarty->assign("Name","Fred Irving Johnathan Bradley Peppergill",true);
|
||||
$smarty->assign("FirstName",array("John","Mary","James","Henry"));
|
||||
$smarty->assign("LastName",array("Doe","Smith","Johnson","Case"));
|
||||
$smarty->assign("Class",array(array("A","B","C","D"), array("E", "F", "G", "H"),
|
||||
array("I", "J", "K", "L"), array("M", "N", "O", "P")));
|
||||
|
||||
$smarty->assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"),
|
||||
array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234")));
|
||||
|
||||
$smarty->assign("option_values", array("NY","NE","KS","IA","OK","TX"));
|
||||
$smarty->assign("option_output", array("New York","Nebraska","Kansas","Iowa","Oklahoma","Texas"));
|
||||
$smarty->assign("option_selected", "NE");
|
||||
|
||||
$smarty->display('index.tpl');
|
||||
?>
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* APC CacheResource
|
||||
*
|
||||
* CacheResource Implementation based on the KeyValueStore API to use
|
||||
* memcache as the storage resource for Smarty's output caching.
|
||||
* *
|
||||
* @package CacheResource-examples
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
// test if APC is present
|
||||
if(!function_exists('apc_cache_info')) {
|
||||
throw new Exception('APC Template Caching Error: APC is not installed');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read values for a set of keys from cache
|
||||
*
|
||||
* @param array $keys list of keys to fetch
|
||||
* @return array list of values with the given keys used as indexes
|
||||
* @return boolean true on success, false on failure
|
||||
*/
|
||||
protected function read(array $keys)
|
||||
{
|
||||
$_res = array();
|
||||
$res = apc_fetch($keys);
|
||||
foreach ($res as $k => $v) {
|
||||
$_res[$k] = $v;
|
||||
}
|
||||
return $_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save values for a set of keys to cache
|
||||
*
|
||||
* @param array $keys list of values to save
|
||||
* @param int $expire expiration time
|
||||
* @return boolean true on success, false on failure
|
||||
*/
|
||||
protected function write(array $keys, $expire=null)
|
||||
{
|
||||
foreach ($keys as $k => $v) {
|
||||
apc_store($k, $v, $expire);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove values from cache
|
||||
*
|
||||
* @param array $keys list of keys to delete
|
||||
* @return boolean true on success, false on failure
|
||||
*/
|
||||
protected function delete(array $keys)
|
||||
{
|
||||
foreach ($keys as $k) {
|
||||
apc_delete($k);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove *all* values from cache
|
||||
*
|
||||
* @return boolean true on success, false on failure
|
||||
*/
|
||||
protected function purge()
|
||||
{
|
||||
return apc_clear_cache('user');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Memcache CacheResource
|
||||
*
|
||||
* CacheResource Implementation based on the KeyValueStore API to use
|
||||
* memcache as the storage resource for Smarty's output caching.
|
||||
*
|
||||
* Note that memcache has a limitation of 256 characters per cache-key.
|
||||
* To avoid complications all cache-keys are translated to a sha1 hash.
|
||||
*
|
||||
* @package CacheResource-examples
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore {
|
||||
/**
|
||||
* memcache instance
|
||||
* @var Memcache
|
||||
*/
|
||||
protected $memcache = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->memcache = new Memcache();
|
||||
$this->memcache->addServer( '127.0.0.1', 11211 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Read values for a set of keys from cache
|
||||
*
|
||||
* @param array $keys list of keys to fetch
|
||||
* @return array list of values with the given keys used as indexes
|
||||
* @return boolean true on success, false on failure
|
||||
*/
|
||||
protected function read(array $keys)
|
||||
{
|
||||
$_keys = $lookup = array();
|
||||
foreach ($keys as $k) {
|
||||
$_k = sha1($k);
|
||||
$_keys[] = $_k;
|
||||
$lookup[$_k] = $k;
|
||||
}
|
||||
$_res = array();
|
||||
$res = $this->memcache->get($_keys);
|
||||
foreach ($res as $k => $v) {
|
||||
$_res[$lookup[$k]] = $v;
|
||||
}
|
||||
return $_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save values for a set of keys to cache
|
||||
*
|
||||
* @param array $keys list of values to save
|
||||
* @param int $expire expiration time
|
||||
* @return boolean true on success, false on failure
|
||||
*/
|
||||
protected function write(array $keys, $expire=null)
|
||||
{
|
||||
foreach ($keys as $k => $v) {
|
||||
$k = sha1($k);
|
||||
$this->memcache->set($k, $v, 0, $expire);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove values from cache
|
||||
*
|
||||
* @param array $keys list of keys to delete
|
||||
* @return boolean true on success, false on failure
|
||||
*/
|
||||
protected function delete(array $keys)
|
||||
{
|
||||
foreach ($keys as $k) {
|
||||
$k = sha1($k);
|
||||
$this->memcache->delete($k);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove *all* values from cache
|
||||
*
|
||||
* @return boolean true on success, false on failure
|
||||
*/
|
||||
protected function purge()
|
||||
{
|
||||
return $this->memcache->flush();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* MySQL CacheResource
|
||||
*
|
||||
* CacheResource Implementation based on the Custom API to use
|
||||
* MySQL as the storage resource for Smarty's output caching.
|
||||
*
|
||||
* Table definition:
|
||||
* <pre>CREATE TABLE IF NOT EXISTS `output_cache` (
|
||||
* `id` CHAR(40) NOT NULL COMMENT 'sha1 hash',
|
||||
* `name` VARCHAR(250) NOT NULL,
|
||||
* `cache_id` VARCHAR(250) NULL DEFAULT NULL,
|
||||
* `compile_id` VARCHAR(250) NULL DEFAULT NULL,
|
||||
* `modified` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
* `content` LONGTEXT NOT NULL,
|
||||
* PRIMARY KEY (`id`),
|
||||
* INDEX(`name`),
|
||||
* INDEX(`cache_id`),
|
||||
* INDEX(`compile_id`),
|
||||
* INDEX(`modified`)
|
||||
* ) ENGINE = InnoDB;</pre>
|
||||
*
|
||||
* @package CacheResource-examples
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom {
|
||||
// PDO instance
|
||||
protected $db;
|
||||
protected $fetch;
|
||||
protected $fetchTimestamp;
|
||||
protected $save;
|
||||
|
||||
public function __construct() {
|
||||
try {
|
||||
$this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty", "smarty");
|
||||
} catch (PDOException $e) {
|
||||
throw new SmartyException('Mysql Resource failed: ' . $e->getMessage());
|
||||
}
|
||||
$this->fetch = $this->db->prepare('SELECT modified, content FROM output_cache WHERE id = :id');
|
||||
$this->fetchTimestamp = $this->db->prepare('SELECT modified FROM output_cache WHERE id = :id');
|
||||
$this->save = $this->db->prepare('REPLACE INTO output_cache (id, name, cache_id, compile_id, content)
|
||||
VALUES (:id, :name, :cache_id, :compile_id, :content)');
|
||||
}
|
||||
|
||||
/**
|
||||
* fetch cached content and its modification time from data source
|
||||
*
|
||||
* @param string $id unique cache content identifier
|
||||
* @param string $name template name
|
||||
* @param string $cache_id cache id
|
||||
* @param string $compile_id compile id
|
||||
* @param string $content cached content
|
||||
* @param integer $mtime cache modification timestamp (epoch)
|
||||
* @return void
|
||||
*/
|
||||
protected function fetch($id, $name, $cache_id, $compile_id, &$content, &$mtime)
|
||||
{
|
||||
$this->fetch->execute(array('id' => $id));
|
||||
$row = $this->fetch->fetch();
|
||||
$this->fetch->closeCursor();
|
||||
if ($row) {
|
||||
$content = $row['content'];
|
||||
$mtime = strtotime($row['modified']);
|
||||
} else {
|
||||
$content = null;
|
||||
$mtime = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch cached content's modification timestamp from data source
|
||||
*
|
||||
* @note implementing this method is optional. Only implement it if modification times can be accessed faster than loading the complete cached content.
|
||||
* @param string $id unique cache content identifier
|
||||
* @param string $name template name
|
||||
* @param string $cache_id cache id
|
||||
* @param string $compile_id compile id
|
||||
* @return integer|boolean timestamp (epoch) the template was modified, or false if not found
|
||||
*/
|
||||
protected function fetchTimestamp($id, $name, $cache_id, $compile_id)
|
||||
{
|
||||
$this->fetchTimestamp->execute(array('id' => $id));
|
||||
$mtime = strtotime($this->fetchTimestamp->fetchColumn());
|
||||
$this->fetchTimestamp->closeCursor();
|
||||
return $mtime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save content to cache
|
||||
*
|
||||
* @param string $id unique cache content identifier
|
||||
* @param string $name template name
|
||||
* @param string $cache_id cache id
|
||||
* @param string $compile_id compile id
|
||||
* @param integer|null $exp_time seconds till expiration time in seconds or null
|
||||
* @param string $content content to cache
|
||||
* @return boolean success
|
||||
*/
|
||||
protected function save($id, $name, $cache_id, $compile_id, $exp_time, $content)
|
||||
{
|
||||
$this->save->execute(array(
|
||||
'id' => $id,
|
||||
'name' => $name,
|
||||
'cache_id' => $cache_id,
|
||||
'compile_id' => $compile_id,
|
||||
'content' => $content,
|
||||
));
|
||||
return !!$this->save->rowCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete content from cache
|
||||
*
|
||||
* @param string $name template name
|
||||
* @param string $cache_id cache id
|
||||
* @param string $compile_id compile id
|
||||
* @param integer|null $exp_time seconds till expiration or null
|
||||
* @return integer number of deleted caches
|
||||
*/
|
||||
protected function delete($name, $cache_id, $compile_id, $exp_time)
|
||||
{
|
||||
// delete the whole cache
|
||||
if ($name === null && $cache_id === null && $compile_id === null && $exp_time === null) {
|
||||
// returning the number of deleted caches would require a second query to count them
|
||||
$query = $this->db->query('TRUNCATE TABLE output_cache');
|
||||
return -1;
|
||||
}
|
||||
// build the filter
|
||||
$where = array();
|
||||
// equal test name
|
||||
if ($name !== null) {
|
||||
$where[] = 'name = ' . $this->db->quote($name);
|
||||
}
|
||||
// equal test compile_id
|
||||
if ($compile_id !== null) {
|
||||
$where[] = 'compile_id = ' . $this->db->quote($compile_id);
|
||||
}
|
||||
// range test expiration time
|
||||
if ($exp_time !== null) {
|
||||
$where[] = 'modified < DATE_SUB(NOW(), INTERVAL ' . intval($exp_time) . ' SECOND)';
|
||||
}
|
||||
// equal test cache_id and match sub-groups
|
||||
if ($cache_id !== null) {
|
||||
$where[] = '(cache_id = '. $this->db->quote($cache_id)
|
||||
. ' OR cache_id LIKE '. $this->db->quote($cache_id .'|%') .')';
|
||||
}
|
||||
// run delete query
|
||||
$query = $this->db->query('DELETE FROM output_cache WHERE ' . join(' AND ', $where));
|
||||
return $query->rowCount();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Extends All Resource
|
||||
*
|
||||
* Resource Implementation modifying the extends-Resource to walk
|
||||
* through the template_dirs and inherit all templates of the same name
|
||||
*
|
||||
* @package Resource-examples
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
class Smarty_Resource_Extendsall extends Smarty_Internal_Resource_Extends {
|
||||
|
||||
/**
|
||||
* populate Source Object with meta data from Resource
|
||||
*
|
||||
* @param Smarty_Template_Source $source source object
|
||||
* @param Smarty_Internal_Template $_template template object
|
||||
* @return void
|
||||
*/
|
||||
public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template=null)
|
||||
{
|
||||
$uid = '';
|
||||
$sources = array();
|
||||
$exists = true;
|
||||
foreach ($_template->smarty->getTemplateDir() as $key => $directory) {
|
||||
try {
|
||||
$s = Smarty_Resource::source(null, $source->smarty, '[' . $key . ']' . $source->name );
|
||||
if (!$s->exists) {
|
||||
continue;
|
||||
}
|
||||
$sources[$s->uid] = $s;
|
||||
$uid .= $s->filepath;
|
||||
}
|
||||
catch (SmartyException $e) {}
|
||||
}
|
||||
|
||||
if (!$sources) {
|
||||
$source->exists = false;
|
||||
$source->template = $_template;
|
||||
return;
|
||||
}
|
||||
|
||||
$sources = array_reverse($sources, true);
|
||||
reset($sources);
|
||||
$s = current($sources);
|
||||
|
||||
$source->components = $sources;
|
||||
$source->filepath = $s->filepath;
|
||||
$source->uid = sha1($uid);
|
||||
$source->exists = $exists;
|
||||
if ($_template && $_template->smarty->compile_check) {
|
||||
$source->timestamp = $s->timestamp;
|
||||
}
|
||||
// need the template at getContent()
|
||||
$source->template = $_template;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* MySQL Resource
|
||||
*
|
||||
* Resource Implementation based on the Custom API to use
|
||||
* MySQL as the storage resource for Smarty's templates and configs.
|
||||
*
|
||||
* Table definition:
|
||||
* <pre>CREATE TABLE IF NOT EXISTS `templates` (
|
||||
* `name` varchar(100) NOT NULL,
|
||||
* `modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
* `source` text,
|
||||
* PRIMARY KEY (`name`)
|
||||
* ) ENGINE=InnoDB DEFAULT CHARSET=utf8;</pre>
|
||||
*
|
||||
* Demo data:
|
||||
* <pre>INSERT INTO `templates` (`name`, `modified`, `source`) VALUES ('test.tpl', "2010-12-25 22:00:00", '{$x="hello world"}{$x}');</pre>
|
||||
*
|
||||
* @package Resource-examples
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
class Smarty_Resource_Mysql extends Smarty_Resource_Custom {
|
||||
// PDO instance
|
||||
protected $db;
|
||||
// prepared fetch() statement
|
||||
protected $fetch;
|
||||
// prepared fetchTimestamp() statement
|
||||
protected $mtime;
|
||||
|
||||
public function __construct() {
|
||||
try {
|
||||
$this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty", "smarty");
|
||||
} catch (PDOException $e) {
|
||||
throw new SmartyException('Mysql Resource failed: ' . $e->getMessage());
|
||||
}
|
||||
$this->fetch = $this->db->prepare('SELECT modified, source FROM templates WHERE name = :name');
|
||||
$this->mtime = $this->db->prepare('SELECT modified FROM templates WHERE name = :name');
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a template and its modification time from database
|
||||
*
|
||||
* @param string $name template name
|
||||
* @param string $source template source
|
||||
* @param integer $mtime template modification timestamp (epoch)
|
||||
* @return void
|
||||
*/
|
||||
protected function fetch($name, &$source, &$mtime)
|
||||
{
|
||||
$this->fetch->execute(array('name' => $name));
|
||||
$row = $this->fetch->fetch();
|
||||
$this->fetch->closeCursor();
|
||||
if ($row) {
|
||||
$source = $row['source'];
|
||||
$mtime = strtotime($row['modified']);
|
||||
} else {
|
||||
$source = null;
|
||||
$mtime = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a template's modification time from database
|
||||
*
|
||||
* @note implementing this method is optional. Only implement it if modification times can be accessed faster than loading the comple template source.
|
||||
* @param string $name template name
|
||||
* @return integer timestamp (epoch) the template was modified
|
||||
*/
|
||||
protected function fetchTimestamp($name) {
|
||||
$this->mtime->execute(array('name' => $name));
|
||||
$mtime = $this->mtime->fetchColumn();
|
||||
$this->mtime->closeCursor();
|
||||
return strtotime($mtime);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* MySQL Resource
|
||||
*
|
||||
* Resource Implementation based on the Custom API to use
|
||||
* MySQL as the storage resource for Smarty's templates and configs.
|
||||
*
|
||||
* Note that this MySQL implementation fetches the source and timestamps in
|
||||
* a single database query, instead of two seperate like resource.mysql.php does.
|
||||
*
|
||||
* Table definition:
|
||||
* <pre>CREATE TABLE IF NOT EXISTS `templates` (
|
||||
* `name` varchar(100) NOT NULL,
|
||||
* `modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
* `source` text,
|
||||
* PRIMARY KEY (`name`)
|
||||
* ) ENGINE=InnoDB DEFAULT CHARSET=utf8;</pre>
|
||||
*
|
||||
* Demo data:
|
||||
* <pre>INSERT INTO `templates` (`name`, `modified`, `source`) VALUES ('test.tpl', "2010-12-25 22:00:00", '{$x="hello world"}{$x}');</pre>
|
||||
*
|
||||
* @package Resource-examples
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
class Smarty_Resource_Mysqls extends Smarty_Resource_Custom {
|
||||
// PDO instance
|
||||
protected $db;
|
||||
// prepared fetch() statement
|
||||
protected $fetch;
|
||||
|
||||
public function __construct() {
|
||||
try {
|
||||
$this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty", "smarty");
|
||||
} catch (PDOException $e) {
|
||||
throw new SmartyException('Mysql Resource failed: ' . $e->getMessage());
|
||||
}
|
||||
$this->fetch = $this->db->prepare('SELECT modified, source FROM templates WHERE name = :name');
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a template and its modification time from database
|
||||
*
|
||||
* @param string $name template name
|
||||
* @param string $source template source
|
||||
* @param integer $mtime template modification timestamp (epoch)
|
||||
* @return void
|
||||
*/
|
||||
protected function fetch($name, &$source, &$mtime)
|
||||
{
|
||||
$this->fetch->execute(array('name' => $name));
|
||||
$row = $this->fetch->fetch();
|
||||
$this->fetch->closeCursor();
|
||||
if ($row) {
|
||||
$source = $row['source'];
|
||||
$mtime = strtotime($row['modified']);
|
||||
} else {
|
||||
$source = null;
|
||||
$mtime = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -0,0 +1,5 @@
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>{$title} - {$Name}</TITLE>
|
||||
</HEAD>
|
||||
<BODY bgcolor="#ffffff">
|
||||
@@ -0,0 +1,82 @@
|
||||
{config_load file="test.conf" section="setup"}
|
||||
{include file="header.tpl" title=foo}
|
||||
|
||||
<PRE>
|
||||
|
||||
{* bold and title are read from the config file *}
|
||||
{if #bold#}<b>{/if}
|
||||
{* capitalize the first letters of each word of the title *}
|
||||
Title: {#title#|capitalize}
|
||||
{if #bold#}</b>{/if}
|
||||
|
||||
The current date and time is {$smarty.now|date_format:"%Y-%m-%d %H:%M:%S"}
|
||||
|
||||
The value of global assigned variable $SCRIPT_NAME is {$SCRIPT_NAME}
|
||||
|
||||
Example of accessing server environment variable SERVER_NAME: {$smarty.server.SERVER_NAME}
|
||||
|
||||
The value of {ldelim}$Name{rdelim} is <b>{$Name}</b>
|
||||
|
||||
variable modifier example of {ldelim}$Name|upper{rdelim}
|
||||
|
||||
<b>{$Name|upper}</b>
|
||||
|
||||
|
||||
An example of a section loop:
|
||||
|
||||
{section name=outer
|
||||
loop=$FirstName}
|
||||
{if $smarty.section.outer.index is odd by 2}
|
||||
{$smarty.section.outer.rownum} . {$FirstName[outer]} {$LastName[outer]}
|
||||
{else}
|
||||
{$smarty.section.outer.rownum} * {$FirstName[outer]} {$LastName[outer]}
|
||||
{/if}
|
||||
{sectionelse}
|
||||
none
|
||||
{/section}
|
||||
|
||||
An example of section looped key values:
|
||||
|
||||
{section name=sec1 loop=$contacts}
|
||||
phone: {$contacts[sec1].phone}<br>
|
||||
fax: {$contacts[sec1].fax}<br>
|
||||
cell: {$contacts[sec1].cell}<br>
|
||||
{/section}
|
||||
<p>
|
||||
|
||||
testing strip tags
|
||||
{strip}
|
||||
<table border=0>
|
||||
<tr>
|
||||
<td>
|
||||
<A HREF="{$SCRIPT_NAME}">
|
||||
<font color="red">This is a test </font>
|
||||
</A>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
{/strip}
|
||||
|
||||
</PRE>
|
||||
|
||||
This is an example of the html_select_date function:
|
||||
|
||||
<form>
|
||||
{html_select_date start_year=1998 end_year=2010}
|
||||
</form>
|
||||
|
||||
This is an example of the html_select_time function:
|
||||
|
||||
<form>
|
||||
{html_select_time use_24_hours=false}
|
||||
</form>
|
||||
|
||||
This is an example of the html_options function:
|
||||
|
||||
<form>
|
||||
<select name=states>
|
||||
{html_options values=$option_values selected=$option_selected output=$option_output}
|
||||
</select>
|
||||
</form>
|
||||
|
||||
{include file="footer.tpl"}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<?php $_config_vars = array (
|
||||
'sections' =>
|
||||
array (
|
||||
'setup' =>
|
||||
array (
|
||||
'vars' =>
|
||||
array (
|
||||
'bold' => true,
|
||||
),
|
||||
),
|
||||
),
|
||||
'vars' =>
|
||||
array (
|
||||
'title' => 'Welcome to Smarty!',
|
||||
'cutoff_size' => 40,
|
||||
),
|
||||
); ?>
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
<?php /* Smarty version Smarty-3.1.6, created on 2011-12-06 22:48:48
|
||||
compiled from "./templates/footer.tpl" */ ?>
|
||||
<?php /*%%SmartyHeaderCode:9463925564ede8dc0ab4d69-42836539%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
|
||||
$_valid = $_smarty_tpl->decodeProperties(array (
|
||||
'file_dependency' =>
|
||||
array (
|
||||
'3a4f6f0d327fc7bc3ea86f63906a1bf934ca50c7' =>
|
||||
array (
|
||||
0 => './templates/footer.tpl',
|
||||
1 => 1323208095,
|
||||
2 => 'file',
|
||||
),
|
||||
),
|
||||
'nocache_hash' => '9463925564ede8dc0ab4d69-42836539',
|
||||
'function' =>
|
||||
array (
|
||||
),
|
||||
'has_nocache_code' => false,
|
||||
'version' => 'Smarty-3.1.6',
|
||||
'unifunc' => 'content_4ede8dc0ab8fc',
|
||||
),false); /*/%%SmartyHeaderCode%%*/?>
|
||||
<?php if ($_valid && !is_callable('content_4ede8dc0ab8fc')) {function content_4ede8dc0ab8fc($_smarty_tpl) {?></BODY>
|
||||
</HTML>
|
||||
<?php }} ?>
|
||||
@@ -0,0 +1,201 @@
|
||||
<?php /* Smarty version Smarty-3.1.6, created on 2011-12-06 22:48:48
|
||||
compiled from "/Users/m0/Documents/workspace/Kunden/smarty/libs/debug.tpl" */ ?>
|
||||
<?php /*%%SmartyHeaderCode:20718490644ede8dc0ac6826-45661612%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
|
||||
$_valid = $_smarty_tpl->decodeProperties(array (
|
||||
'file_dependency' =>
|
||||
array (
|
||||
'52fa74a3223ba70ba76870b810dcc7344bf6988e' =>
|
||||
array (
|
||||
0 => '/Users/m0/Documents/workspace/Kunden/smarty/libs/debug.tpl',
|
||||
1 => 1323208095,
|
||||
2 => 'file',
|
||||
),
|
||||
),
|
||||
'nocache_hash' => '20718490644ede8dc0ac6826-45661612',
|
||||
'function' =>
|
||||
array (
|
||||
),
|
||||
'variables' =>
|
||||
array (
|
||||
'template_name' => 0,
|
||||
'execution_time' => 0,
|
||||
'template_data' => 0,
|
||||
'template' => 0,
|
||||
'assigned_vars' => 0,
|
||||
'vars' => 0,
|
||||
'config_vars' => 0,
|
||||
'id' => 0,
|
||||
'debug_output' => 0,
|
||||
),
|
||||
'has_nocache_code' => false,
|
||||
'version' => 'Smarty-3.1.6',
|
||||
'unifunc' => 'content_4ede8dc0c1d9c',
|
||||
),false); /*/%%SmartyHeaderCode%%*/?>
|
||||
<?php if ($_valid && !is_callable('content_4ede8dc0c1d9c')) {function content_4ede8dc0c1d9c($_smarty_tpl) {?><?php if (!is_callable('smarty_modifier_debug_print_var')) include '/Users/m0/Documents/workspace/Kunden/smarty/libs/plugins/modifier.debug_print_var.php';
|
||||
?><?php $_smarty_tpl->_capture_stack[] = array('_smarty_debug', 'debug_output', null); ob_start(); ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<head>
|
||||
<title>Smarty Debug Console</title>
|
||||
<style type="text/css">
|
||||
|
||||
body, h1, h2, td, th, p {
|
||||
font-family: sans-serif;
|
||||
font-weight: normal;
|
||||
font-size: 0.9em;
|
||||
margin: 1px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
text-align: left;
|
||||
padding: 2px;
|
||||
background-color: #f0c040;
|
||||
color: black;
|
||||
font-weight: bold;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
h2 {
|
||||
background-color: #9B410E;
|
||||
color: white;
|
||||
text-align: left;
|
||||
font-weight: bold;
|
||||
padding: 2px;
|
||||
border-top: 1px solid black;
|
||||
}
|
||||
|
||||
body {
|
||||
background: black;
|
||||
}
|
||||
|
||||
p, table, div {
|
||||
background: #f0ead8;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
font-style: italic;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
th, td {
|
||||
font-family: monospace;
|
||||
vertical-align: top;
|
||||
text-align: left;
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
td {
|
||||
color: green;
|
||||
}
|
||||
|
||||
.odd {
|
||||
background-color: #eeeeee;
|
||||
}
|
||||
|
||||
.even {
|
||||
background-color: #fafafa;
|
||||
}
|
||||
|
||||
.exectime {
|
||||
font-size: 0.8em;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
#table_assigned_vars th {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
#table_config_vars th {
|
||||
color: maroon;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>Smarty Debug Console - <?php if (isset($_smarty_tpl->tpl_vars['template_name']->value)){?><?php echo smarty_modifier_debug_print_var($_smarty_tpl->tpl_vars['template_name']->value);?>
|
||||
<?php }else{ ?>Total Time <?php echo sprintf("%.5f",$_smarty_tpl->tpl_vars['execution_time']->value);?>
|
||||
<?php }?></h1>
|
||||
|
||||
<?php if (!empty($_smarty_tpl->tpl_vars['template_data']->value)){?>
|
||||
<h2>included templates & config files (load time in seconds)</h2>
|
||||
|
||||
<div>
|
||||
<?php $_smarty_tpl->tpl_vars['template'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['template']->_loop = false;
|
||||
$_from = $_smarty_tpl->tpl_vars['template_data']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
|
||||
foreach ($_from as $_smarty_tpl->tpl_vars['template']->key => $_smarty_tpl->tpl_vars['template']->value){
|
||||
$_smarty_tpl->tpl_vars['template']->_loop = true;
|
||||
?>
|
||||
<font color=brown><?php echo $_smarty_tpl->tpl_vars['template']->value['name'];?>
|
||||
</font>
|
||||
<span class="exectime">
|
||||
(compile <?php echo sprintf("%.5f",$_smarty_tpl->tpl_vars['template']->value['compile_time']);?>
|
||||
) (render <?php echo sprintf("%.5f",$_smarty_tpl->tpl_vars['template']->value['render_time']);?>
|
||||
) (cache <?php echo sprintf("%.5f",$_smarty_tpl->tpl_vars['template']->value['cache_time']);?>
|
||||
)
|
||||
</span>
|
||||
<br>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php }?>
|
||||
|
||||
<h2>assigned template variables</h2>
|
||||
|
||||
<table id="table_assigned_vars">
|
||||
<?php $_smarty_tpl->tpl_vars['vars'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['vars']->_loop = false;
|
||||
$_from = $_smarty_tpl->tpl_vars['assigned_vars']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
|
||||
$_smarty_tpl->tpl_vars['vars']->iteration=0;
|
||||
foreach ($_from as $_smarty_tpl->tpl_vars['vars']->key => $_smarty_tpl->tpl_vars['vars']->value){
|
||||
$_smarty_tpl->tpl_vars['vars']->_loop = true;
|
||||
$_smarty_tpl->tpl_vars['vars']->iteration++;
|
||||
?>
|
||||
<tr class="<?php if ($_smarty_tpl->tpl_vars['vars']->iteration%2==0){?>odd<?php }else{ ?>even<?php }?>">
|
||||
<th>$<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['vars']->key, ENT_QUOTES, 'UTF-8', true);?>
|
||||
</th>
|
||||
<td><?php echo smarty_modifier_debug_print_var($_smarty_tpl->tpl_vars['vars']->value);?>
|
||||
</td></tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
|
||||
<h2>assigned config file variables (outer template scope)</h2>
|
||||
|
||||
<table id="table_config_vars">
|
||||
<?php $_smarty_tpl->tpl_vars['vars'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['vars']->_loop = false;
|
||||
$_from = $_smarty_tpl->tpl_vars['config_vars']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
|
||||
$_smarty_tpl->tpl_vars['vars']->iteration=0;
|
||||
foreach ($_from as $_smarty_tpl->tpl_vars['vars']->key => $_smarty_tpl->tpl_vars['vars']->value){
|
||||
$_smarty_tpl->tpl_vars['vars']->_loop = true;
|
||||
$_smarty_tpl->tpl_vars['vars']->iteration++;
|
||||
?>
|
||||
<tr class="<?php if ($_smarty_tpl->tpl_vars['vars']->iteration%2==0){?>odd<?php }else{ ?>even<?php }?>">
|
||||
<th><?php echo htmlspecialchars($_smarty_tpl->tpl_vars['vars']->key, ENT_QUOTES, 'UTF-8', true);?>
|
||||
</th>
|
||||
<td><?php echo smarty_modifier_debug_print_var($_smarty_tpl->tpl_vars['vars']->value);?>
|
||||
</td></tr>
|
||||
<?php } ?>
|
||||
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
<?php list($_capture_buffer, $_capture_assign, $_capture_append) = array_pop($_smarty_tpl->_capture_stack);
|
||||
if (!empty($_capture_buffer)) {
|
||||
if (isset($_capture_assign)) $_smarty_tpl->assign($_capture_assign, ob_get_contents());
|
||||
if (isset( $_capture_append)) $_smarty_tpl->append( $_capture_append, ob_get_contents());
|
||||
Smarty::$_smarty_vars['capture'][$_capture_buffer]=ob_get_clean();
|
||||
} else $_smarty_tpl->capture_error();?>
|
||||
<script type="text/javascript">
|
||||
<?php $_smarty_tpl->tpl_vars['id'] = new Smarty_variable(md5((($tmp = @$_smarty_tpl->tpl_vars['template_name']->value)===null||$tmp==='' ? '' : $tmp)), null, 0);?>
|
||||
_smarty_console = window.open("","console<?php echo $_smarty_tpl->tpl_vars['id']->value;?>
|
||||
","width=680,height=600,resizable,scrollbars=yes");
|
||||
_smarty_console.document.write("<?php echo strtr($_smarty_tpl->tpl_vars['debug_output']->value, array("\\" => "\\\\", "'" => "\\'", "\"" => "\\\"", "\r" => "\\r", "\n" => "\\n", "</" => "<\/" ));?>
|
||||
");
|
||||
_smarty_console.document.close();
|
||||
</script>
|
||||
<?php }} ?>
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
<?php /* Smarty version Smarty-3.1.6, created on 2011-12-06 22:48:48
|
||||
compiled from "./templates/header.tpl" */ ?>
|
||||
<?php /*%%SmartyHeaderCode:8838242404ede8dc0a25577-15282059%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
|
||||
$_valid = $_smarty_tpl->decodeProperties(array (
|
||||
'file_dependency' =>
|
||||
array (
|
||||
'97c13ae6868bbc459509c9f1b968154acd23eecc' =>
|
||||
array (
|
||||
0 => './templates/header.tpl',
|
||||
1 => 1323208095,
|
||||
2 => 'file',
|
||||
),
|
||||
),
|
||||
'nocache_hash' => '8838242404ede8dc0a25577-15282059',
|
||||
'function' =>
|
||||
array (
|
||||
),
|
||||
'variables' =>
|
||||
array (
|
||||
'title' => 0,
|
||||
'Name' => 1,
|
||||
),
|
||||
'has_nocache_code' => true,
|
||||
'version' => 'Smarty-3.1.6',
|
||||
'unifunc' => 'content_4ede8dc0a3817',
|
||||
),false); /*/%%SmartyHeaderCode%%*/?>
|
||||
<?php if ($_valid && !is_callable('content_4ede8dc0a3817')) {function content_4ede8dc0a3817($_smarty_tpl) {?><HTML>
|
||||
<HEAD>
|
||||
<TITLE><?php echo $_smarty_tpl->tpl_vars['title']->value;?>
|
||||
- <?php echo '/*%%SmartyNocache:8838242404ede8dc0a25577-15282059%%*/<?php echo $_smarty_tpl->tpl_vars[\'Name\']->value;?>
|
||||
/*/%%SmartyNocache:8838242404ede8dc0a25577-15282059%%*/';?>
|
||||
</TITLE>
|
||||
</HEAD>
|
||||
<BODY bgcolor="#ffffff">
|
||||
<?php }} ?>
|
||||
+175
@@ -0,0 +1,175 @@
|
||||
<?php /* Smarty version Smarty-3.1.6, created on 2011-12-06 22:48:48
|
||||
compiled from "./templates/index.tpl" */ ?>
|
||||
<?php /*%%SmartyHeaderCode:12640292194ede8dc07d9679-56216527%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
|
||||
$_valid = $_smarty_tpl->decodeProperties(array (
|
||||
'file_dependency' =>
|
||||
array (
|
||||
'c0360d049dff10f364dfc53ba2cc3958abf6ee6d' =>
|
||||
array (
|
||||
0 => './templates/index.tpl',
|
||||
1 => 1323208095,
|
||||
2 => 'file',
|
||||
),
|
||||
),
|
||||
'nocache_hash' => '12640292194ede8dc07d9679-56216527',
|
||||
'function' =>
|
||||
array (
|
||||
),
|
||||
'variables' =>
|
||||
array (
|
||||
'SCRIPT_NAME' => 0,
|
||||
'Name' => 1,
|
||||
'FirstName' => 0,
|
||||
'LastName' => 0,
|
||||
'contacts' => 0,
|
||||
'option_values' => 0,
|
||||
'option_selected' => 0,
|
||||
'option_output' => 0,
|
||||
),
|
||||
'has_nocache_code' => true,
|
||||
'version' => 'Smarty-3.1.6',
|
||||
'unifunc' => 'content_4ede8dc09ce5a',
|
||||
),false); /*/%%SmartyHeaderCode%%*/?>
|
||||
<?php if ($_valid && !is_callable('content_4ede8dc09ce5a')) {function content_4ede8dc09ce5a($_smarty_tpl) {?><?php if (!is_callable('smarty_modifier_capitalize')) include '/Users/m0/Documents/workspace/Kunden/smarty/libs/plugins/modifier.capitalize.php';
|
||||
if (!is_callable('smarty_modifier_date_format')) include '/Users/m0/Documents/workspace/Kunden/smarty/libs/plugins/modifier.date_format.php';
|
||||
if (!is_callable('smarty_function_html_select_date')) include '/Users/m0/Documents/workspace/Kunden/smarty/libs/plugins/function.html_select_date.php';
|
||||
if (!is_callable('smarty_function_html_select_time')) include '/Users/m0/Documents/workspace/Kunden/smarty/libs/plugins/function.html_select_time.php';
|
||||
if (!is_callable('smarty_function_html_options')) include '/Users/m0/Documents/workspace/Kunden/smarty/libs/plugins/function.html_options.php';
|
||||
?><?php $_config = new Smarty_Internal_Config("test.conf", $_smarty_tpl->smarty, $_smarty_tpl);$_config->loadConfigVars("setup", 'local'); ?>
|
||||
<?php echo $_smarty_tpl->getSubTemplate ("header.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 9999, null, array('title'=>'foo'), 0);?>
|
||||
|
||||
|
||||
<PRE>
|
||||
<?php if ($_smarty_tpl->getConfigVariable('bold')){?><b><?php }?>
|
||||
Title: <?php echo smarty_modifier_capitalize($_smarty_tpl->getConfigVariable('title'));?>
|
||||
|
||||
<?php if ($_smarty_tpl->getConfigVariable('bold')){?></b><?php }?>
|
||||
|
||||
The current date and time is <?php echo smarty_modifier_date_format(time(),"%Y-%m-%d %H:%M:%S");?>
|
||||
|
||||
|
||||
The value of global assigned variable $SCRIPT_NAME is <?php echo $_smarty_tpl->tpl_vars['SCRIPT_NAME']->value;?>
|
||||
|
||||
|
||||
Example of accessing server environment variable SERVER_NAME: <?php echo $_SERVER['SERVER_NAME'];?>
|
||||
|
||||
|
||||
The value of {$Name} is <b><?php echo '/*%%SmartyNocache:12640292194ede8dc07d9679-56216527%%*/<?php echo $_smarty_tpl->tpl_vars[\'Name\']->value;?>
|
||||
/*/%%SmartyNocache:12640292194ede8dc07d9679-56216527%%*/';?>
|
||||
</b>
|
||||
|
||||
variable modifier example of {$Name|upper}
|
||||
|
||||
<b><?php echo '/*%%SmartyNocache:12640292194ede8dc07d9679-56216527%%*/<?php echo mb_strtoupper($_smarty_tpl->tpl_vars[\'Name\']->value,SMARTY_RESOURCE_CHAR_SET);?>
|
||||
/*/%%SmartyNocache:12640292194ede8dc07d9679-56216527%%*/';?>
|
||||
</b>
|
||||
|
||||
|
||||
An example of a section loop:
|
||||
|
||||
<?php if (isset($_smarty_tpl->tpl_vars['smarty']->value['section']['outer'])) unset($_smarty_tpl->tpl_vars['smarty']->value['section']['outer']);
|
||||
$_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['name'] = 'outer';
|
||||
$_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['loop'] = is_array($_loop=$_smarty_tpl->tpl_vars['FirstName']->value) ? count($_loop) : max(0, (int)$_loop); unset($_loop);
|
||||
$_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['show'] = true;
|
||||
$_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['max'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['loop'];
|
||||
$_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['step'] = 1;
|
||||
$_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['start'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['step'] > 0 ? 0 : $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['loop']-1;
|
||||
if ($_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['show']) {
|
||||
$_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['total'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['loop'];
|
||||
if ($_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['total'] == 0)
|
||||
$_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['show'] = false;
|
||||
} else
|
||||
$_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['total'] = 0;
|
||||
if ($_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['show']):
|
||||
|
||||
for ($_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['index'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['start'], $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['iteration'] = 1;
|
||||
$_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['iteration'] <= $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['total'];
|
||||
$_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['index'] += $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['step'], $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['iteration']++):
|
||||
$_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['rownum'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['iteration'];
|
||||
$_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['index_prev'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['index'] - $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['step'];
|
||||
$_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['index_next'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['index'] + $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['step'];
|
||||
$_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['first'] = ($_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['iteration'] == 1);
|
||||
$_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['last'] = ($_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['iteration'] == $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['total']);
|
||||
?>
|
||||
<?php if ((1 & $_smarty_tpl->getVariable('smarty')->value['section']['outer']['index'] / 2)){?>
|
||||
<?php echo $_smarty_tpl->getVariable('smarty')->value['section']['outer']['rownum'];?>
|
||||
. <?php echo $_smarty_tpl->tpl_vars['FirstName']->value[$_smarty_tpl->getVariable('smarty')->value['section']['outer']['index']];?>
|
||||
<?php echo $_smarty_tpl->tpl_vars['LastName']->value[$_smarty_tpl->getVariable('smarty')->value['section']['outer']['index']];?>
|
||||
|
||||
<?php }else{ ?>
|
||||
<?php echo $_smarty_tpl->getVariable('smarty')->value['section']['outer']['rownum'];?>
|
||||
* <?php echo $_smarty_tpl->tpl_vars['FirstName']->value[$_smarty_tpl->getVariable('smarty')->value['section']['outer']['index']];?>
|
||||
<?php echo $_smarty_tpl->tpl_vars['LastName']->value[$_smarty_tpl->getVariable('smarty')->value['section']['outer']['index']];?>
|
||||
|
||||
<?php }?>
|
||||
<?php endfor; else: ?>
|
||||
none
|
||||
<?php endif; ?>
|
||||
|
||||
An example of section looped key values:
|
||||
|
||||
<?php if (isset($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1'])) unset($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']);
|
||||
$_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['name'] = 'sec1';
|
||||
$_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['loop'] = is_array($_loop=$_smarty_tpl->tpl_vars['contacts']->value) ? count($_loop) : max(0, (int)$_loop); unset($_loop);
|
||||
$_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['show'] = true;
|
||||
$_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['max'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['loop'];
|
||||
$_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['step'] = 1;
|
||||
$_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['start'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['step'] > 0 ? 0 : $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['loop']-1;
|
||||
if ($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['show']) {
|
||||
$_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['total'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['loop'];
|
||||
if ($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['total'] == 0)
|
||||
$_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['show'] = false;
|
||||
} else
|
||||
$_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['total'] = 0;
|
||||
if ($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['show']):
|
||||
|
||||
for ($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['index'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['start'], $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['iteration'] = 1;
|
||||
$_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['iteration'] <= $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['total'];
|
||||
$_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['index'] += $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['step'], $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['iteration']++):
|
||||
$_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['rownum'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['iteration'];
|
||||
$_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['index_prev'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['index'] - $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['step'];
|
||||
$_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['index_next'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['index'] + $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['step'];
|
||||
$_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['first'] = ($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['iteration'] == 1);
|
||||
$_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['last'] = ($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['iteration'] == $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['total']);
|
||||
?>
|
||||
phone: <?php echo $_smarty_tpl->tpl_vars['contacts']->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec1']['index']]['phone'];?>
|
||||
<br>
|
||||
fax: <?php echo $_smarty_tpl->tpl_vars['contacts']->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec1']['index']]['fax'];?>
|
||||
<br>
|
||||
cell: <?php echo $_smarty_tpl->tpl_vars['contacts']->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec1']['index']]['cell'];?>
|
||||
<br>
|
||||
<?php endfor; endif; ?>
|
||||
<p>
|
||||
|
||||
testing strip tags
|
||||
<table border=0><tr><td><A HREF="<?php echo $_smarty_tpl->tpl_vars['SCRIPT_NAME']->value;?>
|
||||
"><font color="red">This is a test </font></A></td></tr></table>
|
||||
|
||||
</PRE>
|
||||
|
||||
This is an example of the html_select_date function:
|
||||
|
||||
<form>
|
||||
<?php echo smarty_function_html_select_date(array('start_year'=>1998,'end_year'=>2010),$_smarty_tpl);?>
|
||||
|
||||
</form>
|
||||
|
||||
This is an example of the html_select_time function:
|
||||
|
||||
<form>
|
||||
<?php echo smarty_function_html_select_time(array('use_24_hours'=>false),$_smarty_tpl);?>
|
||||
|
||||
</form>
|
||||
|
||||
This is an example of the html_options function:
|
||||
|
||||
<form>
|
||||
<select name=states>
|
||||
<?php echo smarty_function_html_options(array('values'=>$_smarty_tpl->tpl_vars['option_values']->value,'selected'=>$_smarty_tpl->tpl_vars['option_selected']->value,'output'=>$_smarty_tpl->tpl_vars['option_output']->value),$_smarty_tpl);?>
|
||||
|
||||
</select>
|
||||
</form>
|
||||
|
||||
<?php echo $_smarty_tpl->getSubTemplate ("footer.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 9999, null, array(), 0);?>
|
||||
|
||||
<?php }} ?>
|
||||
Reference in New Issue
Block a user