/PhpOnAzure.Web/data/class/SC_PageNavi.php
PHP | 147 lines | 82 code | 18 blank | 47 comment | 32 complexity | 1c3c95439f7c8981a87b78fc50c26a0d MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
- <?php
- /*
- * This file is part of EC-CUBE
- *
- * Copyright(c) 2000-2011 LOCKON CO.,LTD. All Rights Reserved.
- *
- * http://www.lockon.co.jp/
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
- /* ??????
- ?form???????????
- <input type="hidden" name="pageno" value="<!--{$tpl_pageno}-->">
- ????????????????
- $objPage->tpl_pageno = $_POST['pageno'];
- ?$func_name?????JavaScript??
- // ??????????
- function fnNaviPage(pageno) {
- document.form1['pageno'].value = pageno;
- document.form1.submit();
- }
- */
- class SC_PageNavi {
- var $now_page; // ????????
- var $max_page; // ????????
- var $start_row; // ??????
- var $strnavi; // ????????
- var $arrPagenavi = array(); // ???
- // ???????
- function SC_PageNavi($now_page, $all_row, $page_row, $func_name, $navi_max = NAVI_PMAX, $urlParam = '', $display_number = true) {
- $this->arrPagenavi['mode'] = 'search';
- //?????($now_page)???????????
- if (!preg_match("/^[[:digit:]]+$/", $now_page) || $now_page < 1 || strlen($now_page) == 0) {
- $this->now_page = 1;
- } else {
- $this->now_page = htmlspecialchars($now_page, ENT_QUOTES, CHAR_CODE);
- }
- $this->arrPagenavi['now_page'] = $this->now_page;
- // ????????
- $this->max_page = ceil($all_row/$page_row);
- // ???????????????????????????
- if ($this->max_page < $this->now_page) {
- $this->now_page = 1;
- }
- $this->start_row = ($this->now_page - 1) * $page_row;
- $this->all_row = $all_row;
- // ?????????
- if (!($this->start_row < $all_row && $this->start_row >= 0)) {
- $this->start_row = 0;
- }
- if ($all_row > 1) {
- //???????????
- $before = "";
- $next = "";
- if ($this->now_page > 1) {
- $this->arrPagenavi['before'] = $this->now_page - 1;
- $urlParamThis = str_replace('#page#', $this->arrPagenavi['before'], $urlParam);
- $urlParamThis = htmlentities($urlParamThis, ENT_QUOTES);
- $before = "<a href=\"?$urlParamThis\" onclick=\"$func_name('{$this->arrPagenavi['before']}'); return false;\"><<??</a> ";
- } else {
- $this->arrPagenavi['before'] = $this->now_page;
- }
- if ($this->now_page < $this->max_page) {
- $this->arrPagenavi['next'] = $this->now_page + 1;
- $urlParamThis = str_replace('#page#', $this->arrPagenavi['next'], $urlParam);
- $urlParamThis = htmlentities($urlParamThis, ENT_QUOTES);
- $next = " <a href=\"?$urlParamThis\" onclick=\"$func_name('{$this->arrPagenavi['next']}'); return false;\">??>></a>";
- } else {
- $this->arrPagenavi['next'] = $this->now_page;
- }
- // ??????????????
- if ($navi_max == "" || $navi_max > $this->max_page) {
- // ??????????????????????????????
- $disp_max = $this->max_page;
- } else {
- // ???????????????????
- $disp_max = $this->now_page + $navi_max - 1;
- // ????????????????????????????
- if ($disp_max > $this->max_page) {
- $disp_max = $this->max_page;
- }
- }
- // ??????????????
- if ($navi_max == "" || $navi_max > $this->now_page) {
- // ???????????????????????????????
- $disp_min = 1;
- } else {
- // ??????-????????????
- $disp_min = $this->now_page - $navi_max + 1;
- }
- $this->arrPagenavi['arrPageno'] = array();
- $page_number = "";
- for ($i = $disp_min; $i <= $disp_max; $i++) {
- if ($i == $this->now_page) {
- $page_number .= "<li><strong>$i</strong></li>";
- } else {
- $urlParamThis = str_replace('#page#', $i, $urlParam);
- $urlParamThis = htmlentities($urlParamThis, ENT_QUOTES);
- $page_number .= "<li><a href=\"?$urlParamThis\" onclick=\"$func_name('$i'); return false;\">$i</a></li>";
- }
- $page_number .= ' ';
- // FIXME CSS ????
- $this->arrPagenavi['arrPageno'][$i] = $i;
- }
- if ($before && $next) {
- $this->strnavi = $before .(($display_number) ? $page_number : ' | ') .$next;
- } else if ($before || $next) {
- $this->strnavi = $before .(($display_number) ? $page_number : '') .$next;
- }
- } else {
- $this->arrPagenavi['arrPageno'][0] = 1;
- $this->arrPagenavi['before'] = 1;
- $this->arrPagenavi['next'] = 1;
- }
- }
- }
- ?>