  |
12 | 12 | | |
| |
13 | 13 | | class osC_Boxes { |
| |
14 | 14 | | var $_boxes, |
  |
| 15 | + | $_code, |
|
15 | 16 | | $_title, |
| |
16 | 17 | | $_title_link, |
  |
17 | | - | $_content; |
| |
| 18 | + | $_content, |
| |
| 19 | + | $_author_name, |
| |
| 20 | + | $_author_www, |
| |
| 21 | + | $_keys; |
|
18 | 22 | | |
| |
19 | 23 | | function osC_Boxes() { |
  |
20 | | - | $this->_boxes['left'] = array('categories.php', 'manufacturers.php', 'whats_new.php', 'search.php', 'information.php'); |
| |
21 | | - | $this->_boxes['right'] = array('shopping_cart.php', 'manufacturer_info.php', 'order_history.php', 'best_sellers.php', 'product_notifications.php', 'tell_a_friend.php', 'specials.php', 'reviews.php', 'languages.php', 'currencies.php'); |
| |
| 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(); |
|
22 | 40 | | } |
| |
23 | 41 | | |
  |
| 42 | + | function getCode() { |
| |
| 43 | + | return $this->_code; |
| |
| 44 | + | } |
| |
| 45 | + | |
|
24 | 46 | | function getTitle() { |
| |
25 | 47 | | return $this->_title; |
| |
26 | 48 | | } |
| |
|
|
 |
… |
|
46 | 68 | | |
| |
47 | 69 | | if (isset($this->_boxes[$group])) { |
| |
48 | 70 | | foreach ($this->_boxes[$group] as $box) { |
  |
49 | | - | if (file_exists('includes/boxes/' . $box)) { |
| |
50 | | - | $box_class = 'osC_Boxes_' . substr($box, 0, strrpos($box, '.')); |
| |
| 71 | + | if (file_exists('includes/boxes/' . $box . '.php')) { |
| |
| 72 | + | $box_class = 'osC_Boxes_' . $box; |
|
51 | 73 | | |
| |
52 | 74 | | if (class_exists($box_class) === false) { |
  |
53 | | - | include('includes/boxes/' . $box); |
| |
| 75 | + | include('includes/boxes/' . $box . '.php'); |
|
54 | 76 | | } |
| |
55 | 77 | | |
  |
56 | | - | $boxes[] = array('class' => $box, 'object' => $box_class); |
| |
| 78 | + | $boxes[] = array('class' => $box . '.php', 'object' => $box_class); |
|
57 | 79 | | } |
| |
58 | 80 | | } |
| |
59 | 81 | | } |
| |
60 | 82 | | |
| |
61 | 83 | | return $boxes; |
| |
62 | 84 | | } |
  |
| 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 | + | } |
  |
63 | 158 | | } |
| |
64 | 159 | | ?> |