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 / Tableless.php < prev   
Encoding:
PHP Script  |  2008-07-02  |  5.7 KB  |  186 lines

  1. <?php
  2. /**
  3.  * Copyright (c) 2006-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 2006-2008 Laurent Laville
  38.  * @license   http://www.opensource.org/licenses/bsd-license.php  New BSD License
  39.  * @version   CVS: $Id: Tableless.php,v 1.6 2008/03/20 21:27:55 farell Exp $
  40.  * @link      http://pear.php.net/package/HTML_Progress2
  41.  * @since     File available since Release 2.1.0
  42.  */
  43.  
  44. require_once 'HTML/QuickForm/Renderer/Tableless.php';
  45.  
  46. /**
  47.  * The ActionDisplay class provides the table less form rendering.
  48.  *
  49.  * @category  HTML
  50.  * @package   HTML_Progress2
  51.  * @author    Laurent Laville <pear@laurent-laville.org>
  52.  * @copyright 2006-2008 Laurent Laville
  53.  * @license   http://www.opensource.org/licenses/bsd-license.php  New BSD License
  54.  * @version   Release: 2.4.0
  55.  * @link      http://pear.php.net/package/HTML_Progress2
  56.  * @since     Class available since Release 2.1.0
  57.  */
  58.  
  59. class ActionDisplay extends HTML_QuickForm_Action_Display
  60. {
  61.     /**
  62.      * Style sheet for the custom layout
  63.      *
  64.      * @var    string
  65.      * @access public
  66.      * @since  2.1.0
  67.      */
  68.     var $css;
  69.  
  70.     /**
  71.      * class constructor
  72.      *
  73.      * @param string $css custom stylesheet to apply, or default if not set
  74.      *
  75.      * @access public
  76.      * @since  version 2.1.0 (2006-08-12)
  77.      */
  78.     function ActionDisplay($css = null)
  79.     {
  80.         // when no user-styles defined, used the default values
  81.         $this->setStyleSheet($css);
  82.     }
  83.  
  84.     /**
  85.      * Outputs the form.
  86.      *
  87.      * @param object &$page the page being processed
  88.      *
  89.      * @return void
  90.      * @access public
  91.      * @since  version 2.1.0 (2006-08-12)
  92.      */
  93.     function _renderForm(&$page)
  94.     {
  95.         $renderer =& new HTML_QuickForm_Renderer_Tableless();
  96.  
  97.         $styles = $this->getStyleSheet();
  98.         $js     = '';
  99.  
  100.         // on preview tab, add progress bar javascript and stylesheet
  101.         if ($page->getAttribute('id') == 'Preview') {
  102.             $pb = $page->controller->createProgressBar();
  103.             $pb->setTab('    ');
  104.  
  105.             $styles .= $pb->getStyle();
  106.             $js      = $pb->getScript();
  107.  
  108.             $pbElement =& $page->getElement('progressBar');
  109.             $pbElement->setText($pb->toHtml() . '<br /><br />');
  110.         }
  111.         $page->accept($renderer);
  112.  
  113.         $body = $renderer->toHtml();
  114.  
  115.         $html = <<<HTML
  116. <!DOCTYPE HTML
  117.     PUBLIC "-//W3C//DTD HTML 4.01//EN"
  118.     "http://www.w3.org/TR/html4/strict.dtd">
  119. <html>
  120. <head>
  121. <title>HTML_Progress2 Generator</title>
  122. <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
  123. <style type="text/css">
  124. <!--
  125. $styles
  126.  -->
  127. </style>
  128. <script type="text/javascript">
  129. //<![CDATA[
  130. $js
  131. //]]>
  132. </script>
  133. </head>
  134. <body>
  135. $body
  136. </body>
  137. </html>
  138. HTML;
  139.         echo $html;
  140.     }
  141.  
  142.     /**
  143.      * Returns the custom style sheet to use for layout
  144.      *
  145.      * @param bool $content (optional) Either return css filename or string contents
  146.      *
  147.      * @return string
  148.      * @access public
  149.      * @since  version 2.1.0 (2006-08-12)
  150.      */
  151.     function getStyleSheet($content = true)
  152.     {
  153.         if ($content) {
  154.             $styles = file_get_contents($this->css);
  155.         } else {
  156.             $styles = $this->css;
  157.         }
  158.         return $styles;
  159.     }
  160.  
  161.     /**
  162.      * Set the custom style sheet to use your own styles
  163.      *
  164.      * @param string $css (optional) File to read user-defined styles from
  165.      *
  166.      * @return bool    true if custom styles, false if default styles applied
  167.      * @access public
  168.      * @since  version 2.1.0 (2006-08-12)
  169.      */
  170.     function setStyleSheet($css = null)
  171.     {
  172.         // default stylesheet is into package data directory
  173.         if (!isset($css)) {
  174.             $this->css = 'C:\php5\pear\data' . DIRECTORY_SEPARATOR
  175.                  . 'HTML_Progress2' . DIRECTORY_SEPARATOR
  176.                  . 'tableless.css';
  177.         }
  178.  
  179.         $res = isset($css) && file_exists($css);
  180.         if ($res) {
  181.             $this->css = $css;
  182.         }
  183.         return $res;
  184.     }
  185. }
  186. ?>