Exemplo n.º 1
0
 public function setHref($value)
 {
     if (!is_string($value)) {
         return $this->error('Incorrect value for setHref [' . $value . ']');
     }
     $url = new Curl($value);
     $value = $url->getUrl();
     $this->setAttribute('href', $value);
 }
Exemplo n.º 2
0
 public function setUrl($value)
 {
     if (is_null($this->nosid)) {
         $uri = new Curl($value);
         $url = $uri->getUrl();
     } else {
         $url = $value;
     }
     $this->setAttribute('href', $url);
 }
 public function setVars($value = null)
 {
     $url = '?cancel=1';
     if (!empty($value)) {
         $url .= $value;
     }
     $uri = new Curl($url);
     $url = $uri->getUrl();
     return $this->setAttribute('onclick', "javascript: return redirect('" . $url . "');");
 }
Exemplo n.º 4
0
 public function setVars($value = NULL)
 {
     global $page;
     $url = '?cancel=1';
     if (!is_null($value)) {
         $url .= $value;
     }
     $uri = new Curl($url);
     $url = $uri->getUrl();
     return parent::setAction("javascript: return redirect('" . $url . "');");
 }
 public function setAction($value = null)
 {
     if (!is_null($value)) {
         return parent::setAction($value);
     }
     global $page;
     $confirmation = "Confirm('" . $this->msg . "')";
     if (isset($this->vars)) {
         $link = $page['file'] . '?' . $this->name . '=1' . $this->vars;
         $url = new Curl($link);
         $action = "redirect('" . $url->getUrl() . "')";
     } else {
         $action = 'true';
     }
     return parent::setAction('if(' . $confirmation . ') return ' . $action . '; else return false;');
 }
Exemplo n.º 6
0
 /**
  * @param array $options['objectOptions'] 	an array of parameters to be added to the request URL
  *
  * @see jQuery.multiSelect()
  */
 public function __construct(array $options = array())
 {
     parent::__construct('div', 'yes');
     $this->addClass('multiselect');
     $this->attr('id', zbx_formatDomId($options['name']));
     // url
     $url = new Curl('jsrpc.php');
     $url->setArgument('type', PAGE_TYPE_TEXT_RETURN_JSON);
     $url->setArgument('method', 'multiselect.get');
     $url->setArgument('objectName', $options['objectName']);
     if (!empty($options['objectOptions'])) {
         foreach ($options['objectOptions'] as $optionName => $optionvalue) {
             $url->setArgument($optionName, $optionvalue);
         }
     }
     $params = array('id' => $this->getAttribute('id'), 'url' => $url->getUrl(), 'name' => $options['name'], 'labels' => array('No matches found' => _('No matches found'), 'More matches found...' => _('More matches found...'), 'type here to search' => _('type here to search'), 'new' => _('new'), 'Select' => _('Select')), 'data' => empty($options['data']) ? array() : zbx_cleanHashes($options['data']), 'ignored' => isset($options['ignored']) ? $options['ignored'] : null, 'defaultValue' => isset($options['defaultValue']) ? $options['defaultValue'] : null, 'disabled' => isset($options['disabled']) ? $options['disabled'] : false, 'selectedLimit' => isset($options['selectedLimit']) ? $options['selectedLimit'] : null, 'addNew' => isset($options['addNew']) ? $options['addNew'] : false, 'popup' => array('parameters' => isset($options['popup']['parameters']) ? $options['popup']['parameters'] : null, 'width' => isset($options['popup']['width']) ? $options['popup']['width'] : null, 'height' => isset($options['popup']['height']) ? $options['popup']['height'] : null, 'buttonClass' => isset($options['popup']['buttonClass']) ? $options['popup']['buttonClass'] : null));
     zbx_add_post_js('jQuery("#' . $this->getAttribute('id') . '").multiSelect(' . CJs::encodeJson($params) . ')');
 }
Exemplo n.º 7
0
/**
 * Returns paging line.
 *
 * @param array $items				list of items
 * @param array $removeUrlParams	params to remove from URL
 * @param array $urlParams			params to add in URL
 *
 * @return CTable
 */
function getPagingLine(&$items, array $removeUrlParams = array(), array $urlParams = array())
{
    global $page;
    $config = select_config();
    $searchLimit = '';
    if ($config['search_limit'] < count($items)) {
        array_pop($items);
        $searchLimit = '+';
    }
    $rowsPerPage = CWebUser::$data['rows_per_page'];
    $itemsCount = count($items);
    $pagesCount = $itemsCount > 0 ? ceil($itemsCount / $rowsPerPage) : 1;
    $currentPage = getPageNumber();
    if ($currentPage < 1) {
        $currentPage = 1;
    }
    if ($itemsCount < ($currentPage - 1) * $rowsPerPage) {
        $currentPage = $pagesCount;
    }
    $start = ($currentPage - 1) * $rowsPerPage;
    CProfile::update('web.paging.lastpage', $page['file'], PROFILE_TYPE_STR);
    CProfile::update('web.paging.page', $currentPage, PROFILE_TYPE_INT);
    // trim array with items to contain items for current page
    $items = array_slice($items, $start, $rowsPerPage, true);
    // viewed pages (better to use not odd)
    $pagingNavRange = 11;
    $endPage = $currentPage + floor($pagingNavRange / 2);
    if ($endPage < $pagingNavRange) {
        $endPage = $pagingNavRange;
    }
    if ($endPage > $pagesCount) {
        $endPage = $pagesCount;
    }
    $startPage = $endPage > $pagingNavRange ? $endPage - $pagingNavRange + 1 : 1;
    $pageLine = array();
    $table = null;
    if ($pagesCount > 1) {
        $url = new Curl();
        if (is_array($urlParams) && $urlParams) {
            foreach ($urlParams as $key => $value) {
                $url->setArgument($key, $value);
            }
        }
        $removeUrlParams = array_merge($removeUrlParams, array('go', 'form', 'delete', 'cancel'));
        foreach ($removeUrlParams as $param) {
            $url->removeArgument($param);
        }
        if ($startPage > 1) {
            $url->setArgument('page', 1);
            $pageLine[] = new CLink('<< ' . _x('First', 'page navigation'), $url->getUrl(), null, null, true);
            $pageLine[] = '&nbsp;&nbsp;';
        }
        if ($currentPage > 1) {
            $url->setArgument('page', $currentPage - 1);
            $pageLine[] = new CLink('< ' . _x('Previous', 'page navigation'), $url->getUrl(), null, null, true);
            $pageLine[] = ' | ';
        }
        for ($p = $startPage; $p <= $pagesCount; $p++) {
            if ($p > $endPage) {
                break;
            }
            if ($p == $currentPage) {
                $pagespan = new CSpan($p, 'bold textcolorstyles');
            } else {
                $url->setArgument('page', $p);
                $pagespan = new CLink($p, $url->getUrl(), null, null, true);
            }
            $pageLine[] = $pagespan;
            $pageLine[] = ' | ';
        }
        array_pop($pageLine);
        if ($currentPage < $pagesCount) {
            $pageLine[] = ' | ';
            $url->setArgument('page', $currentPage + 1);
            $pageLine[] = new CLink(_x('Next', 'page navigation') . ' >', $url->getUrl(), null, null, true);
        }
        if ($p < $pagesCount) {
            $pageLine[] = '&nbsp;&nbsp;';
            $url->setArgument('page', $pagesCount);
            $pageLine[] = new CLink(_x('Last', 'page navigation') . ' >>', $url->getUrl(), null, null, true);
        }
        $table = new CTable(null, 'paging');
        $table->addRow(new CCol($pageLine));
    }
    $viewFromPage = ($currentPage - 1) * $rowsPerPage + 1;
    $viewTillPage = $currentPage * $rowsPerPage;
    if ($viewTillPage > $itemsCount) {
        $viewTillPage = $itemsCount;
    }
    $pageView = array();
    $pageView[] = _('Displaying') . SPACE;
    if ($itemsCount > 0) {
        $pageView[] = new CSpan($viewFromPage, 'info');
        $pageView[] = SPACE . _('to') . SPACE;
    }
    $pageView[] = new CSpan($viewTillPage, 'info');
    $pageView[] = SPACE . _('of') . SPACE;
    $pageView[] = new CSpan($itemsCount, 'info');
    $pageView[] = $searchLimit;
    $pageView[] = SPACE . _('found');
    $pageView = new CSpan($pageView);
    zbx_add_post_js('insertInElement("numrows", ' . zbx_jsvalue($pageView->toString()) . ', "div");');
    return $table;
}
Exemplo n.º 8
0
function get_icon($name, $params = array())
{
    switch ($name) {
        case 'favourite':
            if (infavorites($params['fav'], $params['elid'], $params['elname'])) {
                $icon = new CIcon(_('Remove from favourites'), 'iconminus', 'rm4favorites("' . $params['elname'] . '", "' . $params['elid'] . '", 0);');
            } else {
                $icon = new CIcon(_('Add to favourites'), 'iconplus', 'add2favorites("' . $params['elname'] . '", "' . $params['elid'] . '");');
            }
            $icon->setAttribute('id', 'addrm_fav');
            break;
        case 'fullscreen':
            $url = new Curl();
            $url->setArgument('fullscreen', $params['fullscreen'] ? '0' : '1');
            $icon = new CIcon($_REQUEST['fullscreen'] ? _('Normal view') : _('Fullscreen'), 'fullscreen', "document.location = '" . $url->getUrl() . "';");
            break;
        case 'menu':
            $icon = new CIcon(_('Menu'), 'iconmenu', 'create_page_menu(event, "' . $params['menu'] . '");');
            break;
        case 'reset':
            $icon = new CIcon(_('Reset'), 'iconreset', 'timeControl.objectReset();');
            break;
    }
    return $icon;
}
function pager($items, $itemsPerPage, $currentPage, $urlParams = array(), $removeUrlParams = array())
{
    $startPage = 1;
    $pagesCount = floor($items / $itemsPerPage) + 1;
    $endPage = $pagesCount;
    $url = new Curl();
    $pageLine = array();
    if (is_array($urlParams) && $urlParams) {
        foreach ($urlParams as $key => $value) {
            $url->setArgument($key, $value);
        }
    }
    $removeUrlParams = array_merge($removeUrlParams, array('go', 'form', 'delete', 'cancel'));
    foreach ($removeUrlParams as $param) {
        $url->removeArgument($param);
    }
    if ($startPage > 1) {
        $url->setArgument('page', 1);
        $pageLine[] = new CLink('<< ' . _x('First', 'page navigation'), $url->getUrl(), null, null, true);
        $pageLine[] = '&nbsp;&nbsp;';
    }
    if ($currentPage > 1) {
        $url->setArgument('page', $currentPage - 1);
        $pageLine[] = new CLink('< ' . _x('Previous', 'page navigation'), $url->getUrl(), null, null, true);
        $pageLine[] = ' | ';
    }
    for ($p = $startPage; $p <= $pagesCount; $p++) {
        if ($p > $endPage) {
            break;
        }
        if ($p == $currentPage) {
            $pagespan = new CSpan($p, 'bold textcolorstyles');
        } else {
            $url->setArgument('page', $p);
            $pagespan = new CLink($p, $url->getUrl(), null, null, true);
        }
        $pageLine[] = $pagespan;
        $pageLine[] = ' | ';
    }
    array_pop($pageLine);
    if ($currentPage < $pagesCount) {
        $pageLine[] = ' | ';
        $url->setArgument('page', $currentPage + 1);
        $pageLine[] = new CLink(_x('Next', 'page navigation') . ' >', $url->getUrl(), null, null, true);
    }
    if ($p < $pagesCount) {
        $pageLine[] = '&nbsp;&nbsp;';
        $url->setArgument('page', $pagesCount);
        $pageLine[] = new CLink(_x('Last', 'page navigation') . ' >>', $url->getUrl(), null, null, true);
    }
    $table = new CTable(null, 'paging');
    $table->addRow(new CCol($pageLine));
    $pageView = array();
    $pageView[] = _('Displaying') . SPACE;
    if ($items > $itemsPerPage) {
        $pageView[] = new CSpan($itemsPerPage * $currentPage, 'info');
        $pageView[] = SPACE . _('to') . SPACE;
    }
    $to = min($itemsPerPage * $currentPage + $itemsPerPage, $items);
    $pageView[] = new CSpan($to, 'info');
    $pageView[] = SPACE . _('of') . SPACE;
    $pageView[] = new CSpan($items, 'info');
    $pageView[] = SPACE . _('found');
    $pageView = new CSpan($pageView);
    zbx_add_post_js('insertInElement("numrows", ' . zbx_jsvalue($pageView->toString()) . ', "div");');
    return $table;
}
Exemplo n.º 10
0
                echo '$("addrm_fav").title = "' . _('Add to favourites') . '";' . "\n";
                echo '$("addrm_fav").onclick = function() { add2favorites("graphid", "' . $_REQUEST['favid'] . '"); }' . "\n";
            }
        }
        if ($page['type'] == PAGE_TYPE_JS && $result) {
            echo 'switchElementsClass("addrm_fav", "iconminus", "iconplus");';
        }
    }
}
if (!empty($_REQUEST['period']) || !empty($_REQUEST['stime'])) {
    CScreenBase::calculateTime(array('profileIdx' => 'web.screens', 'profileIdx2' => $pageFilter->graphid, 'updateProfile' => true, 'period' => get_request('period'), 'stime' => get_request('stime')));
    $curl = new Curl($_SERVER['REQUEST_URI']);
    $curl->removeArgument('period');
    $curl->removeArgument('stime');
    ob_end_clean();
    redirect($curl->getUrl());
}
ob_end_flush();
if ($page['type'] == PAGE_TYPE_JS || $page['type'] == PAGE_TYPE_HTML_BLOCK) {
    require_once dirname(__FILE__) . '/include/page_footer.php';
    exit;
}
/*
 * Display
 */
$data = array('pageFilter' => $pageFilter, 'graphid' => $pageFilter->graphid, 'fullscreen' => get_request('fullscreen'));
// render view
$chartsView = new CView('monitoring.charts', $data);
$chartsView->render();
$chartsView->show();
require_once dirname(__FILE__) . '/include/page_footer.php';
Exemplo n.º 11
0
 public function getBaseUrl()
 {
     $info = parse_url($this->curl->getUrl());
     return $info['scheme'] . '://' . $info['host'] . ':' . $info['port'] . '/';
 }
Exemplo n.º 12
0
function get_icon($name, $params = array())
{
    switch ($name) {
        case 'favourite':
            if (infavorites($params['fav'], $params['elid'], $params['elname'])) {
                $icon = new CIcon(S_REMOVE_FROM . ' ' . S_FAVOURITES, 'iconminus', 'rm4favorites("' . $params['elname'] . '","' . $params['elid'] . '", 0);');
            } else {
                $icon = new CIcon(S_ADD_TO . ' ' . S_FAVOURITES, 'iconplus', 'add2favorites("' . $params['elname'] . '","' . $params['elid'] . '");');
            }
            $icon->setAttribute('id', 'addrm_fav');
            break;
        case 'fullscreen':
            $url = new Curl();
            $url->setArgument('fullscreen', $params['fullscreen'] ? '0' : '1');
            $icon = new CIcon($_REQUEST['fullscreen'] ? S_NORMAL . ' ' . S_VIEW : S_FULLSCREEN, 'fullscreen', "document.location = '" . $url->getUrl() . "';");
            break;
        case 'menu':
            $icon = new CIcon(S_MENU, 'iconmenu', 'create_page_menu(event, "' . $params['menu'] . '");');
            break;
        case 'reset':
            $icon = new CIcon(S_RESET, 'iconreset', 'timeControl.objectReset("' . $params['id'] . '");');
            break;
    }
    return $icon;
}
Exemplo n.º 13
0
function make_sorting_header($obj, $tabfield, $url = '')
{
    global $page;
    $sortorder = $_REQUEST['sort'] == $tabfield && $_REQUEST['sortorder'] == ZBX_SORT_UP ? ZBX_SORT_DOWN : ZBX_SORT_UP;
    $link = new Curl($url);
    if (empty($url)) {
        $link->formatGetArguments();
    }
    $link->setArgument('sort', $tabfield);
    $link->setArgument('sortorder', $sortorder);
    $url = $link->getUrl();
    if ($page['type'] != PAGE_TYPE_HTML && defined('ZBX_PAGE_MAIN_HAT')) {
        $script = "javascript: return updater.onetime_update('" . ZBX_PAGE_MAIN_HAT . "','" . $url . "');";
    } else {
        $script = "javascript: redirect('" . $url . "');";
    }
    zbx_value2array($obj);
    $div = new CDiv();
    $div->setAttribute('style', 'float:left;');
    foreach ($obj as $enum => $el) {
        if (is_object($el) || $el === SPACE) {
            $div->addItem($el);
        } else {
            $div->addItem(new CSpan($el, 'underline'));
        }
    }
    $div->addItem(SPACE);
    $img = null;
    if (isset($_REQUEST['sort']) && $tabfield == $_REQUEST['sort']) {
        if ($sortorder == ZBX_SORT_UP) {
            $img = new CDiv(SPACE, 'icon_sortdown');
        } else {
            $img = new CDiv(SPACE, 'icon_sortup');
        }
        $img->setAttribute('style', 'float: left;');
    }
    $col = new CCol(array($div, $img), 'nowrap hover_grey');
    $col->setAttribute('onclick', $script);
    return $col;
}
Exemplo n.º 14
0
            $submenu = array();
            echo 'page_submenu["menu_screens"] = ' . zbx_jsvalue(make_screen_submenu()) . ';';
        }
    }
}
if (PAGE_TYPE_JS == $page['type'] || PAGE_TYPE_HTML_BLOCK == $page['type']) {
    exit;
}
//	$time = new CSpan(date("[H:i:s]",time()));
//	$time->addOption('id','refreshed');
$p_elements = array();
// Header
$url = new Curl('?fullscreen=' . ($_REQUEST['fullscreen'] ? '0' : '1'));
$fs_icon = new CDiv(SPACE, 'fullscreen');
$fs_icon->addOption('title', $_REQUEST['fullscreen'] ? S_NORMAL . ' ' . S_VIEW : S_FULLSCREEN);
$fs_icon->addAction('onclick', new CScript("javascript: document.location = '" . $url->getUrl() . "';"));
//-------------
$left_tab = new CTable();
$left_tab->setCellPadding(3);
$left_tab->setCellSpacing(3);
$left_tab->addOption('border', 0);
$menu = array();
$submenu = array();
// js menu arrays
make_graph_menu($menu, $submenu);
make_sysmap_menu($menu, $submenu);
make_screen_menu($menu, $submenu);
make_refresh_menu('mainpage', 'hat_syssum', get_profile('web.dahsboard.rf_rate.hat_syssum', 60), null, $menu, $submenu);
make_refresh_menu('mainpage', 'hat_stszbx', get_profile('web.dahsboard.rf_rate.hat_stszbx', 60), null, $menu, $submenu);
make_refresh_menu('mainpage', 'hat_lastiss', get_profile('web.dahsboard.rf_rate.hat_lastiss', 60), null, $menu, $submenu);
make_refresh_menu('mainpage', 'hat_webovr', get_profile('web.dahsboard.rf_rate.hat_webovr', 60), null, $menu, $submenu);