Quick Search:

View

Revision:

Diff

Diff from 432 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 432 2006-02-15 07:41:34Z 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
1
65     function process() {
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
89     function output() {
90       $output_string = '';
hpdl
428
91
92       foreach ($this->modules as $module) {
93         $module = 'osC_OrderTotal_' . $module;
94
hpdl
432
95         if ($GLOBALS[$module]->getStatus() === true) {
hpdl
428
96           foreach ($GLOBALS[$module]->output as $output) {
97             $output_string .= '              <tr>' . "\n" .
98                               '                <td align="right" class="main">' . $output['title'] . '</td>' . "\n" .
99                               '                <td align="right" class="main">' . $output['text'] . '</td>' . "\n" .
100                               '              </tr>';
hpdl
1
101           }
102         }
103       }
104
105       return $output_string;
106     }
hpdl
428
107
hpdl
431
108     function hasActive() {
109       static $has_active;
110
111       if (isset($has_active) === false) {
112         $has_active = false;
113
114         foreach ($this->modules as $module) {
hpdl
432
115           if ($GLOBALS['osC_OrderTotal_' . $module]->getStatus() === true) {
hpdl
431
116             $has_active = true;
117             break;
118           }
119         }
120       }
121
122       return $has_active;
123     }
124
hpdl
428
125     function hasKeys() {
126       static $has_keys;
127
128       if (isset($has_keys) === false) {
129         $has_keys = (sizeof($this->getKeys()) > 0) ? true : false;
130       }
131
132       return $has_keys;
133     }
134
135     function install() {
136       global $osC_Database, $osC_Language;
137
138       $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)');
139       $Qinstall->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
140       $Qinstall->bindValue(':title', $this->_title);
141       $Qinstall->bindValue(':code', $this->_code);
142       $Qinstall->bindValue(':author_name', $this->_author_name);
143       $Qinstall->bindValue(':author_www', $this->_author_www);
144       $Qinstall->bindValue(':modules_group', $this->_group);
145       $Qinstall->execute();
146
147       foreach ($osC_Language->getAll() as $key => $value) {
148         if (file_exists(dirname(__FILE__) . '/../languages/' . $key . '/modules/' . $this->_group . '/' . $this->_code . '.xml')) {
149           foreach ($osC_Language->extractDefinitions($key . '/modules/' . $this->_group . '/' . $this->_code . '.xml') as $def) {
150             $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');
151             $Qcheck->bindTable(':table_languages_definitions', TABLE_LANGUAGES_DEFINITIONS);
152             $Qcheck->bindValue(':definition_key', $def['key']);
153             $Qcheck->bindValue(':content_group', $def['group']);
154             $Qcheck->bindInt(':languages_id', $value['id']);
155             $Qcheck->execute();
156
157             if ($Qcheck->numberOfRows() === 1) {
158               $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');
159             } else {
160               $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)');
161             }
162             $Qdef->bindTable(':table_languages_definitions', TABLE_LANGUAGES_DEFINITIONS);
163             $Qdef->bindInt(':languages_id', $value['id']);
164             $Qdef->bindValue(':content_group', $def['group']);
165             $Qdef->bindValue(':definition_key', $def['key']);
166             $Qdef->bindValue(':definition_value', $def['value']);
167             $Qdef->execute();
168           }
169         }
170       }
171
172       osC_Cache::clear('languages');
173     }
174
175     function remove() {
176       global $osC_Database, $osC_Language;
177
178       $Qdel = $osC_Database->query('delete from :table_templates_boxes where code = :code and modules_group = :modules_group');
179       $Qdel->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
180       $Qdel->bindValue(':code', $this->_code);
181       $Qdel->bindValue(':modules_group', $this->_group);
182       $Qdel->execute();
183
184       if ($this->hasKeys()) {
185         $Qdel = $osC_Database->query('delete from :table_configuration where configuration_key in (":configuration_key")');
186         $Qdel->bindTable(':table_configuration', TABLE_CONFIGURATION);
187         $Qdel->bindRaw(':configuration_key', implode('", "', $this->getKeys()));
188         $Qdel->execute();
189       }
190
191       if (file_exists(dirname(__FILE__) . '/../languages/' . $osC_Language->getCode() . '/modules/' . $this->_group . '/' . $this->_code . '.xml')) {
192         foreach ($osC_Language->extractDefinitions($osC_Language->getCode() . '/modules/' . $this->_group . '/' . $this->_code . '.xml') as $def) {
193           $Qdel = $osC_Database->query('delete from :table_languages_definitions where definition_key = :definition_key and content_group = :content_group');
194           $Qdel->bindTable(':table_languages_definitions', TABLE_LANGUAGES_DEFINITIONS);
195           $Qdel->bindValue(':definition_key', $def['key']);
196           $Qdel->bindValue(':content_group', $def['group']);
197           $Qdel->execute();
198         }
199
200         osC_Cache::clear('languages');
201       }
202     }
203
204     function _usortModules($a, $b) {
hpdl
432
205       if ($GLOBALS['osC_OrderTotal_' . $a]->getSortOrder() == $GLOBALS['osC_OrderTotal_' . $b]->getSortOrder()) {
206         return strnatcasecmp($GLOBALS['osC_OrderTotal_' . $a]->getTitle(), $GLOBALS['osC_OrderTotal_' . $a]->getTitle());
hpdl
428
207       }
208
hpdl
432
209       return ($GLOBALS['osC_OrderTotal_' . $a]->getSortOrder() < $GLOBALS['osC_OrderTotal_' . $b]->getSortOrder()) ? -1 : 1;
hpdl
428
210     }
hpdl
1
211   }
hpdl
428
212 ?>