これは、主要なコントローラーを備えたいわゆるモデルです。 つまり、コントローラーは、テンプレートエンジンを受信し、通常はすべてにコマンドを送信するという事実に完全に責任を負います。
一流のパフォーマンスを備えたモデルもあります。 その中で、ビューはコントローラーに「Give me、親愛なる、最近の投稿のリスト」と伝え、その後コントローラーはモデルを取得し、このリストを抽出して処理し、ビュー(この場合はテンプレートエンジン)に渡します。
これらのモデルはどれも最適ではありません。異なる場合には、どちらか一方を使用すると便利です。 それにもかかわらず、箱のスマートアウトは、最初のスキームに従ってのみ機能します。 彼に2番目の作業も訓練することは非常に簡単であることが判明しました。
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
<?php /** * index.php * * View-driven smarty usage sample * * Use {data id="SOMEID" var="TPLVAR"} construction in template * to fetch data for template. Return of the DataFetcher object * will be assigned to the variable with TPLVAR name. * * DataFetcher object must have function called fetch() with only * parameter which value will be SOMEID. * * Smarty included in this archieve only for your convenience. * * Remember: it's just a sample * * @copyright (c) Gregory Sitnin, 2009. All rights reserved. * @author Gregory Sitnin <gregor@gregor.ru> * */ $config[ 'base' ] = dirname(__FILE__); $config[ 'tmp' ] = $config[ 'base' ]. '/tmp' ; final class DataFetcher extends ConfiguratedObject { function fetch($name) { return 'Hello, World!' ; } } final class SmartyRender extends ConfiguratedObject { private $smarty; function __construct($config) { parent::__construct($config); require_once $ this ->config[ 'base' ]. '/smarty/Smarty.class.php' ; $ this ->smarty = new Smarty(); $ this ->smarty->template_dir = $ this ->config[ 'base' ]; $ this ->smarty->compile_dir = $ this ->config[ 'tmp' ]; $ this ->smarty->register_function( 'data' , array ($ this , 'getDataProxy' )); } public function getDataProxy($ params , &$smarty) { if (!isset($ params [ 'id' ])) { $smarty->trigger_error( "data: id parameter must be set." ); } elseif (!isset($ params [ 'var' ])) { $smarty->trigger_error( "data: var parameter must be set." ); } else { try { $fetcher = new DataFetcher($ this ->config); $smarty->assign($ params [ 'var' ], $fetcher->fetch($ params [ 'id' ])); } catch (Exception $e) { $smarty->trigger_error( 'data: (' .$e->getCode(). ')' .$e->getMessage()); } } } function render($template, array $vars = null ) { $ this ->smarty->assign($vars); return $ this ->smarty->fetch($template); } } final class App extends ConfiguratedObject { function run() { $render = new SmartyRender($ this ->config); echo $render->render( 'index.tpl' ); } } abstract class ConfiguratedObject { protected $config; function __construct($config) { $ this ->config = $config; } } $app = new App($config); $app->run(); ?> * This source code was highlighted with Source Code Highlighter .
41〜57行目で興味深いことが起こります。 $ smarty-> register_function()メソッドを使用して、「data」という新しいテンプレート関数を宣言しました。 テンプレート内でこの構造が検出されると、SmartyRenderオブジェクトの$ this-> getDataProxy()メソッドが呼び出されます。
このメソッドは、テンプレートで指定されたパラメーターの配列へのリンクと、スマート関数を呼び出したテンプレートを操作するsmartyオブジェクトへのリンクを取得します。
ここでもそれ以降でも、魔法はありません。 パラメーターを確認し、すべてが問題なければ、DataFetcherクラスのインスタンスを作成します。 DataFetcherオブジェクトのfetch()メソッドを呼び出した結果は、テンプレート変数になり、必要に応じて使用できます。
私の場合、テンプレート自体は次のようになります。
*このソースコードは、 ソースコードハイライターで強調表示されました。
- < html >
- < 頭 >
- < title >ビュー駆動のSmartyテスト</ title >
- </ 頭 >
- < 本体 >
- {data id = "test" var = "test"}
- 取得済み:{$ test}
- </ body >
- </ html >
この例の作業コード(Smartyを含む): http : //gregor.ru/files/blog/vdsmarty.zip