/** * The progress bar's UI extended model class constructor * * @param string $file file name of model properties * @param string $type type of external ressource (phpArray, iniFile, XML ...) * * @since 1.0 * @access public * @throws HTML_PROGRESS_ERROR_INVALID_INPUT */ function HTML_Progress_Model($file, $type) { $this->_package = 'HTML_Progress'; if (!file_exists($file)) { return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error', array('var' => '$file', 'was' => $file, 'expected' => 'file exists', 'paramnum' => 1)); } $conf = new Config(); if (!$conf->isConfigTypeRegistered($type)) { return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error', array('var' => '$type', 'was' => $type, 'expected' => implode(" | ", array_keys($GLOBALS['CONFIG_TYPES'])), 'paramnum' => 2)); } $data = $conf->parseConfig($file, $type); $structure = $data->toArray(false); $this->_progress =& $structure['root']; if (is_array($this->_progress['cell']['font-family'])) { $this->_progress['cell']['font-family'] = implode(",", $this->_progress['cell']['font-family']); } if (is_array($this->_progress['string']['font-family'])) { $this->_progress['string']['font-family'] = implode(",", $this->_progress['string']['font-family']); } $this->_orientation = $this->_progress['orientation']['shape']; $this->_fillWay = $this->_progress['orientation']['fillway']; if (isset($this->_progress['script']['file'])) { $this->_script = $this->_progress['script']['file']; } else { $this->_script = null; } if (isset($this->_progress['cell']['count'])) { $this->_cellCount = $this->_progress['cell']['count']; } else { $this->_cellCount = 10; } $this->_updateProgressSize(); }
/** * Register a new container * * @param string $configType Type of config * @param array|false $configInfo Array of format: * array('path/to/Name.php', * 'Config_Container_Class_Name'). * * If left false, defaults to: * array('Config/Container/$configType.php', * 'Config_Container_$configType') * @access public * @static * @author Greg Beaver <*****@*****.**> * @return true|PEAR_Error true on success */ function registerConfigType($configType, $configInfo = false) { if (Config::isConfigTypeRegistered($configType)) { $info = $GLOBALS['CONFIG_TYPES'][strtolower($configType)]; if ($info[0] == $configInfo[0] && $info[1] == $configInfo[1]) { return true; } else { return PEAR::raiseError("Config::registerConfigType registration of existing {$configType} failed.", null, PEAR_ERROR_RETURN); } } if (!is_array($configInfo)) { // make the normal assumption, that this is a standard config container added in at runtime $configInfo = array('Config/Container/' . $configType . '.php', 'Config_Container_' . $configType); } $file_exists = @(include_once $configInfo[0]); if ($file_exists) { if (!class_exists($configInfo[1])) { return PEAR::raiseError("Config::registerConfigType class '{$configInfo['1']}' not found in {$configInfo['0']}", null, PEAR_ERROR_RETURN); } } else { return PEAR::raiseError("Config::registerConfigType file {$configInfo['0']} not found", null, PEAR_ERROR_RETURN); } $GLOBALS['CONFIG_TYPES'][strtolower($configType)] = $configInfo; return true; }
/** * Sets the look-and-feel model that renders the progress bar. * * @param string $file file name of model properties * @param string $type type of external ressource (phpArray, iniFile, XML ...) * * @return void * @since 1.0 * @access public * @throws HTML_PROGRESS_ERROR_INVALID_INPUT * @see setUI() */ function setModel($file, $type) { if (!file_exists($file)) { return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error', array('var' => '$file', 'was' => $file, 'expected' => 'file exists', 'paramnum' => 1)); } include_once 'Config.php'; $conf = new Config(); if (!$conf->isConfigTypeRegistered($type)) { return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error', array('var' => '$type', 'was' => $type, 'expected' => implode(" | ", array_keys($GLOBALS['CONFIG_TYPES'])), 'paramnum' => 2)); } $data = $conf->parseConfig($file, $type); $structure = $data->toArray(false); $progress = $structure['root']; $ui = new HTML_Progress_UI(); if (isset($progress['core']['speed'])) { $this->setAnimSpeed(intval($progress['core']['speed'])); } if (isset($progress['core']['indeterminate'])) { $mode = strtolower(trim($progress['core']['indeterminate'])) == 'true'; $this->setIndeterminate($mode); } if (isset($progress['core']['increment'])) { $this->setIncrement(intval($progress['core']['increment'])); } if (isset($progress['core']['javascript']) && file_exists($progress['core']['javascript'])) { $ui->setScript($progress['core']['javascript']); } if (isset($progress['orientation']['shape'])) { $ui->setOrientation(intval($progress['orientation']['shape'])); } if (isset($progress['orientation']['fillway'])) { $ui->setFillWay($progress['orientation']['fillway']); } if (isset($progress['cell']['count'])) { $ui->setCellCount(intval($progress['cell']['count'])); } if (isset($progress['cell']['font-family'])) { if (is_array($progress['cell']['font-family'])) { $progress['cell']['font-family'] = implode(",", $progress['cell']['font-family']); } } if (isset($progress['cell'])) { $ui->setCellAttributes($progress['cell']); } if (isset($progress['border'])) { $this->setBorderPainted(true); $ui->setBorderAttributes($progress['border']); } if (isset($progress['string']['font-family'])) { if (is_array($progress['string']['font-family'])) { $progress['string']['font-family'] = implode(",", $progress['string']['font-family']); } } if (isset($progress['string'])) { $this->setStringPainted(true); $ui->setStringAttributes($progress['string']); } if (isset($progress['progress'])) { $ui->setProgressAttributes($progress['progress']); } $this->_UI = $ui; }