當前位置: 首頁>>代碼示例>>PHP>>正文


PHP sfDoctrinePager::getPage方法代碼示例

本文整理匯總了PHP中sfDoctrinePager::getPage方法的典型用法代碼示例。如果您正苦於以下問題:PHP sfDoctrinePager::getPage方法的具體用法?PHP sfDoctrinePager::getPage怎麽用?PHP sfDoctrinePager::getPage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sfDoctrinePager的用法示例。


在下文中一共展示了sfDoctrinePager::getPage方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: get_sympal_pager_navigation

/**
 * Get the navigation links for given sfDoctrinePager instance
 *
 * @param sfDoctrinePager $pager
 * @param string $uri  The uri to prefix to the links
 * @return string $html
 */
function get_sympal_pager_navigation($pager, $uri, $requestKey = 'page')
{
    sympal_use_stylesheet('/sfSympalPlugin/css/pager.css');
    $navigation = '<div class="sympal_pager_navigation">';
    if ($pager->haveToPaginate()) {
        $uri .= (preg_match('/\\?/', $uri) ? '&' : '?') . $requestKey . '=';
        // First and previous page
        if ($pager->getPage() != 1) {
            $navigation .= link_to(image_tag('/sf/sf_admin/images/first.png', 'align=absmiddle'), $uri . '1');
            $navigation .= link_to(image_tag('/sf/sf_admin/images/previous.png', 'align=absmiddle'), $uri . $pager->getPreviousPage()) . ' ';
        }
        // Pages one by one
        $links = array();
        foreach ($pager->getLinks() as $page) {
            $links[] = '<span>' . link_to_unless($page == $pager->getPage(), $page, $uri . $page) . '</span>';
        }
        $navigation .= join('  ', $links);
        // Next and last page
        if ($pager->getPage() != $pager->getLastPage()) {
            $navigation .= ' ' . link_to(image_tag('/sf/sf_admin/images/next.png', 'align=absmiddle'), $uri . $pager->getNextPage());
            $navigation .= link_to(image_tag('/sf/sf_admin/images/last.png', 'align=absmiddle'), $uri . $pager->getLastPage());
        }
    }
    $navigation .= '</div>';
    return $navigation;
}
開發者ID:RafalJachimczyk,項目名稱:sympal,代碼行數:33,代碼來源:SympalPagerHelper.php

示例2: getPager

 public function getPager($page = 1, $size = 20, $isCheckActive = false, $isPc = null, $isMobile = null)
 {
     if (!$this->isValid()) {
         throw $this->getErrorSchema();
     }
     $query = Doctrine::getTable('Application')->createQuery('a')->leftJoin('a.Translation t');
     if ($isCheckActive) {
         $query->where('a.is_active = ?', true);
     }
     if (null !== $isPc) {
         $query->andWhere('a.is_pc = ?', $isPc);
     }
     if (null !== $isMobile) {
         $query->andWhere('a.is_mobile = ?', $isMobile);
     }
     $keywords = $this->getValue('keyword');
     if ($keywords) {
         if (!is_array($keywords)) {
             $keywords = array($keywords);
         }
         foreach ($keywords as $keyword) {
             $query->addWhere('t.title LIKE ?', '%' . $keyword . '%');
         }
     }
     $orderBy = $this->getValue('order_by');
     if (!$orderBy) {
         $orderBy = 'created_at_desc';
     }
     $isDesc = false;
     if (preg_match('/_desc$/', $orderBy)) {
         $isDesc = true;
         $orderBy = substr($orderBy, 0, strlen($orderBy) - 5);
     }
     $orderByDql = null;
     switch ($orderBy) {
         case 'created_at':
             $orderByDql = 't.created_at';
             break;
         case 'users':
             $subquery = Doctrine::getTable('MemberApplication')->createQuery('ma')->select('COUNT(*)')->where('ma.application_id = a.id');
             $query->select('*, (' . $subquery->getDql() . ') AS users');
             $orderByDql = 'users';
     }
     if ($orderByDql) {
         if ($isDesc) {
             $orderByDql .= ' DESC';
         }
         $query->orderBy($orderByDql);
     }
     $pager = new sfDoctrinePager('Application', $size);
     $pager->setQuery($query);
     $pager->getPage($page);
     $pager->init();
     return $pager;
 }
開發者ID:niryuu,項目名稱:opOpenSocialPlugin,代碼行數:55,代碼來源:ApplicationSearchForm.class.php


注:本文中的sfDoctrinePager::getPage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。