dm.php
来自「视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.」· PHP 代码 · 共 511 行 · 第 1/2 页
PHP
511 行
/**
* Sets the progress bar's minimum value.
*
* @param integer $min progress bar's minimal value
*
* @return void
* @since 1.0
* @access public
* @throws HTML_PROGRESS_ERROR_INVALID_INPUT
* @see getMinimum()
* @tutorial dm.setminimum.pkg
*/
function setMinimum($min)
{
if (!is_int($min)) {
return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception',
array('var' => '$min',
'was' => gettype($min),
'expected' => 'integer',
'paramnum' => 1));
} elseif ($min < 0) {
return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error',
array('var' => '$min',
'was' => $min,
'expected' => 'positive',
'paramnum' => 1));
} elseif ($min > $this->getMaximum()) {
return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error',
array('var' => '$min',
'was' => $min,
'expected' => 'less than $max = '.$this->getMaximum(),
'paramnum' => 1));
}
$this->_minimum = $min;
/* set current value to minimum if less than minimum */
if ($this->getValue() < $min) {
$this->setValue($min);
}
}
/**
* Returns the progress bar's maximum value. The default value is 100.
*
* @return integer
* @since 1.0
* @access public
* @see setMaximum()
* @tutorial dm.getmaximum.pkg
*/
function getMaximum()
{
return $this->_maximum;
}
/**
* Sets the progress bar's maximum value.
*
* @param integer $max progress bar's maximal value
*
* @return void
* @since 1.0
* @access public
* @throws HTML_PROGRESS_ERROR_INVALID_INPUT
* @see getMaximum()
* @tutorial dm.setmaximum.pkg
*/
function setMaximum($max)
{
if (!is_int($max)) {
return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception',
array('var' => '$max',
'was' => gettype($max),
'expected' => 'integer',
'paramnum' => 1));
} elseif ($max < 0) {
return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error',
array('var' => '$max',
'was' => $max,
'expected' => 'positive',
'paramnum' => 1));
} elseif ($max < $this->getMinimum()) {
return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error',
array('var' => '$max',
'was' => $max,
'expected' => 'greater than $min = '.$this->getMinimum(),
'paramnum' => 1));
}
$this->_maximum = $max;
/* set current value to maximum if greater to maximum */
if ($this->getValue() > $max) {
$this->setValue($max);
}
}
/**
* Returns the progress bar's increment value. The default value is +1.
*
* @return integer
* @since 1.0
* @access public
* @see setIncrement()
* @tutorial dm.getincrement.pkg
*/
function getIncrement()
{
return $this->_increment;
}
/**
* Sets the progress bar's increment value.
*
* @param integer $inc progress bar's increment value
*
* @return void
* @since 1.0
* @access public
* @throws HTML_PROGRESS_ERROR_INVALID_INPUT
* @see getIncrement()
* @tutorial dm.setincrement.pkg
*/
function setIncrement($inc)
{
if (!is_int($inc)) {
return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception',
array('var' => '$inc',
'was' => gettype($inc),
'expected' => 'integer',
'paramnum' => 1));
} elseif ($inc == 0) {
return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error',
array('var' => '$inc',
'was' => $inc,
'expected' => 'not equal zero',
'paramnum' => 1));
}
$this->_increment = $inc;
}
/**
* Returns the progress bar's current value. The value is always between
* the minimum and maximum values, inclusive.
* By default, the value is initialized with the minimum value.
*
* @return integer
* @since 1.0
* @access public
* @see setValue()
* @tutorial dm.getvalue.pkg
*/
function getValue()
{
return $this->_value;
}
/**
* Sets the progress bar's current value.
* If the new value is different from previous value, all change listeners
* are notified.
*
* @param integer $val progress bar's current value
*
* @return void
* @since 1.0
* @access public
* @throws HTML_PROGRESS_ERROR_INVALID_INPUT
* @see getValue()
* @tutorial dm.setvalue.pkg
*/
function setValue($val)
{
if (!is_int($val)) {
return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception',
array('var' => '$val',
'was' => gettype($val),
'expected' => 'integer',
'paramnum' => 1));
} elseif ($val < $this->getMinimum()) {
return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error',
array('var' => '$val',
'was' => $val,
'expected' => 'greater than $min = '.$this->getMinimum(),
'paramnum' => 1));
} elseif ($val > $this->getMaximum()) {
return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error',
array('var' => '$val',
'was' => $val,
'expected' => 'less than $max = '.$this->getMaximum(),
'paramnum' => 1));
}
$this->_value = $val;
}
/**
* Updates the progress bar's current value by adding increment value.
*
* @return void
* @since 1.0
* @access public
* @see getValue(), setValue()
* @tutorial dm.incvalue.pkg
*/
function incValue()
{
$newVal = $this->getValue() + $this->getIncrement();
$newVal = min($this->getMaximum(), $newVal);
$this->setValue( $newVal );
}
/**
* Returns the percent complete for the progress bar. Note that this number is
* between 0.00 and 1.00 or 0 and 100.
*
* @param boolean $float (optional) float or integer format
*
* @return mixed
* @since 1.0
* @access public
* @throws HTML_PROGRESS2_ERROR_INVALID_INPUT
* @see getValue(), getMaximum()
* @tutorial dm.getpercentcomplete.pkg
*/
function getPercentComplete($float = true)
{
if (!is_bool($float)) {
return HTML_Progress::raiseError(HTML_PROGRESS2_ERROR_INVALID_INPUT, 'exception',
array('var' => '$float',
'was' => gettype($float),
'expected' => 'boolean',
'paramnum' => 1));
}
$min = $this->_minimum;
$max = $this->_maximum;
$val = $this->_value;
$percent = round((($val - $min) / ($max - $min)), 4);
if ($float) {
return $percent;
} else {
return intval($percent * 100);
}
}
}
?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?