Quick Search:

View

Revision:

Diff

Diff from 428 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 428 2006-02-14 16:47:41Z 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
85     function hasKeys() {
86       static $has_keys;
87
88       if (isset($has_keys) === false) {
89         $has_keys = (sizeof($this->getKeys()) > 0) ? true : false;
90       }
91
92       return $has_keys;
93     }
94
95     function install() {
96       global $osC_Database, $osC_Language;
97
98       $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)');
99       $Qinstall->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
100       $Qinstall->bindValue(':title', $this->_title);
101       $Qinstall->bindValue(':code', $this->_code);
102       $Qinstall->bindValue(':author_name', $this->_author_name);
103       $Qinstall->bindValue(':author_www', $this->_author_www);
104       $Qinstall->bindValue(':modules_group', $this->_group);
105       $Qinstall->execute();
106
107       foreach ($osC_Language->getAll() as $key => $value) {
108         if (file_exists(dirname(__FILE__) . '/../languages/' . $key . '/modules/' . $this->_group . '/' . $this->_code . '.xml')) {
109           foreach ($osC_Language->extractDefinitions($key . '/modules/' . $this->_group . '/' . $this->_code . '.xml') as $def) {
110             $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');
111             $Qcheck->bindTable(':table_languages_definitions', TABLE_LANGUAGES_DEFINITIONS);
112             $Qcheck->bindValue(':definition_key', $def['key']);
113             $Qcheck->bindValue(':content_group', $def['group']);
114             $Qcheck->bindInt(':languages_id', $value['id']);
115             $Qcheck->execute();
116
117             if ($Qcheck->numberOfRows() === 1) {
118               $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');
119             } else {
120               $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)');
121             }
122             $Qdef->bindTable(':table_languages_definitions', TABLE_LANGUAGES_DEFINITIONS);
123             $Qdef->bindInt(':languages_id', $value['id']);
124             $Qdef->bindValue(':content_group', $def['group']);
125             $Qdef->bindValue(':definition_key', $def['key']);
126             $Qdef->bindValue(':definition_value', $def['value']);
127             $Qdef->execute();
128           }
129         }
130       }
131
132       osC_Cache::clear('languages');
133     }
134
135     function remove() {
136       global $osC_Database, $osC_Language;
137
138       $Qdel = $osC_Database->query('delete from :table_templates_boxes where code = :code and modules_group = :modules_group');
139       $Qdel->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
140       $Qdel->bindValue(':code', $this->_code);
141       $Qdel->bindValue(':modules_group', $this->_group);
142       $Qdel->execute();
143
144       if ($this->hasKeys()) {
145         $Qdel = $osC_Database->query('delete from :table_configuration where configuration_key in (":configuration_key")');
146         $Qdel->bindTable(':table_configuration', TABLE_CONFIGURATION);
147         $Qdel->bindRaw(':configuration_key', implode('", "', $this->getKeys()));
148         $Qdel->execute();
149       }
150
151       if (file_exists(dirname(__FILE__) . '/../languages/' . $osC_Language->getCode() . '/modules/' . $this->_group . '/' . $this->_code . '.xml')) {
152         foreach ($osC_Language->extractDefinitions($osC_Language->getCode() . '/modules/' . $this->_group . '/' . $this->_code . '.xml') as $def) {
153           $Qdel = $osC_Database->query('delete from :table_languages_definitions where definition_key = :definition_key and content_group = :content_group');
154           $Qdel->bindTable(':table_languages_definitions', TABLE_LANGUAGES_DEFINITIONS);
155           $Qdel->bindValue(':definition_key', $def['key']);
156           $Qdel->bindValue(':content_group', $def['group']);
157           $Qdel->execute();
158         }
159
160         osC_Cache::clear('languages');
161       }
162     }
163
164     function _usortModules($a, $b) {
165       if ($GLOBALS['osC_Shipping_' . $a]->sort_order == $GLOBALS['osC_Shipping_' . $b]->sort_order) {
166         return strnatcasecmp($GLOBALS['osC_Shipping_' . $a]->title, $GLOBALS['osC_Shipping_' . $a]->title);
167       }
168
169       return ($GLOBALS['osC_Shipping_' . $a]->sort_order < $GLOBALS['osC_Shipping_' . $b]->sort_order) ? -1 : 1;
170     }
hpdl
1
171   }
hpdl
428
172 ?>