Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function index() {
- if ($this->journal2->page->getType() !== 'product' && $this->journal2->page->getType() !== 'quickview') return;
- Journal2::startTimer('ProductTabs');
- $product_id = (int)$this->journal2->page->getId();
- /* recently viewed */
- $recently_viewed = isset($this->request->cookie['jrv']) && $this->request->cookie['jrv'] ? explode(',', $this->request->cookie['jrv']) : array();
- $recently_viewed = array_diff($recently_viewed, array($product_id));
- array_unshift($recently_viewed, $product_id);
- $limit = (int)$this->config->get(version_compare(VERSION, '2', '>=') ? 'config_product_limit' : 'config_catalog_limit');
- if (!$limit) {
- $limit = 50;
- }
- $recently_viewed = array_splice($recently_viewed, 0, $limit);
- setcookie('jrv', implode(',', $recently_viewed), time() + 60 * 60 * 24 * 30, '/', $this->request->server['HTTP_HOST']);
- $product_info = $this->model_catalog_product->getProduct($product_id);
- $tabs = $this->model_journal2_module->getProductTabs($product_id, $product_info);
- $tabs = Journal2Utils::sortArray($tabs);
- $tab_tab = array();
- $tab_desc_top = array();
- $tab_desc_bottom = array();
- $tab_image = array();
- $tab_enquiry = array();
- foreach ($tabs as $tab) {
- if (!$tab['status']) continue;
- if ($this->journal2->settings->get('responsive_design')) {
- $device = Journal2Utils::getDevice();
- if (Journal2Utils::getProperty($tab, 'enable_on_phone', '1') == '0') {
- if ($device === 'phone') {
- continue;
- }
- }
- if (Journal2Utils::getProperty($tab, 'enable_on_tablet', '1') == '0') {
- if ($device === 'tablet') {
- continue;
- }
- }
- if (Journal2Utils::getProperty($tab, 'enable_on_desktop', '1') == '0') {
- if ($device === 'desktop') {
- continue;
- }
- }
- }
- $css = array();
- if (Journal2Utils::getColor(Journal2Utils::getProperty($tab, 'icon_bg_color.value.color'))) {
- $css[] = 'background-color: ' . Journal2Utils::getColor(Journal2Utils::getProperty($tab, 'icon_bg_color.value.color'));
- }
- if (Journal2Utils::getProperty($tab, 'icon_width')) {
- $css[] = 'width: ' . Journal2Utils::getProperty($tab, 'icon_width') . 'px';
- }
- if (Journal2Utils::getProperty($tab, 'icon_height')) {
- $css[] = 'height: ' . Journal2Utils::getProperty($tab, 'icon_height') . 'px';
- $css[] = 'line-height: ' . Journal2Utils::getProperty($tab, 'icon_height') . 'px';
- }
- if (Journal2Utils::getProperty($tab, 'icon_border')) {
- $css = array_merge($css, Journal2Utils::getBorderCssProperties(Journal2Utils::getProperty($tab, 'icon_border')));
- }
- $position = Journal2Utils::getProperty($tab, 'position');
- $name = Journal2Utils::getProperty($tab, 'name.value.' . $this->config->get('config_language_id'));
- $has_icon = Journal2Utils::getProperty($tab, 'icon_status');
- $icon = Journal2Utils::getIconOptions2(Journal2Utils::getProperty($tab, 'icon'));
- $icon_css = implode('; ', $css);
- switch (Journal2Utils::getProperty($tab, 'content_type', 'custom')) {
- case 'custom':
- $content = Journal2Utils::getProperty($tab, 'content.' . $this->config->get('config_language_id'));
- break;
- case 'description':
- $content = html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8');
- $this->journal2->settings->set('hide_product_description', true);
- break;
- case 'enquiry':
- $position = 'enquiry';
- $this->journal2->settings->set('hide_add_to_cart_button', true);
- $href = "javascript:Journal.openPopup('" . (int)Journal2Utils::getProperty($tab, 'popup') . "', '" . $product_id . "')";
- $content = "<a class=\"button enquiry-button\" href=\"{$href}\">{$icon}{$name}</a>";
- break;
- }
- $position_desc = $position === 'desc' ? '_' . Journal2Utils::getProperty($tab, 'option_position') : '';
- $names[] = $name;
- if($name == 'PDF') {
- $qq = $this->db->query('SELECT pdf FROM oc_product WHERE product_id = "'. $product_id .'"');
- if(isset($qq->row['pdf']) && !empty($qq->row)) {
- $content = str_replace('data="image/pdf/sample.pdf"','data="image/'.$qq->row['pdf'] .'"',$content);
- } else {
- continue;
- }
- } elseif($name == 'Полезни съвети') {
- $q3 = $this->db->query('
- SELECT oc_category_advice.title, oc_category_advice.text
- FROM oc_category_advice
- JOIN oc_product_to_category ON oc_product_to_category.category_id = oc_category_advice.cat_id
- WHERE oc_product_to_category.product_id = "'. $product_id .'"
- ');
- if(isset($q3->rows) && !empty($q3->rows)) {
- $content = '';
- $tabn = 1;
- foreach ($q3->rows as $r) {
- $content .= "<h3>". $r['title'] ."</h3><p>". $r['text'] ."</p><br><br>";
- }
- } else {
- $catq = $this->db->query('
- SELECT oc_category.*
- FROM oc_category
- JOIN oc_product_to_category ON oc_product_to_category.category_id = oc_category.category_id
- WHERE oc_product_to_category.product_id = "'. $product_id .'"
- ');
- if(isset($catq->row) && !empty($catq->row) && $catq->row['parent_id'] != 0) {
- $q4 = $this->db->query('
- SELECT * FROM oc_category_advice WHERE cat_id = "'. $catq->row['parent_id'] .'"
- ');
- if(isset($q4->rows) && !empty($q4->rows)) {
- $content = '';
- foreach ($q4->rows as $r) {
- $content .= "<h3>". $r['title'] ."</h3><p>". $r['text'] ."</p><br><br>";
- }
- } else {
- continue;
- }
- } else {
- continue;
- }
- }
- }
- $data = array (
- 'name' => $name,
- 'has_icon' => $has_icon,
- 'icon' => $icon,
- 'icon_css' => $icon_css,
- 'content' => $content
- );
- $var = 'tab_' . $position . $position_desc;
- array_push($$var, $data);
- }
- $this->journal2->settings->set('additional_product_tabs', $tab_tab);
- $this->journal2->settings->set('additional_product_description_top', $tab_desc_top);
- $this->journal2->settings->set('additional_product_description_bottom', $tab_desc_bottom);
- $this->journal2->settings->set('additional_product_description_image', $tab_image);
- $this->journal2->settings->set('additional_product_enquiry', $tab_enquiry);
- Journal2::stopTimer('ProductTabs');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement