2013-10-16 18:50:19 +02:00
|
|
|
<?php
|
|
|
|
// {{{ICINGA_LICENSE_HEADER}}}
|
|
|
|
// {{{ICINGA_LICENSE_HEADER}}}
|
|
|
|
|
2014-09-05 16:57:26 +02:00
|
|
|
use \Zend_View_Helper_FormElement;
|
2013-10-16 18:50:19 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper to generate a "datetime" element
|
|
|
|
*/
|
|
|
|
class Zend_View_Helper_FormTriStateCheckbox extends Zend_View_Helper_FormElement
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Generate a tri-state checkbox
|
|
|
|
*
|
|
|
|
* @param string $name The element name
|
|
|
|
* @param int $value The checkbox value
|
|
|
|
* @param array $attribs Attributes for the element tag
|
|
|
|
*
|
|
|
|
* @return string The element XHTML
|
2014-04-09 19:13:46 +02:00
|
|
|
*/
|
2013-10-16 18:50:19 +02:00
|
|
|
public function formTriStateCheckbox($name, $value = null, $attribs = null)
|
|
|
|
{
|
|
|
|
$class = "";
|
2014-04-16 19:43:56 +02:00
|
|
|
$xhtml = '<div class="tristate">'
|
2014-04-09 19:13:46 +02:00
|
|
|
. '<div>' . ($value == 1 ? ' ' : ($value === 'unchanged' ? ' ' : ' ' )) . '</div>'
|
2014-04-16 19:43:56 +02:00
|
|
|
|
2014-04-09 19:13:46 +02:00
|
|
|
. '<input class="' . $class . '" type="radio" value=1 name="'
|
|
|
|
. $name . '" ' . ($value == 1 ? 'checked' : '') . ' ">On</input> '
|
2014-04-16 19:43:56 +02:00
|
|
|
|
2014-04-09 19:13:46 +02:00
|
|
|
. '<input class="' . $class . '" type="radio" value=0 name="'
|
|
|
|
. $name . '" ' . ($value == 0 ? 'checked' : '') . ' ">Off</input> ';
|
2014-04-16 19:43:56 +02:00
|
|
|
|
2013-10-18 16:43:37 +02:00
|
|
|
if ($value === 'unchanged') {
|
|
|
|
$xhtml = $xhtml . '<input class="' . $class . '" type="radio" value="unchanged" name="'
|
2014-04-09 19:13:46 +02:00
|
|
|
. $name . '" ' . 'checked "> Undefined </input>';
|
2013-10-18 16:43:37 +02:00
|
|
|
};
|
|
|
|
return $xhtml . '</div>';
|
2013-10-16 18:50:19 +02:00
|
|
|
}
|
|
|
|
}
|