public function addItem($value, $caption = '', $selected = null, $enabled = 'yes') { if ($value instanceof CComboItem || $value instanceof COptGroup) { parent::addItem($value); } else { $title = false; // if caption is too long ( > 44 symbols), we add new class - 'selectShorten', // so that the select box would not stretch if (zbx_strlen($caption) > 44 && !$this->hasClass('selectShorten')) { $this->setAttribute('class', $this->getAttribute('class') . ' selectShorten'); $title = true; } if (is_null($selected)) { $selected = 'no'; if (is_array($this->value)) { if (str_in_array($value, $this->value)) { $selected = 'yes'; } } elseif (strcmp($value, $this->value) == 0) { $selected = 'yes'; } } else { $selected = 'yes'; } $citem = new CComboItem($value, $caption, $selected, $enabled); if ($title) { $citem->setTitle($caption); } parent::addItem($citem); } }