コード例 #1
0
ファイル: SesameHelper.php プロジェクト: rmhdev/sfSesame
/**
 * @param sfPager $pager
 * @param string $route
 * @return string 
 */
function sesame_render_pager($pager, $route)
{
    $html = "<div class=\"pagination pagination-right\">\n";
    $html .= "<ul>\n";
    $urlPattern = "{$route}?page=%d";
    $html .= sprintf("  <li class=\"prev %s\"><a href=\"%s\">Previous</a></li>\n", $pager->isFirstPage() ? "disabled" : "", $pager->isFirstPage() ? "#" : url_for(sprintf($urlPattern, 1)));
    foreach ($pager->getLinks(5) as $page) {
        $html .= sprintf("  <li class=\"%s\">%s</li>\n", $pager->getPage() == $page ? "active" : "", link_to($page, url_for(sprintf($urlPattern, $page))));
    }
    $html .= sprintf("  <li class=\"next %s\"><a href=\"%s\">Next</a></li>\n", $pager->isLastPage() ? "disabled" : "", $pager->isLastPage() ? "#" : url_for(sprintf($urlPattern, $pager->getNextPage())));
    $html .= "</ul>\n";
    $html .= "</div>\n";
    return $html;
}
コード例 #2
0
ファイル: FormHelper.php プロジェクト: nagiro/intra
/**
 * setPager()
 * Imprimeix per pantalla la indexació de pàgines 
 * @param mixed $pager
 * @param mixed $url
 * @param mixed $page
 * @return
 */
function setPager(sfPager $pager, $url)
{
    $e = '&p=';
    if (!stripos($url, '?')) {
        $e = '?p=';
    }
    $RET = '<div class="pager">';
    if ($pager->haveToPaginate()) {
        $RET .= link_to('&laquo;', $url . $e . $pager->getFirstPage());
        $RET .= '&nbsp;&nbsp;' . link_to('&lt;', $url . $e . $pager->getPreviousPage());
        $links = $pager->getLinks();
        foreach ($links as $page) {
            $RET .= $page == $pager->getPage() ? $page : link_to($page, $url . $e . $page);
            if ($page != $pager->getCurrentMaxLink()) {
                $RET .= '-';
            }
        }
        $RET .= '&nbsp;&nbsp;' . link_to('&gt;', $url . $e . $pager->getNextPage());
        $RET .= '&nbsp;&nbsp;' . link_to('&raquo;', $url . $e . $pager->getLastPage());
    }
    $RET .= '</div>';
    return $RET;
}
コード例 #3
0
/**
 * A pagination with ajax links
 *
 * @param sfPager $pager The pager
 * @param String $uri The url of the ajax link
 * @param String $div The id of the element to update
 * @return String
 */
function pager_navigation_ajax($pager, $uri, $div)
{
    $navigation = '';
    if ($pager->haveToPaginate()) {
        $uri .= (preg_match('/\\?/', $uri) ? '&' : '?') . 'page=';
        // First and previous page
        if ($pager->getPage() != $pager->getFirstPage()) {
            $navigation .= link_to_remote(' <<', array('update' => $div, 'url' => $uri . '1', 'complete' => visual_effect('appear', $div)));
            $navigation .= link_to_remote(' < ', array('update' => $div, 'url' => $uri . $pager->getPreviousPage(), 'complete' => visual_effect('appear', $div)));
        }
        // Pages one by one
        $links = array();
        foreach ($pager->getLinks() as $page) {
            if ($page == $pager->getPage()) {
                $links[] = $page;
            } else {
                $links[] = link_to_remote($page, array('update' => $div, 'url' => $uri . $page, 'complete' => visual_effect('appear', $div)));
            }
        }
        $navigation .= join('&nbsp;&nbsp;', $links);
        // Next and last page
        if ($pager->getPage() != $pager->getCurrentMaxLink()) {
            $navigation .= '&nbsp;' . link_to_remote(' > ', array('update' => $div, 'url' => $uri . $pager->getNextPage(), 'complete' => visual_effect('appear', $div)));
            $navigation .= '&nbsp;' . link_to_remote('>> ', array('update' => $div, 'url' => $uri . $pager->getLastPage(), 'complete' => visual_effect('appear', $div)));
        }
    }
    return $navigation;
}