pagination.php

Gesponsorde koppelingen

PHP script bestanden

  1. pagination.php

« Lees de omschrijving en reacties

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<?php
include_once 'includes/language.php';//my own translation static class
/**
 * _pn::pagination('index.php?page',
 *                  $maxpages, //comes from count(filelist)
 *                  $pageno,   //comes from web application
 *                  PAGEROWS,  //constant
 *                  PAGECOLS,  //constant
 *                  PAGINATION)//constant
 *
 * define('PAGEROWS', 4);
 * define('PAGECOLS', 3);
 * define('PAGINATION', 6);
 * define('PAGEMAX', 8); //max numbers in pagination
 *
 * _lang::lang('previous'), uses your own translation class or function
 */

class _pn {
    protected static $_instance = null;
    private static $page, $pages;//never used ...

    public static function instance() {
        if (is_null(static::$_instance)) {
            static::$_instance = new self();
        }

        return static::$_instance;
    }


    public static function static_instance() {
        if (is_null(static::$_instance)) {
            static::$_instance = new static();
        }

        return static::$_instance;
    }


    public static function pagination($path,
                                      $maxpages,
                                      $start=1,
                                      $row=4,
                                      $column=4,
                                      $max=6) {
        
        if ($maxpages<$max) {
            $end = $maxpages;
        }
elseif ($start<$max) {
            $end = $max;
        }
elseif ($maxpages>$max) {
            $end = ($start+$max<=$maxpages)?$start+$max-1:$maxpages;
            $end = ($end==$maxpages)?$end-1:$end;
        }
elseif ($maxpages==$max) {
            $end = $max;
        }
elseif ($max>$maxpages) {
            $end = $maxpages-1;
        }
elseif ($start+$max>$maxpages) {
            $end = $maxpages;
        }

        $page = $start;
        if ($start== $max&&($maxpages<=$max)) {
            $start = 1;
        }
elseif ($start+$end <= $max) {
            $start = 1;
        }
elseif ($start<$max) {
            $start = 1;
        }
elseif ($start+$max>$maxpages) {
            $start = (($maxpages-$start)>=0)?($maxpages-$max):1;
          //$start = $maxpages - $start;  
        } elseif ($maxpages == $max) {
            $start = 1;
        }

        $html =  '<div style="width:100%" class="center">';
            $html .=  '<div class="center">';
                $html .= '<div class="float_left btn">';
                    $html .= '<a class="pagination" href="' . $path . '=previous">' . _lang::lang('previous') . '</a>';
                $html .= '</div>';
                for ($i = $start; $i <= ($end); $i++) {
                    if (($i<=$end)) {
                        $html .= '<div class="float_left btn">';
                            $html .= '<a class="pagination" href="' . $path . '=' . $i . '"> ';
                                $html .= ($page==$i)?'<b>'. $i .'</b>':$i;
                            $html .= '</a>';
                        $html .= '</div>';
                    }
                }

                if (($maxpages!=$max)&&($maxpages>$max)&&($i<$maxpages)&&($maxpages>($end-1))) {
                    $html .= '<div class="float_left empty_btn">';
                        $html .=  ' ... ';//'<a class="pagination" href="' . $path . '=' . $i . '"> ' . $i . '</a>';
                    $html .= '</div>';
                }

                if ($i<=$maxpages) {
                    $html .= '<div class="float_left btn">';
                        $html .= '<a class="pagination" href="' . $path . '=' . $maxpages . '"> ';
                            $html .= ($page==$maxpages)?'<b>' . $maxpages . '</b>':$maxpages;
                        $html .= '</a>';
                    $html .= '</div>';
                }

                $html .= '<div class="float_left btn">';
                    $html .= '<a class="pagination" href="' . $path . '=next">' . _lang::lang('next') . '</a>';
                $html .= '</div>';
            $html .= '</div>';
        $html .= '</div>';
        return $html;
    }
}

/**
 * Language
    $lang['nl']['previous']     = 'Vorig';
    $lang['nl']['next']         = 'Volgend';
 */
/**
 * Style items
 * .empty_btn {
    background-color: rgba(192,192,192,0.3);
    word-break: normal;
    border: #73AD21 solid thin;
    padding: 6px;
    margin: 1px;
}  
.btn {
    background-color: rgba(192,192,192,0.3);
    word-break: normal;
    border: #73AD21 solid thin;
    padding: 6px;
    margin: 1px;
}  
.btn:hover {
    background-color: #73AD21;
    border: #DDD inset medium;
    color: white;
}
a.pagination {
    color : #73AD21;
}
a.pagination:hover {
    color : white;
}
.float_left {
    float:left;
}

 *
 */
/**
 * Sample piece web application part
 *
 * if (isset($_GET['page'])) {//do navigation choice  
    //take session values or default
    $page_set=$_GET['page'];
    //$pageno = a_sessions::_SessionGet('page_set');
    (isset($pageno))||$pageno = 1;
    switch ($page_set) {
        case 'previous':
            $pageno = a_sessions::_SessionGet('pageno');
            if ($pageno>1) {
                $pageno=$pageno-1;
            } else {
                $pageno = 1;
            }
            break;
        case 'next':
            $pageno = a_sessions::_SessionGet('pageno');
            (!isset($pageno))&&$pageno = 1;
            $fCount = a_sessions::_SessionGet('maxpages');
            (!isset($fCount))&&$fCount = PAGEMAX;
            if ($pageno+1<=$fCount) {
                $pageno=$pageno+1;
            }
            break;

        default:
            $pageno = $page_set;
            break;
    }
    a_sessions::_SessionSet('pageno', $pageno);

 */

?>

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.