Quick Search:

View

Revision:

Diff

Diff from 433 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 433 2006-02-15 19:43:33Z 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
10   Released under the GNU General Public License
11 */
12
hpdl
428
13   class osC_OrderTotal {
hpdl
1
14     var $modules;
15
hpdl
432
16     var $_group = 'order_total';
17
hpdl
1
18 // class constructor
hpdl
428
19     function osC_OrderTotal() {
20       global $osC_Database, $osC_Language;
hpdl
377
21
hpdl
428
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
428
27       while ($Qmodules->next()) {
28         $this->modules[] = $Qmodules->value('code');
29       }
hpdl
404
30
hpdl
428
31       $Qmodules->freeResult();
hpdl
1
32
hpdl
428
33       $osC_Language->load('modules-order_total');
34
35       foreach ($this->modules as $module) {
36         include('includes/modules/order_total/' . $module . '.' . substr(basename(__FILE__), (strrpos(basename(__FILE__), '.')+1)));
37
38         $module_class = 'osC_OrderTotal_' . $module;
39
40         $GLOBALS[$module_class] = new $module_class();
hpdl
1
41       }
42     }
43
hpdl
432
44 // class methods
45     function getCode() {
46       return $this->_code;
47     }
48
49     function getTitle() {
50       return $this->_title;
51     }
52
53     function getDescription() {
54       return $this->_description;
55     }
56
57     function getStatus() {
58       return $this->_status;
59     }
60
61     function getSortOrder() {
62       return $this->_sort_order;
63     }
64
hpdl
433
65     function getResult() {
hpdl
1
66       $order_total_array = array();
67
hpdl
428
68       foreach ($this->modules as $module) {
69         $module = 'osC_OrderTotal_' . $module;
70
hpdl
432
71         if ($GLOBALS[$module]->getStatus() === true) {
hpdl
428
72           $GLOBALS[$module]->process();
73
74           foreach ($GLOBALS[$module]->output as $output) {
75             if (tep_not_null($output['title']) && tep_not_null($output['text'])) {
hpdl
432
76               $order_total_array[] = array('code' => $GLOBALS[$module]->getCode(),
hpdl
428
77                                            'title' => $output['title'],
78                                            'text' => $output['text'],
79                                            'value' => $output['value'],
hpdl
432
80                                            'sort_order' => $GLOBALS[$module]->getSortOrder());
hpdl
1
81             }
82           }
83         }
84       }
85
86       return $order_total_array;
87     }
88
hpdl
431
89     function hasActive() {
90       static $has_active;
91
92       if (isset($has_active) === false) {
93         $has_active = false;
94
95         foreach ($this->modules as $module) {
hpdl
432
96           if ($GLOBALS['osC_OrderTotal_' . $module]->getStatus() === true) {
hpdl
431
97             $has_active = true;
98             break;
99           }
100         }
101       }
102
103       return $has_active;
104     }
105
hpdl
428
106     function hasKeys() {
107       static $has_keys;
108
109       if (isset($has_keys) === false) {
110         $has_keys = (sizeof($this->getKeys()) > 0) ? true : false;
111       }
112
113       return $has_keys;
114     }
115
116     function install() {
117       global $osC_Database, $osC_Language;
118
119       $Qinstall = $osC_Database->query('insert into :table_templates_boxes (title, code, author_name, author_www, modules_group) values (:title, :code, :author_name, :author_www, :modules_group)');
120       $Qinstall->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
121       $Qinstall->bindValue(':title', $this->_title);
122       $Qinstall->bindValue(':code', $this->_code);
123       $Qinstall->bindValue(':author_name', $this->_author_name);
124       $Qinstall->bindValue(':author_www', $this->_author_www);
125       $Qinstall->bindValue(':modules_group', $this->_group);
126       $Qinstall->execute();
127
128       foreach ($osC_Language->getAll() as $key => $value) {
129         if (file_exists(dirname(__FILE__) . '/../languages/' . $key . '/modules/' . $this->_group . '/' . $this->_code . '.xml')) {
130           foreach ($osC_Language->extractDefinitions($key . '/modules/' . $this->_group . '/' . $this->_code . '.xml') as $def) {
131             $Qcheck = $osC_Database->query('select id from :table_languages_definitions where definition_key = :definition_key and content_group = :content_group and languages_id = :languages_id limit 1');
132             $Qcheck->bindTable(':table_languages_definitions', TABLE_LANGUAGES_DEFINITIONS);
133             $Qcheck->bindValue(':definition_key', $def['key']);
134             $Qcheck->bindValue(':content_group', $def['group']);
135             $Qcheck->bindInt(':languages_id', $value['id']);
136             $Qcheck->execute();
137
138             if ($Qcheck->numberOfRows() === 1) {
139               $Qdef = $osC_Database->query('update :table_languages_definitions set definition_value = :definition_value where definition_key = :definition_key and content_group = :content_group and languages_id = :languages_id');
140             } else {
141               $Qdef = $osC_Database->query('insert into :table_languages_definitions (languages_id, content_group, definition_key, definition_value) values (:languages_id, :content_group, :definition_key, :definition_value)');
142             }
143             $Qdef->bindTable(':table_languages_definitions', TABLE_LANGUAGES_DEFINITIONS);
144             $Qdef->bindInt(':languages_id', $value['id']);
145             $Qdef->bindValue(':content_group', $def['group']);
146             $Qdef->bindValue(':definition_key', $def['key']);
147             $Qdef->bindValue(':definition_value', $def['value']);
148             $Qdef->execute();
149           }
150         }
151       }
152
153       osC_Cache::clear('languages');
154     }
155
156     function remove() {
157       global $osC_Database, $osC_Language;
158
159       $Qdel = $osC_Database->query('delete from :table_templates_boxes where code = :code and modules_group = :modules_group');
160       $Qdel->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
161       $Qdel->bindValue(':code', $this->_code);
162       $Qdel->bindValue(':modules_group', $this->_group);
163       $Qdel->execute();
164
165       if ($this->hasKeys()) {
166         $Qdel = $osC_Database->query('delete from :table_configuration where configuration_key in (":configuration_key")');
167         $Qdel->bindTable(':table_configuration', TABLE_CONFIGURATION);
168         $Qdel->bindRaw(':configuration_key', implode('", "', $this->getKeys()));
169         $Qdel->execute();
170       }
171
172       if (file_exists(dirname(__FILE__) . '/../languages/' . $osC_Language->getCode() . '/modules/' . $this->_group . '/' . $this->_code . '.xml')) {
173         foreach ($osC_Language->extractDefinitions($osC_Language->getCode() . '/modules/' . $this->_group . '/' . $this->_code . '.xml') as $def) {
174           $Qdel = $osC_Database->query('delete from :table_languages_definitions where definition_key = :definition_key and content_group = :content_group');
175           $Qdel->bindTable(':table_languages_definitions', TABLE_LANGUAGES_DEFINITIONS);
176           $Qdel->bindValue(':definition_key', $def['key']);
177           $Qdel->bindValue(':content_group', $def['group']);
178           $Qdel->execute();
179         }
180
181         osC_Cache::clear('languages');
182       }
183     }
184
185     function _usortModules($a, $b) {
hpdl
432
186       if ($GLOBALS['osC_OrderTotal_' . $a]->getSortOrder() == $GLOBALS['osC_OrderTotal_' . $b]->getSortOrder()) {
187         return strnatcasecmp($GLOBALS['osC_OrderTotal_' . $a]->getTitle(), $GLOBALS['osC_OrderTotal_' . $a]->getTitle());
hpdl
428
188       }
189
hpdl
432
190       return ($GLOBALS['osC_OrderTotal_' . $a]->getSortOrder() < $GLOBALS['osC_OrderTotal_' . $b]->getSortOrder()) ? -1 : 1;
hpdl
428
191     }
hpdl
1
192   }
hpdl
428
193 ?>