Quick Search:

View

Revision:

Diff

Diff from 318 to:

Annotations

Annotate by Age | Author | Mixed | None
/fisheye/browse/osCommerce/branches/hpdl/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,
21         $_keys;
hpdl
308
22
23     function osC_Boxes() {
hpdl
317
24       global $osC_Database, $osC_Template, $osC_Cache;
hpdl
313
25
hpdl
317
26       if ($osC_Cache->read('templates_boxes_layout-' . $osC_Template->getTemplate() . '-' . $osC_Template->getGroup() . '-' . $osC_Template->getPageContentsFilename())) {
27         $data = $osC_Cache->getCache();
28       } else {
29         $data = array();
hpdl
313
30
hpdl
317
31         $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 b2p.templates_id = t.id order by b2p.boxes_group, b2p.sort_order');
32         $Qspecific->bindTable(':table_templates_boxes_to_pages', TABLE_TEMPLATES_BOXES_TO_PAGES);
33         $Qspecific->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
34         $Qspecific->bindTable(':table_templates', TABLE_TEMPLATES);
35         $Qspecific->bindInt(':templates_id', 1);
hpdl
318
36         $Qspecific->bindRaw(':content_page', '"*", "' . $osC_Template->getGroup() . '/*", "' . $osC_Template->getGroup() . '/' . $osC_Template->getPageContentsFilename() . '"');
hpdl
317
37         $Qspecific->execute();
38
39         if ($Qspecific->numberOfRows()) {
40           while ($Qspecific->next()) {
41             $data[$Qspecific->value('boxes_group')][] = $Qspecific->value('code');
42           }
43         } else {
44           $Qboxes = $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.content_page in (:content_page) and b2p.templates_boxes_id = b.id and b2p.templates_id = t.id order by b2p.boxes_group, b2p.sort_order');
45           $Qboxes->bindTable(':table_templates_boxes_to_pages', TABLE_TEMPLATES_BOXES_TO_PAGES);
46           $Qboxes->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
47           $Qboxes->bindTable(':table_templates', TABLE_TEMPLATES);
48           $Qboxes->bindInt(':templates_id', 1);
hpdl
318
49           $Qboxes->bindRaw(':content_page', '"*", "' . $osC_Template->getGroup() . '/*", "' . $osC_Template->getGroup() . '/' . $osC_Template->getPageContentsFilename() . '"');
hpdl
317
50           $Qboxes->execute();
51
52           while ($Qboxes->next()) {
53             $data[$Qboxes->value('boxes_group')][] = $Qboxes->value('code');
54           }
55         }
56
57         $osC_Cache->writeBuffer($data);
hpdl
313
58       }
59
hpdl
317
60       $this->_boxes = $data;
hpdl
308
61     }
62
hpdl
313
63     function getCode() {
64       return $this->_code;
65     }
66
hpdl
308
67     function getTitle() {
68       return $this->_title;
69     }
70
71     function getTitleLink() {
72       return $this->_title_link;
73     }
74
75     function hasTitleLink() {
76       return !empty($this->_title_link);
77     }
78
79     function getContent() {
80       return $this->_content;
81     }
82
83     function hasContent() {
84       return !empty($this->_content);
85     }
86
87     function getGroup($group) {
88       $boxes = array();
89
hpdl
310
90       if (isset($this->_boxes[$group])) {
91         foreach ($this->_boxes[$group] as $box) {
hpdl
313
92           if (file_exists('includes/boxes/' . $box . '.php')) {
93             $box_class = 'osC_Boxes_' . $box;
hpdl
308
94
hpdl
310
95             if (class_exists($box_class) === false) {
hpdl
313
96               include('includes/boxes/' . $box . '.php');
hpdl
310
97             }
98
hpdl
313
99             $boxes[] = array('class' => $box . '.php', 'object' => $box_class);
hpdl
308
100           }
101         }
102       }
103
104       return $boxes;
105     }
hpdl
313
106
107     function isInstalled() {
108       global $osC_Database;
109
110       static $is_installed;
111
112       if (isset($is_installed) === false) {
113         $Qcheck = $osC_Database->query('select id from :table_templates_boxes where code = :code');
114         $Qcheck->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
115         $Qcheck->bindValue(':code', $this->_code);
116         $Qcheck->execute();
117
118         $is_installed = ($Qcheck->numberOfRows()) ? true : false;
119       }
120
121       return $is_installed;
122     }
123
124     function hasKeys() {
125       static $has_keys;
126
127       if (isset($has_keys) === false) {
128         $has_keys = (sizeof($this->getKeys()) > 0) ? true : false;
129       }
130
131       return $has_keys;
132     }
133
134     function getKeys() {
135       if (!isset($this->_keys)) {
136         $this->_keys = array();
137       }
138
139       return $this->_keys;
140     }
141
142     function isActive() {
143       return true;
144     }
145
146     function remove() {
147       global $osC_Database;
148
149       $Qbox = $osC_Database->query('select id from :table_templates_boxes where code = :code');
150       $Qbox->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
151       $Qbox->bindValue(':code', $this->_code);
152       $Qbox->execute();
153
154       $Qdel = $osC_Database->query('delete from :table_templates_boxes_to_pages where templates_boxes_id = :templates_boxes_id');
155       $Qdel->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
156       $Qdel->bindValue(':templates_boxes_id', $Qbox->valueInt('id'));
157       $Qdel->execute();
158
159       $Qdel = $osC_Database->query('delete from :table_templates_boxes where code = :code');
160       $Qdel->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
161       $Qdel->bindValue(':code', $this->_code);
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
172     function getAuthorName() {
173       return $this->_author_name;
174     }
175
176     function getAuthorAddress() {
177       return $this->_author_www;
178     }
hpdl
308
179   }
180 ?>