_module_group = $module_group; global $osC_Database, $osC_Template, $osC_Cache; if ($osC_Cache->read('templates_' . $this->_module_group . '_layout-' . $osC_Template->getTemplate() . '-' . $osC_Template->getGroup() . '-' . $osC_Template->getPageContentsFilename())) { $data = $osC_Cache->getCache(); } else { $data = array(); $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 b.modules_group = :modules_group and b2p.templates_id = t.id order by b2p.boxes_group, b2p.sort_order'); $Qspecific->bindTable(':table_templates_boxes_to_pages', TABLE_TEMPLATES_BOXES_TO_PAGES); $Qspecific->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES); $Qspecific->bindTable(':table_templates', TABLE_TEMPLATES); $Qspecific->bindInt(':templates_id', 1); $Qspecific->bindRaw(':content_page', '"*", "' . $osC_Template->getGroup() . '/*", "' . $osC_Template->getGroup() . '/' . substr($osC_Template->getPageContentsFilename(), 0, strrpos($osC_Template->getPageContentsFilename(), '.')) . '"'); $Qspecific->bindValue(':modules_group', $this->_module_group); $Qspecific->execute(); if ($Qspecific->numberOfRows()) { while ($Qspecific->next()) { $data[$Qspecific->value('boxes_group')][] = $Qspecific->value('code'); } } else { $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'); $Qboxes->bindTable(':table_templates_boxes_to_pages', TABLE_TEMPLATES_BOXES_TO_PAGES); $Qboxes->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES); $Qboxes->bindTable(':table_templates', TABLE_TEMPLATES); $Qboxes->bindInt(':templates_id', 1); $Qboxes->bindRaw(':content_page', '"*", "' . $osC_Template->getGroup() . '/*", "' . $osC_Template->getGroup() . '/' . substr($osC_Template->getPageContentsFilename(), 0, strrpos($osC_Template->getPageContentsFilename(), '.')) . '"'); $Qboxes->bindValue(':modules_group', $this->_module_group); $Qboxes->execute(); while ($Qboxes->next()) { $_data[$Qboxes->value('boxes_group')][] = array('code' => $Qboxes->value('code'), 'page' => $Qboxes->value('content_page')); } foreach ($_data as $groups => $boxes) { $clean = array(); foreach ($boxes as $box) { if (isset($clean[$box['code']])) { if (substr_count($box['page'], '/') > substr_count($clean[$box['code']]['page'], '/')) { unset($clean[$box['code']]); } } $clean[$box['code']] = $box; } $_data[$groups] = $clean; } foreach ($_data as $groups => $boxes) { foreach ($boxes as $box) { $data[$groups][] = $box['code']; } } } $osC_Cache->writeBuffer($data); } $this->_boxes = $data; } function getCode() { return $this->_code; } function getTitle() { return $this->_title; } function getTitleLink() { return $this->_title_link; } function hasTitleLink() { return !empty($this->_title_link); } function getContent() { return $this->_content; } function hasContent() { return !empty($this->_content); } function getGroup($group) { $boxes = array(); if (isset($this->_boxes[$group])) { foreach ($this->_boxes[$group] as $box) { if (file_exists('includes/modules/' . $this->_module_group . '/' . $box . '.php')) { $box_class = 'osC_' . ucfirst($this->_module_group) . '_' . $box; if (class_exists($box_class) === false) { include('includes/modules/' . $this->_module_group . '/' . $box . '.php'); } $boxes[] = $box_class; } } } return $boxes; } function isInstalled() { global $osC_Database; static $is_installed; if (isset($is_installed) === false) { $Qcheck = $osC_Database->query('select id from :table_templates_boxes where code = :code and modules_group = :modules_group'); $Qcheck->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES); $Qcheck->bindValue(':code', $this->_code); $Qcheck->bindValue(':modules_group', $this->_module_group); $Qcheck->execute(); $is_installed = ($Qcheck->numberOfRows()) ? true : false; } return $is_installed; } function hasKeys() { static $has_keys; if (isset($has_keys) === false) { $has_keys = (sizeof($this->getKeys()) > 0) ? true : false; } return $has_keys; } function getKeys() { if (!isset($this->_keys)) { $this->_keys = array(); } return $this->_keys; } function isActive() { return true; } function remove() { global $osC_Database; $Qbox = $osC_Database->query('select id from :table_templates_boxes where code = :code and modules_group = :modules_group'); $Qbox->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES); $Qbox->bindValue(':code', $this->_code); $Qbox->bindValue(':modules_group', $this->_module_group); $Qbox->execute(); $Qdel = $osC_Database->query('delete from :table_templates_boxes_to_pages where templates_boxes_id = :templates_boxes_id'); $Qdel->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES); $Qdel->bindValue(':templates_boxes_id', $Qbox->valueInt('id')); $Qdel->execute(); $Qdel = $osC_Database->query('delete from :table_templates_boxes where code = :code and modules_group = :modules_group'); $Qdel->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES); $Qdel->bindValue(':code', $this->_code); $Qdel->bindValue(':modules_group', $this->_module_group); $Qdel->execute(); if ($this->hasKeys()) { $Qdel = $osC_Database->query('delete from :table_configuration where configuration_key in (":configuration_key")'); $Qdel->bindTable(':table_configuration', TABLE_CONFIGURATION); $Qdel->bindRaw(':configuration_key', implode('", "', $this->getKeys())); $Qdel->execute(); } } function getAuthorName() { return $this->_author_name; } function getAuthorAddress() { return $this->_author_www; } } ?>