  |
10 | 10 | | Released under the GNU General Public License |
| |
11 | 11 | | */ |
| |
12 | 12 | | |
  |
13 | | - | class osC_Boxes { |
| |
14 | | - | var $_boxes, |
| |
| 13 | + | class osC_Modules { |
| |
| 14 | + | var $_modules, |
|
15 | 15 | | $_code, |
| |
16 | 16 | | $_title, |
| |
17 | 17 | | $_title_link, |
| |
18 | 18 | | $_content, |
| |
19 | 19 | | $_author_name, |
| |
20 | 20 | | $_author_www, |
| |
21 | 21 | | $_keys, |
  |
22 | | - | $_module_group; |
| |
| 22 | + | $_group; |
|
23 | 23 | | |
  |
24 | | - | function osC_Boxes($module_group) { |
| |
25 | | - | $this->_module_group = $module_group; |
| |
26 | | - | |
| |
| 24 | + | function osC_Modules($group) { |
|
27 | 25 | | global $osC_Database, $osC_Template, $osC_Cache; |
| |
28 | 26 | | |
  |
29 | | - | if ($osC_Cache->read('templates_' . $this->_module_group . '_layout-' . $osC_Template->getTemplate() . '-' . $osC_Template->getGroup() . '-' . $osC_Template->getPageContentsFilename())) { |
| |
| 27 | + | $this->_group = $group; |
| |
| 28 | + | |
| |
| 29 | + | if ($osC_Cache->read('templates_' . $this->_group . '_layout-' . $osC_Template->getTemplate() . '-' . $osC_Template->getGroup() . '-' . $osC_Template->getPageContentsFilename())) { |
|
30 | 30 | | $data = $osC_Cache->getCache(); |
| |
31 | 31 | | } else { |
| |
32 | 32 | | $data = array(); |
| |
|
|
 |
… |
|
37 | 37 | | $Qspecific->bindTable(':table_templates', TABLE_TEMPLATES); |
| |
38 | 38 | | $Qspecific->bindInt(':templates_id', 1); |
| |
39 | 39 | | $Qspecific->bindRaw(':content_page', '"*", "' . $osC_Template->getGroup() . '/*", "' . $osC_Template->getGroup() . '/' . substr($osC_Template->getPageContentsFilename(), 0, strrpos($osC_Template->getPageContentsFilename(), '.')) . '"'); |
  |
40 | | - | $Qspecific->bindValue(':modules_group', $this->_module_group); |
| |
| 40 | + | $Qspecific->bindValue(':modules_group', $this->_group); |
|
41 | 41 | | $Qspecific->execute(); |
| |
42 | 42 | | |
| |
43 | 43 | | if ($Qspecific->numberOfRows()) { |
| |
44 | 44 | | while ($Qspecific->next()) { |
| |
45 | 45 | | $data[$Qspecific->value('boxes_group')][] = $Qspecific->value('code'); |
| |
46 | 46 | | } |
| |
47 | 47 | | } else { |
  |
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'); |
| |
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); |
| |
53 | | - | $Qboxes->bindRaw(':content_page', '"*", "' . $osC_Template->getGroup() . '/*", "' . $osC_Template->getGroup() . '/' . substr($osC_Template->getPageContentsFilename(), 0, strrpos($osC_Template->getPageContentsFilename(), '.')) . '"'); |
| |
54 | | - | $Qboxes->bindValue(':modules_group', $this->_module_group); |
| |
55 | | - | $Qboxes->execute(); |
| |
| 48 | + | $_data = array(); |
|
56 | 49 | | |
  |
57 | | - | while ($Qboxes->next()) { |
| |
58 | | - | $_data[$Qboxes->value('boxes_group')][] = array('code' => $Qboxes->value('code'), |
| |
59 | | - | 'page' => $Qboxes->value('content_page')); |
| |
| 50 | + | $Qmodules = $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'); |
| |
| 51 | + | $Qmodules->bindTable(':table_templates_boxes_to_pages', TABLE_TEMPLATES_BOXES_TO_PAGES); |
| |
| 52 | + | $Qmodules->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES); |
| |
| 53 | + | $Qmodules->bindTable(':table_templates', TABLE_TEMPLATES); |
| |
| 54 | + | $Qmodules->bindInt(':templates_id', 1); |
| |
| 55 | + | $Qmodules->bindRaw(':content_page', '"*", "' . $osC_Template->getGroup() . '/*", "' . $osC_Template->getGroup() . '/' . substr($osC_Template->getPageContentsFilename(), 0, strrpos($osC_Template->getPageContentsFilename(), '.')) . '"'); |
| |
| 56 | + | $Qmodules->bindValue(':modules_group', $this->_group); |
| |
| 57 | + | $Qmodules->execute(); |
| |
| 58 | + | |
| |
| 59 | + | while ($Qmodules->next()) { |
| |
| 60 | + | $_data[$Qmodules->value('boxes_group')][] = array('code' => $Qmodules->value('code'), |
| |
| 61 | + | 'page' => $Qmodules->value('content_page')); |
|
60 | 62 | | } |
| |
61 | 63 | | |
  |
62 | | - | foreach ($_data as $groups => $boxes) { |
| |
| 64 | + | foreach ($_data as $groups => $modules) { |
|
63 | 65 | | $clean = array(); |
| |
64 | 66 | | |
  |
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']]); |
| |
| 67 | + | foreach ($modules as $module) { |
| |
| 68 | + | if (isset($clean[$module['code']])) { |
| |
| 69 | + | if (substr_count($module['page'], '/') > substr_count($clean[$module['code']]['page'], '/')) { |
| |
| 70 | + | unset($clean[$module['code']]); |
|
69 | 71 | | } |
| |
70 | 72 | | } |
| |
71 | 73 | | |
  |
72 | | - | $clean[$box['code']] = $box; |
| |
| 74 | + | $clean[$module['code']] = $module; |
|
73 | 75 | | } |
| |
74 | 76 | | |
| |
75 | 77 | | $_data[$groups] = $clean; |
| |
76 | 78 | | } |
| |
77 | 79 | | |
  |
78 | | - | foreach ($_data as $groups => $boxes) { |
| |
79 | | - | foreach ($boxes as $box) { |
| |
80 | | - | $data[$groups][] = $box['code']; |
| |
| 80 | + | foreach ($_data as $groups => $modules) { |
| |
| 81 | + | foreach ($modules as $module) { |
| |
| 82 | + | $data[$groups][] = $module['code']; |
|
81 | 83 | | } |
| |
82 | 84 | | } |
| |
83 | 85 | | } |
| |
84 | 86 | | |
| |
85 | 87 | | $osC_Cache->writeBuffer($data); |
| |
86 | 88 | | } |
| |
87 | 89 | | |
  |
88 | | - | $this->_boxes = $data; |
| |
| 90 | + | $this->_modules = $data; |
|
89 | 91 | | } |
| |
90 | 92 | | |
| |
91 | 93 | | function getCode() { |
| |
|
|
 |
… |
|
112 | 114 | | return !empty($this->_content); |
| |
113 | 115 | | } |
| |
114 | 116 | | |
  |
| 117 | + | function getAuthorName() { |
| |
| 118 | + | return $this->_author_name; |
| |
| 119 | + | } |
| |
| 120 | + | |
| |
| 121 | + | function getAuthorAddress() { |
| |
| 122 | + | return $this->_author_www; |
| |
| 123 | + | } |
| |
| 124 | + | |
|
115 | 125 | | function getGroup($group) { |
  |
116 | | - | $boxes = array(); |
| |
| 126 | + | $modules = array(); |
|
117 | 127 | | |
  |
118 | | - | if (isset($this->_boxes[$group])) { |
| |
119 | | - | foreach ($this->_boxes[$group] as $box) { |
| |
120 | | - | if (file_exists('includes/modules/' . $this->_module_group . '/' . $box . '.php')) { |
| |
121 | | - | $box_class = 'osC_' . ucfirst($this->_module_group) . '_' . $box; |
| |
| 128 | + | if (isset($this->_modules[$group])) { |
| |
| 129 | + | foreach ($this->_modules[$group] as $module) { |
| |
| 130 | + | if (file_exists('includes/modules/' . $this->_group . '/' . $module . '.php')) { |
| |
| 131 | + | $class = 'osC_' . ucfirst($this->_group) . '_' . $module; |
|
122 | 132 | | |
  |
123 | | - | if (class_exists($box_class) === false) { |
| |
124 | | - | include('includes/modules/' . $this->_module_group . '/' . $box . '.php'); |
| |
| 133 | + | if (class_exists($class) === false) { |
| |
| 134 | + | include('includes/modules/' . $this->_group . '/' . $module . '.php'); |
|
125 | 135 | | } |
| |
126 | 136 | | |
  |
127 | | - | $boxes[] = $box_class; |
| |
| 137 | + | $modules[] = $class; |
|
128 | 138 | | } |
| |
129 | 139 | | } |
| |
130 | 140 | | } |
| |
131 | 141 | | |
  |
132 | | - | return $boxes; |
| |
| 142 | + | return $modules; |
|
133 | 143 | | } |
| |
134 | 144 | | |
| |
135 | 145 | | function isInstalled() { |
| |
|
|
 |
… |
|
141 | 151 | | $Qcheck = $osC_Database->query('select id from :table_templates_boxes where code = :code and modules_group = :modules_group'); |
| |
142 | 152 | | $Qcheck->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES); |
| |
143 | 153 | | $Qcheck->bindValue(':code', $this->_code); |
  |
144 | | - | $Qcheck->bindValue(':modules_group', $this->_module_group); |
| |
| 154 | + | $Qcheck->bindValue(':modules_group', $this->_group); |
|
145 | 155 | | $Qcheck->execute(); |
| |
146 | 156 | | |
| |
147 | 157 | | $is_installed = ($Qcheck->numberOfRows()) ? true : false; |
| |
|
|
 |
… |
|
161 | 171 | | } |
| |
162 | 172 | | |
| |
163 | 173 | | function getKeys() { |
  |
164 | | - | if (!isset($this->_keys)) { |
| |
| 174 | + | if (isset($this->_keys) === false) { |
|
165 | 175 | | $this->_keys = array(); |
| |
166 | 176 | | } |
| |
167 | 177 | | |
| |
|
|
 |
… |
|
175 | 185 | | function remove() { |
| |
176 | 186 | | global $osC_Database; |
| |
177 | 187 | | |
  |
178 | | - | $Qbox = $osC_Database->query('select id from :table_templates_boxes where code = :code and modules_group = :modules_group'); |
| |
179 | | - | $Qbox->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES); |
| |
180 | | - | $Qbox->bindValue(':code', $this->_code); |
| |
181 | | - | $Qbox->bindValue(':modules_group', $this->_module_group); |
| |
182 | | - | $Qbox->execute(); |
| |
| 188 | + | $Qmodule = $osC_Database->query('select id from :table_templates_boxes where code = :code and modules_group = :modules_group'); |
| |
| 189 | + | $Qmodule->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES); |
| |
| 190 | + | $Qmodule->bindValue(':code', $this->_code); |
| |
| 191 | + | $Qmodule->bindValue(':modules_group', $this->_group); |
| |
| 192 | + | $Qmodule->execute(); |
|
183 | 193 | | |
| |
184 | 194 | | $Qdel = $osC_Database->query('delete from :table_templates_boxes_to_pages where templates_boxes_id = :templates_boxes_id'); |
| |
185 | 195 | | $Qdel->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES); |
  |
186 | | - | $Qdel->bindValue(':templates_boxes_id', $Qbox->valueInt('id')); |
| |
| 196 | + | $Qdel->bindValue(':templates_boxes_id', $Qmodule->valueInt('id')); |
|
187 | 197 | | $Qdel->execute(); |
| |
188 | 198 | | |
| |
189 | 199 | | $Qdel = $osC_Database->query('delete from :table_templates_boxes where code = :code and modules_group = :modules_group'); |
| |
190 | 200 | | $Qdel->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES); |
| |
191 | 201 | | $Qdel->bindValue(':code', $this->_code); |
  |
192 | | - | $Qdel->bindValue(':modules_group', $this->_module_group); |
| |
| 202 | + | $Qdel->bindValue(':modules_group', $this->_group); |
|
193 | 203 | | $Qdel->execute(); |
| |
194 | 204 | | |
| |
195 | 205 | | if ($this->hasKeys()) { |
| |
|
|
 |
… |
|
199 | 209 | | $Qdel->execute(); |
| |
200 | 210 | | } |
| |
201 | 211 | | } |
  |
202 | | - | |
| |
203 | | - | function getAuthorName() { |
| |
204 | | - | return $this->_author_name; |
| |
205 | | - | } |
| |
206 | | - | |
| |
207 | | - | function getAuthorAddress() { |
| |
208 | | - | return $this->_author_www; |
| |
209 | | - | } |
  |
210 | 212 | | } |
| |
211 | 213 | | ?> |