public function index($setting)
 {
     if (!defined('JOURNAL_INSTALLED')) {
         return;
     }
     Journal2::startTimer(get_class($this));
     /* get module data from db */
     $module_data = $this->model_journal2_module->getModule($setting['module_id']);
     if (!$module_data || !isset($module_data['module_data']) || !$module_data['module_data']) {
         return;
     }
     $module_data = $module_data['module_data'];
     /* device detection */
     $this->data['disable_on_classes'] = array();
     if ($this->journal2->settings->get('responsive_design')) {
         $device = Journal2Utils::getDevice();
         if (Journal2Utils::getProperty($module_data, 'enable_on_phone', '1') == '0') {
             if ($device === 'phone') {
                 return;
             } else {
                 $this->data['disable_on_classes'][] = 'hide-on-phone';
             }
         }
         if (Journal2Utils::getProperty($module_data, 'enable_on_tablet', '1') == '0') {
             if ($device === 'tablet') {
                 return;
             } else {
                 $this->data['disable_on_classes'][] = 'hide-on-tablet';
             }
         }
         if (Journal2Utils::getProperty($module_data, 'enable_on_desktop', '1') == '0') {
             if ($device === 'desktop') {
                 return;
             } else {
                 $this->data['disable_on_classes'][] = 'hide-on-desktop';
             }
         }
     }
     $this->data['css'] = '';
     /* css for top / bottom positions */
     if (in_array($setting['position'], array('top', 'bottom'))) {
         $padding = $this->journal2->settings->get('module_margins', 20) . 'px';
         /* outer */
         $css = Journal2Utils::getBackgroundCssProperties(Journal2Utils::getProperty($module_data, 'background'));
         $css[] = 'padding-top: ' . Journal2Utils::getProperty($module_data, 'margin_top', 0) . 'px';
         $css[] = 'padding-bottom: ' . Journal2Utils::getProperty($module_data, 'margin_bottom', 0) . 'px';
         $this->journal2->settings->set('module_journal2_cms_blocks_' . $setting['module_id'], implode('; ', $css));
         $this->journal2->settings->set('module_journal2_cms_blocks_' . $setting['module_id'] . '_classes', implode(' ', $this->data['disable_on_classes']));
         /* inner css */
         $css = array();
         if (Journal2Utils::getProperty($module_data, 'fullwidth')) {
             $css[] = 'max-width: 100%';
             $css[] = 'padding-left: ' . $padding;
             $css[] = 'padding-right: ' . $padding;
         } else {
             $css[] = 'max-width: ' . $this->journal2->settings->get('site_width', 1024) . 'px';
             $css = array_merge($css, Journal2Utils::getBackgroundCssProperties(Journal2Utils::getProperty($module_data, 'module_background')));
             if (Journal2Utils::getProperty($module_data, 'module_padding')) {
                 $this->data['gutter_on_class'] = 'gutter-on';
                 $css[] = 'padding: 20px';
             }
         }
         $this->data['css'] = implode('; ', $css);
     }
     $cache_property = "module_journal_cms_blocks_{$setting['module_id']}_{$setting['layout_id']}_{$setting['position']}";
     $cache = $this->journal2->cache->get($cache_property);
     if ($cache === null || self::$CACHEABLE !== true) {
         $module = mt_rand();
         /* set global module properties */
         $this->data['module'] = $module;
         $this->data['title'] = Journal2Utils::getProperty($module_data, 'module_title.value.' . $this->config->get('config_language_id'), '');
         /* sort sections */
         $sections = Journal2Utils::getProperty($module_data, 'sections', array());
         $sections = Journal2Utils::sortArray($sections);
         /* generate sections */
         $this->data['sections'] = array();
         foreach ($sections as $section) {
             if (!$section['status']) {
                 continue;
             }
             $css = array();
             if (Journal2Utils::getColor(Journal2Utils::getProperty($section, 'icon_bg_color.value.color'))) {
                 $css[] = 'background-color: ' . Journal2Utils::getColor(Journal2Utils::getProperty($section, 'icon_bg_color.value.color'));
             }
             if (Journal2Utils::getProperty($section, 'icon_width')) {
                 $css[] = 'width: ' . Journal2Utils::getProperty($section, 'icon_width') . 'px';
             }
             if (Journal2Utils::getProperty($section, 'icon_height')) {
                 $css[] = 'height: ' . Journal2Utils::getProperty($section, 'icon_height') . 'px';
                 $css[] = 'line-height: ' . Journal2Utils::getProperty($section, 'icon_height') . 'px';
             }
             if (Journal2Utils::getProperty($section, 'icon_border')) {
                 $css = array_merge($css, Journal2Utils::getBorderCssProperties(Journal2Utils::getProperty($section, 'icon_border')));
             }
             if ($color = Journal2Utils::getProperty($section, 'bg_color.value.color')) {
                 $color = 'background-color: ' . Journal2Utils::getColor($color);
             } else {
                 $color = null;
             }
             $this->data['sections'][] = array('css' => $color, 'has_icon' => Journal2Utils::getProperty($section, 'icon_status'), 'icon_position' => Journal2Utils::getProperty($section, 'icon_position', 'top'), 'icon' => Journal2Utils::getIconOptions2(Journal2Utils::getProperty($section, 'icon')), 'icon_css' => implode('; ', $css), 'type' => 'html', 'title' => Journal2Utils::getProperty($section, 'section_title.value.' . $this->config->get('config_language_id'), ''), 'content_align' => Journal2Utils::getProperty($section, 'text_align', 'left'), 'content' => Journal2Utils::getProperty($section, 'text.' . $this->config->get('config_language_id'), 'Not Translated'));
         }
         /* grid classes */
         if (in_array($setting['position'], array('column_left', 'column_right'))) {
             $this->data['grid_classes'] = 'xs-100 sm-100 md-100 lg-100 xl-100';
         } else {
             $columns = in_array($setting['position'], array('top', 'bottom')) ? 0 : $this->journal2->settings->get('config_columns_count', 0);
             $this->data['grid_classes'] = Journal2Utils::getProductGridClasses(Journal2Utils::getProperty($module_data, 'items_per_row.value'), $this->journal2->settings->get('site_width', 1024), $columns);
         }
         $this->template = $this->config->get('config_template') . '/template/journal2/module/cms_blocks.tpl';
         if (self::$CACHEABLE === true) {
             $html = Minify_HTML::minify($this->render(), array('xhtml' => false, 'jsMinifier' => 'j2_js_minify'));
             $this->journal2->cache->set($cache_property, $html);
         }
     } else {
         $this->template = $this->config->get('config_template') . '/template/journal2/cache/cache.tpl';
         $this->data['cache'] = $cache;
     }
     $output = $this->render();
     Journal2::stopTimer(get_class($this));
     return $output;
 }
 public function index($setting)
 {
     if (!defined('JOURNAL_INSTALLED')) {
         return;
     }
     if (!$this->model_journal2_blog->isEnabled()) {
         return;
     }
     Journal2::startTimer(get_class($this));
     /* get module data from db */
     $module_data = $this->model_journal2_module->getModule($setting['module_id']);
     if (!$module_data || !isset($module_data['module_data']) || !$module_data['module_data']) {
         return;
     }
     /* device detection */
     $this->data['disable_on_classes'] = array();
     if ($this->journal2->settings->get('responsive_design')) {
         $device = Journal2Utils::getDevice();
         if (Journal2Utils::getProperty($module_data, 'module_data.enable_on_phone', '1') == '0') {
             if ($device === 'phone') {
                 return;
             } else {
                 $this->data['disable_on_classes'][] = 'hide-on-phone';
             }
         }
         if (Journal2Utils::getProperty($module_data, 'module_data.enable_on_tablet', '1') == '0') {
             if ($device === 'tablet') {
                 return;
             } else {
                 $this->data['disable_on_classes'][] = 'hide-on-tablet';
             }
         }
         if (Journal2Utils::getProperty($module_data, 'module_data.enable_on_desktop', '1') == '0') {
             if ($device === 'desktop') {
                 return;
             } else {
                 $this->data['disable_on_classes'][] = 'hide-on-desktop';
             }
         }
     }
     $hash = isset($this->request->server['REQUEST_URI']) ? md5($this->request->server['REQUEST_URI']) : null;
     if (in_array($setting['position'], array('top', 'bottom'))) {
         $padding = $this->journal2->settings->get('module_margins', 20) . 'px';
         /* outer */
         $css = Journal2Utils::getBackgroundCssProperties(Journal2Utils::getProperty($module_data, 'module_data.background'));
         $css[] = 'padding-top: ' . Journal2Utils::getProperty($module_data, 'module_data.margin_top', 0) . 'px';
         $css[] = 'padding-bottom: ' . Journal2Utils::getProperty($module_data, 'module_data.margin_bottom', 0) . 'px';
         $this->journal2->settings->set('module_journal2_blog_posts_' . $setting['module_id'], implode('; ', $css));
         $this->journal2->settings->set('module_journal2_blog_posts_' . $setting['module_id'] . '_classes', implode(' ', $this->data['disable_on_classes']));
         /* inner css */
         $css = array();
         if (Journal2Utils::getProperty($module_data, 'module_data.fullwidth')) {
             $css[] = 'max-width: 100%';
             $css[] = 'padding-left: ' . $padding;
             $css[] = 'padding-right: ' . $padding;
         } else {
             $css[] = 'max-width: ' . $this->journal2->settings->get('site_width', 1024) . 'px';
             $css = array_merge($css, Journal2Utils::getBackgroundCssProperties(Journal2Utils::getProperty($module_data, 'module_data.module_background')));
             if (Journal2Utils::getProperty($module_data, 'module_data.module_padding')) {
                 $this->data['gutter_on_class'] = 'gutter-on';
                 $css[] = 'padding: 20px';
             }
         }
         $this->data['css'] = implode('; ', $css);
     }
     $cache_property = "module_journal_blog_posts_{$setting['module_id']}_{$setting['layout_id']}_{$setting['position']}_{$hash}";
     $cache = $this->journal2->cache->get($cache_property);
     if ($cache === null || self::$CACHEABLE !== true || $hash === null) {
         $module = mt_rand();
         $this->data['module'] = $module;
         $this->data['heading_title'] = Journal2Utils::getProperty($module_data, 'module_data.title.value.' . $this->config->get('config_language_id'));
         $this->data['display'] = Journal2Utils::getProperty($module_data, 'module_data.display', 'grid');
         $this->data['content_align'] = Journal2Utils::getProperty($module_data, 'module_data.content_align', 'center');
         /* carousel */
         $this->data['carousel'] = Journal2Utils::getProperty($module_data, 'module_data.carousel');
         if ($this->data['carousel']) {
             $columns = in_array($setting['position'], array('top', 'bottom')) ? 0 : $this->journal2->settings->get('config_columns_count', 0);
             if ($this->data['display'] === 'list') {
                 $this->data['grid'] = array(array(0, 1), array(470, 1), array(760, 1), array(980, 1), array(1100, 1));
             } else {
                 $this->data['grid'] = Journal2Utils::getItemGrid(Journal2Utils::getProperty($module_data, 'module_data.items_per_row.value'), $this->journal2->settings->get('site_width', 1024), $columns);
                 $this->data['grid'] = array(array(0, (int) $this->data['grid']['xs']), array(470, (int) $this->data['grid']['sm']), array(760, (int) $this->data['grid']['md']), array(980, (int) $this->data['grid']['lg']), array(1100, (int) $this->data['grid']['xl']));
             }
             $this->data['arrows'] = Journal2Utils::getProperty($module_data, 'module_data.carousel_arrows');
             $this->data['bullets'] = Journal2Utils::getProperty($module_data, 'module_data.carousel_bullets');
             if (Journal2Utils::getProperty($module_data, 'module_data.autoplay')) {
                 $this->data['autoplay'] = Journal2Utils::getProperty($module_data, 'module_data.transition_delay', 3000);
             } else {
                 $this->data['autoplay'] = false;
             }
             $this->data['slide_speed'] = (int) Journal2Utils::getProperty($module_data, 'module_data.transition_speed', 400);
             $this->data['pause_on_hover'] = Journal2Utils::getProperty($module_data, 'module_data.pause_on_hover');
             $this->data['touch_drag'] = Journal2Utils::getProperty($module_data, 'module_data.touch_drag');
         }
         $module_type = Journal2Utils::getProperty($module_data, 'module_data.module_type', 'newest');
         $limit = Journal2Utils::getProperty($module_data, 'module_data.limit', 5);
         $posts = array();
         switch ($module_type) {
             case 'newest':
             case 'comments':
             case 'views':
                 $posts = $this->model_journal2_blog->getPosts(array('sort' => $module_type, 'start' => 0, 'limit' => $limit));
                 break;
             case 'related':
                 if (isset($this->request->get['route']) && $this->request->get['route'] === 'product/product' && isset($this->request->get['product_id'])) {
                     $posts = $this->model_journal2_blog->getRelatedPosts($this->request->get['product_id'], $limit);
                 }
                 break;
             case 'custom':
                 $custom_posts = Journal2Utils::getProperty($module_data, 'module_data.posts', array());
                 $custom_posts_ids = array();
                 foreach ($custom_posts as $custom_post) {
                     $post_id = (int) Journal2Utils::getProperty($custom_post, 'data.id', 0);
                     if ($post_id) {
                         $custom_posts_ids[$post_id] = $post_id;
                     }
                 }
                 if ($custom_posts_ids) {
                     $posts = $this->model_journal2_blog->getPosts(array('post_ids' => implode(',', $custom_posts_ids)));
                 }
                 break;
         }
         if (!$posts) {
             return;
         }
         if (in_array($setting['position'], array('column_left', 'column_right'))) {
             $this->data['is_column'] = true;
             $this->data['grid_classes'] = 'xs-100 sm-100 md-100 lg-100 xl-100';
         } else {
             $this->data['is_column'] = false;
             $columns = in_array($setting['position'], array('top', 'bottom')) ? 0 : $this->journal2->settings->get('config_columns_count', 0);
             $this->data['grid_classes'] = Journal2Utils::getProductGridClasses(Journal2Utils::getProperty($module_data, 'module_data.items_per_row.value'), $this->journal2->settings->get('site_width', 1024), $columns);
         }
         $this->data['image_width'] = Journal2Utils::getProperty($module_data, 'module_data.image_width', 50);
         $this->data['image_height'] = Journal2Utils::getProperty($module_data, 'module_data.image_height', 50);
         $this->data['image_resize_type'] = Journal2Utils::getProperty($module_data, 'module_data.image_type', 'fit');
         $this->data['show_description'] = Journal2Utils::getProperty($module_data, 'module_data.description', '1');
         $char_limit = Journal2Utils::getProperty($module_data, 'module_data.description_limit', 150);
         $this->data['posts'] = array();
         foreach ($posts as $post) {
             $this->data['posts'][] = array('name' => $post['name'], 'author' => $this->model_journal2_blog->getAuthorName($post), 'comments' => $post['comments'], 'description' => $this->data['show_description'] ? utf8_substr(strip_tags(html_entity_decode($post['description'], ENT_QUOTES, 'UTF-8')), 0, $char_limit) . '...' : false, 'date' => date($this->language->get('date_format_short'), strtotime($post['date'])), 'image' => Journal2Utils::resizeImage($this->model_tool_image, $post['image'] ? $post['image'] : 'data/journal2/no_image_large.jpg', $this->data['image_width'], $this->data['image_height'], $this->data['image_resize_type']), 'href' => $this->url->link('journal2/blog/post', 'journal_blog_post_id=' . $post['post_id']));
         }
         $this->template = $this->config->get('config_template') . '/template/journal2/module/blog_posts.tpl';
         if (self::$CACHEABLE === true) {
             $html = Minify_HTML::minify($this->render(), array('xhtml' => false, 'jsMinifier' => 'j2_js_minify'));
             $this->journal2->cache->set($cache_property, $html);
         }
     } else {
         $this->template = $this->config->get('config_template') . '/template/journal2/cache/cache.tpl';
         $this->data['cache'] = $cache;
     }
     $output = $this->render();
     Journal2::stopTimer(get_class($this));
     return $output;
 }
예제 #3
0
 public function post()
 {
     $this->data['breadcrumbs'] = array();
     $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home'), 'separator' => false);
     $this->data['breadcrumbs'][] = array('text' => $this->blog_title, 'href' => $this->url->link('journal2/blog'), 'separator' => $this->language->get('text_separator'));
     if (isset($this->request->get['journal_blog_category_id'])) {
         $category_id = $this->request->get['journal_blog_category_id'];
     } else {
         $category_id = 0;
     }
     $category_info = $this->model_journal2_blog->getCategory($category_id);
     if ($category_info) {
         $this->data['breadcrumbs'][] = array('text' => $category_info['name'], 'href' => $this->url->link('journal2/blog', 'journal_blog_category_id=' . $category_id), 'separator' => $this->language->get('text_separator'));
     }
     if (isset($this->request->get['journal_blog_post_id'])) {
         $post_id = $this->request->get['journal_blog_post_id'];
     } else {
         $post_id = 0;
     }
     $post_info = $this->model_journal2_blog->getPost($post_id);
     if ($post_info) {
         $this->data['breadcrumbs'][] = array('text' => $post_info['name'], 'href' => $this->url->link('journal2/blog/post', ($category_info ? 'journal_blog_category_id=' . $category_id . '&' : '') . 'journal_blog_post_id=' . $post_info['post_id']), 'separator' => $this->language->get('text_separator'));
         $this->data['text_tags'] = $this->language->get('text_tags');
         $this->data['tab_related'] = $this->language->get(Front::$IS_OC2 ? 'text_related' : 'tab_related');
         $this->data['button_cart'] = $this->language->get('button_cart');
         $this->data['button_wishlist'] = $this->language->get('button_wishlist');
         $this->data['button_compare'] = $this->language->get('button_compare');
         $this->blog_title = $post_info['name'];
         $this->blog_heading_title = $post_info['name'];
         $this->blog_meta_title = $post_info['meta_title'];
         $this->blog_meta_description = $post_info['meta_description'];
         $this->blog_meta_keywords = $post_info['meta_keywords'];
         $this->data['post_id'] = $post_info['post_id'];
         $this->data['post_author'] = $this->model_journal2_blog->getAuthorName($post_info);
         $this->data['post_date'] = $post_info['date_created'];
         $this->data['post_content'] = $post_info['description'];
         $this->data['default_author_image'] = Journal2Utils::resizeImage($this->model_tool_image, 'data/journal2/misc/avatar.png', 70, 70);
         $this->data['post_tags'] = array();
         foreach (explode(',', $post_info['tags']) as $tag) {
             $tag = trim($tag);
             if (!$tag) {
                 continue;
             }
             $this->data['post_tags'][] = array('href' => $this->url->link('journal2/blog', 'journal_blog_tag=' . $tag), 'name' => $tag);
         }
         $results = $this->model_journal2_blog->getCategoriesByPostId($post_id);
         $this->data['post_categories'] = array();
         foreach ($results as $result) {
             $this->data['post_categories'][] = array('href' => $this->url->link('journal2/blog', 'journal_blog_category_id=' . $result['category_id']), 'name' => $result['name']);
         }
         $this->data['grid_classes'] = Journal2Utils::getProductGridClasses($this->journal2->settings->get('config_blog_settings.related_products_per_row.value'), $this->journal2->settings->get('site_width', 1024), $this->journal2->settings->get('config_columns_count', 0));
         $this->data['carousel'] = $this->journal2->settings->get('config_blog_settings.related_products_carousel');
         $this->data['related_products'] = array();
         if ($this->journal2->settings->get('config_blog_settings.related_products', '1')) {
             $results = $this->model_journal2_blog->getRelatedProducts($post_id);
             foreach ($results as $result) {
                 $image = Journal2Utils::resizeImage($this->model_tool_image, $result['image'], $this->config->get('config_image_related_width'), $this->config->get('config_image_related_height'), 'fit');
                 if ($this->config->get('config_customer_price') && $this->customer->isLogged() || !$this->config->get('config_customer_price')) {
                     $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
                 } else {
                     $price = false;
                 }
                 if ((double) $result['special']) {
                     $special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')));
                 } else {
                     $special = false;
                 }
                 if ($this->config->get('config_review_status')) {
                     $rating = (int) $result['rating'];
                 } else {
                     $rating = false;
                 }
                 $date_end = false;
                 if (strpos($this->config->get('config_template'), 'journal2') === 0 && $special && $this->journal2->settings->get('show_countdown', 'never') !== 'never') {
                     $this->load->model('journal2/product');
                     $date_end = $this->model_journal2_product->getSpecialCountdown($result['product_id']);
                     if ($date_end === '0000-00-00') {
                         $date_end = false;
                     }
                 }
                 $additional_images = $this->model_catalog_product->getProductImages($result['product_id']);
                 $image2 = false;
                 if (count($additional_images) > 0) {
                     $image2 = $this->model_tool_image->resize($additional_images[0]['image'], $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height'));
                 }
                 $this->data['related_products'][] = array('product_id' => $result['product_id'], 'thumb' => $image, 'thumb2' => $image2, 'labels' => $this->model_journal2_product->getLabels($result['product_id']), 'date_end' => $date_end, 'name' => $result['name'], 'price' => $price, 'special' => $special, 'rating' => $rating, 'reviews' => sprintf($this->language->get('text_reviews'), (int) $result['reviews']), 'href' => $this->url->link('product/product', 'product_id=' . $result['product_id']));
             }
         }
         $this->data['allow_comments'] = $this->model_journal2_blog->getCommentsStatus($post_id);
         $this->data['comments'] = $this->model_journal2_blog->getComments($post_id);
         /* default comment fields */
         if (version_compare(VERSION, '2.1', '<')) {
             $this->load->library('user');
         }
         if ($this->customer->isLogged()) {
             $this->load->model('account/customer');
             $customer_info = $this->model_account_customer->getCustomer($this->customer->getId());
             $this->data['default_name'] = trim($customer_info['firstname'] . ' ' . $customer_info['lastname']);
             $this->data['default_email'] = $customer_info['email'];
         } else {
             if ($this->user->isLogged()) {
                 $admin_info = $this->model_journal2_blog->getAdminInfo($this->user->getId());
                 $this->data['default_name'] = trim($admin_info['firstname'] . ' ' . $admin_info['lastname']);
                 $this->data['default_email'] = $admin_info['email'];
             } else {
                 $this->data['default_name'] = '';
                 $this->data['default_email'] = '';
             }
         }
         $this->model_journal2_blog->updateViews($post_id);
         $this->data['heading_title'] = $this->blog_heading_title;
         $this->document->setTitle($this->blog_title);
         $this->document->setDescription($this->blog_meta_description);
         $this->document->setKeywords($this->blog_meta_keywords);
         $this->document->addLink($this->url->link('journal2/blog/post', 'journal_blog_post_id=' . $post_id), 'canonical');
         $this->journal2->settings->set('blog_meta_title', $this->blog_meta_title);
         $this->journal2->settings->set('fb_meta_title', $this->blog_title);
         $this->journal2->settings->set('fb_meta_description', trim(utf8_substr(strip_tags(html_entity_decode($post_info['description'], ENT_QUOTES, 'UTF-8')), 0, 300)) . '...');
         $this->journal2->settings->set('fb_meta_image', Journal2Utils::staticAsset('image/' . $post_info['image']));
         $this->blog_template = $this->config->get('config_template') . '/template/journal2/blog/post.tpl';
     } else {
         $this->language->load('error/not_found');
         $this->document->setTitle($this->language->get('text_error'));
         $this->data['heading_title'] = $this->language->get('text_error');
         $this->data['text_error'] = $this->language->get('text_error');
         $this->data['button_continue'] = $this->language->get('button_continue');
         $this->data['continue'] = $this->url->link('common/home');
         $this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . '/1.1 404 Not Found');
         if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/not_found.tpl')) {
             $this->blog_template = $this->config->get('config_template') . '/template/error/not_found.tpl';
         } else {
             $this->blog_template = 'default/template/error/not_found.tpl';
         }
     }
     if (Front::$IS_OC2) {
         $this->data['column_left'] = $this->load->controller('common/column_left');
         $this->data['column_right'] = $this->load->controller('common/column_right');
         $this->data['content_top'] = $this->load->controller('common/content_top');
         $this->data['content_bottom'] = $this->load->controller('common/content_bottom');
         $this->data['footer'] = $this->load->controller('common/footer');
         $this->data['header'] = $this->load->controller('common/header');
     } else {
         $this->children = array('common/column_left', 'common/column_right', 'common/content_top', 'common/content_bottom', 'common/footer', 'common/header');
     }
     $this->response->setOutput($this->render());
 }
 private function generateMenuItem(&$menu, $menu_item, $image_width, $image_height, $image_resize_type)
 {
     $items_limit = Journal2Utils::getProperty($menu_item, 'items_limit', 0);
     switch (Journal2Utils::getProperty($menu_item, 'type')) {
         /* categories menu */
         case 'categories':
             switch (Journal2Utils::getProperty($menu_item, 'categories.render_as', 'megamenu')) {
                 case 'megamenu':
                     $menu['show'] = Journal2Utils::getProperty($menu_item, 'categories.show');
                     switch ($menu['show']) {
                         case 'links':
                             $menu['show_class'] = 'menu-no-image';
                             break;
                         case 'image':
                             $menu['show_class'] = 'menu-no-links';
                             break;
                         default:
                             $menu['show_class'] = '';
                     }
                     $menu['classes'] .= ' menu-image-' . Journal2Utils::getProperty($menu_item, 'categories.image_position', 'right');
                     $menu['type'] = 'mega-menu-categories';
                     $links_type = Journal2Utils::getProperty($menu_item, 'categories.links_type', 'categories');
                     switch (Journal2Utils::getProperty($menu_item, 'categories.type')) {
                         /* existing categories */
                         case 'existing':
                             $parent_category = $this->model_catalog_category->getCategory(Journal2Utils::getProperty($menu_item, 'categories.top.id'));
                             if (!$parent_category) {
                                 continue;
                             }
                             $menu['name'] = $parent_category['name'];
                             $menu['href'] = $this->url->link('product/category', 'path=' . $parent_category['category_id']);
                             switch ($links_type) {
                                 case 'categories':
                                     $subcategories = $this->model_catalog_category->getCategories(Journal2Utils::getProperty($menu_item, 'categories.top.id'));
                                     foreach ($subcategories as $subcategory) {
                                         $submenu = array();
                                         $sub_categories = $this->model_catalog_category->getCategories($subcategory['category_id']);
                                         foreach ($sub_categories as $sub_category) {
                                             $submenu[] = array('name' => $sub_category['name'], 'href' => $this->url->link('product/category', 'path=' . $parent_category['category_id'] . '_' . $subcategory['category_id'] . '_' . $sub_category['category_id']), 'image' => Journal2Utils::resizeImage($this->model_tool_image, $sub_category, $image_width, $image_height, $image_resize_type), 'image_width' => $image_width ? $image_width : 100, 'image_height' => $image_height ? $image_height : 100, 'dummy' => Journal2Utils::resizeImage($this->model_tool_image, 'data/journal2/transparent.png', $image_width, $image_height, 'fit'));
                                         }
                                         $menu['items'][] = array('name' => $subcategory['name'], 'href' => $this->url->link('product/category', 'path=' . $parent_category['category_id'] . '_' . $subcategory['category_id']), 'items' => $submenu, 'image' => Journal2Utils::resizeImage($this->model_tool_image, $subcategory, $image_width, $image_height, $image_resize_type), 'image_width' => $image_width ? $image_width : 100, 'image_height' => $image_height ? $image_height : 100, 'dummy' => Journal2Utils::resizeImage($this->model_tool_image, 'data/journal2/transparent.jpg', $image_width, $image_height, 'fit'), 'image-class' => count($submenu) ? '' : 'full-img');
                                     }
                                     break;
                                 case 'products':
                                     $subcategories = $this->model_catalog_category->getCategories(Journal2Utils::getProperty($menu_item, 'categories.top.id'));
                                     foreach ($subcategories as $subcategory) {
                                         $submenu = array();
                                         $sub_categories = $this->model_journal2_product->getProductsByCategory($subcategory['category_id'], $items_limit ? $items_limit : 5);
                                         foreach ($sub_categories as $sub_category) {
                                             $submenu[] = array('name' => $sub_category['name'], 'href' => $this->url->link('product/product', 'path=' . $parent_category['category_id'] . '_' . $subcategory['category_id'] . '&product_id=' . $sub_category['product_id']), 'image' => Journal2Utils::resizeImage($this->model_tool_image, $sub_category, $image_width, $image_height, $image_resize_type), 'image_width' => $image_width ? $image_width : $this->config->get('config_image_product_width'), 'image_height' => $image_height ? $image_height : $this->config->get('config_image_product_height'), 'dummy' => Journal2Utils::resizeImage($this->model_tool_image, 'data/journal2/transparent.jpg', $image_width, $image_height, 'fit'));
                                         }
                                         $menu['items'][] = array('name' => $subcategory['name'], 'href' => $this->url->link('product/category', 'path=' . $parent_category['category_id'] . '_' . $subcategory['category_id']), 'items' => $submenu, 'image' => Journal2Utils::resizeImage($this->model_tool_image, $subcategory, $image_width, $image_height, $image_resize_type), 'image_width' => $image_width ? $image_width : $this->config->get('config_image_product_width'), 'image_height' => $image_height ? $image_height : $this->config->get('config_image_product_height'), 'dummy' => Journal2Utils::resizeImage($this->model_tool_image, 'data/journal2/transparent.jpg', $image_width, $image_height, 'fit'), 'image-class' => count($submenu) ? '' : 'full-img');
                                     }
                                     break;
                             }
                             break;
                             /* custom categories */
                         /* custom categories */
                         case 'custom':
                             switch ($links_type) {
                                 case 'categories':
                                     $menu['name'] = Journal2Utils::getProperty($menu_item, 'name.value.' . $this->config->get('config_language_id'), 'Not Translated');
                                     $menu['href'] = 'javascript:;';
                                     foreach (Journal2Utils::getProperty($menu_item, 'categories.items', array()) as $category) {
                                         $parent_category = $this->model_catalog_category->getCategory(Journal2Utils::getProperty($category, 'data.id'));
                                         if (!$parent_category) {
                                             continue;
                                         }
                                         $sub_categories = $this->model_catalog_category->getCategories(Journal2Utils::getProperty($category, 'data.id'));
                                         $submenu = array();
                                         foreach ($sub_categories as $sub_category) {
                                             $submenu[] = array('name' => $sub_category['name'], 'href' => $this->url->link('product/category', 'path=' . $parent_category['category_id'] . '_' . $sub_category['category_id']), 'image' => Journal2Utils::resizeImage($this->model_tool_image, $sub_category, $image_width, $image_height, $image_resize_type), 'image_width' => $image_width ? $image_width : 100, 'image_height' => $image_height ? $image_height : 100, 'dummy' => Journal2Utils::resizeImage($this->model_tool_image, 'data/journal2/transparent.jpg', $image_width, $image_height, 'fit'));
                                         }
                                         $menu['items'][] = array('name' => $parent_category['name'], 'href' => $this->url->link('product/category', 'path=' . $parent_category['category_id']), 'image' => Journal2Utils::resizeImage($this->model_tool_image, $parent_category, $image_width, $image_height, $image_resize_type), 'image_width' => $image_width ? $image_width : 100, 'image_height' => $image_height ? $image_height : 100, 'dummy' => Journal2Utils::resizeImage($this->model_tool_image, 'data/journal2/transparent.jpg', $image_width, $image_height, 'fit'), 'items' => $submenu, 'image-class' => count($submenu) ? '' : 'full-img');
                                     }
                                     break;
                                 case 'products':
                                     $menu['name'] = Journal2Utils::getProperty($menu_item, 'name.value.' . $this->config->get('config_language_id'), 'Not Translated');
                                     $menu['href'] = 'javascript:;';
                                     foreach (Journal2Utils::getProperty($menu_item, 'categories.items', array()) as $category) {
                                         $parent_category = $this->model_catalog_category->getCategory(Journal2Utils::getProperty($category, 'data.id'));
                                         if (!$parent_category) {
                                             continue;
                                         }
                                         $sub_categories = $this->model_journal2_product->getProductsByCategory(Journal2Utils::getProperty($category, 'data.id'), $items_limit);
                                         $submenu = array();
                                         foreach ($sub_categories as $sub_category) {
                                             $submenu[] = array('name' => $sub_category['name'], 'href' => $this->url->link('product/product', 'path=' . $parent_category['category_id'] . '&product_id=' . $sub_category['product_id']), 'image' => Journal2Utils::resizeImage($this->model_tool_image, $sub_category, $image_width, $image_height, $image_resize_type), 'image_width' => $image_width ? $image_width : $this->config->get('config_image_product_width'), 'image_height' => $image_height ? $image_height : $this->config->get('config_image_product_height'), 'dummy' => Journal2Utils::resizeImage($this->model_tool_image, 'data/journal2/transparent.jpg', $image_width, $image_height, 'fit'));
                                         }
                                         $menu['items'][] = array('name' => $parent_category['name'], 'href' => $this->url->link('product/category', 'path=' . $parent_category['category_id']), 'image' => Journal2Utils::resizeImage($this->model_tool_image, $parent_category, $image_width, $image_height, $image_resize_type), 'image_width' => $image_width ? $image_width : $this->config->get('config_image_product_width'), 'image_height' => $image_height ? $image_height : $this->config->get('config_image_product_height'), 'dummy' => Journal2Utils::resizeImage($this->model_tool_image, 'data/journal2/transparent.jpg', $image_width, $image_height, 'fit'), 'items' => $submenu, 'image-class' => count($submenu) ? '' : 'full-img');
                                     }
                                     break;
                             }
                             break;
                     }
                     break;
                 case 'dropdown':
                     $menu['type'] = 'drop-down';
                     switch (Journal2Utils::getProperty($menu_item, 'categories.type')) {
                         /* existing categories */
                         case 'existing':
                             $parent_category = $this->model_catalog_category->getCategory(Journal2Utils::getProperty($menu_item, 'categories.top.id'));
                             if (!$parent_category) {
                                 continue;
                             }
                             $menu['name'] = $parent_category['name'];
                             $menu['href'] = $this->url->link('product/category', 'path=' . $parent_category['category_id']);
                             $menu['subcategories'] = $this->generateMultiLevelCategoryMenu($parent_category['category_id']);
                             break;
                             /* custom categories */
                         /* custom categories */
                         case 'custom':
                             $menu['name'] = Journal2Utils::getProperty($menu_item, 'name.value.' . $this->config->get('config_language_id'), 'Not Translated');
                             $menu['href'] = 'javascript:;';
                             $menu['subcategories'] = array();
                             foreach (Journal2Utils::getProperty($menu_item, 'categories.items', array()) as $category) {
                                 $category_info = $this->model_catalog_category->getCategory(Journal2Utils::getProperty($category, 'data.id'));
                                 if (!$category_info) {
                                     continue;
                                 }
                                 $menu['subcategories'][] = array('name' => $category_info['name'], 'href' => $this->url->link('product/category', 'path=' . $category_info['category_id']), 'subcategories' => $this->generateMultiLevelCategoryMenu($category_info['category_id']));
                             }
                             break;
                     }
                     if ($name_overwrite = Journal2Utils::getProperty($menu_item, 'name.value.' . $this->config->get('config_language_id'))) {
                         $menu['name'] = $name_overwrite;
                     }
                     break;
             }
             break;
             /* products menu */
         /* products menu */
         case 'products':
             $menu['type'] = 'mega-menu-products';
             $menu['href'] = $this->model_journal2_menu->getLink(Journal2Utils::getProperty($menu_item, 'html_menu_link'));
             switch (Journal2Utils::getProperty($menu_item, 'products.source')) {
                 /* products from category */
                 case 'category':
                     $parent_category = $this->model_catalog_category->getCategory(Journal2Utils::getProperty($menu_item, 'products.category.id'));
                     if (!$parent_category) {
                         continue;
                     }
                     $menu['name'] = $parent_category['name'];
                     $menu['href'] = $this->url->link('product/category', 'path=' . $parent_category['category_id']);
                     $products = $this->model_journal2_product->getProductsByCategory($parent_category['category_id'], $items_limit ? $items_limit : 5);
                     foreach ($products as $product) {
                         $menu['items'][] = array('product_id' => $product['product_id'], 'labels' => $this->model_journal2_product->getLabels($product['product_id']), 'name' => $product['name'], 'href' => $this->url->link('product/product', 'path=' . $parent_category['category_id'] . '&product_id=' . $product['product_id']), 'image' => Journal2Utils::resizeImage($this->model_tool_image, $product, $image_width, $image_height, $image_resize_type), 'image_width' => $image_width ? $image_width : 100, 'image_height' => $image_height ? $image_height : 100, 'dummy' => Journal2Utils::resizeImage($this->model_tool_image, 'data/journal2/transparent.jpg', $image_width, $image_height, 'fit'), 'price' => $this->getProductPrice($product), 'special' => $this->getProductSpecialPrice($product), 'rating' => $this->config->get('config_review_status') ? $product['rating'] : false, 'reviews' => sprintf($this->language->get('text_reviews'), (int) $product['reviews']), 'items' => array());
                     }
                     break;
                     /* products from module */
                 /* products from module */
                 case 'module':
                     $products = array();
                     switch (Journal2Utils::getProperty($menu_item, 'products.module_type')) {
                         case 'featured':
                             $products = $this->model_journal2_product->getFeatured($items_limit ? $items_limit : 5, Journal2Utils::getProperty($menu_item, 'products.featured_module_id'));
                             $this->load->language('module/featured');
                             break;
                         case 'special':
                             $products = $this->model_journal2_product->getSpecials($items_limit ? $items_limit : 5);
                             $this->load->language('module/special');
                             break;
                         case 'bestseller':
                             $products = $this->model_journal2_product->getBestsellers($items_limit ? $items_limit : 5);
                             $this->load->language('module/bestseller');
                             break;
                         case 'latest':
                             $products = $this->model_journal2_product->getLatest($items_limit ? $items_limit : 5);
                             $this->load->language('module/latest');
                             break;
                     }
                     $menu['name'] = $this->language->get('heading_title');
                     foreach ($products as $product) {
                         $menu['items'][] = array('product_id' => $product['product_id'], 'labels' => $this->model_journal2_product->getLabels($product['product_id']), 'name' => $product['name'], 'href' => $this->url->link('product/product', 'product_id=' . $product['product_id']), 'image' => Journal2Utils::resizeImage($this->model_tool_image, $product, $image_width, $image_height, $image_resize_type), 'image_width' => $image_width ? $image_width : $this->config->get('config_image_product_width'), 'image_height' => $image_height ? $image_height : $this->config->get('config_image_product_height'), 'dummy' => Journal2Utils::resizeImage($this->model_tool_image, 'data/journal2/transparent.jpg', $image_width, $image_height, 'fit'), 'price' => $this->getProductPrice($product), 'special' => $this->getProductSpecialPrice($product), 'rating' => $this->config->get('config_review_status') ? $product['rating'] : false, 'reviews' => sprintf($this->language->get('text_reviews'), (int) $product['reviews']), 'items' => array());
                     }
                     break;
                     /* products from manufacturer */
                 /* products from manufacturer */
                 case 'manufacturer':
                     $manufacturer = $this->model_catalog_manufacturer->getManufacturer(Journal2Utils::getProperty($menu_item, 'products.manufacturer.id'));
                     if (!$manufacturer) {
                         continue;
                     }
                     $menu['name'] = $manufacturer['name'];
                     $menu['href'] = $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $manufacturer['manufacturer_id']);
                     $products = $this->model_journal2_product->getProductsByManufacturer($manufacturer['manufacturer_id']);
                     foreach ($products as $product) {
                         $menu['items'][] = array('product_id' => $product['product_id'], 'labels' => $this->model_journal2_product->getLabels($product['product_id']), 'name' => $product['name'], 'href' => $this->url->link('product/product', '&manufacturer_id=' . $manufacturer['manufacturer_id'] . '&product_id=' . $product['product_id']), 'image' => Journal2Utils::resizeImage($this->model_tool_image, $product, $image_width, $image_height, $image_resize_type), 'image_width' => $image_width ? $image_width : $this->config->get('config_image_product_width'), 'image_height' => $image_height ? $image_height : $this->config->get('config_image_product_height'), 'dummy' => Journal2Utils::resizeImage($this->model_tool_image, 'data/journal2/transparent.jpg', $image_width, $image_height, 'fit'), 'price' => $this->getProductPrice($product), 'special' => $this->getProductSpecialPrice($product), 'rating' => $this->config->get('config_review_status') ? $product['rating'] : false, 'reviews' => sprintf($this->language->get('text_reviews'), (int) $product['reviews']), 'items' => array());
                     }
                     break;
                     /* custom products */
                 /* custom products */
                 case 'custom':
                     $products = Journal2Utils::sortArray(Journal2Utils::getProperty($menu_item, 'products.items', array()));
                     foreach ($products as $product) {
                         $result = $this->model_catalog_product->getProduct(Journal2Utils::getProperty($product, 'data.id'));
                         if (!$result) {
                             continue;
                         }
                         $menu['items'][] = array('product_id' => $result['product_id'], 'labels' => $this->model_journal2_product->getLabels($result['product_id']), 'name' => $result['name'], 'href' => $this->url->link('product/product', '&product_id=' . $result['product_id']), 'image' => Journal2Utils::resizeImage($this->model_tool_image, $result, $image_width, $image_height, $image_resize_type), 'image_width' => $image_width ? $image_width : $this->config->get('config_image_product_width'), 'image_height' => $image_height ? $image_height : $this->config->get('config_image_product_height'), 'dummy' => Journal2Utils::resizeImage($this->model_tool_image, 'data/journal2/transparent.jpg', $image_width, $image_height, 'fit'), 'price' => $this->getProductPrice($result), 'special' => $this->getProductSpecialPrice($result), 'rating' => $this->config->get('config_review_status') ? $result['rating'] : false, 'reviews' => sprintf($this->language->get('text_reviews'), (int) $result['reviews']), 'items' => array());
                     }
                     $menu['limit'] = PHP_INT_MAX;
                     break;
                     /* random */
                 /* random */
                 case 'random':
                     $this->mega_has_random_products = true;
                     $this->load->model('journal2/product');
                     $random_products = $this->model_journal2_product->getRandomProducts($items_limit);
                     foreach ($random_products as $product) {
                         $result = $this->model_catalog_product->getProduct($product['product_id']);
                         if (!$result) {
                             continue;
                         }
                         $menu['items'][] = array('product_id' => $result['product_id'], 'labels' => $this->model_journal2_product->getLabels($result['product_id']), 'name' => $result['name'], 'href' => $this->url->link('product/product', '&product_id=' . $result['product_id']), 'image' => Journal2Utils::resizeImage($this->model_tool_image, $result, $image_width, $image_height, $image_resize_type), 'image_width' => $image_width ? $image_width : $this->config->get('config_image_product_width'), 'image_height' => $image_height ? $image_height : $this->config->get('config_image_product_height'), 'dummy' => Journal2Utils::resizeImage($this->model_tool_image, 'data/journal2/transparent.jpg', $image_width, $image_height, 'fit'), 'price' => $this->getProductPrice($result), 'special' => $this->getProductSpecialPrice($result), 'rating' => $this->config->get('config_review_status') ? $result['rating'] : false, 'reviews' => sprintf($this->language->get('text_reviews'), (int) $result['reviews']), 'items' => array());
                     }
                     break;
             }
             break;
             /* manufacturer menu */
         /* manufacturer menu */
         case 'manufacturers':
             $menu['type'] = 'mega-menu-brands';
             $menu['href'] = $this->model_journal2_menu->getLink(Journal2Utils::getProperty($menu_item, 'html_menu_link'));
             $manufacturers = array();
             switch (Journal2Utils::getProperty($menu_item, 'manufacturers.type')) {
                 case 'all':
                     $manufacturers = $this->model_catalog_manufacturer->getManufacturers();
                     if ($items_limit > 0) {
                         $manufacturers = array_slice($manufacturers, 0, $items_limit);
                     }
                     break;
                 case 'custom':
                     foreach (Journal2Utils::getProperty($menu_item, 'manufacturers.items', array()) as $manufacturer) {
                         $manufacturers[] = array('manufacturer_id' => Journal2Utils::getProperty($manufacturer, 'data.id', -1));
                     }
             }
             $show_name = Journal2Utils::getProperty($menu_item, 'manufacturers.name');
             foreach ($manufacturers as $manufacturer) {
                 $manufacturer_info = $this->model_catalog_manufacturer->getManufacturer($manufacturer['manufacturer_id']);
                 if (!$manufacturer_info) {
                     continue;
                 }
                 $menu['items'][] = array('name' => $manufacturer_info['name'], 'show' => Journal2Utils::getProperty($menu_item, 'manufacturers.show', 'both'), 'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $manufacturer_info['manufacturer_id']), 'image' => Journal2Utils::resizeImage($this->model_tool_image, $manufacturer_info, $image_width, $image_height, $image_resize_type), 'image_width' => $image_width ? $image_width : 100, 'image_height' => $image_height ? $image_height : 100, 'dummy' => Journal2Utils::resizeImage($this->model_tool_image, 'data/journal2/transparent.jpg', $image_width, $image_height, 'fit'), 'items' => array());
             }
             break;
             /* custom menu */
         /* custom menu */
         case 'custom':
             $menu['type'] = 'drop-down';
             $menu['target'] = Journal2Utils::getProperty($menu_item, 'custom.target') ? 'target="_blank"' : '';
             switch (Journal2Utils::getProperty($menu_item, 'custom.top.menu_type')) {
                 case 'category':
                     $category_info = $this->model_catalog_category->getCategory(Journal2Utils::getProperty($menu_item, 'custom.top.menu_item.id', -1));
                     if (!$category_info) {
                         continue;
                     }
                     $menu['name'] = $category_info['name'];
                     $menu['href'] = $this->url->link('product/category', 'path=' . $category_info['category_id']);
                     $menu['subcategories'] = $this->generateMenu(Journal2Utils::getProperty($menu_item, 'custom.items', array()));
                     break;
                 case 'product':
                     $product_info = $this->model_catalog_product->getProduct(Journal2Utils::getProperty($menu_item, 'custom.top.menu_item.id', -1));
                     if (!$product_info) {
                         continue;
                     }
                     $menu['name'] = $product_info['name'];
                     $menu['href'] = $this->url->link('product/product', 'product_id=' . $product_info['product_id']);
                     $menu['subcategories'] = $this->generateMenu(Journal2Utils::getProperty($menu_item, 'custom.items', array()));
                     break;
                 case 'manufacturer':
                     $manufacturer_info = $this->model_catalog_manufacturer->getManufacturer(Journal2Utils::getProperty($menu_item, 'custom.top.menu_item.id', -1));
                     if (!$manufacturer_info) {
                         continue;
                     }
                     $menu['name'] = $manufacturer_info['name'];
                     $menu['href'] = $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $manufacturer_info['manufacturer_id']);
                     $menu['subcategories'] = $this->generateMenu(Journal2Utils::getProperty($menu_item, 'custom.items', array()));
                     break;
                 case 'information':
                     $information_info = $this->model_catalog_information->getInformation(Journal2Utils::getProperty($menu_item, 'custom.top.menu_item.id', -1));
                     if (!$information_info) {
                         continue;
                     }
                     $menu['name'] = $information_info['title'];
                     $menu['href'] = $this->url->link('information/information', 'information_id=' . $information_info['information_id']);
                     $menu['subcategories'] = $this->generateMenu(Journal2Utils::getProperty($menu_item, 'custom.items', array()));
                     break;
                 case 'opencart':
                     $customer_name = null;
                     switch (Journal2Utils::getProperty($menu_item, 'custom.top.menu_item.page')) {
                         case 'login':
                             $menu_item['custom']['top']['menu_item']['page'] = $this->customer->isLogged() ? 'account/account' : 'account/login';
                             $customer_name = $this->customer->isLogged() ? '{{_customer_}}' : null;
                             break;
                         case 'register':
                             $menu_item['custom']['top']['menu_item']['page'] = $this->customer->isLogged() ? 'account/logout' : 'account/register';
                             break;
                         default:
                     }
                     $menu['name'] = $customer_name ? $customer_name : $this->model_journal2_menu->getMenuName($menu_item['custom']['top']['menu_item']['page']);
                     $menu['href'] = $this->model_journal2_menu->link($menu_item['custom']['top']['menu_item']['page']);
                     $menu['subcategories'] = $this->generateMenu(Journal2Utils::getProperty($menu_item, 'custom.items', array()));
                     break;
                 case 'popup':
                     $menu['name'] = Journal2Utils::getProperty($menu_item, 'custom.menu_item.name.value.' . $this->config->get('config_language_id'), 'Not Translated');
                     $menu['href'] = "javascript:Journal.openPopup('" . Journal2Utils::getProperty($menu_item, 'custom.top.menu_item') . "')";
                     $menu['subcategories'] = $this->generateMenu(Journal2Utils::getProperty($menu_item, 'custom.items', array()));
                     break;
                 case 'blog_home':
                     $menu['name'] = $this->journal2->settings->get('config_blog_settings.title.value.' . $this->config->get('config_language_id'), 'Journal Blog');
                     $menu['href'] = $this->url->link('journal2/blog');
                     $menu['subcategories'] = $this->generateMenu(Journal2Utils::getProperty($menu_item, 'custom.items', array()));
                     break;
                 case 'blog_category':
                     $category_info = $this->model_journal2_blog->getCategory(Journal2Utils::getProperty($menu_item, 'custom.top.menu_item.id', -1));
                     if (!$category_info) {
                         continue;
                     }
                     $menu['name'] = $category_info['name'];
                     $menu['href'] = $this->url->link('journal2/blog', 'journal_blog_category_id=' . $category_info['category_id']);
                     $menu['subcategories'] = $this->generateMenu(Journal2Utils::getProperty($menu_item, 'custom.items', array()));
                     break;
                 case 'blog_post':
                     $post_info = $this->model_journal2_blog->getPost(Journal2Utils::getProperty($menu_item, 'custom.top.menu_item.id', -1));
                     if (!$post_info) {
                         continue;
                     }
                     $menu['name'] = $post_info['name'];
                     $menu['href'] = $this->url->link('journal2/blog/post', 'journal_blog_post_id=' . $post_info['post_id']);
                     $menu['subcategories'] = $this->generateMenu(Journal2Utils::getProperty($menu_item, 'custom.items', array()));
                     break;
                 case 'custom':
                     $menu['name'] = Journal2Utils::getProperty($menu_item, 'name.value.' . $this->config->get('config_language_id'), 'Not Translated');
                     $menu['href'] = Journal2Utils::getProperty($menu_item, 'custom.top.menu_item.url');
                     $menu['subcategories'] = $this->generateMenu(Journal2Utils::getProperty($menu_item, 'custom.items', array()));
                     break;
             }
             if ($name_overwrite = Journal2Utils::getProperty($menu_item, 'name.value.' . $this->config->get('config_language_id'))) {
                 $menu['name'] = $name_overwrite;
             }
             break;
             /* html */
         /* html */
         case 'html':
             $menu['type'] = 'mega-menu-html';
             $menu['name'] = Journal2Utils::getProperty($menu_item, 'html.' . $this->config->get('config_language_id'));
             $menu['html_blocks'] = array();
             $menu['href'] = $this->model_journal2_menu->getLink(Journal2Utils::getProperty($menu_item, 'html_menu_link'));
             foreach (Journal2Utils::sortArray(Journal2Utils::getProperty($menu_item, 'html_blocks', array())) as $block) {
                 if (!Journal2Utils::getProperty($block, 'status')) {
                     continue;
                 }
                 $menu['html_blocks'][] = array('title' => Journal2Utils::getProperty($block, 'title.value.' . $this->config->get('config_language_id'), ''), 'text' => Journal2Utils::getProperty($block, 'text.' . $this->config->get('config_language_id')), 'link' => $this->model_journal2_menu->getLink(Journal2Utils::getProperty($block, 'link')));
             }
             break;
             /* mixed */
         /* mixed */
         case 'mixed':
             $menu['type'] = 'mega-menu-mixed';
             $menu['name'] = Journal2Utils::getProperty($menu_item, 'name.value.' . $this->config->get('config_language_id'));
             $menu['html_blocks'] = array();
             $menu['href'] = $this->model_journal2_menu->getLink(Journal2Utils::getProperty($menu_item, 'html_menu_link'));
             $columns = Journal2Utils::getProperty($menu_item, 'mixed_columns', array());
             $columns = Journal2Utils::sortArray($columns);
             foreach ($columns as $column) {
                 $image_width = Journal2Utils::getProperty($column, 'image_width', 250);
                 $image_height = Journal2Utils::getProperty($column, 'image_height', 250);
                 $image_resize_type = Journal2Utils::getProperty($column, 'image_type', 'fit');
                 if (!Journal2Utils::getProperty($column, 'status', 1)) {
                     continue;
                 }
                 $class = Journal2Utils::getProperty($column, 'hide_on_mobile') ? 'hide-on-mobile' : '';
                 if ($class === 'hide-on-mobile' && (Journal2Cache::$mobile_detect->isMobile() || Journal2Cache::$mobile_detect->isTablet()) && $this->journal2->settings->get('responsive_design')) {
                     continue;
                 }
                 if (Journal2Utils::getProperty($column, 'hide_on_desktop', '0') === '1' && !Journal2Cache::$mobile_detect->isMobile()) {
                     continue;
                 }
                 $cms_blocks = array('top' => array(), 'bottom' => array());
                 foreach (Journal2Utils::getProperty($column, 'cms_blocks', array()) as $cms_block) {
                     if (!$cms_block['status']) {
                         return;
                     }
                     $cms_blocks[Journal2Utils::getProperty($cms_block, 'position', 'top')][] = array('content' => Journal2Utils::getProperty($cms_block, 'content.' . $this->config->get('config_language_id')), 'sort_order' => Journal2Utils::getProperty($cms_block, 'sort_order'));
                 }
                 $column_menu = array('top_cms_blocks' => Journal2Utils::sortArray($cms_blocks['top']), 'bottom_cms_blocks' => Journal2Utils::sortArray($cms_blocks['bottom']), 'name' => '', 'href' => '', 'items' => array(), 'type' => '', 'class' => $class, 'width' => Journal2Utils::getProperty($column, 'width', '25') . '%', 'classes' => Journal2Utils::getProductGridClasses(Journal2Utils::getProperty($column, 'items_per_row.value'), $this->journal2->settings->get('site_width', 1024)), 'limit' => Journal2Utils::getProperty($column, 'items_limit', 0), 'icon' => Journal2Utils::getIconOptions2(Journal2Utils::getProperty($menu_item, 'icon')), 'hide_text' => Journal2Utils::getProperty($menu_item, 'hide_text'));
                 $this->generateMenuItem($column_menu, $column, $image_width, $image_height, $image_resize_type);
                 $name_overwrite = Journal2Utils::getProperty($column, 'name.value.' . $this->config->get('config_language_id'));
                 if ($name_overwrite) {
                     $column_menu['name'] = $name_overwrite;
                 }
                 $menu['mixed_columns'][] = $column_menu;
             }
             break;
             /* html block */
         /* html block */
         case 'html-block':
             $menu['type'] = 'mega-menu-html-block';
             $menu['name'] = Journal2Utils::getProperty($menu_item, 'html.' . $this->config->get('config_language_id'));
             $menu['html_text'] = Journal2Utils::getProperty($menu_item, 'html_text.' . $this->config->get('config_language_id'));
             break;
     }
 }
 public function index($setting)
 {
     if (!defined('JOURNAL_INSTALLED')) {
         return;
     }
     if (!$this->model_journal2_blog->isEnabled()) {
         return;
     }
     Journal2::startTimer(get_class($this));
     /* get module data from db */
     $module_data = $this->model_journal2_module->getModule($setting['module_id']);
     if (!$module_data || !isset($module_data['module_data']) || !$module_data['module_data']) {
         return;
     }
     if (Journal2Cache::$mobile_detect->isMobile() && !Journal2Cache::$mobile_detect->isTablet() && $this->journal2->settings->get('responsive_design')) {
         return;
     }
     $hash = isset($this->request->server['REQUEST_URI']) ? md5($this->request->server['REQUEST_URI']) : null;
     $cache_property = "module_journal_blog_side_posts_{$setting['module_id']}_{$setting['layout_id']}_{$setting['position']}_{$hash}";
     $cache = $this->journal2->cache->get($cache_property);
     if ($cache === null || self::$CACHEABLE !== true || $hash === null) {
         $module = mt_rand();
         $this->data['module'] = $module;
         $this->data['heading_title'] = Journal2Utils::getProperty($module_data, 'module_data.title.value.' . $this->config->get('config_language_id'), 'Not Translated');
         $module_type = Journal2Utils::getProperty($module_data, 'module_data.module_type', 'newest');
         $limit = Journal2Utils::getProperty($module_data, 'module_data.limit', 5);
         $posts = array();
         switch ($module_type) {
             case 'newest':
             case 'comments':
             case 'views':
                 $posts = $this->model_journal2_blog->getPosts(array('sort' => $module_type, 'start' => 0, 'limit' => $limit));
                 break;
             case 'related':
                 if (isset($this->request->get['route']) && $this->request->get['route'] === 'product/product' && isset($this->request->get['product_id'])) {
                     $posts = $this->model_journal2_blog->getRelatedPosts($this->request->get['product_id'], $limit);
                 }
                 break;
             case 'custom':
                 $custom_posts = Journal2Utils::getProperty($module_data, 'module_data.posts', array());
                 $custom_posts_ids = array();
                 foreach ($custom_posts as $custom_post) {
                     $post_id = (int) Journal2Utils::getProperty($custom_post, 'data.id', 0);
                     if ($post_id) {
                         $custom_posts_ids[$post_id] = $post_id;
                     }
                 }
                 if ($custom_posts_ids) {
                     $posts = $this->model_journal2_blog->getPosts(array('post_ids' => implode(',', $custom_posts_ids)));
                 }
                 break;
         }
         if (!$posts) {
             return;
         }
         if (in_array($setting['position'], array('column_left', 'column_right'))) {
             $this->data['is_column'] = true;
             $this->data['grid_classes'] = 'xs-100 sm-100 md-100 lg-100 xl-100';
         } else {
             $this->data['is_column'] = false;
             $columns = in_array($setting['position'], array('top', 'bottom')) ? 0 : $this->journal2->settings->get('config_columns_count', 0);
             $this->data['grid_classes'] = Journal2Utils::getProductGridClasses(Journal2Utils::getProperty($module_data, 'items_per_row.value'), $this->journal2->settings->get('site_width', 1024), $columns);
         }
         $this->data['image_width'] = $this->journal2->settings->get('side_post_image_width', 55);
         $this->data['image_height'] = $this->journal2->settings->get('side_post_image_height', 55);
         $this->data['posts'] = array();
         foreach ($posts as $post) {
             $this->data['posts'][] = array('name' => $post['name'], 'comments' => $post['comments'], 'date' => date($this->language->get('date_format_short'), strtotime($post['date'])), 'image' => Journal2Utils::resizeImage($this->model_tool_image, $post, $this->data['image_width'], $this->data['image_height'], 'crop'), 'href' => $this->url->link('journal2/blog/post', 'journal_blog_post_id=' . $post['post_id']));
         }
         $this->template = $this->config->get('config_template') . '/template/journal2/module/blog_side_posts.tpl';
         if (self::$CACHEABLE === true) {
             $html = Minify_HTML::minify($this->render(), array('xhtml' => false, 'jsMinifier' => 'j2_js_minify'));
             $this->journal2->cache->set($cache_property, $html);
         }
     } else {
         $this->template = $this->config->get('config_template') . '/template/journal2/cache/cache.tpl';
         $this->data['cache'] = $cache;
     }
     $output = $this->render();
     Journal2::stopTimer(get_class($this));
     return $output;
 }
 public function index($setting)
 {
     if (!defined('JOURNAL_INSTALLED')) {
         return;
     }
     Journal2::startTimer(get_class($this));
     /* get module data from db */
     $module_data = $this->model_journal2_module->getModule($setting['module_id']);
     if (!$module_data || !isset($module_data['module_data']) || !$module_data['module_data']) {
         return;
     }
     $module_data = $module_data['module_data'];
     /* device detection */
     $this->data['disable_on_classes'] = array();
     if ($this->journal2->settings->get('responsive_design')) {
         $device = Journal2Utils::getDevice();
         if (Journal2Utils::getProperty($module_data, 'enable_on_phone', '1') == '0') {
             if ($device === 'phone') {
                 return;
             } else {
                 $this->data['disable_on_classes'][] = 'hide-on-phone';
             }
         }
         if (Journal2Utils::getProperty($module_data, 'enable_on_tablet', '1') == '0') {
             if ($device === 'tablet') {
                 return;
             } else {
                 $this->data['disable_on_classes'][] = 'hide-on-tablet';
             }
         }
         if (Journal2Utils::getProperty($module_data, 'enable_on_desktop', '1') == '0') {
             if ($device === 'desktop') {
                 return;
             } else {
                 $this->data['disable_on_classes'][] = 'hide-on-desktop';
             }
         }
     }
     $this->data['css'] = '';
     /* css for top / bottom positions */
     if (in_array($setting['position'], array('top', 'bottom'))) {
         $padding = $this->journal2->settings->get('module_margins', 20) . 'px';
         /* outer */
         $css = Journal2Utils::getBackgroundCssProperties(Journal2Utils::getProperty($module_data, 'background'));
         $css[] = 'padding-top: ' . Journal2Utils::getProperty($module_data, 'margin_top', 0) . 'px';
         $css[] = 'padding-bottom: ' . Journal2Utils::getProperty($module_data, 'margin_bottom', 0) . 'px';
         $this->journal2->settings->set('module_journal2_custom_sections_' . $setting['module_id'], implode('; ', $css));
         $this->journal2->settings->set('module_journal2_custom_sections_' . $setting['module_id'] . '_classes', implode(' ', $this->data['disable_on_classes']));
         /* inner css */
         $css = array();
         if (Journal2Utils::getProperty($module_data, 'fullwidth')) {
             $css[] = 'max-width: 100%';
             $css[] = 'padding-left: ' . $padding;
             $css[] = 'padding-right: ' . $padding;
         } else {
             $css[] = 'max-width: ' . $this->journal2->settings->get('site_width', 1024) . 'px';
             $css = array_merge($css, Journal2Utils::getBackgroundCssProperties(Journal2Utils::getProperty($module_data, 'module_background')));
             if (Journal2Utils::getProperty($module_data, 'module_padding')) {
                 $this->data['gutter_on_class'] = 'gutter-on';
                 $css[] = 'padding: 20px';
             }
         }
         $this->data['css'] = implode('; ', $css);
     }
     $cache_property = "module_journal_custom_sections_{$setting['module_id']}_{$setting['layout_id']}_{$setting['position']}" . $this->journal2->cache->getRouteCacheKey();
     $cache = $this->journal2->cache->get($cache_property);
     if ($cache === null || self::$CACHEABLE !== true) {
         $module = mt_rand();
         /* set global module properties */
         $this->data['module'] = $module;
         $this->data['show_title'] = Journal2Utils::getProperty($module_data, 'show_title');
         $this->data['show_title_class'] = $this->data['show_title'] ? '' : 'no-heading';
         $this->data['brand_name'] = Journal2Utils::getProperty($module_data, 'brand_name');
         $this->data['module_type'] = Journal2Utils::getProperty($module_data, 'module_type');
         $this->data['render_as'] = Journal2Utils::getProperty($module_data, 'display_as');
         $this->data['default_section'] = '';
         /* generate sections */
         $this->data['sections'] = array();
         $this->data['items'] = array();
         /* image dimensions */
         $this->data['image_width'] = Journal2Utils::getProperty($module_data, 'image_width', $this->config->get('config_image_product_width'));
         $this->data['image_height'] = Journal2Utils::getProperty($module_data, 'image_height', $height = $this->config->get('config_image_product_height'));
         $this->data['image_resize_type'] = Journal2Utils::getProperty($module_data, 'image_type', 'fit');
         $this->data['dummy_image'] = $this->model_tool_image->resize('data/journal2/transparent.png', $this->data['image_width'], $this->data['image_height']);
         /* image border */
         if (Journal2Utils::getProperty($module_data, 'image_border')) {
             $this->data['image_border_css'] = implode('; ', Journal2Utils::getBorderCssProperties(Journal2Utils::getProperty($module_data, 'image_border')));
         } else {
             $this->data['image_border_css'] = null;
         }
         /* image background color */
         if (Journal2Utils::getProperty($module_data, 'image_bgcolor.value.color')) {
             $this->data['image_bgcolor'] = 'background-color: ' . Journal2Utils::getColor(Journal2Utils::getProperty($module_data, 'image_bgcolor.value.color'));
         } else {
             $this->data['image_bgcolor'] = null;
         }
         switch ($this->data['module_type']) {
             case 'product':
                 $sections = Journal2Utils::getProperty($module_data, 'product_sections', array());
                 $sections = Journal2Utils::sortArray($sections);
                 $this->generateProductSections($sections);
                 $this->data['text_tax'] = $this->language->get('text_tax');
                 $this->data['button_cart'] = $this->language->get('button_cart');
                 $this->data['button_wishlist'] = $this->language->get('button_wishlist');
                 $this->data['button_compare'] = $this->language->get('button_compare');
                 break;
             case 'category':
                 $sections = Journal2Utils::getProperty($module_data, 'category_sections', array());
                 $sections = Journal2Utils::sortArray($sections);
                 $this->generateCategorySections($sections);
                 break;
             case 'manufacturer':
                 $sections = Journal2Utils::getProperty($module_data, 'manufacturer_sections', array());
                 $sections = Journal2Utils::sortArray($sections);
                 $this->generateManufacturerSections($sections);
                 break;
         }
         if (!$this->has_items) {
             return;
         }
         $columns = in_array($setting['position'], array('top', 'bottom')) ? 0 : $this->journal2->settings->get('config_columns_count', 0);
         $this->data['single_class'] = count($this->data['sections']) == 1 ? 'single-section' : '';
         $this->data['grid_classes'] = Journal2Utils::getProductGridClasses(Journal2Utils::getProperty($module_data, 'items_per_row.value'), $this->journal2->settings->get('site_width', 1024), $columns);
         $this->template = $this->config->get('config_template') . "/template/journal2/module/custom_sections_{$this->data['module_type']}.tpl";
         if (self::$CACHEABLE === true && !$this->has_random_products) {
             $html = Minify_HTML::minify($this->render(), array('xhtml' => false, 'jsMinifier' => 'j2_js_minify'));
             $this->journal2->cache->set($cache_property, $html);
         }
     } else {
         $this->template = $this->config->get('config_template') . '/template/journal2/cache/cache.tpl';
         $this->data['cache'] = $cache;
     }
     $this->document->addScript('catalog/view/theme/journal2/lib/isotope/jquery.isotope.min.js');
     $this->document->addScript('catalog/view/theme/journal2/lib/isotope/jquery.isotope.sloppy-masonry.min.js');
     if ($this->journal2->html_classes->hasClass('mobile')) {
         $this->document->addScript('catalog/view/theme/journal2/lib/lazy/jquery.lazy.1.6.min.js');
     }
     $output = $this->render();
     Journal2::stopTimer(get_class($this));
     return $output;
 }
 public function index($setting)
 {
     if (!defined('JOURNAL_INSTALLED')) {
         return;
     }
     Journal2::startTimer(get_class($this));
     /* get module data from db */
     $module_data = $this->model_journal2_module->getModule($setting['module_id']);
     if (!$module_data || !isset($module_data['module_data']) || !$module_data['module_data']) {
         return;
     }
     $module_data = $module_data['module_data'];
     /* device detection */
     $this->data['disable_on_classes'] = array();
     if ($this->journal2->settings->get('responsive_design')) {
         $device = Journal2Utils::getDevice();
         if (Journal2Utils::getProperty($module_data, 'enable_on_phone', '1') == '0') {
             if ($device === 'phone') {
                 return;
             } else {
                 $this->data['disable_on_classes'][] = 'hide-on-phone';
             }
         }
         if (Journal2Utils::getProperty($module_data, 'enable_on_tablet', '1') == '0') {
             if ($device === 'tablet') {
                 return;
             } else {
                 $this->data['disable_on_classes'][] = 'hide-on-tablet';
             }
         }
         if (Journal2Utils::getProperty($module_data, 'enable_on_desktop', '1') == '0') {
             if ($device === 'desktop') {
                 return;
             } else {
                 $this->data['disable_on_classes'][] = 'hide-on-desktop';
             }
         }
     }
     /* css for top / bottom positions */
     if (in_array($setting['position'], array('top', 'bottom'))) {
         $padding = $this->journal2->settings->get('module_margins', 20) . 'px';
         /* outer */
         $css = Journal2Utils::getBackgroundCssProperties(Journal2Utils::getProperty($module_data, 'background'));
         $css[] = 'padding-top: ' . Journal2Utils::getProperty($module_data, 'margin_top', 0) . 'px';
         $css[] = 'padding-bottom: ' . Journal2Utils::getProperty($module_data, 'margin_bottom', 0) . 'px';
         $this->journal2->settings->set('module_journal2_static_banners_' . $setting['module_id'], implode('; ', $css));
         $this->journal2->settings->set('module_journal2_static_banners_' . $setting['module_id'] . '_classes', implode(' ', $this->data['disable_on_classes']));
         /* inner css */
         $css = array();
         if (Journal2Utils::getProperty($module_data, 'fullwidth')) {
             $css[] = 'max-width: 100%';
             $css[] = 'padding-left: ' . $padding;
             $css[] = 'padding-right: ' . $padding;
         } else {
             $css[] = 'max-width: ' . $this->journal2->settings->get('site_width', 1024) . 'px';
             $css = array_merge($css, Journal2Utils::getBackgroundCssProperties(Journal2Utils::getProperty($module_data, 'module_background')));
             if (Journal2Utils::getProperty($module_data, 'module_padding')) {
                 $this->data['gutter_on_class'] = 'gutter-on';
                 $css[] = 'padding: 20px';
             }
         }
         $this->data['css'] = implode('; ', $css);
     }
     $cache_property = "module_journal_static_banners_{$setting['module_id']}_{$setting['layout_id']}_{$setting['position']}";
     $cache = $this->journal2->cache->get($cache_property);
     if ($cache === null || self::$CACHEABLE !== true) {
         $module = mt_rand();
         /* set global module properties */
         $this->data['module'] = $module;
         $this->data['title'] = Journal2Utils::getProperty($module_data, 'module_title.value.' . $this->config->get('config_language_id'), '');
         /* icon */
         $this->data['icon'] = Journal2Utils::getIconOptions2(Journal2Utils::getProperty($module_data, 'icon'));
         /* bgcolor*/
         $this->data['bgcolor'] = Journal2Utils::getProperty($module_data, 'bgcolor.value.color');
         /* image border */
         $this->data['image_border'] = implode('; ', Journal2Utils::getBorderCssProperties(Journal2Utils::getProperty($module_data, 'image_border')));
         /* sort sections */
         $sections = Journal2Utils::getProperty($module_data, 'sections', array());
         $sections = Journal2Utils::sortArray($sections);
         /* generate sections */
         $this->data['sections'] = array();
         foreach ($sections as $section) {
             if (!$section['status']) {
                 continue;
             }
             $image = Journal2Utils::getProperty($section, 'image');
             if (is_array($image)) {
                 $image = Journal2Utils::getProperty($image, $this->config->get('config_language_id'));
             }
             if (!$image || !file_exists(DIR_IMAGE . $image)) {
                 $image = Front::$IS_OC2 ? 'no_image.png' : 'no_image.jpg';
             }
             list($width, $height) = getimagesize(DIR_IMAGE . $image);
             $this->data['sections'][] = array('type' => 'image', 'link' => $this->model_journal2_menu->getLink(Journal2Utils::getProperty($section, 'link')), 'target' => Journal2Utils::getProperty($section, 'link_new_window') ? 'target="_blank"' : '', 'image' => Journal2Utils::resizeImage($this->model_tool_image, $image), 'image_title' => Journal2Utils::getProperty($section, 'image_title.value.' . $this->config->get('config_language_id'), ''), 'image_width' => $width, 'image_height' => $height);
         }
         /* carousel mode */
         $this->data['carousel'] = Journal2Utils::getProperty($module_data, 'carousel', '0');
         if (Journal2Utils::getProperty($module_data, 'autoplay')) {
             $this->data['autoplay'] = (int) Journal2Utils::getProperty($module_data, 'transition_delay', 3000);
         } else {
             $this->data['autoplay'] = false;
         }
         $this->data['slide_speed'] = (int) Journal2Utils::getProperty($module_data, 'transition_speed', 400);
         $this->data['pause_on_hover'] = Journal2Utils::getProperty($module_data, 'pause_on_hover');
         $this->data['touch_drag'] = Journal2Utils::getProperty($module_data, 'touch_drag');
         $this->data['default_section'] = '';
         $this->data['arrows'] = Journal2Utils::getProperty($module_data, 'arrows');
         $this->data['bullets'] = Journal2Utils::getProperty($module_data, 'bullets');
         /* grid classes */
         if (in_array($setting['position'], array('column_left', 'column_right'))) {
             $this->data['grid_classes'] = $this->data['carousel'] ? '' : 'xs-100 sm-100 md-100 lg-100 xl-100';
             $this->data['grid'] = $this->data['carousel'] ? array(array(0, 1), array(470, 1), array(760, 1), array(980, 1), array(1100, 1)) : array();
         } else {
             $columns = in_array($setting['position'], array('top', 'bottom')) ? 0 : $this->journal2->settings->get('config_columns_count', 0);
             $this->data['grid_classes'] = $this->data['carousel'] ? '' : Journal2Utils::getProductGridClasses(Journal2Utils::getProperty($module_data, 'items_per_row.value'), $this->journal2->settings->get('site_width', 1024), $columns);
             $grid = Journal2Utils::getItemGrid(Journal2Utils::getProperty($module_data, 'items_per_row.value'), $this->journal2->settings->get('site_width', 1024), $columns);
             $this->data['grid'] = $this->data['carousel'] ? array(array(0, (int) $grid['xs']), array(470, (int) $grid['sm']), array(760, (int) $grid['md']), array(980, (int) $grid['lg']), array(1100, (int) $grid['xl'])) : array();
         }
         $this->template = $this->config->get('config_template') . '/template/journal2/module/static_banners.tpl';
         if (self::$CACHEABLE === true) {
             $html = Minify_HTML::minify($this->render(), array('xhtml' => false, 'jsMinifier' => 'j2_js_minify'));
             $this->journal2->cache->set($cache_property, $html);
         }
     } else {
         $this->template = $this->config->get('config_template') . '/template/journal2/cache/cache.tpl';
         $this->data['cache'] = $cache;
     }
     $output = $this->render();
     Journal2::stopTimer(get_class($this));
     return $output;
 }
예제 #8
0
 public function columns()
 {
     $cols = 0;
     if ($this->journal2->page->hasModules('column_left')) {
         $cols++;
     }
     if ($this->journal2->page->hasModules('column_right')) {
         $cols++;
     }
     if ($cols == 1) {
         $this->journal2->html_classes->addClass('one-column');
     }
     if ($cols == 2) {
         $this->journal2->html_classes->addClass('two-columns');
     }
     $this->journal2->settings->set('config_columns_count', $cols);
     $this->journal2->settings->set('product_grid_classes', Journal2Utils::getProductGridClasses($this->journal2->settings->get('category_page_products_per_row'), $this->journal2->settings->get('site_width', 1024), $cols));
     if (!$this->journal2->settings->get('related_products_carousel')) {
         $this->journal2->settings->set('related_products_grid_classes', Journal2Utils::getProductGridClasses($this->journal2->settings->get('related_products_items_per_row'), $this->journal2->settings->get('site_width', 1024), $cols));
     }
     // product views
     if ($this->journal2->page->getType() === 'product' || $this->journal2->page->getType() === 'quickview') {
         $this->load->model('journal2/product');
         if ($this->journal2->settings->get('product_page_options_views')) {
             $this->journal2->settings->set('product_views', $this->model_journal2_product->getProductViews($this->journal2->page->getId()));
         }
         if ($this->journal2->settings->get('product_page_options_sold')) {
             $text = $this->journal2->settings->get('product_page_options_sold_text', ' Product(s) Sold');
             $count = '<span>' . $this->model_journal2_product->getProductSoldCount($this->journal2->page->getId()) . '</span>';
             if (strpos($text, '%s') !== FALSE) {
                 $text = sprintf($text, $count);
             } else {
                 $text = $count . $text;
             }
             $this->journal2->settings->set('product_sold', $text);
         }
     }
 }
 public function index($setting)
 {
     if (!defined('JOURNAL_INSTALLED')) {
         return;
     }
     Journal2::startTimer(get_class($this));
     /* get module data from db */
     $module_data = $this->model_journal2_module->getModule($setting['module_id']);
     if (!$module_data || !isset($module_data['module_data']) || !$module_data['module_data']) {
         return;
     }
     $module_data = $module_data['module_data'];
     /* device detection */
     $this->data['disable_on_classes'] = array();
     if ($this->journal2->settings->get('responsive_design')) {
         $device = Journal2Utils::getDevice();
         if (Journal2Utils::getProperty($module_data, 'enable_on_phone', '1') == '0') {
             if ($device === 'phone') {
                 return;
             } else {
                 $this->data['disable_on_classes'][] = 'hide-on-phone';
             }
         }
         if (Journal2Utils::getProperty($module_data, 'enable_on_tablet', '1') == '0') {
             if ($device === 'tablet') {
                 return;
             } else {
                 $this->data['disable_on_classes'][] = 'hide-on-tablet';
             }
         }
         if (Journal2Utils::getProperty($module_data, 'enable_on_desktop', '1') == '0') {
             if ($device === 'desktop') {
                 return;
             } else {
                 $this->data['disable_on_classes'][] = 'hide-on-desktop';
             }
         }
     }
     $this->data['css'] = '';
     /* css for top / bottom positions */
     if (in_array($setting['position'], array('top', 'bottom'))) {
         $padding = $this->journal2->settings->get('module_margins', 20) . 'px';
         /* outer */
         $css = Journal2Utils::getBackgroundCssProperties(Journal2Utils::getProperty($module_data, 'background'));
         $css[] = 'padding-top: ' . Journal2Utils::getProperty($module_data, 'margin_top', 0) . 'px';
         $css[] = 'padding-bottom: ' . Journal2Utils::getProperty($module_data, 'margin_bottom', 0) . 'px';
         $this->journal2->settings->set('module_journal2_photo_gallery_' . $setting['module_id'], implode('; ', $css));
         $this->journal2->settings->set('module_journal2_photo_gallery_' . $setting['module_id'] . '_classes', implode(' ', $this->data['disable_on_classes']));
         /* inner css */
         $css = array();
         if (Journal2Utils::getProperty($module_data, 'fullwidth')) {
             $css[] = 'max-width: 100%';
             $css[] = 'padding-left: ' . $padding;
             $css[] = 'padding-right: ' . $padding;
         } else {
             $css[] = 'max-width: ' . $this->journal2->settings->get('site_width', 1024) . 'px';
         }
         $this->data['css'] = implode('; ', $css);
     }
     $cache_property = "module_journal_photo_gallery_{$setting['module_id']}_{$setting['layout_id']}_{$setting['position']}";
     $cache = $this->journal2->cache->get($cache_property);
     if ($cache === null || self::$CACHEABLE !== true) {
         $module = mt_rand();
         /* set global module properties */
         $this->data['module'] = $module;
         $this->data['title'] = Journal2Utils::getProperty($module_data, 'gallery_name.value.' . $this->config->get('config_language_id'), '');
         /* image border */
         $this->data['image_border'] = implode('; ', Journal2Utils::getBorderCssProperties(Journal2Utils::getProperty($module_data, 'image_border')));
         /* grid */
         $this->data['is_column'] = in_array($setting['position'], array('column_left', 'column_right'));
         if (in_array($setting['position'], array('column_left', 'column_right'))) {
             $this->data['grid_classes'] = 'xs-33 sm-33 md-33 lg-33 xl-33';
         } else {
             $columns = in_array($setting['position'], array('top', 'bottom')) ? 0 : $this->journal2->settings->get('config_columns_count', 0);
             $this->data['grid_classes'] = Journal2Utils::getProductGridClasses(Journal2Utils::getProperty($module_data, 'items_per_row.value'), $this->journal2->settings->get('site_width', 1024), $columns);
         }
         /* carousel */
         $this->data['carousel'] = in_array($setting['position'], array('column_left', 'column_right')) ? false : Journal2Utils::getProperty($module_data, 'carousel');
         if ($this->data['carousel']) {
             $this->data['items_per_row'] = Journal2Utils::getProperty($module_data, 'items_per_row.value');
             $this->data['arrows'] = Journal2Utils::getProperty($module_data, 'carousel_arrows');
             $this->data['bullets'] = Journal2Utils::getProperty($module_data, 'carousel_bullets');
             if (Journal2Utils::getProperty($module_data, 'autoplay')) {
                 $this->data['autoplay'] = Journal2Utils::getProperty($module_data, 'transition_delay', 3000);
             } else {
                 $this->data['autoplay'] = false;
             }
             $this->data['slide_speed'] = (int) Journal2Utils::getProperty($module_data, 'transition_speed', 400);
             $this->data['pause_on_hover'] = Journal2Utils::getProperty($module_data, 'pause_on_hover');
             $this->data['touch_drag'] = Journal2Utils::getProperty($module_data, 'touch_drag');
         }
         /* sort images */
         $images = Journal2Utils::getProperty($module_data, 'images', array());
         $images = Journal2Utils::sortArray($images);
         /* generate images */
         $this->data['thumbs_limit'] = Journal2Utils::getProperty($module_data, 'thumbs_limit', PHP_INT_MAX);
         $this->data['thumbs_width'] = Journal2Utils::getProperty($module_data, 'thumbs_width', 200);
         $this->data['thumbs_height'] = Journal2Utils::getProperty($module_data, 'thumbs_height', 200);
         $this->data['thumbs_type'] = Journal2Utils::getProperty($module_data, 'thumbs_type', 'crop');
         $this->data['images'] = array();
         foreach ($images as $image) {
             if (isset($image['status']) && !$image['status']) {
                 continue;
             }
             $this->data['images'][] = array('name' => Journal2Utils::getProperty($image, 'name.value.' . $this->config->get('config_language_id'), ''), 'image' => Journal2Utils::resizeImage($this->model_tool_image, $image), 'thumb' => Journal2Utils::resizeImage($this->model_tool_image, $image, $this->data['thumbs_width'], $this->data['thumbs_height'], $this->data['thumbs_type']));
         }
         $this->template = $this->config->get('config_template') . '/template/journal2/module/photo_gallery.tpl';
         if (self::$CACHEABLE === true) {
             $html = Minify_HTML::minify($this->render(), array('xhtml' => false, 'jsMinifier' => 'j2_js_minify'));
             $this->journal2->cache->set($cache_property, $html);
         }
     } else {
         $this->template = $this->config->get('config_template') . '/template/journal2/cache/cache.tpl';
         $this->data['cache'] = $cache;
     }
     $this->document->addScript('catalog/view/theme/journal2/lib/swipebox/source/jquery.swipebox.js');
     $output = $this->render();
     Journal2::stopTimer(get_class($this));
     return $output;
 }