Quick Search:

View

Revision:

Diff

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