home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / php / PEAR / HTML / Progress / generator / SmartyDynamic.php < prev   
Encoding:
PHP Script  |  2008-07-02  |  3.1 KB  |  91 lines

  1. <?php
  2. /**
  3.  * The ActionDisplay class provides a dynamic form rendering
  4.  * with Smarty template engine.
  5.  *
  6.  * PHP versions 4 and 5
  7.  *
  8.  * LICENSE: This source file is subject to version 3.0 of the PHP license
  9.  * that is available through the world-wide-web at the following URI:
  10.  * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
  11.  * the PHP License and are unable to obtain it through the web, please
  12.  * send a note to license@php.net so we can mail you a copy immediately.
  13.  *
  14.  * @category   HTML
  15.  * @package    HTML_Progress
  16.  * @subpackage Progress_UI
  17.  * @author     Laurent Laville <pear@laurent-laville.org>
  18.  * @copyright  1997-2005 The PHP Group
  19.  * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
  20.  * @version    CVS: $Id: SmartyDynamic.php,v 1.4 2005/07/25 13:00:05 farell Exp $
  21.  * @link       http://pear.php.net/package/HTML_Progress
  22.  */
  23.  
  24. require_once 'HTML/QuickForm/Renderer/Array.php';
  25. // fix this if your Smarty is somewhere else
  26. require_once 'Smarty.class.php';
  27.  
  28. /**
  29.  * The ActionDisplay class provides a dynamic form rendering
  30.  * with Smarty template engine.
  31.  *
  32.  * PHP versions 4 and 5
  33.  *
  34.  * LICENSE: This source file is subject to version 3.0 of the PHP license
  35.  * that is available through the world-wide-web at the following URI:
  36.  * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
  37.  * the PHP License and are unable to obtain it through the web, please
  38.  * send a note to license@php.net so we can mail you a copy immediately.
  39.  *
  40.  * @category   HTML
  41.  * @package    HTML_Progress
  42.  * @subpackage Progress_UI
  43.  * @author     Laurent Laville <pear@laurent-laville.org>
  44.  * @copyright  1997-2005 The PHP Group
  45.  * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
  46.  * @version    Release: 1.2.5
  47.  * @link       http://pear.php.net/package/HTML_Progress
  48.  */
  49.  
  50. class ActionDisplay extends HTML_QuickForm_Action_Display
  51. {
  52.     function _renderForm(&$page)
  53.     {
  54.         $pageName = $page->getAttribute('name');
  55.         $tabPreview = array_slice ($page->controller->_tabs, -2, 1);
  56.  
  57.         // setup a template object
  58.         $tpl =& new Smarty();
  59.         $tpl->template_dir = './templates';
  60.         $tpl->compile_dir  = './templates_c';
  61.  
  62.         // on preview tab, add progress bar javascript and stylesheet
  63.         if ($pageName == $tabPreview[0][0]) {
  64.             $bar = $page->controller->createProgressBar();
  65.  
  66.             $tpl->assign(array(
  67.                 'qf_style'  => $bar->getStyle(),
  68.                 'qf_script' => $bar->getScript()
  69.                 )
  70.             );
  71.  
  72.             $barElement =& $page->getElement('progressBar');
  73.             $barElement->setText( $bar->toHtml() );
  74.         }
  75.  
  76.         $renderer =& new HTML_QuickForm_Renderer_Array(true);
  77.  
  78.         $page->accept($renderer);
  79.         $tpl->assign('form', $renderer->toArray());
  80.  
  81.         // capture the array stucture
  82.         // (only for showing in sample template)
  83.         ob_start();
  84.         print_r($renderer->toArray());
  85.         $tpl->assign('dynamic_array', ob_get_contents());
  86.         ob_end_clean();
  87.  
  88.         $tpl->display('smarty-dynamic.tpl');
  89.     }
  90. }
  91. ?>