$allLocalesAvailable = true;
foreach (getLocales() as $localeId => $locale) {
    if ($locale['display']) {
        // checking if this locale exists in the system. The only way of doing it is to try and set one
        // trying to set only the LC_MONETARY locale to avoid changing LC_NUMERIC
        $localeExists = setlocale(LC_MONETARY, zbx_locale_variants($localeId)) || $localeId == 'en_GB';
        $languageComboBox->addItem($localeId, $locale['name'], $localeId == $this->data['lang'] ? true : null, $localeExists);
        $allLocalesAvailable &= $localeExists;
    }
}
// restoring original locale
setlocale(LC_MONETARY, zbx_locale_variants(CWebUser::$data['lang']));
$languageError = '';
if (!function_exists('bindtextdomain')) {
    $languageError = 'Translations are unavailable because the PHP gettext module is missing.';
    $languageComboBox->attr('disabled', 'disabled');
} elseif (!$allLocalesAvailable) {
    $languageError = _('You are not able to choose some of the languages, because locales for them are not installed on the web server.');
}
$userFormList->addRow(_('Language'), $languageError ? array($languageComboBox, SPACE, new CSpan($languageError, 'red wrap')) : $languageComboBox);
// append themes to form list
$themes = array_merge(array(THEME_DEFAULT => _('System default')), Z::getThemes());
$themeComboBox = new CComboBox('theme', $this->data['theme'], null, $themes);
$userFormList->addRow(_('Theme'), $themeComboBox);
// append auto-login & auto-logout to form list
$autologoutCheckBox = new CCheckBox('autologout_visible', isset($this->data['autologout']) ? 'yes' : 'no');
if (isset($this->data['autologout'])) {
    $autologoutTextBox = new CNumericBox('autologout', $this->data['autologout'], 4);
} else {
    $autologoutTextBox = new CNumericBox('autologout', 900, 4);
    $autologoutTextBox->setAttribute('disabled', 'disabled');
         }
         if (!isset($opcondition['value'])) {
             $opcondition['value'] = 0;
         }
         if (!str_in_array($opcondition['conditiontype'], $allowed_opconditions)) {
             continue;
         }
         $label = num2letter($i);
         $labelCol = new CCol($label, 'label');
         $labelCol->setAttribute('data-conditiontype', $opcondition['conditiontype']);
         $labelCol->setAttribute('data-formulaid', $label);
         $operationConditionsTable->addRow(array($labelCol, get_condition_desc($opcondition['conditiontype'], $opcondition['operator'], $opcondition['value']), array(new CButton('remove', _('Remove'), 'javascript: removeOperationCondition(' . $i . ');', 'link_menu'), new CVar('new_operation[opconditions][' . $i . '][conditiontype]', $opcondition['conditiontype']), new CVar('new_operation[opconditions][' . $i . '][operator]', $opcondition['operator']), new CVar('new_operation[opconditions][' . $i . '][value]', $opcondition['value']))), null, 'opconditions_' . $i);
         $i++;
     }
     $calcTypeComboBox = new CComboBox('new_operation[evaltype]', $this->data['new_operation']['evaltype'], 'submit()');
     $calcTypeComboBox->attr('id', 'operationEvaltype');
     $calcTypeComboBox->addItem(CONDITION_EVAL_TYPE_AND_OR, _('And/Or'));
     $calcTypeComboBox->addItem(CONDITION_EVAL_TYPE_AND, _('And'));
     $calcTypeComboBox->addItem(CONDITION_EVAL_TYPE_OR, _('Or'));
     $newOperationsTable->addRow(array(_('Type of calculation'), array($calcTypeComboBox, new CSpan('', null, 'operationConditionLabel'))), null, 'operationConditionRow');
     if (!isset($_REQUEST['new_opcondition'])) {
         $operationConditionsTable->addRow(new CCol(new CSubmit('new_opcondition', _('New'), null, 'link_menu')));
     }
     $newOperationsTable->addRow(array(_('Conditions'), new CDiv($operationConditionsTable, 'objectgroup inlineblock border_dotted ui-corner-all')), 'indent_top');
 }
 // append new operation condition to form list
 if (isset($_REQUEST['new_opcondition'])) {
     $newOperationConditionTable = new CTable(null, 'formElementTable');
     $allowedOpConditions = get_opconditions_by_eventsource($this->data['eventsource']);
     $new_opcondition = getRequest('new_opcondition', array());
     if (!is_array($new_opcondition)) {
 /**
  * Process screen.
  *
  * @return CDiv (screen inside container)
  */
 public function get()
 {
     $params = array('groupids' => null, 'hostids' => null, 'screenid' => $this->screenid, 'maintenance' => null, 'severity' => null, 'limit' => $this->screenitem['elements'], 'backUrl' => $this->pageFile);
     // by default triggers are sorted by date desc, do we need to override this?
     switch ($this->screenitem['sort_triggers']) {
         case SCREEN_SORT_TRIGGERS_SEVERITY_DESC:
             $params['sortfield'] = 'priority';
             $params['sortorder'] = ZBX_SORT_DOWN;
             break;
         case SCREEN_SORT_TRIGGERS_HOST_NAME_ASC:
             // a little black magic here - there is no such field 'hostname' in 'triggers',
             // but API has a special case for sorting by hostname
             $params['sortfield'] = 'hostname';
             $params['sortorder'] = ZBX_SORT_UP;
             break;
     }
     if ($this->screenitem['resourceid'] > 0) {
         $hosts = API::Host()->get(array('hostids' => $this->screenitem['resourceid'], 'output' => API_OUTPUT_EXTEND));
         $host = reset($hosts);
         $item = new CSpan(_('Host') . ': ' . $host['host'], 'white');
         $params['hostids'] = $host['hostid'];
     } else {
         $groupid = get_request('tr_groupid', CProfile::get('web.screens.tr_groupid', 0));
         $hostid = get_request('tr_hostid', CProfile::get('web.screens.tr_hostid', 0));
         CProfile::update('web.screens.tr_groupid', $groupid, PROFILE_TYPE_ID);
         CProfile::update('web.screens.tr_hostid', $hostid, PROFILE_TYPE_ID);
         // get groups
         $groups = API::HostGroup()->get(array('monitored_hosts' => true, 'output' => API_OUTPUT_EXTEND));
         order_result($groups, 'name');
         // get hsots
         $options = array('monitored_hosts' => true, 'output' => API_OUTPUT_EXTEND);
         if ($groupid > 0) {
             $options['groupids'] = $groupid;
         }
         $hosts = API::Host()->get($options);
         $hosts = zbx_toHash($hosts, 'hostid');
         order_result($hosts, 'host');
         if (!isset($hosts[$hostid])) {
             $hostid = 0;
         }
         if ($groupid > 0) {
             $params['groupids'] = $groupid;
         }
         if ($hostid > 0) {
             $params['hostids'] = $hostid;
         }
         $item = new CForm(null, $this->pageFile);
         $groupComboBox = new CComboBox('tr_groupid', $groupid, 'submit()');
         $groupComboBox->addItem(0, _('all'));
         foreach ($groups as $group) {
             $groupComboBox->addItem($group['groupid'], get_node_name_by_elid($group['groupid'], null, ': ') . $group['name']);
         }
         $hostsComboBox = new CComboBox('tr_hostid', $hostid, 'submit()');
         $hostsComboBox->addItem(0, _('all'));
         foreach ($hosts as $host) {
             $hostsComboBox->addItem($host['hostid'], get_node_name_by_elid($host['hostid'], null, ': ') . $host['host']);
         }
         if ($this->mode == SCREEN_MODE_EDIT) {
             $groupComboBox->attr('disabled', 'disabled');
             $hostsComboBox->attr('disabled', 'disabled');
         }
         $item->addItem(array(_('Group') . SPACE, $groupComboBox));
         $item->addItem(array(SPACE . _('Host') . SPACE, $hostsComboBox));
     }
     $output = new CUIWidget('hat_trstatus', make_latest_issues($params));
     $output->setDoubleHeader(array(_('STATUS OF TRIGGERS'), SPACE, zbx_date2str(_('[H:i:s]')), SPACE), $item);
     return $this->getOutput($output);
 }