Quick Search:

View

Revision:

Diff

Diff from 1498 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 1498 2007-03-29 14:04:50Z 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
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
hpdl
443
15   class osC_OrderTotal {
16     var $_modules = array(),
17         $_data = array(),
18         $_group = 'order_total';
hpdl
1
19
20 // class constructor
hpdl
443
21     function osC_OrderTotal() {
22       global $osC_Database, $osC_Language;
hpdl
383
23
hpdl
443
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
443
29       while ($Qmodules->next()) {
30         $this->_modules[] = $Qmodules->value('code');
31       }
hpdl
410
32
hpdl
443
33       $Qmodules->freeResult();
hpdl
1
34
hpdl
443
35       $osC_Language->load('modules-order_total');
36
37       foreach ($this->_modules as $module) {
38         $module_class = 'osC_OrderTotal_' . $module;
39
40         if (class_exists($module_class) === false) {
41           include('includes/modules/order_total/' . $module . '.' . substr(basename(__FILE__), (strrpos(basename(__FILE__), '.')+1)));
hpdl
1
42         }
hpdl
443
43
44         $GLOBALS[$module_class] = new $module_class();
hpdl
1
45       }
hpdl
443
46
47       usort($this->_modules, array('osC_OrderTotal', '_usortModules'));
hpdl
1
48     }
49
hpdl
443
50 // class methods
51     function getCode() {
52       return $this->_code;
53     }
hpdl
1
54
hpdl
443
55     function getTitle() {
56       return $this->_title;
57     }
58
59     function getDescription() {
60       return $this->_description;
61     }
62
hpdl
637
63     function isEnabled() {
hpdl
443
64       return $this->_status;
65     }
66
67     function getSortOrder() {
68       return $this->_sort_order;
69     }
70
71     function &getResult() {
72       global $osC_ShoppingCart;
73
74       $this->_data = array();
75
76       foreach ($this->_modules as $module) {
77         $module = 'osC_OrderTotal_' . $module;
78
hpdl
637
79         if ($GLOBALS[$module]->isEnabled() === true) {
hpdl
443
80           $GLOBALS[$module]->process();
81
82           foreach ($GLOBALS[$module]->output as $output) {
hpdl
757
83             if (!empty($output['title']) && !empty($output['text'])) {
hpdl
443
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
443
94       return $this->_data;
hpdl
1
95     }
96
hpdl
443
97     function hasActive() {
98       static $has_active;
99
100       if (isset($has_active) === false) {
101         $has_active = false;
102
103         foreach ($this->_modules as $module) {
hpdl
637
104           if ($GLOBALS['osC_OrderTotal_' . $module]->isEnabled() === true) {
hpdl
443
105             $has_active = true;
106             break;
107           }
108         }
109       }
110
111       return $has_active;
112     }
113
114     function _usortModules($a, $b) {
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());
117       }
118
119       return ($GLOBALS['osC_OrderTotal_' . $a]->getSortOrder() < $GLOBALS['osC_OrderTotal_' . $b]->getSortOrder()) ? -1 : 1;
120     }
hpdl
1
121   }
hpdl
443
122 ?>