Quick Search:

View

Revision:

Diff

Diff from 1865 to:

Annotations

Annotate by Age | Author | Mixed | None
/fisheye/browse/osCommerce/branches/hpdl/oscommerce/includes/classes/database.php

Annotated File View

hpdl
1
1 <?php
2 /*
hpdl
15
3   $Id: database.php 1865 2009-03-08 22:00:36Z hpdl $
hpdl
1
4
5   osCommerce, Open Source E-Commerce Solutions
6   http://www.oscommerce.com
7
hpdl
1863
8   Copyright (c) 2009 osCommerce
hpdl
1
9
hpdl
1498
10   This program is free software; you can redistribute it and/or modify
11   it under the terms of the GNU General Public License v2 (1991)
12   as published by the Free Software Foundation.
hpdl
1
13 */
14
15   class osC_Database {
16     var $is_connected = false,
17         $link,
hpdl
368
18         $error_reporting = true,
19         $error = false,
hpdl
1
20         $error_number,
hpdl
368
21         $error_query,
hpdl
1
22         $server,
23         $username,
24         $password,
25         $debug = false,
26         $number_of_queries = 0,
hpdl
1372
27         $time_of_queries = 0,
28         $nextID = null,
29         $logging_transaction = false,
30         $logging_transaction_action = false;
hpdl
1
31
hpdl
1037
32     function &connect($server, $username, $password, $type = DB_DATABASE_CLASS) {
hpdl
1
33       require('database/' . $type . '.php');
34
35       $class = 'osC_Database_' . $type;
hpdl
368
36       $object = new $class($server, $username, $password);
hpdl
1
37
hpdl
368
38       return $object;
hpdl
1
39     }
40
41     function setConnected($boolean) {
42       if ($boolean === true) {
43         $this->is_connected = true;
44       } else {
45         $this->is_connected = false;
46       }
47     }
48
49     function isConnected() {
50       if ($this->is_connected === true) {
51         return true;
52       } else {
53         return false;
54       }
55     }
56
57     function &query($query) {
58       $osC_Database_Result =& new osC_Database_Result($this);
59       $osC_Database_Result->setQuery($query);
60
61       return $osC_Database_Result;
62     }
63
hpdl
368
64     function setError($error, $error_number = '', $query = '') {
hpdl
1863
65       global $osC_MessageStack;
hpdl
1
66
67       if ($this->error_reporting === true) {
68         $this->error = $error;
69         $this->error_number = $error_number;
hpdl
368
70         $this->error_query = $query;
hpdl
1
71
hpdl
1865
72         trigger_error('[MYSQL] ' . $this->error . ' (' . $this->error_number . '): [QUERY] ' . $this->error_query, E_USER_WARNING);
73
hpdl
1863
74         if (isset($osC_MessageStack)) {
75           $osC_MessageStack->add('debug', $this->getError());
hpdl
1
76         }
77       }
78     }
79
80     function isError() {
81       if ($this->error === false) {
82         return false;
83       } else {
84         return true;
85       }
86     }
87
88     function getError() {
89       if ($this->isError()) {
90         $error = '';
91
92         if (!empty($this->error_number)) {
93           $error .= $this->error_number . ': ';
94         }
95
96         $error .= $this->error;
97
hpdl
368
98         if (!empty($this->error_query)) {
99           $error .= '; ' . htmlentities($this->error_query);
100         }
101
hpdl
1
102         return $error;
103       } else {
104         return false;
105       }
106     }
107
108     function setErrorReporting($boolean) {
109       if ($boolean === true) {
110         $this->error_reporting = true;
111       } else {
112         $this->error_reporting = false;
113       }
114     }
115
116     function setDebug($boolean) {
117       if ($boolean === true) {
118         $this->debug = true;
119       } else {
120         $this->debug = false;
121       }
122     }
123
124     function importSQL($sql_file, $database, $table_prefix = -1) {
125       if ($this->selectDatabase($database)) {
126         if (file_exists($sql_file)) {
127           $fd = fopen($sql_file, 'rb');
128           $import_queries = fread($fd, filesize($sql_file));
129           fclose($fd);
130         } else {
131           $this->setError(sprintf(ERROR_SQL_FILE_NONEXISTENT, $sql_file));
132
133           return false;
134         }
135
136         if (!get_cfg_var('safe_mode')) {
137           @set_time_limit(0);
138         }
139
140         $sql_queries = array();
141         $sql_length = strlen($import_queries);
142         $pos = strpos($import_queries, ';');
143
144         for ($i=$pos; $i<$sql_length; $i++) {
145 // remove comments
146           if ($import_queries[0] == '#') {
147             $import_queries = ltrim(substr($import_queries, strpos($import_queries, "\n")));
148             $sql_length = strlen($import_queries);
149             $i = strpos($import_queries, ';')-1;
150             continue;
151           }
152
153           if ($import_queries[($i+1)] == "\n") {
hpdl
658
154             $next = '';
155
hpdl
1
156             for ($j=($i+2); $j<$sql_length; $j++) {
157               if (!empty($import_queries[$j])) {
158                 $next = substr($import_queries, $j, 6);
159
160                 if ($next[0] == '#') {
161 // find out where the break position is so we can remove this line (#comment line)
162                   for ($k=$j; $k<$sql_length; $k++) {
163                     if ($import_queries[$k] == "\n") {
164                       break;
165                     }
166                   }
167
168                   $query = substr($import_queries, 0, $i+1);
169
170                   $import_queries = substr($import_queries, $k);
171
172 // join the query before the comment appeared, with the rest of the dump
173                   $import_queries = $query . $import_queries;
174                   $sql_length = strlen($import_queries);
175                   $i = strpos($import_queries, ';')-1;
176                   continue 2;
177                 }
178
179                 break;
180               }
181             }
182
183             if (empty($next)) { // get the last insert query
184               $next = 'insert';
185             }
186
187             if ((strtoupper($next) == 'DROP T') || (strtoupper($next) == 'CREATE') || (strtoupper($next) == 'INSERT')) {
188               $next = '';
189
190               $sql_query = substr($import_queries, 0, $i);
191
192               if ($table_prefix !== -1) {
193                 if (strtoupper(substr($sql_query, 0, 25)) == 'DROP TABLE IF EXISTS OSC_') {
194                   $sql_query = 'DROP TABLE IF EXISTS ' . $table_prefix . substr($sql_query, 25);
195                 } elseif (strtoupper(substr($sql_query, 0, 17)) == 'CREATE TABLE OSC_') {
196                   $sql_query = 'CREATE TABLE ' . $table_prefix . substr($sql_query, 17);
197                 } elseif (strtoupper(substr($sql_query, 0, 16)) == 'INSERT INTO OSC_') {
198                   $sql_query = 'INSERT INTO ' . $table_prefix . substr($sql_query, 16);
199                 }
200               }
201
hpdl
368
202               $sql_queries[] = trim($sql_query);
hpdl
1
203
204               $import_queries = ltrim(substr($import_queries, $i+1));
205               $sql_length = strlen($import_queries);
206               $i = strpos($import_queries, ';')-1;
207             }
208           }
209         }
210
211         for ($i=0, $n=sizeof($sql_queries); $i<$n; $i++) {
212           $this->simpleQuery($sql_queries[$i]);
hpdl
368
213
214           if ($this->isError()) {
215             break;
216           }
hpdl
1
217         }
218       }
219
220       if ($this->isError()) {
221         return false;
222       } else {
223         return true;
224       }
225     }
226
227     function hasCreatePermission($database) {
228       $db_created = false;
229
230       if (empty($database)) {
231         $this->setError(ERROR_DB_NO_DATABASE_SELECTED);
232
233         return false;
234       }
235
236       $this->setErrorReporting(false);
237
238       if ($this->selectDatabase($database) === false) {
239         $this->setErrorReporting(true);
240
241         if ($this->simpleQuery('create database ' . $database)) {
242           $db_created = true;
243         }
244       }
245
246       $this->setErrorReporting(true);
247
248       if ($this->isError() === false) {
249         if ($this->selectDatabase($database)) {
250           if ($this->simpleQuery('create table osCommerceTestTable1536f ( temp_id int )')) {
251             if ($db_created === true) {
252               $this->simpleQuery('drop database ' . $database);
253             } else {
254               $this->simpleQuery('drop table osCommerceTestTable1536f');
255             }
256           }
257         }
258       }
259
260       if ($this->isError()) {
261         return false;
262       } else {
263         return true;
264       }
265     }
266
267     function numberOfQueries() {
268       return $this->number_of_queries;
269     }
270
271     function timeOfQueries() {
272       return $this->time_of_queries;
273     }
274
275     function getMicroTime() {
276       list($usec, $sec) = explode(' ', microtime());
277
278       return ((float)$usec + (float)$sec);
279     }
280   }
281
282   class osC_Database_Result {
283     var $db_class,
284         $sql_query,
285         $query_handler,
286         $result,
287         $rows,
288         $affected_rows,
289         $cache_key,
290         $cache_expire,
291         $cache_data,
292         $cache_read = false,
293         $debug = false,
294         $batch_query = false,
295         $batch_number,
296         $batch_rows,
297         $batch_size,
298         $batch_to,
299         $batch_from,
hpdl
1372
300         $batch_select_field,
301         $logging = false,
302         $logging_module,
303         $logging_module_id,
304         $logging_fields = array(),
hpdl
1862
305         $logging_changed = array(),
306         $_db_tables = array();
hpdl
1
307
hpdl
1860
308     function __construct(&$db_class) {
hpdl
1
309       $this->db_class =& $db_class;
310     }
311
312     function setQuery($query) {
313       $this->sql_query = $query;
314     }
315
316     function appendQuery($query) {
317       $this->sql_query .= ' ' . $query;
318     }
319
320     function getQuery() {
321       return $this->sql_query;
322     }
323
324     function setDebug($boolean) {
325       if ($boolean === true) {
326         $this->debug = true;
327       } else {
328         $this->debug = false;
329       }
330     }
331
332     function valueMixed($column, $type = 'string') {
333       if (!isset($this->result)) {
334         $this->next();
335       }
336
337       switch ($type) {
338         case 'protected':
hpdl
757
339           return osc_output_string_protected($this->result[$column]);
hpdl
1
340           break;
341         case 'int':
342           return (int)$this->result[$column];
343           break;
344         case 'decimal':
345           return (float)$this->result[$column];
346           break;
347         case 'string':
348         default:
349           return $this->result[$column];
350       }
351     }
352
353     function value($column) {
354       return $this->valueMixed($column, 'string');
355     }
356
357     function valueProtected($column) {
358       return $this->valueMixed($column, 'protected');
359     }
360
361     function valueInt($column) {
362       return $this->valueMixed($column, 'int');
363     }
364
365     function valueDecimal($column) {
366       return $this->valueMixed($column, 'decimal');
367     }
368
hpdl
1372
369     function bindValueMixed($place_holder, $value, $type = 'string', $log = true) {
370       if ($log === true) {
371         $this->logging_fields[substr($place_holder, 1)] = $value;
372       }
373
hpdl
1
374       switch ($type) {
375         case 'int':
376           $value = intval($value);
377           break;
hpdl
368
378         case 'float':
379           $value = floatval($value);
380           break;
hpdl
1
381         case 'raw':
382           break;
383         case 'string':
384         default:
hpdl
1319
385           $value = "'" . $this->db_class->parseString(trim($value)) . "'";
hpdl
1
386       }
387
388       $this->bindReplace($place_holder, $value);
389     }
390
391     function bindReplace($place_holder, $value) {
392       $pos = strpos($this->sql_query, $place_holder);
393
394       if ($pos !== false) {
395         $length = strlen($place_holder);
396         $character_after_place_holder = substr($this->sql_query, $pos+$length, 1);
397
398         if (($character_after_place_holder === false) || ereg('[ ,)"]', $character_after_place_holder)) {
399           $this->sql_query = substr_replace($this->sql_query, $value, $pos, $length);
400         }
401       }
402     }
403
404     function bindValue($place_holder, $value) {
405       $this->bindValueMixed($place_holder, $value, 'string');
406     }
407
408     function bindInt($place_holder, $value) {
409       $this->bindValueMixed($place_holder, $value, 'int');
410     }
411
hpdl
368
412     function bindFloat($place_holder, $value) {
413       $this->bindValueMixed($place_holder, $value, 'float');
414     }
415
hpdl
1
416     function bindRaw($place_holder, $value) {
417       $this->bindValueMixed($place_holder, $value, 'raw');
418     }
419
hpdl
1862
420     function bindTable($place_holder, $value = null) {
421       if ( empty($value) ) { // remove :table_ from $place_holder and prefix it with the database name prefix value
422         if ( !isset($this->_db_tables[$place_holder]) ) {
423           $this->_db_tables[$place_holder] = DB_TABLE_PREFIX . substr($place_holder, 7);
424         }
425
426         $value = $this->_db_tables[$place_holder];
427       }
428
hpdl
1372
429       $this->bindValueMixed($place_holder, $value, 'raw', false);
hpdl
1
430     }
431
432     function next() {
433       if ($this->cache_read === true) {
434         list(, $this->result) = each($this->cache_data);
435       } else {
436         if (!isset($this->query_handler)) {
437           $this->execute();
438         }
439
440         $this->result = $this->db_class->next($this->query_handler);
441
442         if (isset($this->cache_key)) {
443           $this->cache_data[] = $this->result;
444         }
445       }
446
447       return $this->result;
448     }
449
450     function freeResult() {
451       global $osC_Cache;
452
453       if ($this->cache_read === false) {
454         if (eregi('^SELECT', $this->sql_query)) {
455           $this->db_class->freeResult($this->query_handler);
456         }
457
458         if (isset($this->cache_key)) {
hpdl
1860
459           $osC_Cache->write($this->cache_data, $this->cache_key);
hpdl
1
460         }
461       }
462
463       unset($this);
464     }
465
466     function numberOfRows() {
467       if (!isset($this->rows)) {
468         if (!isset($this->query_handler)) {
469           $this->execute();
470         }
471
472         if (isset($this->cache_key) && ($this->cache_read === true)) {
473           $this->rows = sizeof($this->cache_data);
474         } else {
475           $this->rows = $this->db_class->numberOfRows($this->query_handler);
476         }
477       }
478
479       return $this->rows;
480     }
481
482     function affectedRows() {
483       if (!isset($this->affected_rows)) {
484         if (!isset($this->query_handler)) {
485           $this->execute();
486         }
487
488         $this->affected_rows = $this->db_class->affectedRows();
489       }
490
491       return $this->affected_rows;
492     }
493
494     function execute() {
495       global $osC_Cache;
496
497       if (isset($this->cache_key)) {
498         if ($osC_Cache->read($this->cache_key, $this->cache_expire)) {
hpdl
1860
499           $this->cache_data = $osC_Cache->getCache();
hpdl
1
500
501           $this->cache_read = true;
502         }
503       }
504
505       if ($this->cache_read === false) {
hpdl
1372
506         if ($this->logging === true) {
507           $this->logging_action = substr($this->sql_query, 0, strpos($this->sql_query, ' '));
508
509           if ($this->logging_action == 'update') {
510             $db = split(' ', $this->sql_query, 3);
511             $this->logging_database = $db[1];
512
513             $test = $this->db_class->simpleQuery('select ' . implode(', ', array_keys($this->logging_fields)) . ' from ' . $this->logging_database . substr($this->sql_query, osc_strrpos_string($this->sql_query, ' where ')));
514
515             while ($result = $this->db_class->next($test)) {
516               foreach ($this->logging_fields as $key => $value) {
517                 if ($result[$key] != $value) {
518                   $this->logging_changed[] = array('key' => $this->logging_database . '.' . $key, 'old' => $result[$key], 'new' => $value);
519                 }
520               }
521             }
522           } elseif ($this->logging_action == 'insert') {
523             $db = split(' ', $this->sql_query, 4);
524             $this->logging_database = $db[2];
525
526             foreach ($this->logging_fields as $key => $value) {
527               $this->logging_changed[] = array('key' => $this->logging_database . '.' . $key, 'old' => '', 'new' => $value);
528             }
529           } elseif ($this->logging_action == 'delete') {
530             $db = split(' ', $this->sql_query, 4);
531             $this->logging_database = $db[2];
532
533             $del = $this->db_class->simpleQuery('select * from ' . $this->logging_database . ' ' . $db[3]);
534             while ($result = $this->db_class->next($del)) {
535               foreach ($result as $key => $value) {
536                 $this->logging_changed[] = array('key' => $this->logging_database . '.' . $key, 'old' => $value, 'new' => '');
537               }
538             }
539           }
540         }
541
hpdl
1
542         $this->query_handler = $this->db_class->simpleQuery($this->sql_query, $this->debug);
543
hpdl
1372
544         if ($this->logging === true) {
545           if ($this->db_class->logging_transaction_action === false) {
546             $this->db_class->logging_transaction_action = $this->logging_action;
547           }
548
549           if ($this->affectedRows($this->query_handler) > 0) {
550             if (!empty($this->logging_changed)) {
551               if ( ($this->logging_action == 'insert') && !is_numeric($this->logging_module_id) ) {
552                 $this->logging_module_id = $this->db_class->nextID();
553                 $this->setNextID($this->logging_module_id);
554               }
555
hpdl
1863
556               if ( class_exists('osC_AdministratorsLog_Admin') ) {
557                 osC_AdministratorsLog_Admin::insert($this->logging_module, $this->db_class->logging_transaction_action, $this->logging_module_id, $this->logging_action, $this->logging_changed, $this->db_class->logging_transaction);
hpdl
1372
558               }
559             }
560           }
561         }
562
hpdl
1
563         if ($this->batch_query === true) {
hpdl
1385
564           $this->batch_size = $this->db_class->getBatchSize($this->sql_query, $this->batch_select_field);
hpdl
1
565
566           $this->batch_to = ($this->batch_rows * $this->batch_number);
567           if ($this->batch_to > $this->batch_size) {
568             $this->batch_to = $this->batch_size;
569           }
570
571           $this->batch_from = ($this->batch_rows * ($this->batch_number - 1));
572           if ($this->batch_to == 0) {
573             $this->batch_from = 0;
574           } else {
575             $this->batch_from++;
576           }
577         }
578
579         return $this->query_handler;
580       }
581     }
582
583     function executeRandom() {
584       return $this->query_handler = $this->db_class->randomQuery($this->sql_query);
585     }
586
587     function executeRandomMulti() {
588       return $this->query_handler = $this->db_class->randomQueryMulti($this->sql_query);
589     }
590
591     function setCache($key, $expire = 0) {
592       $this->cache_key = $key;
593       $this->cache_expire = $expire;
594     }
595
hpdl
1372
596     function setLogging($module, $id = null) {
597       $this->logging = true;
598       $this->logging_module = $module;
599       $this->logging_module_id = $id;
600     }
601
602     function setNextID($id) {
603       $this->db_class->nextID = $id;
604     }
605
hpdl
1
606     function toArray() {
607       if (!isset($this->result)) {
608         $this->next();
609       }
610
611       return $this->result;
612     }
613
hpdl
368
614     function prepareSearch($keywords, $columns, $embedded = false) {
615       if ($embedded === true) {
616         $this->sql_query .= ' and ';
617       }
618
619       $keywords_array = explode(' ', $keywords);
620
621       if ($this->db_class->use_fulltext === true) {
622         if ($this->db_class->use_fulltext_boolean === true) {
623           $keywords = '';
624
625           foreach ($keywords_array as $keyword) {
626             if ((substr($keyword, 0, 1) != '-') && (substr($keyword, 0, 1) != '+')) {
627               $keywords .= '+';
628             }
629
630             $keywords .= $keyword . ' ';
631           }
632
633           $keywords = substr($keywords, 0, -1);
634         }
635
636         $this->sql_query .= $this->db_class->prepareSearch($columns);
637         $this->bindValue(':keywords', $keywords);
638       } else {
639         foreach ($keywords_array as $keyword) {
640           $this->sql_query .= $this->db_class->prepareSearch($columns);
641
642           foreach ($columns as $column) {
643             $this->bindValue(':keyword', '%' . $keyword . '%');
644           }
645
646           $this->sql_query .= ' and ';
647         }
648
649         $this->sql_query = substr($this->sql_query, 0, -5);
650       }
651     }
652
hpdl
108
653     function setBatchLimit($batch_number = 1, $maximum_rows = 20, $select_field = '') {
hpdl
1
654       $this->batch_query = true;
hpdl
108
655       $this->batch_number = (is_numeric($batch_number) ? $batch_number : 1);
hpdl
1
656       $this->batch_rows = $maximum_rows;
657       $this->batch_select_field = (empty($select_field) ? '*' : $select_field);
658
hpdl
448
659       $from = max(($this->batch_number * $maximum_rows) - $maximum_rows, 0);
hpdl
1
660
661       $this->sql_query = $this->db_class->setBatchLimit($this->sql_query, $from, $maximum_rows);
662
663     }
664
hpdl
368
665     function getBatchSize() {
hpdl
1385
666       return $this->batch_size;
667     }
hpdl
1
668
hpdl
1385
669     function isBatchQuery() {
670       if ($this->batch_query === true) {
671         return true;
hpdl
1
672       }
673
hpdl
1385
674       return false;
hpdl
1
675     }
676
hpdl
1385
677     function getBatchTotalPages($text) {
hpdl
1
678       return sprintf($text, $this->batch_from, $this->batch_to, $this->batch_size);
679     }
680
hpdl
1385
681     function getBatchPageLinks($batch_keyword = 'page', $parameters = '', $with_pull_down_menu = true) {
682       $string = $this->getBatchPreviousPageLink($batch_keyword, $parameters);
683
684       if ( $with_pull_down_menu === true ) {
685         $string .= $this->getBatchPagesPullDownMenu($batch_keyword, $parameters);
686       }
687
688       $string .= $this->getBatchNextPageLink($batch_keyword, $parameters);
689
690       return $string;
691     }
692
693     function getBatchPagesPullDownMenu($batch_keyword = 'page', $parameters = '') {
hpdl
410
694       global $osC_Language;
695
hpdl
1
696       $number_of_pages = ceil($this->batch_size / $this->batch_rows);
697
hpdl
1385
698       if ( $number_of_pages > 1 ) {
hpdl
1
699         $pages_array = array();
hpdl
1385
700
701         for ( $i = 1; $i <= $number_of_pages; $i++ ) {
702           $pages_array[] = array('id' => $i,
703                                  'text' => $i);
hpdl
1
704         }
705
706         $hidden_parameter = '';
hpdl
1076
707
hpdl
1385
708         if ( !empty($parameters) ) {
hpdl
754
709           $parameters = explode('&', $parameters);
hpdl
1076
710
hpdl
1385
711           foreach ( $parameters as $parameter ) {
hpdl
1076
712             $keys = explode('=', $parameter, 2);
hpdl
1
713
hpdl
1385
714             if ( $keys[0] != $batch_keyword ) {
hpdl
1076
715               $hidden_parameter .= osc_draw_hidden_field($keys[0], (isset($keys[1]) ? $keys[1] : ''));
hpdl
1
716             }
717           }
718         }
719
hpdl
1385
720         $string = '<form action="' . osc_href_link(basename($_SERVER['SCRIPT_FILENAME'])) . '" action="get">' . $hidden_parameter .
721                   sprintf($osC_Language->get('result_set_current_page'), osc_draw_pull_down_menu($batch_keyword, $pages_array, $this->batch_number, 'onchange="this.form.submit();"'), $number_of_pages) .
722                   osc_draw_hidden_session_id_field() . '</form>';
723       } else {
724         $string = sprintf($osC_Language->get('result_set_current_page'), 1, 1);
725       }
hpdl
1
726
hpdl
1385
727       return $string;
728     }
hpdl
1
729
hpdl
1385
730     function getBatchPreviousPageLink($batch_keyword = 'page', $parameters = '') {
731       global $osC_Language;
hpdl
1
732
hpdl
1385
733       $get_parameter = '';
734
735       if ( !empty($parameters) ) {
736         $parameters = explode('&', $parameters);
737
738         foreach ( $parameters as $parameter ) {
739           $keys = explode('=', $parameter, 2);
740
741           if ( $keys[0] != $batch_keyword ) {
742             $get_parameter .= $keys[0] . (isset($keys[1]) ? '=' . $keys[1] : '') . '&';
743           }
hpdl
1
744         }
hpdl
1385
745       }
hpdl
1
746
hpdl
1385
747       if ( defined('OSC_IN_ADMIN') && ( OSC_IN_ADMIN === true ) ) {
748         $back_string = osc_icon('nav_back.png');
749         $back_grey_string = osc_icon('nav_back_grey.png');
hpdl
1
750       } else {
hpdl
1385
751         $back_string = $osC_Language->get('result_set_previous_page');
752         $back_grey_string = $osC_Language->get('result_set_previous_page');
hpdl
1
753       }
754
hpdl
1385
755       if ( $this->batch_number > 1 ) {
756         $string = osc_link_object(osc_href_link(basename($_SERVER['SCRIPT_FILENAME']), $get_parameter . $batch_keyword . '=' . ($this->batch_number - 1)), $back_string);
757       } else {
758         $string = $back_grey_string;
759       }
760
761       $string .= '&nbsp;';
762
763       return $string;
hpdl
1
764     }
765
hpdl
1385
766     function getBatchNextPageLink($batch_keyword = 'page', $parameters = '') {
767       global $osC_Language;
768
769       $number_of_pages = ceil($this->batch_size / $this->batch_rows);
770
771       $get_parameter = '';
772
773       if ( !empty($parameters) ) {
774         $parameters = explode('&', $parameters);
775
776         foreach ( $parameters as $parameter ) {
777           $keys = explode('=', $parameter, 2);
778
779           if ( $keys[0] != $batch_keyword ) {
780             $get_parameter .= $keys[0] . (isset($keys[1]) ? '=' . $keys[1] : '') . '&';
781           }
782         }
hpdl
1
783       }
784
hpdl
1385
785       if ( defined('OSC_IN_ADMIN') && ( OSC_IN_ADMIN === true ) ) {
786         $forward_string = osc_icon('nav_forward.png');
787         $forward_grey_string = osc_icon('nav_forward_grey.png');
788       } else {
789         $forward_string = $osC_Language->get('result_set_next_page');
790         $forward_grey_string = $osC_Language->get('result_set_next_page');
791       }
792
793       $string = '&nbsp;';
794
795       if ( ( $this->batch_number < $number_of_pages ) && ( $number_of_pages != 1 ) ) {
796         $string .= osc_link_object(osc_href_link(basename($_SERVER['SCRIPT_FILENAME']), $get_parameter . $batch_keyword . '=' . ($this->batch_number + 1)), $forward_string);
797       } else {
798         $string .= $forward_grey_string;
799       }
800
801       return $string;
hpdl
1
802     }
803   }
804 ?>