Quick Search:

View

Revision:

Diff

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