Quick Search:

View

Revision:

Diff

Diff from 332 to:

Annotations

Annotate by Age | Author | Mixed | None
/fisheye/browse/osCommerce/trunk/oscommerce/includes/classes/modules.php

Annotated File View

hpdl
308
1 <?php
2 /*
3   $Id: $
4
5   osCommerce, Open Source E-Commerce Solutions
6   http://www.oscommerce.com
7
8   Copyright (c) 2005 osCommerce
9
10   Released under the GNU General Public License
11 */
12
13   class osC_Boxes {
14     var $_boxes,
hpdl
313
15         $_code,
hpdl
308
16         $_title,
17         $_title_link,
hpdl
313
18         $_content,
19         $_author_name,
20         $_author_www,
hpdl
331
21         $_keys,
22         $_module_group;
hpdl
308
23
hpdl
331
24     function osC_Boxes($module_group) {
25       $this->_module_group = $module_group;
26
hpdl
317
27       global $osC_Database, $osC_Template, $osC_Cache;
hpdl
313
28
hpdl
331
29       if ($osC_Cache->read('templates_' . $this->_module_group . '_layout-' . $osC_Template->getTemplate() . '-' . $osC_Template->getGroup() . '-' . $osC_Template->getPageContentsFilename())) {
hpdl
317
30         $data = $osC_Cache->getCache();
31       } else {
32         $data = array();
hpdl
313
33
hpdl
331
34         $Qspecific = $osC_Database->query('select b2p.boxes_group, b.code from :table_templates_boxes_to_pages b2p, :table_templates_boxes b, :table_templates t where b2p.templates_id = :templates_id and b2p.page_specific = 1 and b2p.content_page in (:content_page) and b2p.templates_boxes_id = b.id and b.modules_group = :modules_group and b2p.templates_id = t.id order by b2p.boxes_group, b2p.sort_order');
hpdl
317
35         $Qspecific->bindTable(':table_templates_boxes_to_pages', TABLE_TEMPLATES_BOXES_TO_PAGES);
36         $Qspecific->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
37         $Qspecific->bindTable(':table_templates', TABLE_TEMPLATES);
38         $Qspecific->bindInt(':templates_id', 1);
hpdl
320
39         $Qspecific->bindRaw(':content_page', '"*", "' . $osC_Template->getGroup() . '/*", "' . $osC_Template->getGroup() . '/' . substr($osC_Template->getPageContentsFilename(), 0, strrpos($osC_Template->getPageContentsFilename(), '.')) . '"');
hpdl
331
40         $Qspecific->bindValue(':modules_group', $this->_module_group);
hpdl
317
41         $Qspecific->execute();
42
43         if ($Qspecific->numberOfRows()) {
44           while ($Qspecific->next()) {
45             $data[$Qspecific->value('boxes_group')][] = $Qspecific->value('code');
46           }
47         } else {
hpdl
331
48           $Qboxes = $osC_Database->query('select b2p.boxes_group, b2p.content_page, b.code from :table_templates_boxes_to_pages b2p, :table_templates_boxes b, :table_templates t where b2p.templates_id = :templates_id and b2p.content_page in (:content_page) and b2p.templates_boxes_id = b.id and b.modules_group = :modules_group and b2p.templates_id = t.id order by b2p.boxes_group, b2p.sort_order');
hpdl
317
49           $Qboxes->bindTable(':table_templates_boxes_to_pages', TABLE_TEMPLATES_BOXES_TO_PAGES);
50           $Qboxes->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
51           $Qboxes->bindTable(':table_templates', TABLE_TEMPLATES);
52           $Qboxes->bindInt(':templates_id', 1);
hpdl
320
53           $Qboxes->bindRaw(':content_page', '"*", "' . $osC_Template->getGroup() . '/*", "' . $osC_Template->getGroup() . '/' . substr($osC_Template->getPageContentsFilename(), 0, strrpos($osC_Template->getPageContentsFilename(), '.')) . '"');
hpdl
331
54           $Qboxes->bindValue(':modules_group', $this->_module_group);
hpdl
317
55           $Qboxes->execute();
56
57           while ($Qboxes->next()) {
hpdl
319
58             $_data[$Qboxes->value('boxes_group')][] = array('code' => $Qboxes->value('code'),
59                                                             'page' => $Qboxes->value('content_page'));
hpdl
317
60           }
hpdl
319
61
62           foreach ($_data as $groups => $boxes) {
63             $clean = array();
64
65             foreach ($boxes as $box) {
66               if (isset($clean[$box['code']])) {
67                 if (substr_count($box['page'], '/') > substr_count($clean[$box['code']]['page'], '/')) {
68                   unset($clean[$box['code']]);
69                 }
70               }
71
72               $clean[$box['code']] = $box;
73             }
74
75             $_data[$groups] = $clean;
76           }
77
78           foreach ($_data as $groups => $boxes) {
79             foreach ($boxes as $box) {
80               $data[$groups][] = $box['code'];
81             }
82           }
hpdl
317
83         }
84
85         $osC_Cache->writeBuffer($data);
hpdl
313
86       }
87
hpdl
317
88       $this->_boxes = $data;
hpdl
308
89     }
90
hpdl
313
91     function getCode() {
92       return $this->_code;
93     }
94
hpdl
308
95     function getTitle() {
96       return $this->_title;
97     }
98
99     function getTitleLink() {
100       return $this->_title_link;
101     }
102
103     function hasTitleLink() {
104       return !empty($this->_title_link);
105     }
106
107     function getContent() {
108       return $this->_content;
109     }
110
111     function hasContent() {
112       return !empty($this->_content);
113     }
114
115     function getGroup($group) {
116       $boxes = array();
117
hpdl
310
118       if (isset($this->_boxes[$group])) {
119         foreach ($this->_boxes[$group] as $box) {
hpdl
331
120           if (file_exists('includes/modules/' . $this->_module_group . '/' . $box . '.php')) {
121             $box_class = 'osC_' . ucfirst($this->_module_group) . '_' . $box;
hpdl
308
122
hpdl
310
123             if (class_exists($box_class) === false) {
hpdl
331
124               include('includes/modules/' . $this->_module_group . '/' . $box . '.php');
hpdl
310
125             }
126
hpdl
324
127             $boxes[] = $box_class;
hpdl
308
128           }
129         }
130       }
131
132       return $boxes;
133     }
hpdl
313
134
135     function isInstalled() {
136       global $osC_Database;
137
138       static $is_installed;
139
140       if (isset($is_installed) === false) {
hpdl
331
141         $Qcheck = $osC_Database->query('select id from :table_templates_boxes where code = :code and modules_group = :modules_group');
hpdl
313
142         $Qcheck->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
143         $Qcheck->bindValue(':code', $this->_code);
hpdl
331
144         $Qcheck->bindValue(':modules_group', $this->_module_group);
hpdl
313
145         $Qcheck->execute();
146
147         $is_installed = ($Qcheck->numberOfRows()) ? true : false;
148       }
149
150       return $is_installed;
151     }
152
153     function hasKeys() {
154       static $has_keys;
155
156       if (isset($has_keys) === false) {
157         $has_keys = (sizeof($this->getKeys()) > 0) ? true : false;
158       }
159
160       return $has_keys;
161     }
162
163     function getKeys() {
164       if (!isset($this->_keys)) {
165         $this->_keys = array();
166       }
167
168       return $this->_keys;
169     }
170
171     function isActive() {
172       return true;
173     }
174
175     function remove() {
176       global $osC_Database;
177
hpdl
331
178       $Qbox = $osC_Database->query('select id from :table_templates_boxes where code = :code and modules_group = :modules_group');
hpdl
313
179       $Qbox->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
180       $Qbox->bindValue(':code', $this->_code);
hpdl
331
181       $Qbox->bindValue(':modules_group', $this->_module_group);
hpdl
313
182       $Qbox->execute();
183
184       $Qdel = $osC_Database->query('delete from :table_templates_boxes_to_pages where templates_boxes_id = :templates_boxes_id');
185       $Qdel->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
186       $Qdel->bindValue(':templates_boxes_id', $Qbox->valueInt('id'));
187       $Qdel->execute();
188
hpdl
331
189       $Qdel = $osC_Database->query('delete from :table_templates_boxes where code = :code and modules_group = :modules_group');
hpdl
313
190       $Qdel->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
191       $Qdel->bindValue(':code', $this->_code);
hpdl
331
192       $Qdel->bindValue(':modules_group', $this->_module_group);
hpdl
313
193       $Qdel->execute();
194
195       if ($this->hasKeys()) {
196         $Qdel = $osC_Database->query('delete from :table_configuration where configuration_key in (":configuration_key")');
197         $Qdel->bindTable(':table_configuration', TABLE_CONFIGURATION);
198         $Qdel->bindRaw(':configuration_key', implode('", "', $this->getKeys()));
199         $Qdel->execute();
200       }
201     }
202
203     function getAuthorName() {
204       return $this->_author_name;
205     }
206
207     function getAuthorAddress() {
208       return $this->_author_www;
209     }
hpdl
308
210   }
211 ?>