<?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 .
* This source code was highlighted with Source Code Highlighter .
- < html >
- < head >
- < title > View-driven Smarty test </ title >
- </ head >
- < body >
- {data id = "test" var = "test"}
- Fetched: {$ test}
- </ body >
- </ html >
Source: https://habr.com/ru/post/60561/
All Articles