예제 #1
0
 public function paginationWriter(PrmPagination $ppInfo)
 {
     $page = $ppInfo->getCurrentPage();
     $totalPages1 = ceil($ppInfo->getMaxRow() / $ppInfo->getLimit()->end);
     $this->TotalPage = $totalPages1;
     $this->CurrentPage = $page;
     $this->TotalRow = $ppInfo->getMaxRow();
     if ("" == $page || 0 == $page) {
         $page = 1;
     }
     $prev = $page - 1;
     $next = $page + 1;
     if (!isset($maxResults) || "" == $maxResults || 0 == $maxResults) {
         $maxResults = 10;
     }
     $pagination = '<div class="' . $ppInfo->getCssClass() . '">';
     $searchIdParam = "";
     if ($page > 1) {
         $pagination .= '<div id="first"><a href="javascript:' . $ppInfo->getJsFunction() . '(\'1\');">' . $ppInfo->getFirstPageText() . '</a></div>' . '<div  id="previous"><a href="javascript:' . $ppInfo->getJsFunction() . '(\'' . ($page - 1) . '\');"><div>' . $ppInfo->getPreviousPageText() . '</div></a></div>';
     } else {
         $pagination .= '<div id="first">' . $ppInfo->getFirstPageText() . '</div>' . '<div id="previous"><div>' . $ppInfo->getPreviousPageText() . '</div></div>';
     }
     $displayPage = $page;
     if ($displayPage >= 6) {
         $displayStartPage = $displayPage - 1;
         if ($totalPages1 >= $displayPage + 4) {
             $displayEndPage = $displayPage + 4;
         } else {
             $displayEndPage = $totalPages1;
             $displayStartPage = $displayEndPage - 6;
             if ($totalPages1 < 6) {
                 $displayStartPage = 2;
             }
         }
     } else {
         $displayStartPage = 1;
         if ($totalPages1 < 6) {
             $displayEndPage = $totalPages1;
         } else {
             $displayEndPage = 6;
         }
     }
     // Loop through the total pages
     $pagination .= '<div id="Numbers">';
     for ($i = $displayStartPage; $i <= $displayEndPage; $i++) {
         if ($i == $page) {
             $pagination .= '<div class="' . $ppInfo->getSelectedCss() . '"><span>' . $i . '</span></div>';
         } else {
             $pagination .= '<div><a href="javascript:' . $ppInfo->getJsFunction() . '(\'' . $i . '\');">' . $i . '</a></div>';
             if ($i == $displayEndPage && $i < $totalPages1) {
                 $pagination .= "<div>...</div>";
                 if ($i < $totalPages1) {
                     //$pagination .= '<div><a href="javascript:'.$ppInfo->getJsFunction().'(\''.($totalPages1-1).'\');">'.($totalPages1-1).'</a></div>';
                     //$pagination .= '<div><a href="javascript:'.$ppInfo->getJsFunction().'(\''.$totalPages1.'\');">'.$totalPages1.'</a></div>';
                 } else {
                     $pagination .= '<div><a href="javascript:' . $ppInfo->getJsFunction() . '(\'' . $totalPages1 . '\');">' . $totalPages1 . '</a></div>';
                 }
             }
         }
     }
     $pagination .= '</div>';
     if ($page < $totalPages1) {
         $pagination .= '<div id="next"><a href="javascript:' . $ppInfo->getJsFunction() . '(\'' . ($page + 1) . '\');"><div>' . $ppInfo->getNextPageText() . '</div></a></div>' . '<div id="last"><a href="javascript:' . $ppInfo->getJsFunction() . '(\'' . $totalPages1 . '\');">' . $ppInfo->getLastPageText() . '</a></div>';
     } else {
         $pagination .= '<div id="next"><div>' . $ppInfo->getNextPageText() . '</div></div>' . '<div id="last">' . $ppInfo->getLastPageText() . '</div>';
     }
     $pagination .= '<div id="infocontainer">' . ($ppInfo->getLimit()->end * $ppInfo->getCurrentPage() - ($ppInfo->getLimit()->end - 1)) . ' - ' . $ppInfo->getLimit()->end * $ppInfo->getCurrentPage() . '/' . $ppInfo->getMaxRow() . '</div>';
     $pagination .= '<div id="RowLimit">';
     $pagination .= '<form method="post" id="PageCountForm">';
     $pagination .= 'Satır Sayısı : <select name="PageCount33" onchange="javascript:document.getElementById(\'' . $ppInfo->getFormId() . '\').PageCount.value=this.value;document.getElementById(\'' . $ppInfo->getFormId() . '\').submit();">';
     $pagination .= '<option ' . ($ppInfo->getLimit()->end == 10 ? 'selected="selected"' : "") . ' value="10">10</option>';
     $pagination .= '<option ' . ($ppInfo->getLimit()->end == 20 ? 'selected="selected"' : "") . ' value="20">20</option>';
     $pagination .= '<option ' . ($ppInfo->getLimit()->end == 30 ? 'selected="selected"' : "") . ' value="30">30</option>';
     $pagination .= '<option ' . ($ppInfo->getLimit()->end == 50 ? 'selected="selected"' : "") . ' value="50">50</option>';
     $pagination .= '<option ' . ($ppInfo->getLimit()->end == 100 ? 'selected="selected"' : "") . ' value="100">100</option>';
     $pagination .= '</select>';
     $pagination .= '</form>';
     $pagination .= '</div>';
     $extras = "\n        <form method='post' id='" . $ppInfo->getFormId() . "'>\n        \t<input type='hidden' name='" . $ppInfo->getPageContainer() . "' value='" . $ppInfo->getCurrentPage() . "'>" . '<input type="hidden" name="PageCount" value="' . $ppInfo->getLimit()->end . '">';
     if (is_array($_POST)) {
         foreach ($_POST as $key => $value) {
             if ($ppInfo->getPageContainer() != $key && $key != "PageCount") {
                 if (is_array($value)) {
                     foreach ($value as $kk => $vv) {
                         if (is_array($vv)) {
                             foreach ($vv as $kkk => $vvv) {
                                 $extras .= "<input type='hidden' name='" . $key . "[" . $kk . "][" . $kkk . "]' value='" . $vvv . "'>";
                             }
                         } else {
                             $extras .= "<input type='hidden' name='" . $key . "[" . $kk . "]' value='" . $vv . "'>";
                         }
                     }
                 } else {
                     $extras .= "<input type='hidden' name='" . $key . "' value='{$value}'>";
                 }
             }
         }
     }
     $extras .= "\n        </form>\n        <script>\n        \tfunction " . $ppInfo->getJsFunction() . " (PageNumber) {\n    \t\t\tdocument.getElementById('" . $ppInfo->getFormId() . "')." . $ppInfo->getPageContainer() . ".value=PageNumber;\n    \t\t\tdocument.getElementById('" . $ppInfo->getFormId() . "').submit();\n    \t\t}\n        </script>";
     $pagination .= $extras;
     $this->pagination = $pagination;
     return (string) $pagination;
 }