summaryrefslogtreecommitdiff
path: root/demo
diff options
context:
space:
mode:
authormonte.ohrt <monte.ohrt@localhost>2009-03-22 16:09:05 +0000
committermonte.ohrt <monte.ohrt@localhost>2009-03-22 16:09:05 +0000
commitdcaa96a9f804ecb75d5d8e0138482c1cdf8d5c0f (patch)
tree1a5e06e73dcdc46811b73e847c93fd3bc97273b2 /demo
downloadsmarty-dcaa96a9f804ecb75d5d8e0138482c1cdf8d5c0f.tar.gz
smarty-dcaa96a9f804ecb75d5d8e0138482c1cdf8d5c0f.tar.bz2
smarty-dcaa96a9f804ecb75d5d8e0138482c1cdf8d5c0f.zip
rearrange things into distribution and development directories
Diffstat (limited to 'demo')
-rw-r--r--demo/configs/test.conf22
-rw-r--r--demo/index.php48
-rw-r--r--demo/templates/header.tpl5
-rw-r--r--demo/templates/include.tpl3
-rw-r--r--demo/templates/index.tpl10
-rw-r--r--demo/templates/index_view.php11
-rw-r--r--demo/templates/nocache_inc.tpl2
-rw-r--r--demo/templates/test_debug.tpl3
-rw-r--r--demo/templates/test_if.tpl5
-rw-r--r--demo/templates/test_inc.tpl25
-rw-r--r--demo/templates/test_inc2.tpl6
-rw-r--r--demo/templates/test_insert.tpl3
-rw-r--r--demo/templates/test_nocache.tpl11
-rw-r--r--demo/templates/test_nocache2.tpl9
-rw-r--r--demo/templates/test_object.tpl6
-rw-r--r--demo/templates/test_object2.tpl5
-rw-r--r--demo/templates/test_parser.tpl7
-rw-r--r--demo/templates/test_plugin.tpl7
-rw-r--r--demo/templates/test_security.tpl7
-rw-r--r--demo/templates/test_smoke.tpl159
20 files changed, 354 insertions, 0 deletions
diff --git a/demo/configs/test.conf b/demo/configs/test.conf
new file mode 100644
index 00000000..80cfea45
--- /dev/null
+++ b/demo/configs/test.conf
@@ -0,0 +1,22 @@
+title = Welcome to Smarty!
+cutoff_size = 40
+bold = false
+pageTitle = "This is mine"
+bodyBgColor = '#eeeeee'
+tableBorderSize = 3
+tableBgColor = "#bbbbbb"
+rowBgColor = #cccccc
+
+Intro = """This is a value that spans more
+ than one line. you must enclose
+ it in triple quotes."""
+
+Quote1 = """'value should contain a
+sigle quote'"""
+
+Quote2 = """ "value should contain a " double quote" """
+
+[setup]
+bold = true
+
+[params]
diff --git a/demo/index.php b/demo/index.php
new file mode 100644
index 00000000..2ae64c0a
--- /dev/null
+++ b/demo/index.php
@@ -0,0 +1,48 @@
+<?php
+/**
+* Test script for PHP template
+* @author Monte Ohrt <monte at ohrt dot com>
+* @package SmartyTestScripts
+*/
+require('./libs/Smarty.class.php');
+ini_set('short_open_tag','1');
+
+ class Person
+{
+ private $m_szName;
+ private $m_iAge;
+
+ public function setName($szName)
+ {
+ $this->m_szName = $szName;
+ return $this; // We now return $this (the Person)
+ }
+
+ public function setAge($iAge)
+ {
+ $this->m_iAge = $iAge;
+ return $this; // Again, return our Person
+ }
+
+ public function introduce()
+ {
+ return 'Hello my name is '.$this->m_szName.' and I am '.$this->m_iAge.' years old.';
+ }
+}
+
+$smarty = new Smarty();
+$smarty->force_compile = false;
+$smarty->caching = false;
+$smarty->caching_lifetime = 10;
+
+$smarty->assign('foo','<bar>');
+
+$person = new Person;
+
+$smarty->assign('person',$person);
+
+$smarty->assign('array',array('a'=>array('aa'=>'This is a long string'),'b'=>2));
+
+$smarty->display('php:index_view.php');
+
+?>
diff --git a/demo/templates/header.tpl b/demo/templates/header.tpl
new file mode 100644
index 00000000..f161a929
--- /dev/null
+++ b/demo/templates/header.tpl
@@ -0,0 +1,5 @@
+This is the header
+
+gee is {$gee} foo is {$foo}
+
+done with header
diff --git a/demo/templates/include.tpl b/demo/templates/include.tpl
new file mode 100644
index 00000000..56088dc5
--- /dev/null
+++ b/demo/templates/include.tpl
@@ -0,0 +1,3 @@
+
+Include file
+<br>{assign var=inc value='assign include'}{$inc}
diff --git a/demo/templates/index.tpl b/demo/templates/index.tpl
new file mode 100644
index 00000000..2398756f
--- /dev/null
+++ b/demo/templates/index.tpl
@@ -0,0 +1,10 @@
+This is an example of a compiled template.
+
+$foo = {$foo}
+$foo[0] = {$foo[0]}
+$foo[1] = {$foo[1]}
+$foo[2] = {$foo[2]}
+
+function:
+
+End Test
diff --git a/demo/templates/index_view.php b/demo/templates/index_view.php
new file mode 100644
index 00000000..56f27386
--- /dev/null
+++ b/demo/templates/index_view.php
@@ -0,0 +1,11 @@
+PHP file test
+$foo is <?=$foo?>
+<br> Test modifier chaining
+<?=$foo->trim()->escape('html')?>
+<br>Test objects
+<?=$person->setName('Paul')->setAge(39)->introduce()->trim()->truncate(10)?>
+<br>Arrays
+<?=$array['a']['aa']->truncate(5)?><?=$array['b']?>
+<br>Function
+<?=$_f->trim($array['a']['aa'])->truncate(10)?>
+DONE
diff --git a/demo/templates/nocache_inc.tpl b/demo/templates/nocache_inc.tpl
new file mode 100644
index 00000000..81f5c359
--- /dev/null
+++ b/demo/templates/nocache_inc.tpl
@@ -0,0 +1,2 @@
+<br>This is from nocache_inc.tpl
+<br>cached time is {time()}
diff --git a/demo/templates/test_debug.tpl b/demo/templates/test_debug.tpl
new file mode 100644
index 00000000..b55eeb49
--- /dev/null
+++ b/demo/templates/test_debug.tpl
@@ -0,0 +1,3 @@
+
+Test debug
+{debug}
diff --git a/demo/templates/test_if.tpl b/demo/templates/test_if.tpl
new file mode 100644
index 00000000..d7a00d49
--- /dev/null
+++ b/demo/templates/test_if.tpl
@@ -0,0 +1,5 @@
+Test of if tags <br>
+{foreach item=value from=$values}
+Value of {$value} is {if $value<10} less then 10 {elseif ($value GT 100) AND ($value <= 500)} something between 100 and 500 {else} somthing else {/if}<br>
+{/foreach}
+
diff --git a/demo/templates/test_inc.tpl b/demo/templates/test_inc.tpl
new file mode 100644
index 00000000..068017e7
--- /dev/null
+++ b/demo/templates/test_inc.tpl
@@ -0,0 +1,25 @@
+Test of { include } and local/global variable scope
+<br>the original value of $foo = {$foo}
+<br>
+{assign var=foo2 value='yzx'}
+<br> foo2 before { include } = {$foo2}
+{include file='test_inc2.tpl'}
+<br>
+<br>Here we are back in test_inc.tpl
+<br>$foo has its old value = {$foo}
+<br>this is $foo2 a global variable created in test_inc2.tpl = {$foo2}
+<br>{if isset($foo3)} $foo3 must be unknow here {/if}
+<br>
+<br>Test include with parent scope
+{include file='test_inc2.tpl' scope='parent'}
+<br>Here we are back in test_inc.tpl
+<br>$foo has its new value = {$foo}
+<br>this is $foo2 a global variable created in test_inc2.tpl = {$foo2}
+<br>this is $foo3 a normal variable created in test_inc2.tpl = {$foo3}
+<br>
+<br>Test include with root scope
+{include file='test_inc2.tpl' scope='root'}
+<br>Here we are back in test_inc.tpl
+<br>$foo has its new value = {$foo}
+<br>this is $foo2 a global variable created in test_inc2.tpl = {$foo2}
+<br>this is $foo3 a normal variable created in test_inc2.tpl = {$foo3}
diff --git a/demo/templates/test_inc2.tpl b/demo/templates/test_inc2.tpl
new file mode 100644
index 00000000..c4b0ef65
--- /dev/null
+++ b/demo/templates/test_inc2.tpl
@@ -0,0 +1,6 @@
+<br>Here starts test_inc2.tpl
+<br>$foo in test_inc2 before changing = {$foo}
+{assign var=foo value="bah"}
+<br>$foo in test_inc2 after changing = {$foo}
+{assign var=foo2 value="bla" global=true}
+{assign var=foo3 value="foo3 was set"}
diff --git a/demo/templates/test_insert.tpl b/demo/templates/test_insert.tpl
new file mode 100644
index 00000000..84d9074b
--- /dev/null
+++ b/demo/templates/test_insert.tpl
@@ -0,0 +1,3 @@
+Test of { insert }
+<br>{insert name='test' foo='bar'}
+<br>insert with assign {insert name='test' foo='bar' assign=var}{$var}
diff --git a/demo/templates/test_nocache.tpl b/demo/templates/test_nocache.tpl
new file mode 100644
index 00000000..39aba1ff
--- /dev/null
+++ b/demo/templates/test_nocache.tpl
@@ -0,0 +1,11 @@
+Test caching and nocache attribute
+<br>cached time is {time()}
+<br>nocached time by '{time() nocache=true}' {time() nocache=true}
+<br>
+<br>calling '{include file="nocache_inc.tpl" caching_lifetime=25}' {include file="nocache_inc.tpl" caching_lifetime=25}
+<br>
+<br>calling '{include file="nocache_inc.tpl" nocache=true}' {include file="nocache_inc.tpl" nocache=true}
+{nocache}
+{assign var=a value=1}
+<br>{if $a < 5}{$a|truncate} lt 5{else}a ge 5{/if}
+{/nocache} \ No newline at end of file
diff --git a/demo/templates/test_nocache2.tpl b/demo/templates/test_nocache2.tpl
new file mode 100644
index 00000000..9da14b6d
--- /dev/null
+++ b/demo/templates/test_nocache2.tpl
@@ -0,0 +1,9 @@
+Test caching and nocache attribute
+<br>cached time is {$t1}
+<br>nocached time is {$t2}
+<br>
+{$t1+$t1} {$t1+$t2}
+<br>
+{nocache}
+{for $i=0;$i<10;$i++}{$i}{/for}
+{/nocache}
diff --git a/demo/templates/test_object.tpl b/demo/templates/test_object.tpl
new file mode 100644
index 00000000..63004556
--- /dev/null
+++ b/demo/templates/test_object.tpl
@@ -0,0 +1,6 @@
+
+Test methode chaining
+{assign var=x value=33}
+<br>{assign var=x2 value=10}{$person->object->setName('peter')->setAge($x+4)->introduce()}
+<br>{$person->object->setAge($x+$x2)->setName('paul')->introduce()}
+
diff --git a/demo/templates/test_object2.tpl b/demo/templates/test_object2.tpl
new file mode 100644
index 00000000..8d573d19
--- /dev/null
+++ b/demo/templates/test_object2.tpl
@@ -0,0 +1,5 @@
+
+Test registered object
+<br>{/test->hello}
+<br>{/test->hello p1=1 p2=2}
+
diff --git a/demo/templates/test_parser.tpl b/demo/templates/test_parser.tpl
new file mode 100644
index 00000000..3250958d
--- /dev/null
+++ b/demo/templates/test_parser.tpl
@@ -0,0 +1,7 @@
+Input form for parser testing <BR>
+<form name="Testparser" action="test_parser.php" method="post">
+<strong>Template input</strong>
+<textarea name="template" rows="10" cols="60">{$template|escape}</textarea>
+<input name="Update" type="submit" value="Update">
+</form >
+
diff --git a/demo/templates/test_plugin.tpl b/demo/templates/test_plugin.tpl
new file mode 100644
index 00000000..e550dd6e
--- /dev/null
+++ b/demo/templates/test_plugin.tpl
@@ -0,0 +1,7 @@
+Test of function plugin
+{nocache}
+{counter assign=foo start=10 skip=5}
+<br>{$foo}
+{counter}
+<br>{$foo}
+{/nocache}
diff --git a/demo/templates/test_security.tpl b/demo/templates/test_security.tpl
new file mode 100644
index 00000000..e550dd6e
--- /dev/null
+++ b/demo/templates/test_security.tpl
@@ -0,0 +1,7 @@
+Test of function plugin
+{nocache}
+{counter assign=foo start=10 skip=5}
+<br>{$foo}
+{counter}
+<br>{$foo}
+{/nocache}
diff --git a/demo/templates/test_smoke.tpl b/demo/templates/test_smoke.tpl
new file mode 100644
index 00000000..d88e2bcf
--- /dev/null
+++ b/demo/templates/test_smoke.tpl
@@ -0,0 +1,159 @@
+<pre>SMARTY SMOKE TEST
+
+VARIABLE TESTS:
+
+$foo is {$foo}
+
+$baz[1] is {$baz[1]}
+
+$blah['b'] is {$blah['b']}
+
+$blah[$baz[1]] is {$blah[$baz[1]]}
+
+$foo.$baz[1] is {$foo.$baz[1]}
+
+$foo.$foo is {$foo.$foo}
+
+{"foo"}
+
+OBJECT TESTS:
+
+$myobj->foo is {$myobj->foo}
+
+$myobj->test is {$myobj->test}
+$myobj->test() is {$myobj->test()}
+$myobj->test(1) is {$myobj->test(1)}
+$myobj->test(1,'two') is {$myobj->test(1,'two')}
+$myobj->test(count($baz)) is {$myobj->test(count($baz))}
+$myobj->test($myobj->test(count($baz))) is {$myobj->test($myobj->test(count($baz)))}
+$myobj->test($foo|escape) is {$myobj->test($foo|escape)}
+
+PHP TESTS:
+
+
+COMMENT TESTS:
+
+{* this is a comment *}
+{* another $foo comment *}
+{* another <?=$foo?> comment *}
+{* multi line
+ comment *}
+{* /* foo */ *}
+A{* comment *}B
+C
+D{* comment *}
+{* comment *}E
+F
+G{* multi
+ line *}H
+I{* multi
+line *}
+J
+
+ASSIGN:
+
+A
+{assign var=zoo value="blah"}
+B
+C{assign var=zoo value="blah"}D
+E{assign var=zoo value="blah"}
+F
+G
+{assign var=zoo value="blah"}H
+{assign var=zoo value="joe{$myobj->test(1)}bar"}
+
+zoo is {$zoo}
+
+SPACING TESTS:
+
+{$foo}
+
+{$foo}{$foo}
+
+A{$foo}
+
+A{$foo}B
+
+{$foo}B
+
+IF TESTS:
+
+{if $foo eq "baz"}
+ IS BAZ
+{elseif $foo == "lala"}
+ IS LALA
+{else}
+ IS NONE
+{/if}
+
+{if $myint+5 EQ 9}
+ IS NINE
+{else}
+ IS NOT NINE
+{/if}
+
+{if $myint + 5 eq 9}
+ IS NINE
+{else}
+ IS NOT NINE
+{/if}
+
+{if count($baz)-2 eq 1}
+ IS ONE
+{else}
+ IS NOT ONE
+{/if}
+
+{if $foo.$foo2 eq "barbar2"}
+ IS BARBAR2
+{else}
+ IS NOT BARBAR2
+{/if}
+
+{if $not_logged}
+ NOT LOGGED
+{/if}
+
+{if "joe{$myobj->test(1)}bar"}
+ FOO
+{/if}
+
+TEST INCLUDE:
+
+{include file="header.tpl" gee="joe"}
+{include file="header.tpl" gee="joe $foo bar"}
+{include file="header.tpl" gee="joe{$foo}bar"}
+{include file="header.tpl" gee="joe{$foo.$foo}bar"}
+{include file="header.tpl" gee="joe{$myobj->test(1)}bar"}
+{include file=$includeme}
+{include file=$includeme gee="joe"}
+{include file="{$top}.tpl"}
+
+JAVSCRIPT TEST
+
+<script language="javascript">
+ function sayhi()
+ {
+ alert('hi there!');
+ }
+ function foobar() { alert('foobar'); }
+</script>
+
+MATH TESTS:
+
+$one+2 is {$one+2}
+$one + 2 - $one is {$one + 2 - $one}
+$one*$one is {$one*$one}
+$one/$one is {$one/$one}
+abs(-$one) is {abs(-$one)}
+
+$footest is {$footest}
+
+FOREACH TESTS:
+
+{foreach from=$blah key="idx" item="val"}
+ $idx/$val is {$idx}/{$val}
+{/foreach}
+
+TEST FINISHED
+</pre>