예제 #1
0
 /**
  * Generates grid paginate code
  *
  * @param \Engine\Crud\Grid $grid
  * @return string
  */
 public static function _(Grid $grid)
 {
     $action = $grid->getAction();
     $pages = $grid->getPaginateParams();
     $sortParams = $grid->getSortParams();
     $sortPageParamName = $grid->getPageParamName();
     if ($sortParams) {
         foreach ($sortParams as $param => $value) {
             $action = self::setUrlParam($action, $param, $value);
         }
     }
     $code = "\n        <div class=\"pagination\">\n            <ul>";
     if ($pages['first']) {
         $link = self::setUrlParam($action, $sortPageParamName, $pages['first']);
         //$first  = '<li><a href="'.$link.'">First</a></li>';
         $first = '<li><a href="' . $link . '"><span>&laquo;</span></a></li>';
     } else {
         //$first  = '<li><img src="/img/page_arrow_first.gif"/></li>';
         //$first  = '<li class="disabled"><a href="#">First</a></li>';
         $first = '<li class="disabled"><a href="#"><span>&laquo;</span></a></li>';
     }
     unset($pages['first']);
     if ($pages['prev']) {
         $link = self::setUrlParam($action, $sortPageParamName, $pages['prev']);
         //$prev   = '<li><a href="'.$link.'"><img src="/img/page_arrow_prev.gif"/></a></li>';
         $prev_w = '<li><a href="' . $link . '"><span>&#8249;</span></a></li>';
     } else {
         //$prev   = '<li><img src="/img/page_arrow_prev.gif"/></li>';
         //$prev_w = '<li>Prev</li>';
         $prev_w = '<li class="disabled"><a href="#"><span>&#8249;</span></a></li>';
     }
     unset($pages['prev']);
     if ($pages['next']) {
         $link = self::setUrlParam($action, $sortPageParamName, $pages['next']);
         //$next   = '<li><a href="'.$link.'"><img src="/img/page_arrow_next.gif"/></a></li>';
         $next_w = '<li><a href="' . $link . '"><span>&#8250;</span></a></li>';
     } else {
         //$next   = '<li><img src="/img/page_arrow_next.gif"/></li>';
         $next_w = '<li class="disabled"><a href="#"><span>&#8250;</span></a></li>';
     }
     unset($pages['next']);
     if ($pages['last']) {
         $link = self::setUrlParam($action, $sortPageParamName, $pages['last']);
         //$last   = '<li><a href="'.$link.'"><img src="/img/page_arrow_last.gif"/></a></li>';
         //$last_w = '<li><a href="'.$link.'">Last</a></li>';
         $last_w = '<li><a href="' . $link . '"><span>&raquo;</span></a></li>';
     } else {
         //$last = '<li><img src="/img/page_arrow_last.gif"/></li>';
         //$last_w =  '<li>Last</li>';
         $last_w = '<li class="disabled"><a href="#"><span>&raquo;</span></a></li>';
     }
     unset($pages['last']);
     $code .= $first . $prev_w;
     //$prev_w.$first.$prev;
     foreach ($pages as $page => $status) {
         if ($status == 'now') {
             // $code .= '<li class="page_now">'.$page.'</li>';
             $code .= '<li class="active"><a href="#"><span>' . $page . '</span></a></li>';
         } else {
             $link = self::setUrlParam($action, $sortPageParamName, $page);
             $code .= '<li class="page_link"><a href="' . $link . '"><span>' . $page . '</span></a></li>';
         }
     }
     $code .= $next_w . $last_w;
     //$next.$last.$next_w;
     $code .= "\n            </ul>\n         </div>";
     return $code;
 }