Quick Search:

View

Revision:

Diff

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