tag_body_start = ''; $this->options['type'] = 'checkbox'; $this->options['value'] = $value; $this->options['name'] = $name; $this->options['onClick'] = $action; $this->SetChecked($checked); } function SetEnabled($value='yes') { if($value=='yes' || $value == true || $value === 1) return $this->DelOption('disabled'); return $this->options['disabled'] = 'disabled'; } function SetChecked($value="yes") { if((is_string($value)&& ($value=="yes" || $value=="checked" || $value=="on") || $value=="1") || (is_int($value)&&$value<>0)) return $this->options['checked'] = 'checked'; $this->DelOption("checked"); } function SetAction($value='submit()', $event='onClick') { $this->options[$event] = $value; } } class CVisibilityBox extends CCheckBox { function CVisibilityBox($name='visibilitybox', $value='yes', $object_name=null, $replace_to=null) { $action = ''; if(!is_array($object_name)) $object_name = array($object_name); $this->object_name = $object_name; $this->replace_to = unpack_object($replace_to); foreach($this->object_name as $obj_name) { if(empty($obj_name)) continue; $action .= 'visibility_status_changeds(this.checked, \''.$obj_name.'\','. ' \''.zbx_jsstr($this->replace_to).'\'); '; } parent::CCheckBox($name, $value, $action, '1'); $this->ShowJavascript(); } function ToString($destroy=true) { global $ZBX_PAGE_POST_JS; if(!isset($this->options['checked'])) { foreach($this->object_name as $obj_name) { if(empty($obj_name)) continue; zbx_add_post_js('visibility_status_changeds(false, "'.$obj_name.'", "'. zbx_jsstr($this->replace_to).'");'); } } return parent::ToString($destroy); } function ShowJavascript() { if(defined('CVISIBILITYBOX_JAVASCRIPT_INSERTED')) return; define('CVISIBILITYBOX_JAVASCRIPT_INSERTED', 1); ?>