Quick Search:

View

Revision:

Diff

Diff from 1497 to:

Annotations

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

Annotated File View

hpdl
1
1 <?php
2 /*
hpdl
153
3   $Id: order_total.php 1497 2007-03-29 13:40:05Z hpdl $
hpdl
1
4
5   osCommerce, Open Source E-Commerce Solutions
6   http://www.oscommerce.com
7
hpdl
404
8   Copyright (c) 2006 osCommerce
hpdl
1
9
hpdl
1497
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
hpdl
428
15   class osC_OrderTotal {
hpdl
434
16     var $_modules = array(),
hpdl
439
17         $_data = array(),
hpdl
434
18         $_group = 'order_total';
hpdl
1
19
20 // class constructor
hpdl
428
21     function osC_OrderTotal() {
22       global $osC_Database, $osC_Language;
hpdl
377
23
hpdl
428
24       $Qmodules = $osC_Database->query('select code from :table_templates_boxes where modules_group = "order_total"');
25       $Qmodules->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
26       $Qmodules->setCache('modules-order_total');
27       $Qmodules->execute();
hpdl
1
28
hpdl
428
29       while ($Qmodules->next()) {
hpdl
434
30         $this->_modules[] = $Qmodules->value('code');
hpdl
428
31       }
hpdl
404
32
hpdl
428
33       $Qmodules->freeResult();
hpdl
1
34
hpdl
428
35       $osC_Language->load('modules-order_total');
36
hpdl
434
37       foreach ($this->_modules as $module) {
hpdl
428
38         $module_class = 'osC_OrderTotal_' . $module;
39
hpdl
439
40         if (class_exists($module_class) === false) {
41           include('includes/modules/order_total/' . $module . '.' . substr(basename(__FILE__), (strrpos(basename(__FILE__), '.')+1)));
42         }
43
hpdl
428
44         $GLOBALS[$module_class] = new $module_class();
hpdl
1
45       }
hpdl
437
46
47       usort($this->_modules, array('osC_OrderTotal', '_usortModules'));
hpdl
1
48     }
49
hpdl
432
50 // class methods
51     function getCode() {
52       return $this->_code;
53     }
54
55     function getTitle() {
56       return $this->_title;
57     }
58
59     function getDescription() {
60       return $this->_description;
61     }
62
hpdl
620
63     function isEnabled() {
hpdl
432
64       return $this->_status;
65     }
66
67     function getSortOrder() {
68       return $this->_sort_order;
69     }
70
hpdl
439
71     function &getResult() {
hpdl
435
72       global $osC_ShoppingCart;
hpdl
1
73
hpdl
439
74       $this->_data = array();
hpdl
428
75
hpdl
439
76       foreach ($this->_modules as $module) {
77         $module = 'osC_OrderTotal_' . $module;
hpdl
428
78
hpdl
620
79         if ($GLOBALS[$module]->isEnabled() === true) {
hpdl
439
80           $GLOBALS[$module]->process();
hpdl
435
81
hpdl
439
82           foreach ($GLOBALS[$module]->output as $output) {
hpdl
734
83             if (!empty($output['title']) && !empty($output['text'])) {
hpdl
439
84               $this->_data[] = array('code' => $GLOBALS[$module]->getCode(),
85                                      'title' => $output['title'],
86                                      'text' => $output['text'],
87                                      'value' => $output['value'],
88                                      'sort_order' => $GLOBALS[$module]->getSortOrder());
hpdl
1
89             }
90           }
91         }
92       }
93
hpdl
439
94       return $this->_data;
hpdl
1
95     }
96
hpdl
431
97     function hasActive() {
98       static $has_active;
99
100       if (isset($has_active) === false) {
101         $has_active = false;
102
hpdl
434
103         foreach ($this->_modules as $module) {
hpdl
620
104           if ($GLOBALS['osC_OrderTotal_' . $module]->isEnabled() === true) {
hpdl
431
105             $has_active = true;
106             break;
107           }
108         }
109       }
110
111       return $has_active;
112     }
113
hpdl
428
114     function _usortModules($a, $b) {
hpdl
432
115       if ($GLOBALS['osC_OrderTotal_' . $a]->getSortOrder() == $GLOBALS['osC_OrderTotal_' . $b]->getSortOrder()) {
116         return strnatcasecmp($GLOBALS['osC_OrderTotal_' . $a]->getTitle(), $GLOBALS['osC_OrderTotal_' . $a]->getTitle());
hpdl
428
117       }
118
hpdl
432
119       return ($GLOBALS['osC_OrderTotal_' . $a]->getSortOrder() < $GLOBALS['osC_OrderTotal_' . $b]->getSortOrder()) ? -1 : 1;
hpdl
428
120     }
hpdl
1
121   }
hpdl
428
122 ?>