Project

General

Profile

1
<?php
2
/*
3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
 *
5
 * This program is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
 */
18
/**
19
 * Unbenannt 3
20
 *
21
 * @category     Addons
22
 * @package      Addons_wrapper
23
 * @subpackage
24
 * @copyright       Dietmar Wöllbrink <dietmar.woellbrink@websitebaker@org>
25
 * @author       Manuela v.d.Decken <manuela@isteam.de>
26
 * @author       Dietmar Wöllbrink <dietmar.woellbrink@websitebaker@org>
27
 * @license      http://www.gnu.org/licenses/gpl.html   GPL License
28
 * @version      3.0.1
29
 * @lastmodified $Date: 2017-07-02 17:14:29 +0200 (Sun, 02 Jul 2017) $
30
 * @since        File available since 2015-12-17
31
 * @deprecated   This interface is deprecated since 2015-12-17
32
 * @description  xyz
33
 * @created      2016-12-3
34
 */
35

    
36
class Pagination {
37

    
38
    protected $oReg    = null;
39
    protected $oDb     = null;
40
    protected $oTrans  = null;
41
    protected $oApp    = null;
42

    
43
    protected $error   = null;
44
    protected $Debug   = false;
45
    protected $aConfig = array();
46
/*
47
    protected $oTpl      = null;
48
    protected $Twig      = null;
49
    protected $loader    = null;
50
    protected $aTwigData = array();
51
*/
52
    public function __construct($aOptions) { $this->init($aOptions);}
53

    
54
    public function __destruct()
55
    {
56
        ini_restore('memory_limit');
57
    }
58

    
59
    public function __isset($name)
60
    {
61
        return isset($this->aConfig[$name]);
62
    }
63

    
64
     public function __set($name, $value)
65
     {
66
//         throw new Exception('Tried to set a readonly or nonexisting property ['.$name.']!!');
67
         return $this->aConfig[$name] = $value;
68
     }
69

    
70
    public function __get($name)
71
    {
72
        $retval = null;
73
        if (!$this->__isset($name)) {
74
            throw new Exception('Tried to get nonexisting property ['.$name.']');
75
        }
76
            $retval = $this->aConfig[$name];
77
        return $retval;
78
    }
79

    
80
/*********************************************************************************************/
81

    
82
/*********************************************************************************************/
83

    
84
    public function set($name, $value = '')
85
    {
86
        $this->aConfig[$name] = $value;
87
    }
88

    
89
    public function get($name)
90
    {
91
        if (!$this->aConfig[$name]){throw new Exception('Tried to get nonexisting property ['.$name.']');;}
92
        return $this->aConfig[$name];
93
    }
94

    
95
    public function removeExtension ($sFilename){
96
        $sRetval = '';
97
        return preg_replace('#^.*?([^/]*?)\.[^\.]*$#i', '\1', $sFilename);
98
    }
99

    
100
    public function isError() {
101
        return sizeof($this->error);
102
    }
103

    
104
    protected function setError($Message) {
105
        $this->error[] = $message;
106
    }
107

    
108
    protected function getError() {
109
        return $this->error;
110
    }
111

    
112
    public function convertToArray ($sList)
113
    {
114
        $retVal = $sList;
115
        if (!is_array($sList)){
116
            $retVal = preg_split('/[\s,=+\;\:\.\|]+/', $sList, -1, PREG_SPLIT_NO_EMPTY);
117
        }
118
        return $retVal;
119
    }
120

    
121
    protected function init($aOptions)
122
    {
123
        $this->oReg   = ($GLOBALS['oReg']?:null);
124
        $this->oDb    = ($GLOBALS['database']?:null);
125
        $this->oTrans = ($GLOBALS['MESSAGE']?:null);
126
        foreach ($aOptions AS $name=>$value){
127
            switch ($name):
128
                case 'ItemPerPage':
129
                case 'CurrentPage':
130
                case 'TotalValues':
131
                    $this->aConfig[$name] = $value;
132
                    break;
133
                case 'Style':
134
                    $this->aConfig[$name] = $value.'.css';
135
                    break;
136
                default:
137
                    $this->setError('Tried to set a not allowed property ['.$name.']!!');
138
            endswitch;
139
        }
140

    
141
        $this->aConfig['bStart'] = TotalValues > $max;
142
        $this->aConfig['bCrump'] = TotalValues > $max;
143

    
144
    }
145

    
146

    
147
} // end of class
148

    
149
/* Old oding
150

    
151

    
152
if (isset($_GET['pPage'])) {
153
    $max = $_GET['pPage'];
154
} elseif (isset($_POST['pPage'])) {
155
    $max = $_POST['pPage'];
156
} else {
157
    $max = 20;
158
}
159

    
160

    
161
<form action="<?php echo $module_edit_link ?>" method="get" name="filterform" >
162
    <input type="hidden" name="tool" value="wb_addons" />
163
    <table class="row_a" style="width: 100%;">
164
        <thead>
165

    
166
        </thead>
167
        <tbody>
168
            <tr style="line-height: 1.5; vertical-align: middle;">
169
                <td style="width: 15%; white-space: nowrap;">
170
                    <label>Addons per Page</label>
171
                </td>
172
                <td style="width: 20%;">
173
                    <select class="pPage" name="pPage">
174
                      <option value="'.$value.'" '.$sSelected.'>'.$name.'</option>
175

    
176
        </tbody>
177
    </table>
178
</form>
179

    
180

    
181
table of data items if existst
182

    
183

    
184

    
185

    
186
//Pagination
187
$page = 1;
188
if (isset($_GET['page'])) $page = $_GET['page'];
189
$total = get_itemcount($addon_type,-1,0,$filter,$new_upl);
190
$npage = 0;
191

    
192
$aPerPage = array('10'=>10,'20'=>20,'30'=>30,'50'=>50,'100'=>100,'All Add-ons'=>$total);
193
//$PagStart = PHP_EOL.''.PHP_EOL;
194
$sDataPerPage  = "\t\t\t\t".'<tr style="height: 4.225em;">'.PHP_EOL;
195
$sDataPerPage  = "".'<select class="pPage" name="pPage">'.PHP_EOL;
196
foreach($aPerPage as $name=>$value){
197
    $sSelected = (($max==$value)?' selected="selected"':'');
198
    $sDataPerPage .= "\t\t\t\t\t\t\t\t".'<option value="'.$value.'" '.$sSelected.'>'.$name.'</option>'.PHP_EOL;
199
}
200
$sDataPerPage .= "\t\t\t\t\t\t\t".'</select>'.PHP_EOL;
201
$links = '';
202
if ($total > $max) {
203
// start Pagination
204
    $links  = "\t\t\t\t\t".'<td  colspan="4">'.PHP_EOL;
205
    $links .= '<div class="w3-center">';
206
    $links .= '<ul class="w3-pagination pagination">'.PHP_EOL;
207
    if ($page > 1) {
208
        $ypage = $page - 1;
209
        $links .= "\t\t\t\t\t\t"."<li><a class=\"w3-hover-green\" href=\"$module_edit_link$urlfilter&page=$ypage&pPage=$max\">Previous page &laquo; </a></li>";
210
    } else {
211
        $links .= "\t\t\t\t\t\t".'<li><a class="w3-disabled">Previous page &laquo; </a></li>';
212
    }
213
    for ($x=0;$x < $total; $x=$x+$max) {
214
        $npage++;
215
        $sCurrent = ($npage==($page)?'current':'');
216
        $links .= "\t\t\t\t\t\t"."<li><a class=\"w3-hover-green ".($sCurrent)."\" href=\"$module_edit_link$urlfilter&page=$npage&pPage=$max\">$npage</a></li>";
217
    }
218
    if ($page < $npage) {
219
        $xpage = $page + 1;
220
        $links .= "\t\t\t\t\t\t"."<li><a class=\"w3-hover-green\" href=\"$module_edit_link$urlfilter&page=$xpage&pPage=$max\"> &raquo; Next Page</a></li>";
221
    } else {
222
        $links .= '<li> <a class="w3-disabled ">&raquo; Next Page</a></li>';
223
    }
224
    $links .= '</ul>'.PHP_EOL;
225
    $links .= '</div>';
226
    $links .= "\t\t\t\t\t".'</td>'.PHP_EOL;
227
// End Pagination
228

    
229
*/
230

    
231
// end of file
(6-6/30)