  |
21 | 21 | | $_keys; |
| |
22 | 22 | | |
| |
23 | 23 | | function osC_Boxes() { |
  |
24 | | - | global $osC_Database, $osC_Template; |
| |
| 24 | + | global $osC_Database, $osC_Template, $osC_Cache; |
|
25 | 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(); |
| |
| 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(); |
|
34 | 30 | | |
  |
35 | | - | while ($Qboxes->next()) { |
| |
36 | | - | $this->_boxes[$Qboxes->value('boxes_group')][] = $Qboxes->value('code'); |
| |
| 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); |
| |
| 36 | + | $Qspecific->bindRaw(':content_page', '"*", "' . $osC_Template->getGroup() . '/' . $osC_Template->getPageContentsFilename() . '"'); |
| |
| 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); |
| |
| 49 | + | $Qboxes->bindRaw(':content_page', '"*", "' . $osC_Template->getGroup() . '/' . $osC_Template->getPageContentsFilename() . '"'); |
| |
| 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); |
|
37 | 58 | | } |
| |
38 | 59 | | |
  |
39 | | - | $Qboxes->freeResult(); |
| |
| 60 | + | $this->_boxes = $data; |
  |
40 | 61 | | } |
| |
41 | 62 | | |
| |
42 | 63 | | function getCode() { |