Quick Search:

View

Revision:

Diff

Diff from 637 to:

Annotations

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

Annotated File View

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