当前位置: 首页>>代码示例>>PHP>>正文


PHP CSpan::toString方法代码示例

本文整理汇总了PHP中CSpan::toString方法的典型用法代码示例。如果您正苦于以下问题:PHP CSpan::toString方法的具体用法?PHP CSpan::toString怎么用?PHP CSpan::toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CSpan的用法示例。


在下文中一共展示了CSpan::toString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: pager

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;
}
开发者ID:OneOaaS,项目名称:zabbix-dashboard-extension,代码行数:67,代码来源:eventlog.php

示例2: getPagingLine

/**
 * Returns paging line.
 *
 * @param array $items				list of items
 *
 * @return CTable
 */
function getPagingLine(&$items)
{
    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 = CUrlFactory::getContextUrl();
        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");');
//.........这里部分代码省略.........
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:101,代码来源:func.inc.php

示例3: getPagingLine


//.........这里部分代码省略.........
    if ($config['search_limit'] < count($items)) {
        array_pop($items);
        $search_limit = '+';
    }
    $start = get_request('start', null);
    if (is_null($start)) {
        $last_page = CProfile::get('web.paging.lastpage');
        $start = $last_page == $page['file'] ? CProfile::get('web.paging.start', 0) : 0;
    }
    $rows_per_page = $USER_DETAILS['rows_per_page'];
    $cnt_items = count($items);
    $cnt_pages = ceil($cnt_items / $rows_per_page);
    if ($cnt_items < $start) {
        $start = 0;
    }
    CProfile::update('web.paging.lastpage', $page['file'], PROFILE_TYPE_STR);
    CProfile::update('web.paging.start', $start, PROFILE_TYPE_INT);
    if ($cnt_pages < 1) {
        $cnt_pages = 1;
    }
    $crnt_page = floor($start / $rows_per_page) + 1;
    if ($autotrim) {
        $items = array_slice($items, $start, $rows_per_page, true);
    }
    // Viewed pages (better to use not odd)
    $view_pages = 11;
    $endPage = $crnt_page + floor($view_pages / 2);
    if ($endPage < $view_pages) {
        $endPage = $view_pages;
    }
    if ($endPage > $cnt_pages) {
        $endPage = $cnt_pages;
    }
    $startPage = $endPage > $view_pages ? $endPage - $view_pages + 1 : 1;
    // Page line
    $pageline = array();
    $table = BR();
    if ($cnt_pages > 1) {
        if ($startPage > 1) {
            $pagespan = new CSpan('<< ' . S_FIRST_PAGE, 'darklink');
            $pagespan->setAttribute('onclick', 'javascript: openPage(0);');
            $pageline[] = $pagespan;
            $pageline[] = '&nbsp;&nbsp;';
        }
        if ($crnt_page > 1) {
            $pagespan = new CSpan('< ' . S_PREVIOUS_PAGE, 'darklink');
            $pagespan->setAttribute('onclick', 'javascript: openPage(' . ($crnt_page - 2) * $rows_per_page . ');');
            $pageline[] = $pagespan;
            $pageline[] = ' | ';
        }
        for ($p = $startPage; $p <= $cnt_pages; $p++) {
            if ($p > $endPage) {
                break;
            }
            if ($p == $crnt_page) {
                $pagespan = new CSpan($p, 'bold textcolorstyles');
            } else {
                $pagespan = new CSpan($p, 'darklink');
                $pagespan->setAttribute('onclick', 'javascript: openPage(' . ($p - 1) * $rows_per_page . ');');
            }
            $pageline[] = $pagespan;
            $pageline[] = ' | ';
        }
        array_pop($pageline);
        if ($crnt_page < $cnt_pages) {
            $pagespan = new CSpan(S_NEXT_PAGE . ' >', 'darklink');
            $pagespan->setAttribute('onclick', 'javascript: openPage(' . $crnt_page * $rows_per_page . ');');
            $pageline[] = ' | ';
            $pageline[] = $pagespan;
        }
        if ($p < $cnt_pages) {
            $pagespan = new CSpan(S_LAST_PAGE . ' >>', 'darklink');
            $pagespan->setAttribute('onclick', 'javascript: openPage(' . ($cnt_pages - 1) * $rows_per_page . ');');
            $pageline[] = '&nbsp;&nbsp;';
            $pageline[] = $pagespan;
        }
        $table = new CTable(null, 'paging');
        $table->addRow(new CCol($pageline));
    }
    // Table view
    $view_from_page = ($crnt_page - 1) * $rows_per_page + 1;
    $view_till_page = $crnt_page * $rows_per_page;
    if ($view_till_page > $cnt_items) {
        $view_till_page = $cnt_items;
    }
    $page_view = array();
    $page_view[] = S_DISPLAYING . SPACE;
    if ($cnt_items > 0) {
        $page_view[] = new CSpan($view_from_page, 'info');
        $page_view[] = SPACE . S_TO_SMALL . SPACE;
    }
    $page_view[] = new CSpan($view_till_page, 'info');
    $page_view[] = SPACE . S_OF_SMALL . SPACE;
    $page_view[] = new CSpan($cnt_items, 'info');
    $page_view[] = $search_limit;
    $page_view[] = SPACE . S_FOUND_SMALL;
    $page_view = new CSpan($page_view);
    zbx_add_post_js('insertInElement("numrows",' . zbx_jsvalue($page_view->toString()) . ',"div");');
    return $table;
}
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:101,代码来源:func.inc.php


注:本文中的CSpan::toString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。