generator.php
来自「视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.」· PHP 代码 · 共 561 行 · 第 1/2 页
PHP
561 行
* @throws HTML_PROGRESS_ERROR_INVALID_INPUT
*/
function createButtons(&$page, $buttons, $attributes = null)
{
if (!is_a($page, 'HTML_QuickForm_Page')) {
return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception',
array('var' => '$page',
'was' => gettype($page),
'expected' => 'HTML_QuickForm_Page object',
'paramnum' => 1));
} elseif (!is_array($buttons)) {
return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception',
array('var' => '$buttons',
'was' => gettype($buttons),
'expected' => 'array',
'paramnum' => 2));
} elseif (!is_array($attributes) && !is_string($attributes) && !is_null($attributes)) {
return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception',
array('var' => '$attributes',
'was' => gettype($attributes),
'expected' => 'array | string',
'paramnum' => 3));
}
$confirm = $attributes = HTML_Common::_parseAttributes($attributes);
$confirm['onClick'] = "return(confirm('Are you sure ?'));";
$prevnext = array();
foreach ($buttons as $event => $label) {
if ($event == 'cancel') {
$type = 'submit';
$attrs = $confirm;
} elseif ($event == 'reset') {
$type = 'reset';
$attrs = $confirm;
} else {
$type = 'submit';
$attrs = $attributes;
}
$prevnext[] =& $page->createElement($type, $page->getButtonName($event), $label, HTML_Common::_getAttrString($attrs));
}
$page->addGroup($prevnext, 'buttons', '', ' ', false);
}
/**
* Enables certain buttons for a page.
*
* Buttons [ = events] : back, next, cancel, reset, apply, help
*
* @param object $page Page where you want to activate buttons
* @param array $events (optional) List of buttons
*
* @since 1.1
* @access public
* @throws HTML_PROGRESS_ERROR_INVALID_INPUT
* @see disableButton()
*/
function enableButton(&$page, $events = array())
{
if (!is_a($page, 'HTML_QuickForm_Page')) {
return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception',
array('var' => '$page',
'was' => gettype($page),
'expected' => 'HTML_QuickForm_Page object',
'paramnum' => 1));
} elseif (!is_array($events)) {
return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception',
array('var' => '$events',
'was' => gettype($events),
'expected' => 'array',
'paramnum' => 2));
}
static $all;
if (!isset($all)) {
$all = array('back','next','cancel','reset','apply','help');
}
$buttons = (count($events) == 0) ? $all : $events;
foreach ($buttons as $event) {
$group =& $page->getElement('buttons');
$elements =& $group->getElements();
foreach (array_keys($elements) as $key) {
if ($group->getElementName($key) == $page->getButtonName($event)) {
$elements[$key]->updateAttributes(array('disabled'=>'false'));
}
}
}
}
/**
* Disables certain buttons for a page.
*
* Buttons [ = events] : back, next, cancel, reset, apply, help
*
* @param object $page Page where you want to activate buttons
* @param array $events (optional) List of buttons
*
* @since 1.1
* @access public
* @throws HTML_PROGRESS_ERROR_INVALID_INPUT
* @see enableButton()
*/
function disableButton(&$page, $events = array())
{
if (!is_a($page, 'HTML_QuickForm_Page')) {
return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception',
array('var' => '$page',
'was' => gettype($page),
'expected' => 'HTML_QuickForm_Page object',
'paramnum' => 1));
} elseif (!is_array($events)) {
return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception',
array('var' => '$events',
'was' => gettype($events),
'expected' => 'array',
'paramnum' => 2));
}
static $all;
if (!isset($all)) {
$all = array('back','next','cancel','reset','apply','help');
}
$buttons = (count($events) == 0) ? $all : $events;
foreach ($buttons as $event) {
$group =& $page->getElement('buttons');
$elements =& $group->getElements();
foreach (array_keys($elements) as $key) {
if ($group->getElementName($key) == $page->getButtonName($event)) {
$elements[$key]->updateAttributes(array('disabled'=>'true'));
}
}
}
}
/**
* Creates a progress bar with options choosen on all wizard tabs.
*
* @return object HTML_Progress instance
* @since 1.1
* @access public
*/
function createProgressBar()
{
$progress = $this->exportValues();
$this->_progress->setIdent('PB1');
$this->_progress->setAnimSpeed(intval($progress['rAnimSpeed']));
if ($progress['model'] != '') {
$this->_progress->setModel($progress['model'], 'iniCommented');
$this->_progress->setIncrement(10);
$ui =& $this->_progress->getUI();
} else {
$this->_progress->setBorderPainted(($progress['borderpainted'] == '1'));
$this->_progress->setStringPainted(($progress['stringpainted'] == '1'));
$ui =& $this->_progress->getUI();
$structure = array();
/* Page 1: Progress attributes **************************************************/
if (strlen(trim($progress['progressclass'])) > 0) {
$structure['progress']['class'] = $progress['progressclass'];
}
if (strlen(trim($progress['progresssize']['bgcolor'])) > 0) {
$structure['progress']['background-color'] = $progress['progresssize']['bgcolor'];
}
if (strlen(trim($progress['progresssize']['width'])) > 0) {
$structure['progress']['width'] = $progress['progresssize']['width'];
}
if (strlen(trim($progress['progresssize']['height'])) > 0) {
$structure['progress']['height'] = $progress['progresssize']['height'];
}
$structure['progress']['auto-size'] = ($progress['autosize'] == '1');
$ui->setProgressAttributes($structure['progress']);
$orient = ($progress['shape'] == '1') ? HTML_PROGRESS_BAR_HORIZONTAL : HTML_PROGRESS_BAR_VERTICAL;
$ui->setOrientation($orient);
$ui->setFillWay($progress['way']);
/* Page 2: Cell attributes ******************************************************/
if (strlen(trim($progress['cellid'])) > 0) {
$structure['cell']['id'] = $progress['cellid'];
}
if (strlen(trim($progress['cellclass'])) > 0) {
$structure['cell']['class'] = $progress['cellclass'];
}
if (strlen(trim($progress['cellvalue']['min'])) > 0) {
$this->_progress->setMinimum(intval($progress['cellvalue']['min']));
}
if (strlen(trim($progress['cellvalue']['max'])) > 0) {
$this->_progress->setMaximum(intval($progress['cellvalue']['max']));
}
if (strlen(trim($progress['cellvalue']['inc'])) > 0) {
$this->_progress->setIncrement(intval($progress['cellvalue']['inc']));
}
if (strlen(trim($progress['cellsize']['width'])) > 0) {
$structure['cell']['width'] = $progress['cellsize']['width'];
}
if (strlen(trim($progress['cellsize']['height'])) > 0) {
$structure['cell']['height'] = $progress['cellsize']['height'];
}
if (strlen(trim($progress['cellsize']['spacing'])) > 0) {
$structure['cell']['spacing'] = $progress['cellsize']['spacing'];
}
if (strlen(trim($progress['cellsize']['count'])) > 0) {
$ui->setCellCount(intval($progress['cellsize']['count']));
}
if (strlen(trim($progress['cellcolor']['active'])) > 0) {
$structure['cell']['active-color'] = $progress['cellcolor']['active'];
}
if (strlen(trim($progress['cellcolor']['inactive'])) > 0) {
$structure['cell']['inactive-color'] = $progress['cellcolor']['inactive'];
}
if (strlen(trim($progress['cellfont']['family'])) > 0) {
$structure['cell']['font-family'] = $progress['cellfont']['family'];
}
if (strlen(trim($progress['cellfont']['size'])) > 0) {
$structure['cell']['font-size'] = $progress['cellfont']['size'];
}
if (strlen(trim($progress['cellfont']['color'])) > 0) {
$structure['cell']['color'] = $progress['cellfont']['color'];
}
$ui->setCellAttributes($structure['cell']);
/* Page 3: Border attributes ****************************************************/
if (strlen(trim($progress['borderclass'])) > 0) {
$structure['border']['class'] = $progress['borderclass'];
}
if (strlen(trim($progress['borderstyle']['width'])) > 0) {
$structure['border']['width'] = $progress['borderstyle']['width'];
}
if (strlen(trim($progress['borderstyle']['style'])) > 0) {
$structure['border']['style'] = $progress['borderstyle']['style'];
}
if (strlen(trim($progress['borderstyle']['color'])) > 0) {
$structure['border']['color'] = $progress['borderstyle']['color'];
}
$ui->setBorderAttributes($structure['border']);
/* Page 4: String attributes ****************************************************/
if (strlen(trim($progress['stringid'])) > 0) {
$structure['string']['id'] = $progress['stringid'];
}
if (strlen(trim($progress['stringsize']['width'])) > 0) {
$structure['string']['width'] = $progress['stringsize']['width'];
}
if (strlen(trim($progress['stringsize']['height'])) > 0) {
$structure['string']['height'] = $progress['stringsize']['height'];
}
if (strlen(trim($progress['stringsize']['bgcolor'])) > 0) {
$structure['string']['background-color'] = $progress['stringsize']['bgcolor'];
}
if (strlen(trim($progress['stringalign'])) > 0) {
$structure['string']['align'] = $progress['stringalign'];
}
if (strlen(trim($progress['stringvalign'])) > 0) {
$structure['string']['valign'] = $progress['stringvalign'];
}
if (strlen(trim($progress['stringfont']['family'])) > 0) {
$structure['string']['font-family'] = $progress['stringfont']['family'];
}
if (strlen(trim($progress['stringfont']['size'])) > 0) {
$structure['string']['font-size'] = $progress['stringfont']['size'];
}
if (strlen(trim($progress['stringfont']['color'])) > 0) {
$structure['string']['color'] = $progress['stringfont']['color'];
}
$ui->setStringAttributes($structure['string']);
} // end-if-no-model
return $this->_progress;
}
}
?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?