public function bodyToString()
 {
     $res = parent::bodyToString();
     $tbl = new CTable(null, $this->tableclass);
     $tbl->setCellSpacing(0);
     $tbl->setCellPadding(1);
     $tbl->setAlign($this->align);
     // add first row
     if (!is_null($this->title)) {
         $col = new CCol(null, 'form_row_first');
         $col->setColSpan(2);
         if (isset($this->help)) {
             $col->addItem($this->help);
         }
         if (isset($this->title)) {
             $col->addItem($this->title);
         }
         $tbl->setHeader($col);
     }
     // add last row
     $tbl->setFooter($this->bottom_items);
     // add center rows
     foreach ($this->center_items as $item) {
         $tbl->addRow($item);
     }
     return $res . $tbl->toString();
 }
$imageComboBoxForm->addItem($imageComboBox);
$this->data['widget']->addHeader(_('Images'), $imageComboBoxForm);
// form
$imageForm = new CForm();
$imageForm->setName('imageForm');
$imageForm->addItem(BR());
$imageTable = new CTable(_('No images found.'), 'header_wide padding_standard');
$count = 0;
$imageRow = new CRow();
foreach ($this->data['images'] as $image) {
    $img = $image['imagetype'] == IMAGE_TYPE_BACKGROUND ? new CLink(new CImg('imgstore.php?width=200&height=200&iconid=' . $image['imageid'], 'no image'), 'image.php?imageid=' . $image['imageid']) : new CImg('imgstore.php?iconid=' . $image['imageid'], 'no image');
    $nodeName = $this->data['displayNodes'] ? new CSpan($image['nodename'], 'unknown') : null;
    $name = new CLink($image['name'], 'adm.images.php?form=update&imageid=' . $image['imageid']);
    $imgColumn = new CCol();
    $imgColumn->setAttribute('align', 'center');
    $imgColumn->addItem(array($img, BR(), $nodeName, $name), 'center');
    $imageRow->addItem($imgColumn);
    $count++;
    if ($count % 4 == 0) {
        $imageTable->addRow($imageRow);
        $imageRow = new CRow();
    }
}
if ($count > 0) {
    while ($count % 4 != 0) {
        $imageRow->addItem(SPACE);
        $count++;
    }
    $imageTable->addRow($imageRow);
}
$imageForm->addItem($imageTable);
Exemple #3
0
 public function bodyToString()
 {
     parent::bodyToString();
     $tbl = new CTable(NULL, $this->tableclass);
     $tbl->setOddRowClass('form_odd_row');
     $tbl->setEvenRowClass('form_even_row');
     $tbl->setCellSpacing(0);
     $tbl->setCellPadding(1);
     $tbl->setAlign($this->align);
     // add first row
     $col = new CCol(NULL, 'form_row_first');
     $col->setColSpan(2);
     if (isset($this->help)) {
         $col->addItem($this->help);
     }
     if (isset($this->title)) {
         $col->addItem($this->title);
     }
     foreach ($this->top_items as $item) {
         $col->addItem($item);
     }
     $tbl->setHeader($col);
     // add last row
     $tbl->setFooter($this->bottom_items);
     // add center rows
     foreach ($this->center_items as $item) {
         $tbl->addRow($item);
     }
     return $tbl->toString();
 }
Exemple #4
0
 private function makeSImgStr($id)
 {
     $tr = new CRow();
     $count = isset($this->tree[$id]['nodeimg']) ? strlen($this->tree[$id]['nodeimg']) : 0;
     for ($i = 0; $i < $count; $i++) {
         $td = new CCol();
         $img = null;
         switch ($this->tree[$id]['nodeimg'][$i]) {
             case 'O':
                 $img = new CImg('images/general/tree/zero.gif', 'o', '22', '14');
                 break;
             case 'I':
                 $td->setAttribute('style', 'background-image: url(images/general/tree/pointc.gif);');
                 $img = new CImg('images/general/tree/zero.gif', 'i', '22', '14');
                 break;
             case 'L':
                 $td->setAttribute('valign', 'top');
                 $div = new CTag('div', 'yes');
                 $div->setAttribute('style', 'height: 10px; background-image: url(images/general/tree/pointc.gif);');
                 if ($this->tree[$id]['nodetype'] == 2) {
                     $img = new CImg('images/general/tree/plus.gif', 'y', '22', '14');
                     $img->setAttribute('onclick', $this->treename . '.closeSNodeX("' . $id . '", this);');
                     $img->setAttribute('id', 'idi_' . $id);
                     $img->setAttribute('class', 'pointer');
                 } else {
                     $img = new CImg('images/general/tree/pointl.gif', 'y', '22', '14');
                 }
                 $div->addItem($img);
                 $img = $div;
                 break;
             case 'T':
                 $td->setAttribute('valign', 'top');
                 if ($this->tree[$id]['nodetype'] == 2) {
                     $td->setAttribute('style', 'background-image: url(images/general/tree/pointc.gif);');
                     $img = new CImg('images/general/tree/plus.gif', 't', '22', '14');
                     $img->setAttribute('onclick', $this->treename . '.closeSNodeX("' . $id . '", this);');
                     $img->setAttribute('id', 'idi_' . $id);
                     $img->setAttribute('class', 'pointer');
                     $img->setAttribute('style', 'top: 1px; position: relative;');
                 } else {
                     $td->setAttribute('style', 'background-image: url(images/general/tree/pointc.gif);');
                     $img = new CImg('images/general/tree/pointl.gif', 't', '22', '14');
                 }
                 break;
         }
         $td->addItem($img);
         $tr->addItem($td);
     }
     return $tr;
 }
Exemple #5
0
function get_regexp_form()
{
    $frm_title = S_REGULAR_EXPRESSION;
    if (isset($_REQUEST['regexpid']) && !isset($_REQUEST["form_refresh"])) {
        $sql = 'SELECT re.* ' . ' FROM regexps re ' . ' WHERE ' . DBin_node('re.regexpid') . ' AND re.regexpid=' . $_REQUEST['regexpid'];
        $regexp = DBfetch(DBSelect($sql));
        $frm_title .= ' [' . $regexp['name'] . ']';
        $rename = $regexp['name'];
        $test_string = $regexp['test_string'];
        $expressions = array();
        $sql = 'SELECT e.* ' . ' FROM expressions e ' . ' WHERE ' . DBin_node('e.expressionid') . ' AND e.regexpid=' . $regexp['regexpid'] . ' ORDER BY e.expression_type';
        $db_exps = DBselect($sql);
        while ($exp = DBfetch($db_exps)) {
            $expressions[] = $exp;
        }
    } else {
        $rename = get_request('rename', '');
        $test_string = get_request('test_string', '');
        $expressions = get_request('expressions', array());
    }
    $tblRE = new CTable('', 'nowrap');
    $tblRE->addStyle('border-left: 1px #AAA solid; border-right: 1px #AAA solid; background-color: #EEE; padding: 2px; padding-left: 6px; padding-right: 6px;');
    $tblRE->addRow(array(S_NAME, new CTextBox('rename', $rename, 60)));
    $tblRE->addRow(array(S_TEST_STRING, new CTextArea('test_string', $test_string, 66, 5)));
    $tabExp = new CTableInfo();
    $td1 = new CCol(S_EXPRESSION);
    $td1->addStyle('background-color: #CCC;');
    $td2 = new CCol(S_EXPECTED_RESULT);
    $td2->addStyle('background-color: #CCC;');
    $td3 = new CCol(S_RESULT);
    $td3->addStyle('background-color: #CCC;');
    $tabExp->setHeader(array($td1, $td2, $td3));
    $final_result = !empty($test_string);
    foreach ($expressions as $id => $expression) {
        $results = array();
        $paterns = array($expression['expression']);
        if (!empty($test_string)) {
            if ($expression['expression_type'] == EXPRESSION_TYPE_ANY_INCLUDED) {
                $paterns = explode($expression['exp_delimiter'], $expression['expression']);
            }
            if (uint_in_array($expression['expression_type'], array(EXPRESSION_TYPE_TRUE, EXPRESSION_TYPE_FALSE))) {
                if ($expression['case_sensitive']) {
                    $results[$id] = ereg($paterns[0], $test_string);
                } else {
                    $results[$id] = eregi($paterns[0], $test_string);
                }
                if ($expression['expression_type'] == EXPRESSION_TYPE_TRUE) {
                    $final_result &= $results[$id];
                } else {
                    $final_result &= !$results[$id];
                }
            } else {
                $results[$id] = true;
                $tmp_result = false;
                if ($expression['case_sensitive']) {
                    foreach ($paterns as $pid => $patern) {
                        $tmp_result |= zbx_stristr($test_string, $patern) !== false;
                    }
                } else {
                    foreach ($paterns as $pid => $patern) {
                        $tmp_result |= zbx_strstr($test_string, $patern) !== false;
                    }
                }
                $results[$id] &= $tmp_result;
                $final_result &= $results[$id];
            }
        }
        if (isset($results[$id]) && $results[$id]) {
            $exp_res = new CSpan(S_TRUE_BIG, 'green bold');
        } else {
            $exp_res = new CSpan(S_FALSE_BIG, 'red bold');
        }
        $expec_result = expression_type2str($expression['expression_type']);
        if (EXPRESSION_TYPE_ANY_INCLUDED == $expression['expression_type']) {
            $expec_result .= ' (' . S_DELIMITER . "='" . $expression['exp_delimiter'] . "')";
        }
        $tabExp->addRow(array($expression['expression'], $expec_result, $exp_res));
    }
    $td = new CCol(S_COMBINED_RESULT, 'bold');
    $td->setColSpan(2);
    if ($final_result) {
        $final_result = new CSpan(S_TRUE_BIG, 'green bold');
    } else {
        $final_result = new CSpan(S_FALSE_BIG, 'red bold');
    }
    $tabExp->addRow(array($td, $final_result));
    $tblRE->addRow(array(S_RESULT, $tabExp));
    $tblFoot = new CTableInfo(null);
    $td = new CCol(array(new CButton('save', S_SAVE)));
    $td->setColSpan(2);
    $td->addStyle('text-align: right;');
    $td->addItem(SPACE);
    $td->addItem(new CButton('test', S_TEST));
    if (isset($_REQUEST['regexpid'])) {
        $td->addItem(SPACE);
        $td->addItem(new CButton('clone', S_CLONE));
        $td->addItem(SPACE);
        $td->addItem(new CButtonDelete(S_DELETE_REGULAR_EXPRESSION_Q, url_param('form') . url_param('config') . url_param('regexpid')));
    }
    $td->addItem(SPACE);
    $td->addItem(new CButtonCancel(url_param("regexpid")));
    $tblFoot->SetFooter($td);
    return array($tblRE, $tblFoot);
}
Exemple #6
0
 private function makeSImgStr($id)
 {
     $tr = new CRow();
     $td = new CCol();
     $count = isset($this->tree[$id]['nodeimg']) ? strlen($this->tree[$id]['nodeimg']) : 0;
     for ($i = 0; $i < $count; $i++) {
         switch ($this->tree[$id]['nodeimg'][$i]) {
             case 'O':
                 $td->setAttribute('style', 'width: 22px');
                 $img = new CImg('images/general/tree/zero.gif', 'o', '22', '14');
                 break;
             case 'I':
                 $td->setAttribute('style', 'width:22px; background-image:url(images/general/tree/pointc.gif);');
                 $img = new CImg('images/general/tree/zero.gif', 'i', '22', '14');
                 break;
             case 'L':
                 $td->setAttribute('valign', 'top');
                 //					$td->setAttribute('style','width:22px; background-image:url(images/general/tree/pointc.gif);');
                 $div = new CTag('div', 'yes');
                 $div->setAttribute('style', 'height: 10px; width:22px; background-image:url(images/general/tree/pointc.gif);');
                 if ($this->tree[$id]['nodetype'] == 2) {
                     $img = new CImg('images/general/tree/plus.gif', 'y', '22', '14');
                     $img->setAttribute('onclick', 'javascript: ' . $this->treename . '.closeSNodeX(' . $id . ',this);' . " showPopupDiv('div_node_tree','select_iframe');");
                     // IE6 Fix
                     $img->setAttribute('id', 'idi_' . $id);
                     $img->setClass('imgnode');
                 } else {
                     $img = new CImg('images/general/tree/pointl.gif', 'y', '22', '14');
                 }
                 $div->addItem($img);
                 $img = $div;
                 break;
             case 'T':
                 $td->setAttribute('valign', 'top');
                 if ($this->tree[$id]['nodetype'] == 2) {
                     $td->setAttribute('style', 'width:22px; background-image:url(images/general/tree/pointc.gif);');
                     $img = new CImg('images/general/tree/plus.gif', 't', '22', '14');
                     $img->setAttribute('onclick', 'javascript: ' . $this->treename . '.closeSNodeX(' . $id . ',this);' . " showPopupDiv('div_node_tree','select_iframe');");
                     // IE6 Fix
                     $img->setAttribute('id', 'idi_' . $id);
                     $img->setClass('imgnode');
                 } else {
                     $td->setAttribute('style', 'width:22px; background-image:url(images/general/tree/pointc.gif);');
                     $img = new CImg('images/general/tree/pointl.gif', 't', '22', '14');
                 }
                 break;
         }
         $td->addItem($img);
         $tr->addItem($td);
         $td = new CCol();
     }
     //	echo $txt.' '.$this->tree[$id]['Name'].'<br />';
     return $tr;
 }
Exemple #7
0
 private function makeCell($id)
 {
     $td = new CCol();
     $caption = new CSpan();
     if ($id != 0 && array_key_exists('childnodes', $this->tree[$id])) {
         $caption->addItem((new CDiv((new CSpan())->addClass('arrow-right')))->addClass('treeview')->onClick($this->treename . '.closeSNodeX("' . $id . '", this.getElementsByTagName(\'span\')[0]);')->setId('idi_' . $id));
     }
     $caption->addItem($this->tree[$id]['caption']);
     if ($this->tree[$id]['Level'] != 0) {
         $level = $this->tree[$id]['Level'];
         $caption->setAttribute('style', 'padding-left:' . 2 * $level . 'em;');
     }
     $td->addItem($caption);
     return $td;
 }
function get_regexp_form()
{
    if (isset($_REQUEST['regexpid']) && !isset($_REQUEST['form_refresh'])) {
        $sql = 'SELECT re.* ' . ' FROM regexps re ' . ' WHERE ' . DBin_node('re.regexpid') . ' AND re.regexpid=' . zbx_dbstr($_REQUEST['regexpid']);
        $regexp = DBfetch(DBSelect($sql));
        $rename = $regexp['name'];
        $test_string = $regexp['test_string'];
        $expressions = array();
        $sql = 'SELECT e.* ' . ' FROM expressions e ' . ' WHERE ' . DBin_node('e.expressionid') . ' AND e.regexpid=' . zbx_dbstr($regexp['regexpid']) . ' ORDER BY e.expression_type';
        $db_exps = DBselect($sql);
        while ($exp = DBfetch($db_exps)) {
            $expressions[] = $exp;
        }
    } else {
        $rename = get_request('rename', '');
        $test_string = get_request('test_string', '');
        $expressions = get_request('expressions', array());
    }
    $tblRE = new CTable('', 'formtable nowrap');
    $tblRE->addRow(array(_('Name'), new CTextBox('rename', $rename, 60, 'no', 128)));
    $tblRE->addRow(array(_('Test string'), new CTextArea('test_string', $test_string)));
    $tabExp = new CTableInfo();
    $td1 = new CCol(_('Expression'));
    $td2 = new CCol(_('Expected result'));
    $td3 = new CCol(_('Result'));
    $tabExp->setHeader(array($td1, $td2, $td3));
    $final_result = !empty($test_string);
    foreach ($expressions as $id => $expression) {
        $results = array();
        $paterns = array($expression['expression']);
        if (!empty($test_string)) {
            if ($expression['expression_type'] == EXPRESSION_TYPE_ANY_INCLUDED) {
                $paterns = explode($expression['exp_delimiter'], $expression['expression']);
            }
            if (uint_in_array($expression['expression_type'], array(EXPRESSION_TYPE_TRUE, EXPRESSION_TYPE_FALSE))) {
                if ($expression['case_sensitive']) {
                    $results[$id] = preg_match('/' . $paterns[0] . '/', $test_string);
                } else {
                    $results[$id] = preg_match('/' . $paterns[0] . '/i', $test_string);
                }
                if ($expression['expression_type'] == EXPRESSION_TYPE_TRUE) {
                    $final_result &= $results[$id];
                } else {
                    $final_result &= !$results[$id];
                }
            } else {
                $results[$id] = true;
                $tmp_result = false;
                if ($expression['case_sensitive']) {
                    foreach ($paterns as $pid => $patern) {
                        $tmp_result |= zbx_strstr($test_string, $patern) !== false;
                    }
                } else {
                    foreach ($paterns as $pid => $patern) {
                        $tmp_result |= zbx_stristr($test_string, $patern) !== false;
                    }
                }
                if (uint_in_array($expression['expression_type'], array(EXPRESSION_TYPE_INCLUDED, EXPRESSION_TYPE_ANY_INCLUDED))) {
                    $results[$id] &= $tmp_result;
                } else {
                    if ($expression['expression_type'] == EXPRESSION_TYPE_NOT_INCLUDED) {
                        $results[$id] &= !$tmp_result;
                    }
                }
                $final_result &= $results[$id];
            }
        }
        if (isset($results[$id]) && $results[$id]) {
            $exp_res = new CSpan(_('TRUE'), 'green bold');
        } else {
            $exp_res = new CSpan(_('FALSE'), 'red bold');
        }
        $expec_result = expression_type2str($expression['expression_type']);
        if (EXPRESSION_TYPE_ANY_INCLUDED == $expression['expression_type']) {
            $expec_result .= ' (' . _('Delimiter') . "='" . $expression['exp_delimiter'] . "')";
        }
        $tabExp->addRow(array($expression['expression'], $expec_result, $exp_res));
    }
    $td = new CCol(_('Combined result'), 'bold');
    $td->setColSpan(2);
    if ($final_result) {
        $final_result = new CSpan(_('TRUE'), 'green bold');
    } else {
        $final_result = new CSpan(_('FALSE'), 'red bold');
    }
    $tabExp->addRow(array($td, $final_result));
    $tblRE->addRow(array(_('Result'), $tabExp));
    $tblFoot = new CTableInfo(null);
    $td = new CCol(array(new CSubmit('save', _('Save'))));
    $td->setColSpan(2);
    $td->addStyle('text-align: right;');
    $td->addItem(SPACE);
    $td->addItem(new CSubmit('test', _('Test')));
    if (isset($_REQUEST['regexpid'])) {
        $td->addItem(SPACE);
        $td->addItem(new CSubmit('clone', _('Clone')));
        $td->addItem(SPACE);
        $td->addItem(new CButtonDelete(_('Delete regular expression?'), url_param('form') . url_param('config') . url_param('regexpid') . url_param('delete', false, 'go')));
    }
    $td->addItem(SPACE);
    $td->addItem(new CButtonCancel(url_param("regexpid")));
    $tblFoot->setFooter($td);
    return array($tblRE, $tblFoot);
}
Exemple #9
0
         case IMAGE_TYPE_ICON:
             $imagetype = S_ICON;
             $img = new CImg('imgstore.php?iconid=' . $image['imageid'], 'no image');
             break;
         case IMAGE_TYPE_BACKGROUND:
             $imagetype = S_BACKGROUND;
             $img = new CImg('imgstore.php?iconid=' . $image['imageid'], 'no image', 200);
             break;
         default:
             $imagetype = S_UNKNOWN;
     }
     $name = new CLink($image['name'], 'config.php?form=update' . url_param('config') . '&imageid=' . $image['imageid']);
     $action = new CLink($img, 'image.php?imageid=' . $image['imageid']);
     $img_td = new CCol();
     $img_td->setAttribute('align', 'center');
     $img_td->addItem(array($action, BR(), $name), 'center');
     $row->addItem($img_td);
     $tr++;
     if ($tr % 4 == 0) {
         $table->addRow($row);
         $row = new CRow();
     }
 }
 if ($tr > 0) {
     while ($tr % 4 != 0) {
         $tr++;
         $row->addItem(SPACE);
     }
     $table->addRow($row);
 }
 $cnf_wdgt->addItem($table);