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 / Progress2 / Generator / ITDynamic.php < prev    next >
Encoding:
PHP Script  |  2008-07-02  |  5.6 KB  |  169 lines

  1. <?php
  2. /**
  3.  * Copyright (c) 2005-2008, Laurent Laville <pear@laurent-laville.org>
  4.  *
  5.  * All rights reserved.
  6.  *
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted provided that the following conditions
  9.  * are met:
  10.  *
  11.  *     * Redistributions of source code must retain the above copyright
  12.  *       notice, this list of conditions and the following disclaimer.
  13.  *     * Redistributions in binary form must reproduce the above copyright
  14.  *       notice, this list of conditions and the following disclaimer in the
  15.  *       documentation and/or other materials provided with the distribution.
  16.  *     * Neither the name of the authors nor the names of its contributors
  17.  *       may be used to endorse or promote products derived from this software
  18.  *       without specific prior written permission.
  19.  *
  20.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  21.  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  23.  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
  24.  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  25.  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  26.  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  27.  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  28.  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  29.  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  30.  * POSSIBILITY OF SUCH DAMAGE.
  31.  *
  32.  * PHP versions 4 and 5
  33.  *
  34.  * @category  HTML
  35.  * @package   HTML_Progress2
  36.  * @author    Laurent Laville <pear@laurent-laville.org>
  37.  * @copyright 2005-2008 Laurent Laville
  38.  * @license   http://www.opensource.org/licenses/bsd-license.php  New BSD License
  39.  * @version   CVS: $Id: ITDynamic.php,v 1.9 2008/03/20 21:27:55 farell Exp $
  40.  * @link      http://pear.php.net/package/HTML_Progress2
  41.  * @since     File available since Release 2.0.0RC1
  42.  */
  43.  
  44. require_once 'HTML/QuickForm/Renderer/ITDynamic.php';
  45. require_once 'HTML/Template/Sigma.php';
  46.  
  47. /**
  48.  * The ActionDisplay class provides a ITDynamic form rendering
  49.  * with template engine IT[x] family.
  50.  *
  51.  * @category  HTML
  52.  * @package   HTML_Progress2
  53.  * @author    Laurent Laville <pear@laurent-laville.org>
  54.  * @copyright 2005-2008 Laurent Laville
  55.  * @license   http://www.opensource.org/licenses/bsd-license.php  New BSD License
  56.  * @version   Release: 2.4.0
  57.  * @link      http://pear.php.net/package/HTML_Progress2
  58.  * @since     Class available since Release 2.0.0RC1
  59.  */
  60.  
  61. class ActionDisplay extends HTML_QuickForm_Action_Display
  62. {
  63.     /**
  64.      * Style sheet for the custom layout
  65.      *
  66.      * @var    string
  67.      * @access public
  68.      * @since  2.1.0
  69.      */
  70.     var $css;
  71.  
  72.     /**
  73.      * class constructor
  74.      *
  75.      * @param string $css custom stylesheet to apply, or default if not set
  76.      *
  77.      * @access public
  78.      * @since  version 2.1.0 (2006-08-12)
  79.      */
  80.     function ActionDisplay($css = null)
  81.     {
  82.         // when no user-styles defined, used the default values
  83.         $this->setStyleSheet($css);
  84.     }
  85.  
  86.     /**
  87.      * Outputs the form.
  88.      *
  89.      * @param object &$page the page being processed
  90.      *
  91.      * @return void
  92.      * @access public
  93.      * @since  version 2.0.0RC1 (2005-06-23)
  94.      */
  95.     function _renderForm(&$page)
  96.     {
  97.         // can use either HTML_Template_Sigma or HTML_Template_ITX
  98.         $tpl =& new HTML_Template_Sigma('.', 'cache/');
  99.         $tpl->loadTemplateFile('itdynamic.html');
  100.  
  101.         $renderer =& new HTML_QuickForm_Renderer_ITDynamic($tpl);
  102.         $renderer->setElementBlock(array(
  103.             'buttons'     => 'qf_buttons'
  104.         ));
  105.  
  106.         $styles = $this->getStyleSheet();
  107.         $js     = '';
  108.  
  109.         // on preview tab, add progress bar javascript and stylesheet
  110.         if ($page->getAttribute('id') == 'Preview') {
  111.             $pb = $page->controller->createProgressBar();
  112.  
  113.             $styles .= $pb->getStyle();
  114.             $js      = $pb->getScript();
  115.  
  116.             $pbElement =& $page->getElement('progressBar');
  117.             $pbElement->setText($pb->toHtml() . '<br /><br />');
  118.         }
  119.         $page->accept($renderer);
  120.  
  121.         $tpl->setVariable(array('qf_style' => $styles, 'qf_script' => $js));
  122.         $tpl->show();
  123.     }
  124.  
  125.     /**
  126.      * Returns the custom style sheet to use for layout
  127.      *
  128.      * @param bool $content (optional) Either return css filename or string contents
  129.      *
  130.      * @return string
  131.      * @access public
  132.      * @since  version 2.1.0 (2006-08-12)
  133.      */
  134.     function getStyleSheet($content = true)
  135.     {
  136.         if ($content) {
  137.             $styles = file_get_contents($this->css);
  138.         } else {
  139.             $styles = $this->css;
  140.         }
  141.         return $styles;
  142.     }
  143.  
  144.     /**
  145.      * Set the custom style sheet to use your own styles
  146.      *
  147.      * @param string $css (optional) File to read user-defined styles from
  148.      *
  149.      * @return bool   true if custom styles, false if default styles applied
  150.      * @access public
  151.      * @since  version 2.1.0 (2006-08-12)
  152.      */
  153.     function setStyleSheet($css = null)
  154.     {
  155.         // default stylesheet is into package data directory
  156.         if (!isset($css)) {
  157.             $this->css = 'C:\php5\pear\data' . DIRECTORY_SEPARATOR
  158.                  . 'HTML_Progress2' . DIRECTORY_SEPARATOR
  159.                  . 'itdynamic.css';
  160.         }
  161.  
  162.         $res = isset($css) && file_exists($css);
  163.         if ($res) {
  164.             $this->css = $css;
  165.         }
  166.         return $res;
  167.     }
  168. }
  169. ?>