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 / model.php < prev    next >
Encoding:
PHP Script  |  2008-07-02  |  4.3 KB  |  122 lines

  1. <?php
  2. /**
  3.  * The HTML_Progress_Model class provides an easy way to set look and feel
  4.  * of a progress bar with external config file.
  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: model.php,v 1.5 2005/07/25 13:02:33 farell Exp $
  21.  * @link       http://pear.php.net/package/HTML_Progress
  22.  */
  23.  
  24. require_once 'Config.php';
  25.  
  26. /**
  27.  * The HTML_Progress_Model class provides an easy way to set look and feel
  28.  * of a progress bar with external config file.
  29.  *
  30.  * PHP versions 4 and 5
  31.  *
  32.  * LICENSE: This source file is subject to version 3.0 of the PHP license
  33.  * that is available through the world-wide-web at the following URI:
  34.  * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
  35.  * the PHP License and are unable to obtain it through the web, please
  36.  * send a note to license@php.net so we can mail you a copy immediately.
  37.  *
  38.  * @category   HTML
  39.  * @package    HTML_Progress
  40.  * @subpackage Progress_UI
  41.  * @author     Laurent Laville <pear@laurent-laville.org>
  42.  * @copyright  1997-2005 The PHP Group
  43.  * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
  44.  * @version    Release: @package_version@
  45.  * @link       http://pear.php.net/package/HTML_Progress
  46.  */
  47.  
  48. class HTML_Progress_Model extends HTML_Progress_UI
  49. {
  50.     /**
  51.      * Package name used by PEAR_ErrorStack functions
  52.      *
  53.      * @var        string
  54.      * @since      1.0
  55.      * @access     private
  56.      */
  57.     var $_package;
  58.  
  59.  
  60.     /**
  61.      * The progress bar's UI extended model class constructor
  62.      *
  63.      * @param      string    $file          file name of model properties
  64.      * @param      string    $type          type of external ressource (phpArray, iniFile, XML ...)
  65.      *
  66.      * @since      1.0
  67.      * @access     public
  68.      * @throws     HTML_PROGRESS_ERROR_INVALID_INPUT
  69.      */
  70.     function HTML_Progress_Model($file, $type)
  71.     {
  72.         $this->_package = 'HTML_Progress';
  73.  
  74.         if (!file_exists($file)) {
  75.             return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error',
  76.                 array('var' => '$file',
  77.                       'was' => $file,
  78.                       'expected' => 'file exists',
  79.                       'paramnum' => 1));
  80.         }
  81.  
  82.         $conf = new Config();
  83.  
  84.         if (!$conf->isConfigTypeRegistered($type)) {
  85.             return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error',
  86.                 array('var' => '$type',
  87.                       'was' => $type,
  88.                       'expected' => implode (" | ", array_keys($GLOBALS['CONFIG_TYPES'])),
  89.                       'paramnum' => 2));
  90.         }
  91.  
  92.         $data = $conf->parseConfig($file, $type);
  93.  
  94.         $structure = $data->toArray(false);
  95.         $this->_progress =& $structure['root'];
  96.  
  97.         if (is_array($this->_progress['cell']['font-family'])) {
  98.             $this->_progress['cell']['font-family'] = implode(",", $this->_progress['cell']['font-family']);
  99.         }
  100.         if (is_array($this->_progress['string']['font-family'])) {
  101.             $this->_progress['string']['font-family'] = implode(",", $this->_progress['string']['font-family']);
  102.         }
  103.         $this->_orientation = $this->_progress['orientation']['shape'];
  104.         $this->_fillWay = $this->_progress['orientation']['fillway'];
  105.  
  106.         if (isset($this->_progress['script']['file'])) {
  107.             $this->_script = $this->_progress['script']['file'];
  108.         } else {
  109.             $this->_script = null;
  110.         }
  111.  
  112.         if (isset($this->_progress['cell']['count'])) {
  113.             $this->_cellCount = $this->_progress['cell']['count'];
  114.         } else {
  115.             $this->_cellCount = 10;
  116.         }
  117.  
  118.         $this->_updateProgressSize();
  119.     }
  120. }
  121.  
  122. ?>