예제 #1
0
 public function refine_images()
 {
     if (!in_array($this->journal2->settings->get('refine_category'), array('grid', 'carousel'))) {
         return;
     }
     if (!isset($this->request->get['route']) || $this->request->get['route'] !== 'product/category') {
         return;
     }
     $path = isset($this->request->get['path']) ? $this->request->get['path'] : false;
     if ($path) {
         $this->load->model('catalog/category');
         $parts = explode('_', (string) $path);
         $category_id = (int) array_pop($parts);
         $categories = $this->model_catalog_category->getCategories($category_id);
         $image_width = $this->journal2->settings->get('refine_image_width', 175);
         $image_height = $this->journal2->settings->get('refine_image_height', 175);
         $image_type = $this->journal2->settings->get('refine_image_type', 'fit');
         $data = array();
         foreach ($categories as $category) {
             $filters = array('filter_category_id' => $category['category_id'], 'filter_sub_category' => true);
             if ($this->config->get('config_product_count')) {
                 $product_total = ' (' . $this->model_catalog_product->getTotalProducts($filters) . ')';
             } else {
                 $product_total = '';
             }
             $data[] = array('name' => $category['name'] . $product_total, 'href' => $this->url->link('product/category', 'path=' . $path . '_' . $category['category_id']), 'thumb' => Journal2Utils::resizeImage($this->model_tool_image, $category, $image_width, $image_height, $image_type));
         }
         $this->journal2->settings->set('refine_category_images', $data);
     }
 }
 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;
     }
     if (Journal2Utils::getProperty($module_data, 'module_data.disable_mobile') && (Journal2Cache::$mobile_detect->isMobile() && !Journal2Cache::$mobile_detect->isTablet())) {
         return;
     }
     $cache_property = "module_journal_fullscreen_slider_{$setting['module_id']}_{$setting['layout_id']}_{$setting['position']}";
     $cache = $this->journal2->cache->get($cache_property);
     if ($cache === null || self::$CACHEABLE !== true) {
         $module = mt_rand();
         $this->data['module'] = $module;
         $this->data['transition'] = Journal2Utils::getProperty($module_data, 'module_data.transition', 'fade');
         $this->data['transition_speed'] = Journal2Utils::getProperty($module_data, 'module_data.transition_speed', '700');
         $this->data['transition_delay'] = Journal2Utils::getProperty($module_data, 'module_data.transition_delay', '3000');
         if (Journal2Utils::getProperty($module_data, 'module_data.transparent_overlay', '')) {
             $this->data['transparent_overlay'] = Journal2Utils::resizeImage($this->model_tool_image, Journal2Utils::getProperty($module_data, 'module_data.transparent_overlay', ''));
         } else {
             $this->data['transparent_overlay'] = '';
         }
         $this->data['images'] = array();
         $images = Journal2Utils::getProperty($module_data, 'module_data.images', array());
         $images = Journal2Utils::sortArray($images);
         foreach ($images as $image) {
             if (!$image['status']) {
                 continue;
             }
             $image = Journal2Utils::getProperty($image, 'image');
             if (is_array($image)) {
                 $image = Journal2Utils::getProperty($image, $this->config->get('config_language_id'));
             }
             $this->data['images'][] = array('image' => Journal2Utils::resizeImage($this->model_tool_image, $image), 'title' => '');
         }
         $this->template = $this->config->get('config_template') . '/template/journal2/module/fullscreen_slider.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->addStyle('catalog/view/theme/journal2/lib/supersized/css/supersized.css');
     $this->document->addScript('catalog/view/theme/journal2/lib/supersized/js/jquery.easing.min.js');
     $this->document->addScript('catalog/view/theme/journal2/lib/supersized/js/supersized.3.2.7.min.js');
     $output = $this->render();
     Journal2::stopTimer(get_class($this));
     return $output;
 }
예제 #3
0
 public function index()
 {
     $this->load->model('journal2/search');
     $this->load->model('catalog/product');
     $this->load->model('tool/image');
     $json = array('results' => array());
     if (isset($this->request->get['search'])) {
         $results = $this->model_journal2_search->search($this->request->get['search'], $this->journal2->settings->get('autosuggest_limit', 0), $this->journal2->settings->get('search_autocomplete_include_description', '1') === '1');
         $image_width = $this->journal2->settings->get('autosuggest_product_image_width', 50);
         $image_height = $this->journal2->settings->get('autosuggest_product_image_height', 50);
         $image_type = $this->journal2->settings->get('autosuggest_product_image_type', 'fit');
         foreach ($results as $result) {
             $result = $this->model_catalog_product->getProduct($result['product_id']);
             if (self::$SHOW_IMAGES) {
                 $image = Journal2Utils::resizeImage($this->model_tool_image, $result['image'], $image_width, $image_height, $image_type);
             } else {
                 $image = null;
             }
             if (self::$SHOW_PRICE && ($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 = null;
             }
             if (self::$SHOW_PRICE && (double) $result['special']) {
                 $special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')));
             } else {
                 $special = null;
             }
             $json['results'][] = array('name' => html_entity_decode($result['name'], ENT_QUOTES, 'UTF-8'), 'url' => htmlspecialchars_decode($this->url->link('product/product', '&product_id=' . $result['product_id'])), 'image' => $image, 'price' => $price, 'special' => $special);
         }
         if ($json['results']) {
             $json['view_more_text'] = $this->journal2->settings->get('autosuggest_view_more_text', 'View More');
             if (VERSION === '1.5.4' || VERSION === '1.5.4.1') {
                 $json['view_more_url'] = $this->url->link('product/search', '&filter_name=' . urlencode(html_entity_decode($this->request->get['search'], ENT_QUOTES, 'UTF-8')));
             } else {
                 $json['view_more_url'] = $this->url->link('product/search', '&search=' . urlencode(html_entity_decode($this->request->get['search'], ENT_QUOTES, 'UTF-8')));
             }
         } else {
             $this->language->load('product/search');
             $json['view_more_text'] = $this->language->get('text_empty');
             $json['view_more_url'] = '';
         }
     }
     $this->response->setOutput(json_encode($json));
 }
 public function index($setting)
 {
     if (!defined('JOURNAL_INSTALLED')) {
         return;
     }
     Journal2::startTimer(get_class($this));
     $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'];
     if (Journal2Utils::getProperty($module_data, 'hideonmobile') && Journal2Cache::$mobile_detect->isMobile() && !Journal2Cache::$mobile_detect->isTablet() && $this->journal2->settings->get('responsive_design')) {
         return;
     }
     /* hide on desktop */
     if (Journal2Utils::getProperty($module_data, 'disable_desktop') && !Journal2Cache::$mobile_detect->isMobile()) {
         return;
     }
     /* 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_simple_slider_' . $setting['module_id'], implode('; ', $css));
     }
     $cache_property = "module_journal_simple_slider_{$setting['module_id']}_{$setting['layout_id']}_{$setting['position']}";
     $cache = $this->journal2->cache->get($cache_property);
     if ($cache === null || self::$CACHEABLE !== true) {
         $module = mt_rand();
         /* slider position */
         $height = Journal2Utils::getProperty($module_data, 'height', 400);
         $width = null;
         switch ($setting['position']) {
             case 'column_left':
             case 'column_right':
                 $width = 220;
                 $this->data['width'] = "max-width: {$width}px";
                 break;
             case 'content_top':
             case 'content_bottom':
                 if (Journal2Cache::$mobile_detect->isMobile() && !Journal2Cache::$mobile_detect->isTablet() && $this->journal2->settings->get('responsive_design')) {
                     $width = $this->journal2->settings->get('site_width', 1024);
                 } else {
                     if ($this->journal2->settings->get('extended_layout')) {
                         $width = $this->journal2->settings->get('site_width', 1024) - 240 * $this->journal2->settings->get('config_columns_count');
                     } else {
                         $width = $this->journal2->settings->get('site_width', 1024) - 40 - 240 * $this->journal2->settings->get('config_columns_count');
                     }
                     $height *= $width / $this->journal2->settings->get('site_width', 1024);
                 }
                 $this->data['width'] = "max-width: {$width}px";
                 break;
             case 'top':
             case 'bottom':
                 $width = $this->journal2->settings->get('site_width', 1024);
                 $this->data['width'] = "max-width: {$width}px";
                 break;
             case 'multi_module':
                 $width = $setting['width'];
                 $height = $setting['height'];
                 $this->data['width'] = "max-width: {$width}px";
                 break;
         }
         /* global style data */
         $this->data['global_style'] = array();
         $slides = Journal2Utils::getProperty($module_data, 'slides', array());
         $slides = Journal2Utils::sortArray($slides);
         $_slides = array();
         $this->data['js_options'] = array('slideSpeed' => (int) Journal2Utils::getProperty($module_data, 'transition_speed', 800), 'stopOnHover' => (bool) Journal2Utils::getProperty($module_data, 'pause_on_hover', 1), 'lazyLoad' => (bool) Journal2Utils::getProperty($module_data, 'preload_images', 1), 'touchDrag' => (bool) Journal2Utils::getProperty($module_data, 'touch_drag', 0), 'navigation' => (bool) Journal2Utils::getProperty($module_data, 'arrows', 1), 'pagination' => (bool) Journal2Utils::getProperty($module_data, 'bullets', 1));
         if (Journal2Utils::getProperty($module_data, 'transition', 'fade') !== 'slide') {
             $this->data['js_options']['transitionStyle'] = Journal2Utils::getProperty($module_data, 'transition', 'fade');
         }
         $this->data['nav_on_hover'] = Journal2Utils::getProperty($module_data, 'show_on_hover', 1) ? 'nav-on-hover' : '';
         if (Journal2Utils::getProperty($module_data, 'autoplay')) {
             $this->data['js_options']['autoPlay'] = (int) Journal2Utils::getProperty($module_data, 'transition_delay', 3000);
         } else {
             $this->data['js_options']['autoPlay'] = false;
         }
         $this->data['image_width'] = $width;
         $this->data['image_height'] = $height;
         foreach ($slides as $slide) {
             if (isset($slide['status']) && !$slide['status']) {
                 continue;
             }
             $image = Journal2Utils::getProperty($slide, 'image');
             if (is_array($image)) {
                 $image = Journal2Utils::getProperty($image, $this->config->get('config_language_id'));
             }
             $_slides[] = array('image' => Journal2Utils::resizeImage($this->model_tool_image, $image, $width, $height, 'crop'), 'name' => Journal2Utils::getProperty($slide, 'slide_name'), 'link' => $this->model_journal2_menu->getLink(Journal2Utils::getProperty($slide, 'link')), 'target' => Journal2Utils::getProperty($slide, 'link_new_window') ? 'target="_blank"' : '');
         }
         $this->data['slides'] = $_slides;
         if (count($_slides) <= 1) {
             $this->data['js_options']['autoPlay'] = false;
         }
         $this->data['module'] = $module;
         $this->data['preload_images'] = Journal2Utils::getProperty($module_data, 'preload_images', '1');
         $this->data['height'] = $height;
         $this->template = $this->config->get('config_template') . '/template/journal2/module/slider_simple.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;
 }
 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;
     }
 }
예제 #6
0
 public function feed()
 {
     if (!$this->journal2->settings->get('config_blog_settings.feed', 1)) {
         $this->response->redirect('index.php?route=error/not_found');
         exit;
     }
     $output = '<?xml version="1.0" encoding="UTF-8" ?>';
     $output .= '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">';
     $output .= '<channel>';
     $output .= '<atom:link href="' . $this->url->link('journal2/blog') . '" rel="self" type="application/rss+xml" />';
     $output .= '<title>' . $this->blog_title . '</title>';
     $output .= '<link>' . $this->url->link('journal2/blog') . '</link>';
     $output .= '<description>' . $this->blog_meta_description . '</description>';
     $data = array('sort' => 'newest', 'start' => 0, 'limit' => PHP_INT_MAX);
     if (isset($this->request->get['journal_blog_feed_category_id'])) {
         $data['category_id'] = $this->request->get['journal_blog_feed_category_id'];
     }
     foreach ($this->model_journal2_blog->getPosts($data) as $post) {
         $output .= '<item>';
         $output .= '<title>' . htmlspecialchars($post['name']) . '</title>';
         $output .= '<author>' . $this->model_journal2_blog->getAuthorName($post) . '</author>';
         $output .= '<pubDate>' . date(DATE_RSS, strtotime($post['date'])) . '</pubDate>';
         $output .= '<link>' . $this->url->link('journal2/blog/post', 'journal_blog_post_id=' . $post['post_id']) . '</link>';
         $output .= '<guid>' . $this->url->link('journal2/blog/post', 'journal_blog_post_id=' . $post['post_id']) . '</guid>';
         $description = '';
         if ($post['image']) {
             $image = Journal2Utils::resizeImage($this->model_tool_image, $post, $this->journal2->settings->get('feed_image_width', 250), $this->journal2->settings->get('feed_image_height', 250), 'crop');
             $description .= '<p><img src="' . $image . '" /></p>';
         }
         $description .= utf8_substr(strip_tags(html_entity_decode($post['description'], ENT_QUOTES, 'UTF-8')), 0, $this->journal2->settings->get('config_blog_settings.description_char_limit', 150)) . '... ';
         $description .= '<a href="' . $this->url->link('journal2/blog/post', 'journal_blog_post_id=' . $post['post_id']) . '">' . $this->journal2->settings->get('blog_button_read_more', 'Read More') . '</a>';
         $output .= '<description>' . htmlspecialchars($description) . '</description>';
         $output .= '</item>';
     }
     $output .= '</channel>';
     $output .= '</rss>';
     $this->response->addHeader('Content-Type: application/rss+xml');
     $this->response->setOutput($output);
 }
예제 #7
0
 private function index2()
 {
     $this->load->language('product/product');
     $this->load->model('catalog/category');
     $this->load->model('catalog/manufacturer');
     $this->load->model('catalog/product');
     if ($this->request->server['HTTPS']) {
         $server = $this->config->get('config_ssl');
     } else {
         $server = $this->config->get('config_url');
     }
     $data['base'] = $server;
     if (isset($this->request->get['pid'])) {
         $product_id = (int) $this->request->get['pid'];
     } else {
         $product_id = 0;
     }
     $product_info = $this->model_catalog_product->getProduct($product_id);
     if ($product_info) {
         $this->document->setTitle($product_info['meta_title']);
         $this->document->setDescription($product_info['meta_description']);
         $this->document->setKeywords($product_info['meta_keyword']);
         $this->document->addLink($this->url->link('product/product', 'product_id=' . $this->request->get['pid']), 'canonical');
         $this->journal2->minifier->addScript('catalog/view/javascript/jquery/datetimepicker/moment.js');
         $this->journal2->minifier->addScript('catalog/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.js');
         $this->journal2->minifier->addStyle('catalog/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.css');
         $data['heading_title'] = $product_info['name'];
         $data['text_select'] = $this->language->get('text_select');
         $data['text_manufacturer'] = $this->language->get('text_manufacturer');
         $data['text_model'] = $this->language->get('text_model');
         $data['text_reward'] = $this->language->get('text_reward');
         $data['text_points'] = $this->language->get('text_points');
         $data['text_stock'] = $this->language->get('text_stock');
         $data['text_discount'] = $this->language->get('text_discount');
         $data['text_tax'] = $this->language->get('text_tax');
         $data['text_option'] = $this->language->get('text_option');
         $data['text_minimum'] = sprintf($this->language->get('text_minimum'), $product_info['minimum']);
         $data['text_write'] = $this->language->get('text_write');
         $data['text_login'] = sprintf($this->language->get('text_login'), $this->url->link('account/login', '', 'SSL'), $this->url->link('account/register', '', 'SSL'));
         $data['text_note'] = $this->language->get('text_note');
         $data['text_tags'] = $this->language->get('text_tags');
         $data['text_related'] = $this->language->get('text_related');
         $data['text_loading'] = $this->language->get('text_loading');
         $data['entry_qty'] = $this->language->get('entry_qty');
         $data['entry_name'] = $this->language->get('entry_name');
         $data['entry_review'] = $this->language->get('entry_review');
         $data['entry_rating'] = $this->language->get('entry_rating');
         $data['entry_good'] = $this->language->get('entry_good');
         $data['entry_bad'] = $this->language->get('entry_bad');
         $data['entry_captcha'] = $this->language->get('entry_captcha');
         $data['button_cart'] = $this->language->get('button_cart');
         $data['button_wishlist'] = $this->language->get('button_wishlist');
         $data['button_compare'] = $this->language->get('button_compare');
         $data['button_upload'] = $this->language->get('button_upload');
         $data['button_continue'] = $this->language->get('button_continue');
         $this->load->model('catalog/review');
         $data['tab_description'] = $this->language->get('tab_description');
         $data['tab_attribute'] = $this->language->get('tab_attribute');
         $data['tab_review'] = sprintf($this->language->get('tab_review'), $product_info['reviews']);
         $data['product_id'] = (int) $this->request->get['pid'];
         $data['manufacturer'] = $product_info['manufacturer'];
         $manufacturer_info = $this->model_catalog_manufacturer->getManufacturer($product_info['manufacturer_id']);
         if ($manufacturer_info && $manufacturer_info['image'] && $this->journal2->settings->get('manufacturer_image', '0') == '1') {
             $this->journal2->settings->set('manufacturer_image', 'on');
             $data['manufacturer_image_width'] = $this->journal2->settings->get('manufacturer_image_width', 100);
             $data['manufacturer_image_height'] = $this->journal2->settings->get('manufacturer_image_height', 100);
             $data['manufacturer_image'] = $this->model_tool_image->resize($manufacturer_info['image'], $data['manufacturer_image_width'], $data['manufacturer_image_height']);
             switch ($this->journal2->settings->get('manufacturer_image_additional_text', 'none')) {
                 case 'brand':
                     $data['manufacturer_image_name'] = $product_info['manufacturer'];
                     break;
                 case 'custom':
                     $data['manufacturer_image_name'] = $this->journal2->settings->get('manufacturer_image_custom_text');
                     break;
             }
         }
         $data['manufacturers'] = $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $product_info['manufacturer_id']);
         $data['model'] = $product_info['model'];
         $data['reward'] = $product_info['reward'];
         $data['points'] = $product_info['points'];
         $this->load->model('journal2/product');
         $data['labels'] = $this->model_journal2_product->getLabels($product_info['product_id']);
         if ($product_info['quantity'] <= 0) {
             $data['stock'] = $product_info['stock_status'];
         } elseif ($this->config->get('config_stock_display')) {
             $data['stock'] = $product_info['quantity'];
         } else {
             $data['stock'] = $this->language->get('text_instock');
         }
         $this->load->model('tool/image');
         if ($product_info['image']) {
             $data['popup_fixed'] = $this->model_tool_image->resize($product_info['image'], $this->config->get('config_image_popup_width'), $this->config->get('config_image_popup_height'));
             $data['popup'] = $this->model_tool_image->resize($product_info['image'], $this->config->get('config_image_popup_width'), $this->config->get('config_image_popup_height'));
         } else {
             $data['popup'] = '';
         }
         if ($product_info['image']) {
             $data['thumb_fixed'] = $this->model_tool_image->resize($product_info['image'], $this->config->get('config_image_additional_width'), $this->config->get('config_image_additional_height'));
             $data['thumb'] = $this->model_tool_image->resize($product_info['image'], $this->config->get('config_image_thumb_width'), $this->config->get('config_image_thumb_height'));
         } else {
             $data['thumb'] = '';
         }
         $data['images'] = array();
         $results = $this->model_catalog_product->getProductImages($this->request->get['pid']);
         foreach ($results as $result) {
             $data['images'][] = array('popup' => $this->model_tool_image->resize($result['image'], $this->config->get('config_image_popup_width'), $this->config->get('config_image_popup_height')), 'thumb' => $this->model_tool_image->resize($result['image'], $this->config->get('config_image_additional_width'), $this->config->get('config_image_additional_height')));
         }
         if ($this->config->get('config_customer_price') && $this->customer->isLogged() || !$this->config->get('config_customer_price')) {
             $data['price'] = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')));
         } else {
             $data['price'] = false;
         }
         if ((double) $product_info['special']) {
             $data['special'] = $this->currency->format($this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax')));
         } else {
             $data['special'] = false;
         }
         if ($this->config->get('config_tax')) {
             $data['tax'] = $this->currency->format((double) $product_info['special'] ? $product_info['special'] : $product_info['price']);
         } else {
             $data['tax'] = false;
         }
         $discounts = $this->model_catalog_product->getProductDiscounts($this->request->get['pid']);
         $data['discounts'] = array();
         foreach ($discounts as $discount) {
             $data['discounts'][] = array('quantity' => $discount['quantity'], 'price' => $this->currency->format($this->tax->calculate($discount['price'], $product_info['tax_class_id'], $this->config->get('config_tax'))));
         }
         $data['options'] = array();
         foreach ($this->model_catalog_product->getProductOptions($this->request->get['pid']) as $option) {
             $product_option_value_data = array();
             foreach ($option['product_option_value'] as $option_value) {
                 if (!$option_value['subtract'] || $option_value['quantity'] > 0) {
                     if (($this->config->get('config_customer_price') && $this->customer->isLogged() || !$this->config->get('config_customer_price')) && (double) $option_value['price']) {
                         $price = $this->currency->format($this->tax->calculate($option_value['price'], $product_info['tax_class_id'], $this->config->get('config_tax') ? 'P' : false));
                     } else {
                         $price = false;
                     }
                     $product_option_value_data[] = array('product_option_value_id' => $option_value['product_option_value_id'], 'option_value_id' => $option_value['option_value_id'], 'name' => $option_value['name'], 'image' => Journal2Utils::resizeImage($this->model_tool_image, $option_value['image'], $this->journal2->settings->get('product_page_options_push_image_width', 30), $this->journal2->settings->get('product_page_options_push_image_height', 30), 'crop'), 'price' => $price, 'price_prefix' => $option_value['price_prefix']);
                 }
             }
             $data['options'][] = array('product_option_id' => $option['product_option_id'], 'product_option_value' => $product_option_value_data, 'option_id' => $option['option_id'], 'name' => $option['name'], 'type' => $option['type'], 'value' => $option['value'], 'required' => $option['required']);
         }
         if ($product_info['minimum']) {
             $data['minimum'] = $product_info['minimum'];
         } else {
             $data['minimum'] = 1;
         }
         $data['review_status'] = $this->config->get('config_review_status');
         if ($this->config->get('config_review_guest') || $this->customer->isLogged()) {
             $data['review_guest'] = true;
         } else {
             $data['review_guest'] = false;
         }
         if ($this->customer->isLogged()) {
             $data['customer_name'] = $this->customer->getFirstName() . '&nbsp;' . $this->customer->getLastName();
         } else {
             $data['customer_name'] = '';
         }
         $data['reviews'] = sprintf($this->language->get('text_reviews'), (int) $product_info['reviews']);
         $data['rating'] = (int) $product_info['rating'];
         $data['description'] = html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8');
         $data['attribute_groups'] = $this->model_catalog_product->getProductAttributes($this->request->get['pid']);
         $data['tags'] = array();
         if ($product_info['tag']) {
             $tags = explode(',', $product_info['tag']);
             foreach ($tags as $tag) {
                 $data['tags'][] = array('tag' => trim($tag), 'href' => $this->url->link('product/search', 'tag=' . trim($tag)));
             }
         }
         $data['text_payment_recurring'] = $this->language->get('text_payment_recurring');
         $data['recurrings'] = $this->model_catalog_product->getProfiles($this->request->get['pid']);
         $this->model_catalog_product->updateViewed($this->request->get['pid']);
         $this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/journal2/quickview/quickview.tpl', $data));
     } else {
         $this->document->setTitle($this->language->get('text_error'));
         $data['heading_title'] = $this->language->get('text_error');
         $data['text_error'] = $this->language->get('text_error');
         $data['button_continue'] = $this->language->get('button_continue');
         $data['continue'] = $this->url->link('common/home');
         $data['breadcrumbs'][] = array('text' => $this->language->get('text_error'), 'href' => $this->url->link('journal2/quickview', '&pid=' . $product_id));
         $this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . ' 404 Not Found');
         $data['column_left'] = $this->load->controller('common/column_left');
         $data['column_right'] = $this->load->controller('common/column_right');
         $data['content_top'] = $this->load->controller('common/content_top');
         $data['content_bottom'] = $this->load->controller('common/content_bottom');
         $data['footer'] = $this->load->controller('common/footer');
         $data['header'] = $this->load->controller('common/header');
         if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/not_found.tpl')) {
             $this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/error/not_found.tpl', $data));
         } else {
             $this->response->setOutput($this->load->view('default/template/error/not_found.tpl', $data));
         }
     }
 }
 public function index()
 {
     $this->language->load('product/product');
     $this->data['breadcrumbs'] = array();
     $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home'), 'separator' => false);
     $this->load->model('catalog/category');
     if (isset($this->request->get['path'])) {
         $path = '';
         $parts = explode('_', (string) $this->request->get['path']);
         $category_id = (int) array_pop($parts);
         foreach ($parts as $path_id) {
             if (!$path) {
                 $path = $path_id;
             } else {
                 $path .= '_' . $path_id;
             }
             $category_info = $this->model_catalog_category->getCategory($path_id);
             if ($category_info) {
                 $this->data['breadcrumbs'][] = array('text' => $category_info['name'], 'href' => $this->url->link('product/category', 'path=' . $path), 'separator' => $this->language->get('text_separator'));
             }
         }
         // Set the last category breadcrumb
         $category_info = $this->model_catalog_category->getCategory($category_id);
         if ($category_info) {
             $url = '';
             if (isset($this->request->get['sort'])) {
                 $url .= '&sort=' . $this->request->get['sort'];
             }
             if (isset($this->request->get['order'])) {
                 $url .= '&order=' . $this->request->get['order'];
             }
             if (isset($this->request->get['page'])) {
                 $url .= '&page=' . $this->request->get['page'];
             }
             if (isset($this->request->get['limit'])) {
                 $url .= '&limit=' . $this->request->get['limit'];
             }
             $this->data['breadcrumbs'][] = array('text' => $category_info['name'], 'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . $url), 'separator' => $this->language->get('text_separator'));
         }
     }
     $this->load->model('catalog/manufacturer');
     if (isset($this->request->get['manufacturer_id'])) {
         $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_brand'), 'href' => $this->url->link('product/manufacturer'), 'separator' => $this->language->get('text_separator'));
         $url = '';
         if (isset($this->request->get['sort'])) {
             $url .= '&sort=' . $this->request->get['sort'];
         }
         if (isset($this->request->get['order'])) {
             $url .= '&order=' . $this->request->get['order'];
         }
         if (isset($this->request->get['page'])) {
             $url .= '&page=' . $this->request->get['page'];
         }
         if (isset($this->request->get['limit'])) {
             $url .= '&limit=' . $this->request->get['limit'];
         }
         $manufacturer_info = $this->model_catalog_manufacturer->getManufacturer($this->request->get['manufacturer_id']);
         if ($manufacturer_info) {
             $this->data['breadcrumbs'][] = array('text' => $manufacturer_info['name'], 'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . $url), 'separator' => $this->language->get('text_separator'));
         }
     }
     if (isset($this->request->get['search']) || isset($this->request->get['tag'])) {
         $url = '';
         if (isset($this->request->get['search'])) {
             $url .= '&search=' . $this->request->get['search'];
         }
         if (isset($this->request->get['tag'])) {
             $url .= '&tag=' . $this->request->get['tag'];
         }
         if (isset($this->request->get['description'])) {
             $url .= '&description=' . $this->request->get['description'];
         }
         if (isset($this->request->get['category_id'])) {
             $url .= '&category_id=' . $this->request->get['category_id'];
         }
         if (isset($this->request->get['sub_category'])) {
             $url .= '&sub_category=' . $this->request->get['sub_category'];
         }
         if (isset($this->request->get['sort'])) {
             $url .= '&sort=' . $this->request->get['sort'];
         }
         if (isset($this->request->get['order'])) {
             $url .= '&order=' . $this->request->get['order'];
         }
         if (isset($this->request->get['page'])) {
             $url .= '&page=' . $this->request->get['page'];
         }
         if (isset($this->request->get['limit'])) {
             $url .= '&limit=' . $this->request->get['limit'];
         }
         $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_search'), 'href' => $this->url->link('product/search', $url), 'separator' => $this->language->get('text_separator'));
     }
     if (isset($this->request->get['product_id'])) {
         $product_id = (int) $this->request->get['product_id'];
     } else {
         $product_id = 0;
     }
     $this->load->model('catalog/product');
     $this->load->model('journal2/product');
     $this->load->model('journal2/product');
     $product_info = $this->model_catalog_product->getProduct($product_id);
     if ($product_info) {
         $url = '';
         if (isset($this->request->get['path'])) {
             $url .= '&path=' . $this->request->get['path'];
         }
         if (isset($this->request->get['filter'])) {
             $url .= '&filter=' . $this->request->get['filter'];
         }
         if (isset($this->request->get['manufacturer_id'])) {
             $url .= '&manufacturer_id=' . $this->request->get['manufacturer_id'];
         }
         if (isset($this->request->get['search'])) {
             $url .= '&search=' . $this->request->get['search'];
         }
         if (isset($this->request->get['tag'])) {
             $url .= '&tag=' . $this->request->get['tag'];
         }
         if (isset($this->request->get['description'])) {
             $url .= '&description=' . $this->request->get['description'];
         }
         if (isset($this->request->get['category_id'])) {
             $url .= '&category_id=' . $this->request->get['category_id'];
         }
         if (isset($this->request->get['sub_category'])) {
             $url .= '&sub_category=' . $this->request->get['sub_category'];
         }
         if (isset($this->request->get['sort'])) {
             $url .= '&sort=' . $this->request->get['sort'];
         }
         if (isset($this->request->get['order'])) {
             $url .= '&order=' . $this->request->get['order'];
         }
         if (isset($this->request->get['page'])) {
             $url .= '&page=' . $this->request->get['page'];
         }
         if (isset($this->request->get['limit'])) {
             $url .= '&limit=' . $this->request->get['limit'];
         }
         $this->data['breadcrumbs'][] = array('text' => $product_info['name'], 'href' => $this->url->link('product/product', $url . '&product_id=' . $this->request->get['product_id']), 'separator' => $this->language->get('text_separator'));
         $this->document->setTitle($product_info['name']);
         $this->document->setDescription($product_info['meta_description']);
         $this->document->setKeywords($product_info['meta_keyword']);
         $this->document->addLink($this->url->link('product/product', 'product_id=' . $this->request->get['product_id']), 'canonical');
         $this->document->addScript('catalog/view/javascript/jquery/tabs.js');
         $this->document->addScript('catalog/view/javascript/jquery/colorbox/jquery.colorbox-min.js');
         $this->document->addStyle('catalog/view/javascript/jquery/colorbox/colorbox.css');
         $this->data['heading_title'] = $product_info['name'];
         $this->data['text_select'] = $this->language->get('text_select');
         $this->data['text_manufacturer'] = $this->language->get('text_manufacturer');
         $this->data['text_model'] = $this->language->get('text_model');
         $this->data['text_reward'] = $this->language->get('text_reward');
         $this->data['text_points'] = $this->language->get('text_points');
         $this->data['text_discount'] = $this->language->get('text_discount');
         $this->data['text_stock'] = $this->language->get('text_stock');
         $this->data['text_price'] = $this->language->get('text_price');
         $this->data['text_tax'] = $this->language->get('text_tax');
         $this->data['text_discount'] = $this->language->get('text_discount');
         $this->data['text_option'] = $this->language->get('text_option');
         $this->data['text_qty'] = $this->language->get('text_qty');
         $this->data['text_minimum'] = sprintf($this->language->get('text_minimum'), $product_info['minimum']);
         $this->data['text_or'] = $this->language->get('text_or');
         $this->data['text_write'] = $this->language->get('text_write');
         $this->data['text_note'] = $this->language->get('text_note');
         $this->data['text_share'] = $this->language->get('text_share');
         $this->data['text_wait'] = $this->language->get('text_wait');
         $this->data['text_tags'] = $this->language->get('text_tags');
         $this->data['entry_name'] = $this->language->get('entry_name');
         $this->data['entry_review'] = $this->language->get('entry_review');
         $this->data['entry_rating'] = $this->language->get('entry_rating');
         $this->data['entry_good'] = $this->language->get('entry_good');
         $this->data['entry_bad'] = $this->language->get('entry_bad');
         $this->data['entry_captcha'] = $this->language->get('entry_captcha');
         $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->data['button_upload'] = $this->language->get('button_upload');
         $this->data['button_continue'] = $this->language->get('button_continue');
         $this->load->model('catalog/review');
         $this->data['tab_description'] = $this->language->get('tab_description');
         $this->data['tab_attribute'] = $this->language->get('tab_attribute');
         $this->data['tab_review'] = sprintf($this->language->get('tab_review'), $product_info['reviews']);
         $this->data['tab_related'] = $this->language->get('tab_related');
         $this->data['product_id'] = $this->request->get['product_id'];
         $this->data['manufacturer'] = $product_info['manufacturer'];
         if ($this->config->get('config_template') === 'journal2') {
             $this->load->model('catalog/manufacturer');
             $manufacturer_info = $this->model_catalog_manufacturer->getManufacturer($product_info['manufacturer_id']);
             if ($manufacturer_info && $manufacturer_info['image'] && $this->journal2->settings->get('manufacturer_image', '0') == '1') {
                 $this->journal2->settings->set('manufacturer_image', 'on');
                 $this->data['manufacturer_image_width'] = $this->journal2->settings->get('manufacturer_image_width', 100);
                 $this->data['manufacturer_image_height'] = $this->journal2->settings->get('manufacturer_image_height', 100);
                 $this->data['manufacturer_image'] = $this->model_tool_image->resize($manufacturer_info['image'], $this->data['manufacturer_image_width'], $this->data['manufacturer_image_height']);
                 switch ($this->journal2->settings->get('manufacturer_image_additional_text', 'none')) {
                     case 'brand':
                         $this->data['manufacturer_image_name'] = $product_info['manufacturer'];
                         break;
                     case 'custom':
                         $this->data['manufacturer_image_name'] = $this->journal2->settings->get('manufacturer_image_custom_text');
                         break;
                 }
             }
         }
         $this->data['manufacturers'] = $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $product_info['manufacturer_id']);
         $this->data['model'] = $product_info['model'];
         $this->data['reward'] = $product_info['reward'];
         $this->data['points'] = $product_info['points'];
         if (true && $product_info['quantity'] <= 0) {
             $this->data['stock_status'] = 'outofstock';
         }
         if (true && $product_info['quantity'] > 0) {
             $this->data['stock_status'] = 'instock';
         }
         $this->data['labels'] = $this->model_journal2_product->getLabels($product_info['product_id']);
         if ($product_info['quantity'] <= 0) {
             $this->data['stock'] = $product_info['stock_status'];
         } elseif ($this->config->get('config_stock_display')) {
             $this->data['stock'] = $product_info['quantity'];
         } else {
             $this->data['stock'] = $this->language->get('text_instock');
         }
         $this->load->model('tool/image');
         if ($product_info['image']) {
             $this->data['popup_fixed'] = $this->model_tool_image->resize($product_info['image'], $this->config->get('config_image_popup_width'), $this->config->get('config_image_popup_height'));
             $this->data['popup'] = $this->model_tool_image->resize($product_info['image'], $this->config->get('config_image_popup_width'), $this->config->get('config_image_popup_height'));
         } else {
             $this->data['popup'] = $this->model_tool_image->resize('no_image.jpg', $this->config->get('config_image_popup_width'), $this->config->get('config_image_popup_height'));
         }
         if ($product_info['image']) {
             $this->data['thumb_fixed'] = $this->model_tool_image->resize($product_info['image'], $this->config->get('config_image_additional_width'), $this->config->get('config_image_additional_height'));
             $this->data['thumb'] = $this->model_tool_image->resize($product_info['image'], $this->config->get('config_image_thumb_width'), $this->config->get('config_image_thumb_height'));
         } else {
             $this->data['thumb'] = $this->model_tool_image->resize('no_image.jpg', $this->config->get('config_image_thumb_width'), $this->config->get('config_image_thumb_height'));
         }
         $this->data['images'] = array();
         $results = $this->model_catalog_product->getProductImages($this->request->get['product_id']);
         foreach ($results as $result) {
             $this->data['images'][] = array('popup' => $this->model_tool_image->resize($result['image'], $this->config->get('config_image_popup_width'), $this->config->get('config_image_popup_height')), 'thumb' => $this->model_tool_image->resize($result['image'], $this->config->get('config_image_additional_width'), $this->config->get('config_image_additional_height')));
         }
         if ($this->config->get('config_customer_price') && $this->customer->isLogged() || !$this->config->get('config_customer_price')) {
             $this->data['price'] = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')));
         } else {
             $this->data['price'] = false;
         }
         if ((double) $product_info['special']) {
             if ($this->config->get('config_template') === 'journal2' && $this->journal2->settings->get('show_countdown_product_page', 'on') == 'on') {
                 $this->load->model('journal2/product');
                 $date_end = $this->model_journal2_product->getSpecialCountdown($this->request->get['product_id']);
                 if ($date_end === '0000-00-00') {
                     $date_end = false;
                 }
                 $this->data['date_end'] = $date_end;
             }
             $this->data['special'] = $this->currency->format($this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax')));
         } else {
             $this->data['special'] = false;
         }
         if ($this->config->get('config_tax')) {
             $this->data['tax'] = $this->currency->format((double) $product_info['special'] ? $product_info['special'] : $product_info['price']);
         } else {
             $this->data['tax'] = false;
         }
         $discounts = $this->model_catalog_product->getProductDiscounts($this->request->get['product_id']);
         $this->data['discounts'] = array();
         foreach ($discounts as $discount) {
             $this->data['discounts'][] = array('quantity' => $discount['quantity'], 'price' => $this->currency->format($this->tax->calculate($discount['price'], $product_info['tax_class_id'], $this->config->get('config_tax'))));
         }
         $this->data['options'] = array();
         foreach ($this->model_catalog_product->getProductOptions($this->request->get['product_id']) as $option) {
             if ($option['type'] == 'select' || $option['type'] == 'radio' || $option['type'] == 'checkbox' || $option['type'] == 'image') {
                 $option_value_data = array();
                 foreach ($option['option_value'] as $option_value) {
                     if (!$option_value['subtract'] || $option_value['quantity'] > 0) {
                         if (($this->config->get('config_customer_price') && $this->customer->isLogged() || !$this->config->get('config_customer_price')) && (double) $option_value['price']) {
                             $price = $this->currency->format($this->tax->calculate($option_value['price'], $product_info['tax_class_id'], $this->config->get('config_tax')));
                         } else {
                             $price = false;
                         }
                         $option_value_data[] = array('product_option_value_id' => $option_value['product_option_value_id'], 'option_value_id' => $option_value['option_value_id'], 'name' => $option_value['name'], 'image' => strpos($this->config->get('config_template'), 'journal2') === 0 ? Journal2Utils::resizeImage($this->model_tool_image, $option_value['image'], $this->journal2->settings->get('product_page_options_push_image_width', 30), $this->journal2->settings->get('product_page_options_push_image_height', 30), 'crop') : $this->model_tool_image->resize($option_value['image'], 50, 50), 'price' => $price, 'price_prefix' => $option_value['price_prefix']);
                     }
                 }
                 $this->data['options'][] = array('product_option_id' => $option['product_option_id'], 'option_id' => $option['option_id'], 'name' => $option['name'], 'type' => $option['type'], 'option_value' => $option_value_data, 'required' => $option['required']);
             } elseif ($option['type'] == 'text' || $option['type'] == 'textarea' || $option['type'] == 'file' || $option['type'] == 'date' || $option['type'] == 'datetime' || $option['type'] == 'time') {
                 $this->data['options'][] = array('product_option_id' => $option['product_option_id'], 'option_id' => $option['option_id'], 'name' => $option['name'], 'type' => $option['type'], 'option_value' => $option['option_value'], 'required' => $option['required']);
             }
         }
         if ($product_info['minimum']) {
             $this->data['minimum'] = $product_info['minimum'];
         } else {
             $this->data['minimum'] = 1;
         }
         $this->data['review_status'] = $this->config->get('config_review_status');
         $this->data['reviews'] = sprintf($this->language->get('text_reviews'), (int) $product_info['reviews']);
         $this->data['rating'] = (int) $product_info['rating'];
         $this->data['description'] = html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8');
         $this->data['attribute_groups'] = $this->model_catalog_product->getProductAttributes($this->request->get['product_id']);
         $this->data['products'] = array();
         $results = $this->model_catalog_product->getProductRelated($this->request->get['product_id']);
         foreach ($results as $result) {
             if ($result['image']) {
                 $image = $this->model_tool_image->resize($result['image'], $this->config->get('config_image_related_width'), $this->config->get('config_image_related_height'));
             } else {
                 $image = false;
             }
             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 ($this->config->get('config_template') === 'journal2' && $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['products'][] = array('product_id' => $result['product_id'], 'thumb' => $image, 'thumb2' => $image2, 'labels' => $this->model_journal2_product->getLabels($result['product_id']), 'name' => $result['name'], 'price' => $price, 'special' => $special, 'date_end' => $date_end, '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['tags'] = array();
         if ($product_info['tag']) {
             $tags = explode(',', $product_info['tag']);
             foreach ($tags as $tag) {
                 $this->data['tags'][] = array('tag' => trim($tag), 'href' => $this->url->link('product/search', 'tag=' . trim($tag)));
             }
         }
         $this->data['text_payment_profile'] = $this->language->get('text_payment_profile');
         $this->data['profiles'] = $this->model_catalog_product->getProfiles($product_info['product_id']);
         $this->model_catalog_product->updateViewed($this->request->get['product_id']);
         if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/product.tpl')) {
             $this->template = $this->config->get('config_template') . '/template/product/product.tpl';
         } else {
             $this->template = 'default/template/product/product.tpl';
         }
         $this->children = array('common/column_left', 'common/column_right', 'common/content_top', 'common/content_bottom', 'common/footer', 'common/header');
         $this->response->setOutput($this->render());
     } else {
         $url = '';
         if (isset($this->request->get['path'])) {
             $url .= '&path=' . $this->request->get['path'];
         }
         if (isset($this->request->get['filter'])) {
             $url .= '&filter=' . $this->request->get['filter'];
         }
         if (isset($this->request->get['manufacturer_id'])) {
             $url .= '&manufacturer_id=' . $this->request->get['manufacturer_id'];
         }
         if (isset($this->request->get['search'])) {
             $url .= '&search=' . $this->request->get['search'];
         }
         if (isset($this->request->get['tag'])) {
             $url .= '&tag=' . $this->request->get['tag'];
         }
         if (isset($this->request->get['description'])) {
             $url .= '&description=' . $this->request->get['description'];
         }
         if (isset($this->request->get['category_id'])) {
             $url .= '&category_id=' . $this->request->get['category_id'];
         }
         if (isset($this->request->get['sub_category'])) {
             $url .= '&sub_category=' . $this->request->get['sub_category'];
         }
         if (isset($this->request->get['sort'])) {
             $url .= '&sort=' . $this->request->get['sort'];
         }
         if (isset($this->request->get['order'])) {
             $url .= '&order=' . $this->request->get['order'];
         }
         if (isset($this->request->get['page'])) {
             $url .= '&page=' . $this->request->get['page'];
         }
         if (isset($this->request->get['limit'])) {
             $url .= '&limit=' . $this->request->get['limit'];
         }
         $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_error'), 'href' => $this->url->link('product/product', $url . '&product_id=' . $product_id), 'separator' => $this->language->get('text_separator'));
         $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->template = $this->config->get('config_template') . '/template/error/not_found.tpl';
         } else {
             $this->template = 'default/template/error/not_found.tpl';
         }
         $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 generateManufacturerSections($sections_data)
 {
     $section_index = 0;
     foreach ($sections_data as $section) {
         if (!$section['status']) {
             continue;
         }
         $manufacturers = array();
         $section_manufacturers = array();
         $section_name = Journal2Utils::getProperty($section, 'section_title.value.' . $this->config->get('config_language_id'), 'Not Translated');
         switch (Journal2Utils::getProperty($section, 'section_type')) {
             case 'all':
                 $manufacturers = $this->model_catalog_manufacturer->getManufacturers(array('start' => 0, 'limit' => Journal2Utils::getProperty($section, 'items_limit', 5)));
                 break;
             case 'custom':
                 foreach (Journal2Utils::getProperty($section, 'manufacturers', array()) as $manufacturer) {
                     $manufacturers[] = array('manufacturer_id' => Journal2Utils::getProperty($manufacturer, 'data.id', -1));
                 }
         }
         foreach ($manufacturers as $manufacturer) {
             $this->has_items = true;
             $manufacturer_info = $this->model_catalog_manufacturer->getManufacturer($manufacturer['manufacturer_id']);
             if (!$manufacturer_info) {
                 continue;
             }
             $manufacturer_sections = isset($this->data['items'][$manufacturer_info['manufacturer_id']]) ? $this->data['items'][$manufacturer_info['manufacturer_id']]['section_class'] : array();
             $manufacturer_sections[$section_index] = 'section-' . $section_index;
             $manufacturer_data = array('section_class' => $manufacturer_sections, 'name' => $manufacturer_info['name'], 'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $manufacturer_info['manufacturer_id']), 'thumb' => Journal2Utils::resizeImage($this->model_tool_image, $manufacturer_info['image'] ? $manufacturer_info['image'] : 'data/journal2/no_image_large.jpg', $this->data['image_width'], $this->data['image_height'], $this->data['image_resize_type']));
             $section_manufacturers[] = $manufacturer_data;
         }
         $this->data['sections'][] = array('section_class' => $section_index, 'section_name' => $section_name, 'items' => $section_manufacturers, 'is_link' => Journal2Utils::getProperty($section, 'section_type') === 'link', 'url' => $this->model_journal2_menu->getLink(Journal2Utils::getProperty($section, 'link')), 'target' => Journal2Utils::getProperty($section, 'new_window') ? 'target="_blank"' : '');
         if (Journal2Utils::getProperty($section, 'default_section')) {
             $this->data['default_section'] = $section_index;
         }
         $section_index++;
     }
 }
 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_text_rotator_' . $setting['module_id'], implode('; ', $css));
         $this->journal2->settings->set('module_journal2_text_rotator_' . $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_text_rotator_{$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['transition_delay'] = Journal2Utils::getProperty($module_data, 'transition_delay', 4000);
         $this->data['bullets_position'] = Journal2Utils::getProperty($module_data, 'bullets_position', 'center');
         $this->data['title'] = Journal2Utils::getProperty($module_data, 'module_title.value.' . $this->config->get('config_language_id'), '');
         /* quote options */
         $css = array();
         $css[] = 'text-align: ' . Journal2Utils::getProperty($module_data, 'text_align', 'center');
         $this->data['text_align'] = Journal2Utils::getProperty($module_data, 'text_align', 'center');
         if (Journal2Utils::getProperty($module_data, 'text_font.value.font_type') === 'google') {
             $font_name = Journal2Utils::getProperty($module_data, 'text_font.value.font_name');
             $font_subset = Journal2Utils::getProperty($module_data, 'text_font.value.font_subset');
             $font_weight = Journal2Utils::getProperty($module_data, 'text_font.value.font_weight');
             $this->journal2->google_fonts->add($font_name, $font_subset, $font_weight);
             $this->google_fonts[] = array('name' => $font_name, 'subset' => $font_subset, 'weight' => $font_weight);
             $weight = filter_var(Journal2Utils::getProperty($module_data, 'text_font.value.font_weight'), FILTER_SANITIZE_NUMBER_INT);
             $css[] = 'font-weight: ' . ($weight ? $weight : 400);
             $css[] = "font-family: '" . Journal2Utils::getProperty($module_data, 'text_font.value.font_name') . "'";
         }
         if (Journal2Utils::getProperty($module_data, 'text_font.value.font_type') === 'system') {
             $css[] = 'font-weight: ' . Journal2Utils::getProperty($module_data, 'text_font.value.font_weight');
             $css[] = 'font-family: ' . Journal2Utils::getProperty($module_data, 'text_font.value.font_family');
         }
         if (Journal2Utils::getProperty($module_data, 'text_font.value.font_type') !== 'none') {
             $css[] = 'font-size: ' . Journal2Utils::getProperty($module_data, 'text_font.value.font_size');
             $css[] = 'font-style: ' . Journal2Utils::getProperty($module_data, 'text_font.value.font_style');
             $css[] = 'text-transform: ' . Journal2Utils::getProperty($module_data, 'text_font.value.text_transform');
         }
         if (Journal2Utils::getProperty($module_data, 'text_font.value.color.value.color')) {
             $css[] = 'color: ' . Journal2Utils::getColor(Journal2Utils::getProperty($module_data, 'text_font.value.color.value.color'));
         }
         $this->data['quote_css'] = implode('; ', $css);
         /* author options */
         $css = array();
         if (Journal2Utils::getProperty($module_data, 'author_font.value.font_type') === 'google') {
             $font_name = Journal2Utils::getProperty($module_data, 'author_font.value.font_name');
             $font_subset = Journal2Utils::getProperty($module_data, 'author_font.value.font_subset');
             $font_weight = Journal2Utils::getProperty($module_data, 'author_font.value.font_weight');
             $this->journal2->google_fonts->add($font_name, $font_subset, $font_weight);
             $this->google_fonts[] = array('name' => $font_name, 'subset' => $font_subset, 'weight' => $font_weight);
             $weight = filter_var(Journal2Utils::getProperty($module_data, 'author_font.value.font_weight'), FILTER_SANITIZE_NUMBER_INT);
             $css[] = 'font-weight: ' . ($weight ? $weight : 400);
             $css[] = "font-family: '" . Journal2Utils::getProperty($module_data, 'author_font.value.font_name') . "'";
         }
         if (Journal2Utils::getProperty($module_data, 'author_font.value.font_type') === 'system') {
             $css[] = 'font-weight: ' . Journal2Utils::getProperty($module_data, 'author_font.value.font_weight');
             $css[] = 'font-family: ' . Journal2Utils::getProperty($module_data, 'author_font.value.font_family');
         }
         $css[] = 'text-align: ' . Journal2Utils::getProperty($module_data, 'author_align', 'center');
         if (Journal2Utils::getProperty($module_data, 'author_font.value.font_type') !== 'none') {
             $css[] = 'font-size: ' . Journal2Utils::getProperty($module_data, 'author_font.value.font_size');
             $css[] = 'font-style: ' . Journal2Utils::getProperty($module_data, 'author_font.value.font_style');
             $css[] = 'text-transform: ' . Journal2Utils::getProperty($module_data, 'author_font.value.text_transform');
         }
         if (Journal2Utils::getProperty($module_data, 'author_font.value.color.value.color')) {
             $css[] = 'color: ' . Journal2Utils::getColor(Journal2Utils::getProperty($module_data, 'author_font.value.color.value.color'));
         }
         $this->data['author_css'] = implode('; ', $css);
         /* rotator options */
         $css = Journal2Utils::getBackgroundCssProperties(Journal2Utils::getProperty($module_data, 'text_background'));
         $this->data['rotator_css'] = implode('; ', $css);
         /* image options */
         $css = array();
         $css = array_merge($css, Journal2Utils::getBorderCssProperties(Journal2Utils::getProperty($module_data, 'image_border')));
         switch (Journal2Utils::getProperty($module_data, 'image_align')) {
             case 'left':
                 $this->data['image_align'] = 'left';
                 $css[] = 'float: left';
                 break;
             case 'center':
                 $this->data['image_align'] = 'center';
                 $css[] = 'float: none';
                 $css[] = 'margin:0 auto';
                 $css[] = 'margin-bottom:10px';
                 break;
             case 'right':
                 $this->data['image_align'] = 'right';
                 $css[] = 'float: right';
                 break;
         }
         $this->data['image_css'] = implode('; ', $css);
         /* sections */
         $this->data['random_sections'] = Journal2Utils::getProperty($module_data, 'random_sections', '0');
         $this->data['sections'] = array();
         $sections = Journal2Utils::getProperty($module_data, 'sections', array());
         $sections = Journal2Utils::sortArray($sections);
         $image_width = Journal2Utils::getProperty($module_data, 'image_width', 150);
         $image_height = Journal2Utils::getProperty($module_data, 'image_height', 150);
         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 (!file_exists(DIR_IMAGE . $image)) {
                 $image = false;
             }
             $this->data['sections'][] = array('author' => Journal2Utils::getProperty($section, 'author'), 'image' => $image ? Journal2Utils::resizeImage($this->model_tool_image, $image, $image_width, $image_height, 'crop') : false, 'image_width' => $image_width, 'image_height' => $image_height, 'text' => Journal2Utils::getProperty($section, 'text.value.' . $this->config->get('config_language_id')), 'icon' => Journal2Utils::getIconOptions2(Journal2Utils::getProperty($section, 'icon')));
         }
         /* bullets */
         $this->data['bullets'] = Journal2Utils::getProperty($module_data, 'bullets') && count($this->data['sections']) > 1 ? true : false;
         /* pause on hover */
         $this->data['pause_on_hover'] = Journal2Utils::getProperty($module_data, 'pause_on_hover', '1');
         $this->template = $this->config->get('config_template') . '/template/journal2/module/text_rotator.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);
             $this->journal2->cache->set($cache_property . '_fonts', json_encode($this->google_fonts));
         }
     } else {
         if ($fonts = $this->journal2->cache->get($cache_property . '_fonts')) {
             $fonts = json_decode($fonts, true);
             if (is_array($fonts)) {
                 foreach ($fonts as $font) {
                     $this->journal2->google_fonts->add($font['name'], $font['subset'], $font['weight']);
                 }
             }
         }
         $this->template = $this->config->get('config_template') . '/template/journal2/cache/cache.tpl';
         $this->data['cache'] = $cache;
     }
     $this->document->addScript('catalog/view/theme/journal2/lib/quovolver/jquery.quovolver.js');
     $output = $this->render();
     Journal2::stopTimer(get_class($this));
     return $output;
 }
예제 #11
0
 public function index()
 {
     $this->load->model('tool/image');
     /* blog manager compatibility */
     $route = isset($this->request->get['route']) ? $this->request->get['route'] : null;
     if ($route !== null && in_array($route, array('blog/article', 'blog/category'))) {
         return;
     }
     /* end of blog manager compatibility */
     $this->s_url = Journal2Cache::getCurrentUrl();
     switch ($this->journal2->page->getType()) {
         case 'product':
             $this->load->model('catalog/product');
             $product_info = $this->model_catalog_product->getProduct($this->journal2->page->getId());
             if ($product_info) {
                 $this->s_title = $product_info['name'];
                 $this->s_description = trim(utf8_substr(strip_tags(html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8')), 0, 300));
                 $this->s_image = Journal2Utils::staticAsset('image/' . $product_info['image']);
                 $this->s_rating = (int) $product_info['rating'];
                 $this->journal2->settings->set('product_google_snippet', 'itemscope itemtype="http://schema.org/Product"');
                 $this->journal2->settings->set('product_price_currency', $this->currency->getCode());
                 $this->journal2->settings->set('product_num_reviews', $product_info['reviews']);
                 $this->journal2->settings->set('product_in_stock', $product_info['quantity'] > 0 ? 'yes' : 'no');
                 /* review ratings */
                 $this->language->load('product/product');
                 $this->load->model('catalog/review');
                 $this->data['text_on'] = $this->language->get('text_on');
                 $this->data['text_no_reviews'] = $this->language->get('text_no_reviews');
                 if (isset($this->request->get['page'])) {
                     $page = $this->request->get['page'];
                 } else {
                     $page = 1;
                 }
                 $this->data['reviews'] = array();
                 $review_total = $this->model_catalog_review->getTotalReviewsByProductId($this->request->get['product_id']);
                 $results = $this->model_catalog_review->getReviewsByProductId($this->request->get['product_id'], ($page - 1) * 5, 5);
                 foreach ($results as $result) {
                     $this->data['reviews'][] = array('author' => $result['author'], 'text' => $result['text'], 'rating' => (int) $result['rating'], 'reviews' => sprintf($this->language->get('text_reviews'), (int) $review_total), 'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])));
                 }
                 $pagination = new Pagination();
                 $pagination->total = $review_total;
                 $pagination->page = $page;
                 $pagination->limit = 5;
                 $pagination->text = $this->language->get('text_pagination');
                 $pagination->url = $this->url->link('product/product/review', 'product_id=' . $this->request->get['product_id'] . '&page={page}');
                 $this->data['pagination'] = $pagination->render();
                 if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/review.tpl')) {
                     $this->template = $this->config->get('config_template') . '/template/product/review.tpl';
                 } else {
                     $this->template = 'default/template/product/review.tpl';
                 }
                 $this->journal2->settings->set('product_reviews', $this->render());
             }
             break;
         case 'category':
             $this->load->model('catalog/category');
             $parts = explode('_', $this->journal2->page->getId());
             $category_id = (int) array_pop($parts);
             $category_info = $this->model_catalog_category->getCategory($category_id);
             if ($category_info) {
                 $this->s_title = $category_info['name'];
                 $this->s_description = trim(utf8_substr(strip_tags(html_entity_decode($category_info['description'], ENT_QUOTES, 'UTF-8')), 0, 300));
                 $this->s_image = Journal2Utils::staticAsset('image/' . $category_info['image']);
             }
             break;
         default:
             $this->s_title = $this->config->get('config_name');
             $meta_description = $this->config->get('config_meta_description');
             if (is_array($meta_description)) {
                 $lang_id = $this->config->get('config_language_id');
                 if (isset($meta_description[$lang_id])) {
                     $this->s_description = $meta_description[$lang_id] . '...';
                 }
             } else {
                 $this->s_description = $meta_description . '...';
             }
             $this->s_image = Journal2Utils::resizeImage($this->model_tool_image, $this->config->get('config_logo'), self::IMG_WIDTH, self::IMG_HEIGHT, 'fit');
             break;
     }
     $this->journal2->settings->set('fb_meta_title', $this->s_title);
     $this->journal2->settings->set('fb_meta_description', $this->s_description);
     $this->journal2->settings->set('fb_meta_url', $this->s_url);
     $this->journal2->settings->set('fb_meta_image', $this->s_image);
 }
 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;
 }
 public function index()
 {
     $this->language->load('product/product');
     $this->data['breadcrumbs'] = array();
     $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home'), 'separator' => false);
     $this->load->model('catalog/category');
     if (isset($this->request->get['path'])) {
         $path = '';
         $parts = explode('_', (string) $this->request->get['path']);
         $category_id = (int) array_pop($parts);
         foreach ($parts as $path_id) {
             if (!$path) {
                 $path = $path_id;
             } else {
                 $path .= '_' . $path_id;
             }
             $category_info = $this->model_catalog_category->getCategory($path_id);
             if ($category_info) {
                 $this->data['breadcrumbs'][] = array('text' => $category_info['name'], 'href' => $this->url->link('product/category', 'path=' . $path), 'separator' => $this->language->get('text_separator'));
             }
         }
         // Set the last category breadcrumb
         $category_info = $this->model_catalog_category->getCategory($category_id);
         if ($category_info) {
             $url = '';
             if (isset($this->request->get['sort'])) {
                 $url .= '&sort=' . $this->request->get['sort'];
             }
             if (isset($this->request->get['order'])) {
                 $url .= '&order=' . $this->request->get['order'];
             }
             if (isset($this->request->get['page'])) {
                 $url .= '&page=' . $this->request->get['page'];
             }
             if (isset($this->request->get['limit'])) {
                 $url .= '&limit=' . $this->request->get['limit'];
             }
             $this->data['breadcrumbs'][] = array('text' => $category_info['name'], 'href' => $this->url->link('product/category', 'path=' . $this->request->get['path']), 'separator' => $this->language->get('text_separator'));
         }
     }
     $this->load->model('catalog/manufacturer');
     if (isset($this->request->get['manufacturer_id'])) {
         $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_brand'), 'href' => $this->url->link('product/manufacturer'), 'separator' => $this->language->get('text_separator'));
         $url = '';
         if (isset($this->request->get['sort'])) {
             $url .= '&sort=' . $this->request->get['sort'];
         }
         if (isset($this->request->get['order'])) {
             $url .= '&order=' . $this->request->get['order'];
         }
         if (isset($this->request->get['page'])) {
             $url .= '&page=' . $this->request->get['page'];
         }
         if (isset($this->request->get['limit'])) {
             $url .= '&limit=' . $this->request->get['limit'];
         }
         $manufacturer_info = $this->model_catalog_manufacturer->getManufacturer($this->request->get['manufacturer_id']);
         if ($manufacturer_info) {
             $this->data['breadcrumbs'][] = array('text' => $manufacturer_info['name'], 'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . $url), 'separator' => $this->language->get('text_separator'));
         }
     }
     if (isset($this->request->get['search']) || isset($this->request->get['tag'])) {
         $url = '';
         if (isset($this->request->get['search'])) {
             $url .= '&search=' . $this->request->get['search'];
         }
         if (isset($this->request->get['tag'])) {
             $url .= '&tag=' . $this->request->get['tag'];
         }
         if (isset($this->request->get['description'])) {
             $url .= '&description=' . $this->request->get['description'];
         }
         if (isset($this->request->get['category_id'])) {
             $url .= '&category_id=' . $this->request->get['category_id'];
         }
         if (isset($this->request->get['sub_category'])) {
             $url .= '&sub_category=' . $this->request->get['sub_category'];
         }
         if (isset($this->request->get['sort'])) {
             $url .= '&sort=' . $this->request->get['sort'];
         }
         if (isset($this->request->get['order'])) {
             $url .= '&order=' . $this->request->get['order'];
         }
         if (isset($this->request->get['page'])) {
             $url .= '&page=' . $this->request->get['page'];
         }
         if (isset($this->request->get['limit'])) {
             $url .= '&limit=' . $this->request->get['limit'];
         }
         $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_search'), 'href' => $this->url->link('product/search', $url), 'separator' => $this->language->get('text_separator'));
     }
     if (isset($this->request->get['product_id'])) {
         $product_id = (int) $this->request->get['product_id'];
     } else {
         $product_id = 0;
     }
     $this->load->model('catalog/product');
     $this->load->model('journal2/product');
     $this->load->model('journal2/product');
     $product_info = $this->model_catalog_product->getProduct($product_id);
     if ($product_info) {
         $url = '';
         if (isset($this->request->get['path'])) {
             $url .= '&path=' . $this->request->get['path'];
         }
         if (isset($this->request->get['filter'])) {
             $url .= '&filter=' . $this->request->get['filter'];
         }
         if (isset($this->request->get['manufacturer_id'])) {
             $url .= '&manufacturer_id=' . $this->request->get['manufacturer_id'];
         }
         if (isset($this->request->get['search'])) {
             $url .= '&search=' . $this->request->get['search'];
         }
         if (isset($this->request->get['tag'])) {
             $url .= '&tag=' . $this->request->get['tag'];
         }
         if (isset($this->request->get['description'])) {
             $url .= '&description=' . $this->request->get['description'];
         }
         if (isset($this->request->get['category_id'])) {
             $url .= '&category_id=' . $this->request->get['category_id'];
         }
         if (isset($this->request->get['sub_category'])) {
             $url .= '&sub_category=' . $this->request->get['sub_category'];
         }
         if (isset($this->request->get['sort'])) {
             $url .= '&sort=' . $this->request->get['sort'];
         }
         if (isset($this->request->get['order'])) {
             $url .= '&order=' . $this->request->get['order'];
         }
         if (isset($this->request->get['page'])) {
             $url .= '&page=' . $this->request->get['page'];
         }
         if (isset($this->request->get['limit'])) {
             $url .= '&limit=' . $this->request->get['limit'];
         }
         $this->data['breadcrumbs'][] = array('text' => $product_info['name'], 'href' => $this->url->link('product/product', $url . '&product_id=' . $this->request->get['product_id']), 'separator' => $this->language->get('text_separator'));
         $product_info['custom_title'] == '' ? $this->document->setTitle((isset($category_info['name']) ? $category_info['name'] . ' : ' : '') . $product_info['name']) : $this->document->setTitle($product_info['custom_title']);
         $this->document->setDescription($product_info['meta_description']);
         $this->document->setKeywords($product_info['meta_keyword']);
         $this->document->addLink($this->url->link('product/product', 'product_id=' . $this->request->get['product_id']), 'canonical');
         $this->document->addScript('catalog/view/javascript/jquery/tabs.js');
         $this->document->addScript('catalog/view/javascript/jquery/colorbox/jquery.colorbox-min.js');
         $this->document->addStyle('catalog/view/javascript/jquery/colorbox/colorbox.css');
         $this->data['heading_title'] = $product_info['name'];
         $this->data['text_select'] = $this->language->get('text_select');
         $this->data['text_manufacturer'] = $this->language->get('text_manufacturer');
         $this->data['text_model'] = $this->language->get('text_model');
         $this->data['text_reward'] = $this->language->get('text_reward');
         $this->data['text_points'] = $this->language->get('text_points');
         $this->data['text_discount'] = $this->language->get('text_discount');
         $this->data['text_stock'] = $this->language->get('text_stock');
         $this->data['text_qty'] = $this->language->get('text_qty');
         $this->data['text_price'] = $this->language->get('text_price');
         $this->data['text_tax'] = $this->language->get('text_tax');
         $this->data['text_discount'] = $this->language->get('text_discount');
         $this->data['text_option'] = $this->language->get('text_option');
         $this->data['text_minimum'] = sprintf($this->language->get('text_minimum'), $product_info['minimum']);
         $this->data['text_or'] = $this->language->get('text_or');
         $this->data['text_write'] = $this->language->get('text_write');
         $this->data['text_note'] = $this->language->get('text_note');
         $this->data['text_share'] = $this->language->get('text_share');
         $this->data['text_wait'] = $this->language->get('text_wait');
         $this->data['text_tags'] = $this->language->get('text_tags');
         $this->data['text_no_stock'] = $this->language->get('text_no_stock');
         $this->data['text_free_delivery'] = $this->language->get('text_free_delivery');
         $this->data['text_return_guarantee'] = $this->language->get('text_return_guarantee');
         $this->data['text_delivery'] = $this->language->get('text_delivery');
         $this->data['text_see_corresponding_size'] = $this->language->get('text_see_corresponding_size');
         //balazs
         $this->data['text_withouth_vat'] = $this->language->get('text_withouth_vat');
         $this->data['text_price_ask'] = $this->language->get('text_price_ask');
         $this->data['entry_name'] = $this->language->get('entry_name');
         $this->data['entry_review'] = $this->language->get('entry_review');
         $this->data['entry_rating'] = $this->language->get('entry_rating');
         $this->data['entry_good'] = $this->language->get('entry_good');
         $this->data['entry_bad'] = $this->language->get('entry_bad');
         $this->data['entry_captcha'] = $this->language->get('entry_captcha');
         $this->data['download_description'] = $this->language->get('download_description');
         $this->data['button_cart'] = $this->language->get('button_cart');
         $this->data['button_view_product'] = $this->language->get('button_view_product');
         $this->data['button_get_info'] = $this->language->get('button_get_info');
         $this->data['button_wishlist'] = $this->language->get('button_wishlist');
         $this->data['button_compare'] = $this->language->get('button_compare');
         $this->data['button_upload'] = $this->language->get('button_upload');
         $this->data['button_continue'] = $this->language->get('button_continue');
         $this->data['error_cart_content'] = $this->language->get('error_cart_content');
         $this->load->model('catalog/review');
         $this->data['tab_description'] = $this->language->get('tab_description');
         $this->data['tab_attribute'] = $this->language->get('tab_attribute');
         $this->data['tab_review'] = sprintf($this->language->get('tab_review'), $product_info['reviews']);
         $this->data['tab_related'] = $this->language->get('tab_related');
         $this->data['tab_complementary'] = $this->language->get('tab_complementary');
         $this->data['product_id'] = $this->request->get['product_id'];
         $this->data['manufacturer'] = $product_info['manufacturer'];
         if ($this->config->get('config_template') === 'journal2') {
             $this->load->model('catalog/manufacturer');
             $manufacturer_info = $this->model_catalog_manufacturer->getManufacturer($product_info['manufacturer_id']);
             if ($manufacturer_info && $manufacturer_info['image'] && $this->journal2->settings->get('manufacturer_image', '0') == '1') {
                 $this->journal2->settings->set('manufacturer_image', 'on');
                 $this->data['manufacturer_image_width'] = $this->journal2->settings->get('manufacturer_image_width', 100);
                 $this->data['manufacturer_image_height'] = $this->journal2->settings->get('manufacturer_image_height', 100);
                 $this->data['manufacturer_image'] = $this->model_tool_image->resize($manufacturer_info['image'], $this->data['manufacturer_image_width'], $this->data['manufacturer_image_height']);
                 switch ($this->journal2->settings->get('manufacturer_image_additional_text', 'none')) {
                     case 'brand':
                         $this->data['manufacturer_image_name'] = $product_info['manufacturer'];
                         break;
                     case 'custom':
                         $this->data['manufacturer_image_name'] = $this->journal2->settings->get('manufacturer_image_custom_text');
                         break;
                 }
             }
         }
         $this->data['manufacturers'] = $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $product_info['manufacturer_id']);
         $this->data['model'] = $product_info['model'];
         $this->data['reward'] = $product_info['reward'];
         $this->data['points'] = $product_info['points'];
         $this->data['mbreadcrumbs'] = array();
         $this->data['mbreadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home'));
         if ($this->model_catalog_product->getFullPath($this->request->get['product_id'])) {
             $path = '';
             $parts = explode('_', (string) $this->model_catalog_product->getFullPath($this->request->get['product_id']));
             $category_id = (int) array_pop($parts);
             foreach ($parts as $path_id) {
                 if (!$path) {
                     $path = $path_id;
                 } else {
                     $path .= '_' . $path_id;
                 }
                 $category_info = $this->model_catalog_category->getCategory($path_id);
                 if ($category_info) {
                     $this->data['mbreadcrumbs'][] = array('text' => $category_info['name'], 'href' => $this->url->link('product/category', 'path=' . $path));
                 }
             }
             $category_info = $this->model_catalog_category->getCategory($category_id);
             if ($category_info) {
                 $url = '';
                 $this->data['mbreadcrumbs'][] = array('text' => $category_info['name'], 'href' => $this->url->link('product/category', 'path=' . $this->model_catalog_product->getFullPath($this->request->get['product_id'])));
             }
         } else {
             $this->data['mbreadcrumb'] = false;
         }
         $this->data['review_no'] = $product_info['reviews'];
         $this->data['quantity'] = $product_info['quantity'];
         if (true && $product_info['quantity'] <= 0) {
             $this->data['stock_status'] = 'outofstock';
         }
         if (true && $product_info['quantity'] > 0) {
             $this->data['stock_status'] = 'instock';
         }
         $this->data['labels'] = $this->model_journal2_product->getLabels($product_info['product_id']);
         if ($product_info['quantity'] <= 0) {
             $this->data['stock'] = $product_info['stock_status'];
         } elseif ($this->config->get('config_stock_display')) {
             $this->data['stock'] = $product_info['quantity'];
         } else {
             $this->data['stock'] = $this->language->get('text_instock');
         }
         $this->data['quantity'] = $product_info['quantity'];
         // if the logged customer is B2B or Gallery + B2B
         $B2B = false;
         if ($this->customer->getCustomerGroupId() == 3 || $this->customer->getCustomerGroupId() == 4) {
             $B2B = true;
         }
         $this->data['B2B'] = $B2B;
         $this->load->model('tool/image');
         if ($product_info['image']) {
             $this->data['popup_fixed'] = $this->model_tool_image->resize($product_info['image'], $this->config->get('config_image_popup_width'), $this->config->get('config_image_popup_height'));
             $this->data['popup'] = $this->model_tool_image->resize($product_info['image'], $this->config->get('config_image_popup_width'), $this->config->get('config_image_popup_height'));
         } else {
             $this->data['popup'] = $this->model_tool_image->resize('no_image.jpg', $this->config->get('config_image_popup_width'), $this->config->get('config_image_popup_height'));
         }
         if ($product_info['image']) {
             $this->data['thumb_fixed'] = $this->model_tool_image->resize($product_info['image'], $this->config->get('config_image_additional_width'), $this->config->get('config_image_additional_height'));
             $this->data['thumb'] = $this->model_tool_image->resize($product_info['image'], $this->config->get('config_image_thumb_width'), $this->config->get('config_image_thumb_height'));
         } else {
             $this->data['thumb'] = $this->model_tool_image->resize('no_image.jpg', $this->config->get('config_image_thumb_width'), $this->config->get('config_image_thumb_height'));
         }
         $this->data['images'] = array();
         $results = $this->model_catalog_product->getProductImages($this->request->get['product_id']);
         foreach ($results as $result) {
             $this->data['images'][] = array('popup' => $this->model_tool_image->resize($result['image'], $this->config->get('config_image_popup_width'), $this->config->get('config_image_popup_height')), 'thumb' => $this->model_tool_image->resize($result['image'], $this->config->get('config_image_additional_width'), $this->config->get('config_image_additional_height')));
         }
         //			if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
         //
         //        $this->language->load('module/cart');
         //        if( $product_info['price'] ==  'NO_B2B_PRICE' )
         //        {
         //            $this->data['price'] = $this->language->get('text_no_price_specified_for_b2b');
         //        }
         //        else if( $product_info['price'] ==  'MORE_OPTION_NEEDED' )
         //        {
         //            $this->data['price'] = $this->language->get('text_select_option_to_show_price');
         //        }
         //        else if( (float)$product_info['price'] == 0)
         //        {
         //            $this->data['price'] = $this->language->get('text_price_ask');
         //        }
         //        else
         //        {
         //            $this->data['price'] = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')));
         //        }
         //
         //			} else {
         //				$this->data['price'] = false;
         //			}
         if ($this->customer->isLogged()) {
             $this->data['cust_reg'] = true;
         } else {
             $this->data['cust_reg'] = false;
         }
         if ((double) $product_info['special']) {
             if ($this->config->get('config_template') === 'journal2' && $this->journal2->settings->get('show_countdown_product_page', 'on') == 'on') {
                 $this->load->model('journal2/product');
                 $date_end = $this->model_journal2_product->getSpecialCountdown($this->request->get['product_id']);
                 if ($date_end === '0000-00-00') {
                     $date_end = false;
                 }
                 $this->data['date_end'] = $date_end;
             }
             $this->data['special'] = $this->currency->format($this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax')));
         } else {
             $this->data['special'] = false;
         }
         if ($this->config->get('config_tax')) {
             $this->data['tax'] = $this->currency->format((double) $product_info['special'] ? $product_info['special'] : $product_info['price']);
         } else {
             $this->data['tax'] = false;
         }
         //if($this->customer->isLogged()) {
         $product_description_doc = $this->model_catalog_product->getProductDescriptionDocument($this->request->get['product_id'], $this->customer->getCustomerGroupId() ? $this->customer->getCustomerGroupId() : 5);
         //echo "<pre>"; print_r($product_description_doc); die('opencart/vqmod/xml/product_description_pdf.xml:774');
         foreach ($product_description_doc as $file_name) {
             $customer_id = (int) $this->session->data['customer_id'];
             $document_id = (int) $file_name['product_description_download_pdf_id'];
             $sec_id = $customer_id + 17;
             $this->data['product_doc'][] = array('href' => $this->url->link('product/product/download', '&id=' . $document_id . '&sec=' . $sec_id), 'name' => $file_name['document_name'], 'type' => $file_name['document_type'], 'description' => $file_name['document_description']);
         }
         //echo "<pre>"; print_r($this->data['product_doc']); die('opencart/vqmod/xml/product_description_pdf.xml:783');
         //}
         $discounts = $this->model_catalog_product->getProductDiscounts($this->request->get['product_id']);
         $this->data['discounts'] = array();
         foreach ($discounts as $discount) {
             $this->data['discounts'][] = array('quantity' => $discount['quantity'], 'price' => $this->currency->format($this->tax->calculate($discount['price'], $product_info['tax_class_id'], $this->config->get('config_tax'))));
         }
         $this->data['options'] = array();
         /*      print_r( $this->model_catalog_product->getProductOptions($this->request->get['product_id']) );
               die();*/
         foreach ($this->model_catalog_product->getProductOptions($this->request->get['product_id']) as $option) {
             if ($option['type'] == 'select' || $option['type'] == 'radio' || $option['type'] == 'checkbox' || $option['type'] == 'image') {
                 $option_value_data = array();
                 foreach ($option['option_value'] as $option_value) {
                     if (!$option_value['subtract'] || $option_value['quantity'] >= 0) {
                         if (($this->config->get('config_customer_price') && $this->customer->isLogged() || !$this->config->get('config_customer_price')) && (double) $option_value['price']) {
                             $price = $this->currency->format($this->tax->calculate($option_value['price'], $product_info['tax_class_id'], TRUE));
                         } else {
                             $price = false;
                         }
                         $option_value_data[] = array('product_option_value_id' => $option_value['product_option_value_id'], 'option_value_id' => $option_value['option_value_id'], 'name' => $option_value['name'], 'image' => strpos($this->config->get('config_template'), 'journal2') === 0 ? Journal2Utils::resizeImage($this->model_tool_image, $option_value['image'], $this->journal2->settings->get('product_page_options_push_image_width', 30), $this->journal2->settings->get('product_page_options_push_image_height', 30), 'crop') : $this->model_tool_image->resize($option_value['image'], 50, 50), 'price' => $price, 'price_prefix' => $option_value['price_prefix']);
                     }
                 }
                 $this->data['options'][] = array('product_option_id' => $option['product_option_id'], 'option_id' => $option['option_id'], 'name' => $option['name'], 'type' => $option['type'], 'option_value' => $option_value_data, 'required' => $option['required']);
             } elseif ($option['type'] == 'text' || $option['type'] == 'textarea' || $option['type'] == 'file' || $option['type'] == 'date' || $option['type'] == 'datetime' || $option['type'] == 'time') {
                 $this->data['options'][] = array('product_option_id' => $option['product_option_id'], 'option_id' => $option['option_id'], 'name' => $option['name'], 'type' => $option['type'], 'option_value' => $option['option_value'], 'required' => $option['required']);
             }
         }
         if ($this->config->get('config_customer_price') && $this->customer->isLogged() || !$this->config->get('config_customer_price')) {
             $this->language->load('module/cart');
             if ($product_info['price'] == 'MORE_OPTION_NEEDED' && sizeof($this->data['options']) == 0) {
                 $this->data['price'] = $this->language->get('text_no_price_specified_for_b2b');
             } else {
                 if ($product_info['price'] == 'MORE_OPTION_NEEDED' && sizeof($this->data['options']) > 0) {
                     $this->data['price'] = $this->language->get('text_select_option_to_show_price');
                 } else {
                     if ((double) $product_info['price'] == 0) {
                         $this->data['price'] = $this->language->get('text_price_ask');
                     } else {
                         $this->data['price'] = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')));
                     }
                 }
             }
         } else {
             $this->data['price'] = false;
         }
         $this->data['error_option_combo'] = $this->language->get('error_option_combo');
         $option_combo_setting = $this->model_catalog_product->getProductOptionComboSetting($this->request->get['product_id']);
         if (isset($option_combo_setting['status']) && $option_combo_setting['status']) {
             $this->data['text_col_quantity'] = $this->language->get('text_col_quantity');
             $this->data['text_col_points'] = $this->language->get('text_col_points');
             $this->data['text_col_total_points'] = $this->language->get('text_col_total_points');
             $this->data['text_col_price'] = $this->language->get('text_col_price');
             $this->data['text_col_total_price'] = $this->language->get('text_col_total_price');
             $this->data['option_combo_table_view'] = $option_combo_setting['table_view'];
             $this->data['option_combo_option_view'] = $option_combo_setting['option_view'];
             $this->data['option_combo_description_view'] = $option_combo_setting['description_view'];
             $this->data['option_combo_col_select_view'] = $option_combo_setting['col_select_view'];
             $this->data['option_combo_col_quantity_view'] = $option_combo_setting['col_quantity_view'];
             $this->data['option_combo_col_price_view'] = $option_combo_setting['col_price_view'];
             $this->data['option_combo_col_total_price_view'] = $option_combo_setting['col_total_price_view'];
             $this->data['option_combo_extax_view'] = $option_combo_setting['extax_view'];
             $this->data['option_combo_col_points_view'] = $option_combo_setting['col_points_view'];
             $this->data['option_combo_col_total_points_view'] = $option_combo_setting['col_total_points_view'];
             $this->data['option_combo_table_split'] = $option_combo_setting['table_split'];
             $this->data['option_combo_quantity_box'] = $option_combo_setting['quantity_box'];
             $this->data['option_combo_status'] = $option_combo_setting['status'];
             if (!$option_combo_setting['price_view']) {
                 $this->data['price'] = false;
             }
             if ($option_combo_setting['description_view']) {
                 $option_combo_description = $this->model_catalog_product->getProductOptionComboDescription($this->request->get['product_id']);
                 $this->data['option_combo_description'] = html_entity_decode($option_combo_description['description'], ENT_QUOTES, 'UTF-8');
             }
             $product_option_combos = $this->model_catalog_product->getProductOptionCombos($this->request->get['product_id']);
             $product_option_combo_headers = $this->model_catalog_product->getProductOptionComboHeaders($product_option_combos);
             //table split
             $table_split_option_combos = array();
             $table_split_options = array();
             if ($option_combo_setting['table_split']) {
                 foreach ($product_option_combos as $key => $product_option_combo) {
                     foreach ($product_option_combo['option_values'] as $option_id => $combo_option_value) {
                         if ($option_id == $option_combo_setting['table_split']) {
                             $temp_keys = array_keys($combo_option_value);
                             if ($product_option_combos[$key]['price_prefix'] == '+') {
                                 $product_option_combo['price'] += $product_info['price'];
                             } else {
                                 if ($product_option_combos[$key]['price_prefix'] == '-') {
                                     $product_option_combo['price'] = $product_info['price'] - $product_option_combo['price'];
                                 } else {
                                     if ($product_option_combos[$key]['price_prefix'] == '0') {
                                         $product_option_combo['price'] = $product_info['price'] + $product_option_combo['option_price_total'];
                                     }
                                 }
                             }
                             $product_option_combo['total_price'] = $product_option_combo['price'];
                             if ($product_option_combos[$key]['quantity'] > 0) {
                                 $product_option_combo['total_price'] = $product_option_combo['price'] * $product_option_combos[$key]['quantity'];
                             }
                             $product_option_combos[$key]['price'] = $this->currency->format($this->tax->calculate($product_option_combo['price'], $product_info['tax_class_id'], $this->config->get('config_tax')));
                             $product_option_combos[$key]['total_price'] = $this->currency->format($this->tax->calculate($product_option_combo['total_price'], $product_info['tax_class_id'], $this->config->get('config_tax')));
                             $product_option_combos[$key]['extax'] = $this->currency->format($product_option_combo['price']);
                             $product_option_combos[$key]['total_extax'] = $this->currency->format($product_option_combo['total_price']);
                             if ($product_option_combos[$key]['points_prefix'] == '+') {
                                 $product_option_combo['points'] += $product_info['reward'];
                             } else {
                                 if ($product_option_combos[$key]['points_prefix'] == '-') {
                                     $product_option_combo['points'] = $product_info['reward'] - $product_option_combo['points'];
                                 } else {
                                     if ($product_option_combos[$key]['points_prefix'] == '0') {
                                         $product_option_combo['points'] = $product_info['reward'];
                                     }
                                 }
                             }
                             $product_option_combo['total_points'] = $product_option_combo['points'];
                             if ($product_option_combos[$key]['quantity'] > 0) {
                                 $product_option_combo['total_points'] = $product_option_combo['points'] * $product_option_combos[$key]['quantity'];
                             }
                             $product_option_combos[$key]['points'] = $product_option_combo['points'];
                             $product_option_combos[$key]['total_points'] = $product_option_combo['total_points'];
                             $table_split_option_combos[$temp_keys[0]][] = $product_option_combos[$key];
                             $table_split_options += $combo_option_value;
                         }
                     }
                 }
                 $option_values = $this->model_catalog_product->getOptionValues($option_combo_setting['table_split']);
                 $table_split_option_combos_sorted = array();
                 $table_split_options_sorted = array();
                 foreach ($option_values as $option_value) {
                     if (isset($table_split_option_combos[$option_value['option_value_id']]) && isset($table_split_options[$option_value['option_value_id']])) {
                         $table_split_option_combos_sorted[$option_value['option_value_id']] = $table_split_option_combos[$option_value['option_value_id']];
                         $table_split_options_sorted[$option_value['option_value_id']] = $table_split_options[$option_value['option_value_id']];
                     }
                 }
                 $this->data['table_split_option_combos'] = $table_split_option_combos_sorted;
                 $this->data['table_split_options'] = $table_split_options_sorted;
             } else {
                 foreach ($product_option_combos as $key => $product_option_combo) {
                     $this->data['product_option_combos'][$key] = $product_option_combo;
                     if ($this->data['product_option_combos'][$key]['price_prefix'] == '+') {
                         $product_option_combo['price'] += $product_info['price'];
                     } else {
                         if ($this->data['product_option_combos'][$key]['price_prefix'] == '-') {
                             $product_option_combo['price'] = $product_info['price'] - $product_option_combo['price'];
                         } else {
                             if ($this->data['product_option_combos'][$key]['price_prefix'] == '0') {
                                 $product_option_combo['price'] = $product_info['price'] + $product_option_combo['option_price_total'];
                             }
                         }
                     }
                     $product_option_combo['total_price'] = $product_option_combo['price'];
                     if ($product_option_combo['quantity'] > 0) {
                         $product_option_combo['total_price'] = $product_option_combo['price'] * $product_option_combo['quantity'];
                     }
                     $this->data['product_option_combos'][$key]['price'] = $this->currency->format($this->tax->calculate($product_option_combo['price'], $product_info['tax_class_id'], $this->config->get('config_tax')));
                     $this->data['product_option_combos'][$key]['total_price'] = $this->currency->format($this->tax->calculate($product_option_combo['total_price'], $product_info['tax_class_id'], $this->config->get('config_tax')));
                     $this->data['product_option_combos'][$key]['extax'] = $this->currency->format($product_option_combo['price']);
                     $this->data['product_option_combos'][$key]['total_extax'] = $this->currency->format($product_option_combo['total_price']);
                     if ($this->data['product_option_combos'][$key]['points_prefix'] == '+') {
                         $product_option_combo['points'] += $product_info['reward'];
                     } else {
                         if ($this->data['product_option_combos'][$key]['points_prefix'] == '-') {
                             $product_option_combo['points'] = $product_info['reward'] - $product_option_combo['points'];
                         } else {
                             if ($this->data['product_option_combos'][$key]['points_prefix'] == '0') {
                                 $product_option_combo['points'] = $product_info['reward'];
                             }
                         }
                     }
                     $product_option_combo['total_points'] = $product_option_combo['points'];
                     if ($product_option_combo['quantity'] > 0) {
                         $product_option_combo['total_points'] = $product_option_combo['points'] * $product_option_combo['quantity'];
                     }
                     $this->data['product_option_combos'][$key]['points'] = $product_option_combo['points'];
                     $this->data['product_option_combos'][$key]['total_points'] = $product_option_combo['total_points'];
                 }
             }
             $this->data['product_option_combo_headers'] = $product_option_combo_headers;
         }
         if ($product_info['minimum']) {
             $this->data['minimum'] = $product_info['minimum'];
         } else {
             $this->data['minimum'] = 1;
         }
         $this->data['review_status'] = $this->config->get('config_review_status');
         $this->data['reviews'] = sprintf($this->language->get('text_reviews'), (int) $product_info['reviews']);
         $this->data['rating'] = (int) $product_info['rating'];
         $this->data['description'] = '<h2 style="display:none;">' . $product_info['name'] . '</h2>' . html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8');
         $autolinks = $this->config->get('autolinks');
         if (isset($autolinks) && strpos($this->data['description'], 'iframe') == false && strpos($this->data['description'], 'object') == false) {
             $xdescription = mb_convert_encoding(html_entity_decode($this->data['description'], ENT_COMPAT, "UTF-8"), 'HTML-ENTITIES', "UTF-8");
             libxml_use_internal_errors(true);
             $dom = new DOMDocument();
             $dom->loadHTML('<div>' . $xdescription . '</div>');
             libxml_use_internal_errors(false);
             $xpath = new DOMXPath($dom);
             foreach ($autolinks as $autolink) {
                 $keyword = $autolink['keyword'];
                 $xlink = mb_convert_encoding(html_entity_decode($autolink['link'], ENT_COMPAT, "UTF-8"), 'HTML-ENTITIES', "UTF-8");
                 $target = $autolink['target'];
                 $tooltip = isset($autolink['tooltip']);
                 $pTexts = $xpath->query(sprintf('///text()[contains(., "%s")]', $keyword));
                 foreach ($pTexts as $pText) {
                     $this->parseText($pText, $keyword, $dom, $xlink, $target, $tooltip);
                 }
             }
             $this->data['description'] = $dom->saveXML($dom->documentElement);
         }
         $this->data['attribute_groups'] = $this->model_catalog_product->getProductAttributes($this->request->get['product_id']);
         $this->data['products'] = array();
         $results = $this->model_catalog_product->getProductRelated($this->request->get['product_id']);
         foreach ($results as $result) {
             if ($result['image']) {
                 $image = $this->model_tool_image->resize($result['image'], $this->config->get('config_image_related_width'), $this->config->get('config_image_related_height'));
             } else {
                 $image = false;
             }
             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'], TRUE));
             } else {
                 $price = false;
             }
             if ((double) $result['special']) {
                 $special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], TRUE));
             } else {
                 $special = false;
             }
             if ($this->config->get('config_review_status')) {
                 $rating = (int) $result['rating'];
             } else {
                 $rating = false;
             }
             // if the logged customer is B2B or Gallery + B2B
             //$B2B = false;
             if ($this->customer->getCustomerGroupId() == 3 || $this->customer->getCustomerGroupId() == 4) {
                 //$B2B = true;
                 $this->data['button_view_product'] = $this->language->get('button_view_product');
             }
             //$this->data['B2B'] = $B2B;
             $date_end = false;
             if ($this->config->get('config_template') === 'journal2' && $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['products'][] = array('product_id' => $result['product_id'], 'thumb' => $image, 'thumb2' => $image2, 'labels' => $result['product_id'] ? $this->model_journal2_product->getLabels($result['product_id']) : "", 'name' => $result['name'], 'price' => $B2B ? '' : $price, 'special' => $special, 'date_end' => $date_end, '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['products_complementary'] = array();
         $complementary_products = $this->model_catalog_product->getProductComplementary($this->request->get['product_id']);
         foreach ($complementary_products as $complementary_product) {
             if ($complementary_product['image']) {
                 $image = $this->model_tool_image->resize($complementary_product['image'], $this->config->get('config_image_related_width'), $this->config->get('config_image_related_height'));
             } else {
                 $image = false;
             }
             if ($this->config->get('config_customer_price') && $this->customer->isLogged() || !$this->config->get('config_customer_price')) {
                 $price = $this->currency->format($this->tax->calculate($complementary_product['price'], $complementary_product['tax_class_id'], TRUE));
             } else {
                 $price = false;
             }
             if ((double) $complementary_product['special']) {
                 $special = $this->currency->format($this->tax->calculate($complementary_product['special'], $complementary_product['tax_class_id'], TRUE));
             } else {
                 $special = false;
             }
             if ($this->config->get('config_review_status')) {
                 $rating = (int) $complementary_product['rating'];
             } else {
                 $rating = false;
             }
             // if the logged customer is B2B or Gallery + B2B
             //$B2B = false;
             if ($this->customer->getCustomerGroupId() == 3 || $this->customer->getCustomerGroupId() == 4) {
                 //$B2B = true;
                 $this->data['button_view_product'] = $this->language->get('button_view_product');
             }
             //$this->data['B2B'] = $B2B;
             $this->data['products_complementary'][] = array('product_id' => $complementary_product['product_id'], 'thumb' => $image, 'thumb2' => $image2, 'labels' => $result['product_id'] ? $this->model_journal2_product->getLabels($result['product_id']) : "", 'name' => $complementary_product['name'], 'price' => $B2B ? '' : $price, 'special' => $special, 'date_end' => $date_end, 'rating' => $rating, 'reviews' => sprintf($this->language->get('text_reviews'), (int) $complementary_product['reviews']), 'href' => $this->url->link('product/product', 'product_id=' . $complementary_product['product_id']));
         }
         $this->data['tags'] = array();
         if ($product_info['tag']) {
             $tags = explode(',', $product_info['tag']);
             foreach ($tags as $tag) {
                 $this->data['tags'][] = array('tag' => trim($tag), 'href' => $this->url->link('product/search', 'tag=' . trim($tag)));
             }
         }
         $this->data['text_payment_profile'] = $this->language->get('text_payment_profile');
         $this->data['profiles'] = $this->model_catalog_product->getProfiles($product_info['product_id']);
         $this->model_catalog_product->updateViewed($this->request->get['product_id']);
         $product_size_chart = $this->model_catalog_product->getProductSizeChart($this->request->get['product_id']);
         $this->data['product_size_chart'] = $product_size_chart;
         if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/product.tpl')) {
             $this->template = $this->config->get('config_template') . '/template/product/product.tpl';
         } else {
             $this->template = 'default/template/product/product.tpl';
         }
         $this->children = array('common/dream_column_header_top', 'common/dream_column_header_bottom', 'common/dream_column_footer_top', 'common/dream_column_footer_bottom', 'common/column_left', 'common/column_right', 'common/content_top', 'common/content_bottom', 'common/footer', 'common/header');
         $this->response->setOutput($this->render());
     } else {
         $url = '';
         if (isset($this->request->get['path'])) {
             $url .= '&path=' . $this->request->get['path'];
         }
         if (isset($this->request->get['filter'])) {
             $url .= '&filter=' . $this->request->get['filter'];
         }
         if (isset($this->request->get['manufacturer_id'])) {
             $url .= '&manufacturer_id=' . $this->request->get['manufacturer_id'];
         }
         if (isset($this->request->get['search'])) {
             $url .= '&search=' . $this->request->get['search'];
         }
         if (isset($this->request->get['tag'])) {
             $url .= '&tag=' . $this->request->get['tag'];
         }
         if (isset($this->request->get['description'])) {
             $url .= '&description=' . $this->request->get['description'];
         }
         if (isset($this->request->get['category_id'])) {
             $url .= '&category_id=' . $this->request->get['category_id'];
         }
         if (isset($this->request->get['sub_category'])) {
             $url .= '&sub_category=' . $this->request->get['sub_category'];
         }
         if (isset($this->request->get['sort'])) {
             $url .= '&sort=' . $this->request->get['sort'];
         }
         if (isset($this->request->get['order'])) {
             $url .= '&order=' . $this->request->get['order'];
         }
         if (isset($this->request->get['page'])) {
             $url .= '&page=' . $this->request->get['page'];
         }
         if (isset($this->request->get['limit'])) {
             $url .= '&limit=' . $this->request->get['limit'];
         }
         $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_error'), 'href' => $this->url->link('product/product', $url . '&product_id=' . $product_id), 'separator' => $this->language->get('text_separator'));
         $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');
         if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/not_found.tpl')) {
             $this->template = $this->config->get('config_template') . '/template/error/not_found.tpl';
         } else {
             $this->template = 'default/template/error/not_found.tpl';
         }
         $this->children = array('common/dream_column_header_top', 'common/dream_column_header_bottom', 'common/dream_column_footer_top', 'common/dream_column_footer_bottom', 'common/column_left', 'common/column_right', 'common/content_top', 'common/content_bottom', 'common/footer', 'common/header');
         $this->response->setOutput($this->render());
     }
 }
예제 #14
0
 private function processFooter()
 {
     /* copyright text */
     $copyright = $this->journal2->settings->get('config_copyright', array());
     $copyright_text = Journal2Utils::getProperty($copyright, 'value.' . $this->config->get('config_language_id'));
     $this->journal2->settings->set('config_copyright', $copyright_text);
     /* payment methods */
     $payments = $this->journal2->settings->get('config_payments.payments', array());
     $payments = Journal2Utils::sortArray($payments);
     $payment_methods = array();
     $width = '';
     $height = '';
     foreach ($payments as $payment) {
         $image = Journal2Utils::getProperty($payment, 'image');
         if (!$image || !file_exists(DIR_IMAGE . $image)) {
             $image = Front::$IS_OC2 ? 'no_image.png' : 'no_image.jpg';
         }
         list($width, $height) = getimagesize(DIR_IMAGE . $image);
         $payment_methods[] = array('image' => Journal2Utils::resizeImage($this->model_tool_image, $image), 'name' => Journal2Utils::getProperty($payment, 'name.value.' . $this->config->get('config_language_id')), 'url' => Journal2Utils::getProperty($payment, 'link.value.text'), 'target' => Journal2Utils::getProperty($payment, 'new_window') ? ' target="_blank"' : '', 'width' => $width, 'height' => $height);
     }
     $this->journal2->settings->set('config_payments', $payment_methods);
     if ($payment_methods) {
         $this->journal2->settings->set('config_payments_dummy', $this->model_tool_image->resize('data/journal2/transparent.png', $width, $height));
     }
     /* custom classes */
     $classes = array();
     if (!$copyright_text) {
         $classes[] = 'no-copyright';
     }
     if (!$payment_methods) {
         $classes[] = 'no-payments';
     }
     $this->journal2->settings->set('config_footer_classes', implode(' ', $classes));
 }
 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'];
     $cache_property = "module_journal_side_products_{$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) {
         $products = array();
         $limit = Journal2Utils::getProperty($module_data, 'items_limit', 5);
         $this->data['image_width'] = $this->journal2->settings->get('side_product_image_width', 50);
         $this->data['image_height'] = $this->journal2->settings->get('side_product_image_height', 50);
         $this->data['image_resize_type'] = $this->journal2->settings->get('side_product_image_type', 'crop');
         $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');
         $product_id = Journal2Utils::getProperty($this->request->get, 'product_id');
         $post_id = Journal2Utils::getProperty($this->request->get, 'journal_blog_post_id');
         switch (Journal2Utils::getProperty($module_data, 'section_type')) {
             case 'module':
                 switch (Journal2Utils::getProperty($module_data, 'module_type')) {
                     case 'featured':
                         $products = $this->model_journal2_product->getFeatured($limit, Journal2Utils::getProperty($module_data, 'featured_module_id'), Journal2Utils::getProperty($module_data, 'filter_category', 0) !== null);
                         break;
                     case 'bestsellers':
                         $products = $this->model_journal2_product->getBestsellers($limit, Journal2Utils::getProperty($module_data, 'filter_category', 0) !== null);
                         break;
                     case 'specials':
                         $products = $this->model_journal2_product->getSpecials($limit, Journal2Utils::getProperty($module_data, 'filter_category', 0) !== null);
                         break;
                     case 'latest':
                         $products = $this->model_journal2_product->getLatest($limit, Journal2Utils::getProperty($module_data, 'filter_category', 0) !== null);
                         break;
                     case 'related':
                         if ($product_id) {
                             $products = $this->model_journal2_product->getProductRelated($product_id, $limit);
                         } else {
                             if ($post_id) {
                                 $products = $this->model_journal2_blog->getRelatedProducts($post_id, $limit);
                             } else {
                                 $products = array();
                             }
                         }
                         break;
                     case 'people-also-bought':
                         $products = $this->model_journal2_product->getPeopleAlsoBought($product_id);
                         break;
                     case 'most-viewed':
                         $products = $this->model_journal2_product->getMostViewed($limit);
                         $this->has_random_products = true;
                         break;
                     case 'recently-viewed':
                         $products = $this->model_journal2_product->getRecentlyViewed($limit);
                         $this->has_random_products = true;
                         break;
                 }
                 break;
             case 'category':
                 $category_info = $this->model_catalog_category->getCategory(Journal2Utils::getProperty($module_data, 'category.data.id'));
                 if (!$category_info) {
                     continue;
                 }
                 $products = $this->model_journal2_product->getProductsByCategory($category_info['category_id'], $limit);
                 break;
             case 'manufacturer':
                 $manufacturer = $this->model_catalog_manufacturer->getManufacturer(Journal2Utils::getProperty($module_data, 'manufacturer.data.id'));
                 if (!$manufacturer) {
                     continue;
                 }
                 $products = $this->model_journal2_product->getProductsByManufacturer($manufacturer['manufacturer_id'], $limit);
                 break;
             case 'custom':
                 foreach (Journal2Utils::sortArray(Journal2Utils::getProperty($module_data, 'products', array())) as $product) {
                     $result = $this->model_catalog_product->getProduct((int) Journal2Utils::getProperty($product, 'data.id'));
                     if (!$result) {
                         continue;
                     }
                     $products[] = $result;
                 }
                 break;
             case 'random':
                 $this->has_random_products = true;
                 $random_type = Journal2Utils::getProperty($module_data, 'random_from', 'all');
                 $category_id = $random_type === 'category' ? Journal2Utils::getProperty($module_data, 'random_from_category.id', -1) : -1;
                 $random_products = $this->model_journal2_product->getRandomProducts($limit, $category_id);
                 foreach ($random_products as $product) {
                     $result = $this->model_catalog_product->getProduct($product['product_id']);
                     if (!$result) {
                         continue;
                     }
                     $products[] = $result;
                 }
                 break;
         }
         if (!count($products)) {
             return;
         }
         $products_data = array();
         foreach ($products as $product) {
             $image = Journal2Utils::resizeImage($this->model_tool_image, $product['image'] ? $product['image'] : 'data/journal2/no_image_large.jpg', $this->data['image_width'], $this->data['image_height'], $this->data['image_resize_type']);
             if ($this->config->get('config_customer_price') && $this->customer->isLogged() || !$this->config->get('config_customer_price')) {
                 $price = $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax')));
             } else {
                 $price = false;
             }
             if ((double) $product['special']) {
                 $special = $this->currency->format($this->tax->calculate($product['special'], $product['tax_class_id'], $this->config->get('config_tax')));
             } else {
                 $special = false;
             }
             if ($this->config->get('config_tax')) {
                 $tax = $this->currency->format((double) $product['special'] ? $product['special'] : $product['price']);
             } else {
                 $tax = false;
             }
             if ($this->config->get('config_review_status')) {
                 $rating = $product['rating'];
             } else {
                 $rating = false;
             }
             $product_sections = isset($this->data['items'][$product['product_id']]) ? $this->data['items'][$product['product_id']]['section_class'] : array();
             $results = $this->model_catalog_product->getProductImages($product['product_id']);
             $products_data[] = array('product_id' => $product['product_id'], 'section_class' => $product_sections, 'thumb' => $image, 'name' => $product['name'], 'price' => $price, 'special' => $special, 'rating' => $rating, 'description' => utf8_substr(strip_tags(html_entity_decode($product['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..', 'tax' => $tax, 'reviews' => sprintf($this->language->get('text_reviews'), (int) $product['reviews']), 'href' => $this->url->link('product/product', 'product_id=' . $product['product_id']), 'labels' => $this->model_journal2_product->getLabels($product['product_id']));
         }
         $this->data['heading_title'] = Journal2Utils::getProperty($module_data, 'section_title.value.' . $this->config->get('config_language_id'));
         $this->data['products'] = $products_data;
         $this->template = $this->config->get('config_template') . "/template/journal2/module/side_products.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;
     }
     $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;
     }
     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 add()
 {
     $this->language->load('account/wishlist');
     $json = array();
     if (!isset($this->session->data['wishlist'])) {
         $this->session->data['wishlist'] = array();
     }
     if (isset($this->request->post['product_id'])) {
         $product_id = $this->request->post['product_id'];
     } else {
         $product_id = 0;
     }
     $this->load->model('catalog/product');
     $this->load->model('journal2/product');
     $product_info = $this->model_catalog_product->getProduct($product_id);
     if ($product_info) {
         if (!in_array($this->request->post['product_id'], $this->session->data['wishlist'])) {
             $this->session->data['wishlist'][] = $this->request->post['product_id'];
         }
         if ($this->customer->isLogged()) {
             if (strpos($this->config->get('config_template'), 'journal2') === 0) {
                 $this->load->model('tool/image');
                 $json['image'] = Journal2Utils::resizeImage($this->model_tool_image, $product_info['image'], $this->config->get('config_image_cart_width'), $this->config->get('config_image_cart_height'));
             }
             $json['success'] = sprintf($this->language->get('text_success'), $this->url->link('product/product', 'product_id=' . $this->request->post['product_id']), $product_info['name'], $this->url->link('account/wishlist'));
         } else {
             if (strpos($this->config->get('config_template'), 'journal2') === 0) {
                 $this->load->model('tool/image');
                 $json['image'] = Journal2Utils::resizeImage($this->model_tool_image, $product_info['image'], $this->config->get('config_image_cart_width'), $this->config->get('config_image_cart_height'));
             }
             $json['success'] = sprintf($this->language->get('text_login'), $this->url->link('account/login', '', 'SSL'), $this->url->link('account/register', '', 'SSL'), $this->url->link('product/product', 'product_id=' . $this->request->post['product_id']), $product_info['name'], $this->url->link('account/wishlist'));
         }
         $json['total'] = sprintf($this->language->get('text_wishlist'), isset($this->session->data['wishlist']) ? count($this->session->data['wishlist']) : 0);
     }
     $this->response->setOutput(json_encode($json));
 }
예제 #18
0
 public function add()
 {
     $this->load->language('checkout/cart');
     $json = array();
     if (isset($this->request->post['product_id'])) {
         $product_id = (int) $this->request->post['product_id'];
     } else {
         $product_id = 0;
     }
     $this->load->model('catalog/product');
     $product_info = $this->model_catalog_product->getProduct($product_id);
     if ($product_info) {
         if (isset($this->request->post['quantity']) && (int) $this->request->post['quantity'] >= $product_info['minimum']) {
             $quantity = (int) $this->request->post['quantity'];
         } else {
             $quantity = $product_info['minimum'] ? $product_info['minimum'] : 1;
         }
         if (isset($this->request->post['option'])) {
             $option = array_filter($this->request->post['option']);
         } else {
             $option = array();
         }
         $product_options = $this->model_catalog_product->getProductOptions($this->request->post['product_id']);
         foreach ($product_options as $product_option) {
             if ($product_option['required'] && empty($option[$product_option['product_option_id']])) {
                 $json['error']['option'][$product_option['product_option_id']] = sprintf($this->language->get('error_required'), $product_option['name']);
             }
         }
         if (isset($this->request->post['recurring_id'])) {
             $recurring_id = $this->request->post['recurring_id'];
         } else {
             $recurring_id = 0;
         }
         $recurrings = $this->model_catalog_product->getProfiles($product_info['product_id']);
         if ($recurrings) {
             $recurring_ids = array();
             foreach ($recurrings as $recurring) {
                 $recurring_ids[] = $recurring['recurring_id'];
             }
             if (!in_array($recurring_id, $recurring_ids)) {
                 $json['error']['recurring'] = $this->language->get('error_recurring_required');
             }
         }
         if (!$json) {
             $this->cart->add($this->request->post['product_id'], $quantity, $option, $recurring_id);
             // added by KC - for Flash Sales purpose
             if ($product_info['ontime_close']) {
                 $this->model_catalog_product->updateQtyBeZero($product_info['product_id']);
             }
             if (strpos($this->config->get('config_template'), 'journal2') === 0) {
                 $this->load->model('tool/image');
                 $json['image'] = Journal2Utils::resizeImage($this->model_tool_image, $product_info['image'], $this->config->get('config_image_cart_width'), $this->config->get('config_image_cart_height'));
             }
             $json['success'] = sprintf($this->language->get('text_success'), $this->url->link('product/product', 'product_id=' . $this->request->post['product_id']), $product_info['name'], $this->url->link('checkout/cart'));
             unset($this->session->data['shipping_method']);
             unset($this->session->data['shipping_methods']);
             unset($this->session->data['payment_method']);
             unset($this->session->data['payment_methods']);
             // Totals
             $this->load->model('extension/extension');
             $total_data = array();
             $total = 0;
             $taxes = $this->cart->getTaxes();
             // Display prices
             if ($this->config->get('config_customer_price') && $this->customer->isLogged() || !$this->config->get('config_customer_price')) {
                 $sort_order = array();
                 $results = $this->model_extension_extension->getExtensions('total');
                 foreach ($results as $key => $value) {
                     $sort_order[$key] = $this->config->get($value['code'] . '_sort_order');
                 }
                 array_multisort($sort_order, SORT_ASC, $results);
                 foreach ($results as $result) {
                     if ($this->config->get($result['code'] . '_status')) {
                         $this->load->model('total/' . $result['code']);
                         $this->{'model_total_' . $result['code']}->getTotal($total_data, $total, $taxes);
                     }
                 }
                 $sort_order = array();
                 foreach ($total_data as $key => $value) {
                     $sort_order[$key] = $value['sort_order'];
                 }
                 array_multisort($sort_order, SORT_ASC, $total_data);
             }
             $json['total'] = sprintf($this->language->get('text_items'), $this->cart->countProducts() + (isset($this->session->data['vouchers']) ? count($this->session->data['vouchers']) : 0), $this->currency->format($total));
         } else {
             $json['redirect'] = str_replace('&amp;', '&', $this->url->link('product/product', 'product_id=' . $this->request->post['product_id']));
         }
     }
     $this->response->addHeader('Content-Type: application/json');
     $this->response->setOutput(json_encode($json));
 }
예제 #19
0
 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'];
     if (Journal2Utils::getProperty($module_data, 'hideonmobile') && Journal2Cache::$mobile_detect->isMobile() && !Journal2Cache::$mobile_detect->isTablet() && $this->journal2->settings->get('responsive_design')) {
         return;
     }
     /* hide on desktop */
     if (Journal2Utils::getProperty($module_data, 'disable_desktop') && !Journal2Cache::$mobile_detect->isMobile()) {
         return;
     }
     /* 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_slider_' . $setting['module_id'], implode('; ', $css));
     }
     $this->journal2->html_classes->removeClass('backface');
     $cache_property = "module_journal_slider_{$setting['module_id']}_{$setting['layout_id']}_{$setting['position']}";
     $cache = $this->journal2->cache->get($cache_property);
     if ($cache === null || self::$CACHEABLE !== true) {
         $module = mt_rand();
         $caption_id = 0;
         /* slider position */
         $height = Journal2Utils::getProperty($module_data, 'height', 400);
         $width = null;
         switch ($setting['position']) {
             case 'column_left':
             case 'column_right':
                 $width = 220;
                 $this->data['width'] = "max-width: {$width}px";
                 $this->data['slider_class'] = 'journal-slider';
                 break;
             case 'content_top':
             case 'content_bottom':
                 if ($this->journal2->settings->get('extended_layout')) {
                     $width = $this->journal2->settings->get('site_width', 1024) - 240 * $this->journal2->settings->get('config_columns_count');
                 } else {
                     $width = $this->journal2->settings->get('site_width', 1024) - 40 - 240 * $this->journal2->settings->get('config_columns_count');
                 }
                 $this->data['width'] = "max-width: {$width}px";
                 $this->data['slider_class'] = 'journal-slider';
                 break;
             case 'top':
             case 'bottom':
                 $width = $this->journal2->settings->get('site_width', 1024);
                 if (Journal2Utils::getProperty($module_data, 'fullwidth')) {
                     $this->data['width'] = "max-width: 100%";
                     $this->data['slider_class'] = 'journal-fullwidth-slider';
                 } else {
                     $this->data['width'] = "max-width: {$width}px";
                     $this->data['slider_class'] = 'journal-slider';
                 }
                 break;
             case 'multi_module':
                 $width = $setting['width'];
                 $height = $setting['height'];
                 $this->data['width'] = "max-width: {$width}px";
                 $this->data['slider_class'] = 'journal-slider';
                 break;
         }
         /* global style data */
         $this->data['global_style'] = array();
         $this->data['js_options'] = Journal2Utils::getProperty($module_data, 'js_options', array());
         $this->data['js_options']['startwidth'] = $width;
         $this->data['js_options']['startheight'] = $height;
         $this->data['height'] = $height;
         if (Journal2Utils::getProperty($module_data, 'hidecaptionsonmobile')) {
             $this->data['js_options']['hideAllCaptionAtLimit'] = 760;
         }
         $slides = Journal2Utils::getProperty($module_data, 'slides', array());
         $slides = Journal2Utils::sortArray($slides);
         $_slides = array();
         $first = true;
         foreach ($slides as $slide) {
             if (isset($slide['status']) && !$slide['status']) {
                 continue;
             }
             $slide_data = array();
             if ($first) {
                 $slide_data[] = 'data-fstransition="fade"';
                 $slide_data[] = 'data-fsslotamount="0"';
                 $slide_data[] = 'data-fsmasterspeed="0"';
                 $first = false;
             }
             $slide_data[] = 'data-transition="' . Journal2Utils::getProperty($slide, 'transition', 'fade') . '"';
             $slide_data[] = 'data-easing="' . Journal2Utils::getProperty($slide, 'easing', 'Expo.easeOut') . '"';
             $slide_data[] = 'data-masterspeed="' . Journal2Utils::getProperty($slide, 'masterspeed', 800) . '"';
             if (Journal2Utils::getProperty($slide, 'slotamount')) {
                 $slide_data[] = 'data-slotamount="' . Journal2Utils::getProperty($slide, 'slotamount') . '"';
             }
             if (Journal2Utils::getProperty($slide, 'delay')) {
                 $slide_data[] = 'data-delay="' . Journal2Utils::getProperty($slide, 'delay') . '"';
             }
             $link = $this->model_journal2_menu->getLink(Journal2Utils::getProperty($slide, 'link'));
             if ($link) {
                 $slide_data[] = 'data-link="' . $link . '"';
                 if (Journal2Utils::getProperty($slide, 'link_new_window')) {
                     $slide_data[] = 'data-target="_blank"';
                 }
             }
             $captions = Journal2Utils::getProperty($slide, 'captions', array());
             $captions = Journal2Utils::sortArray($captions);
             $_captions = array();
             foreach ($captions as $caption) {
                 if (isset($caption['status']) && !$caption['status']) {
                     continue;
                 }
                 $caption_id++;
                 $caption_data = array();
                 $caption_classes = array();
                 if (Journal2Utils::getProperty($caption, 'x', '1')) {
                     $caption_data[] = 'data-x="' . Journal2Utils::getProperty($caption, 'x', '1') . '"';
                 }
                 if (Journal2Utils::getProperty($caption, 'y', '1')) {
                     $caption_data[] = 'data-y="' . Journal2Utils::getProperty($caption, 'y', '1') . '"';
                 }
                 if (Journal2Utils::getProperty($caption, 'speed')) {
                     $caption_data[] = 'data-speed="' . Journal2Utils::getProperty($caption, 'speed') . '"';
                 }
                 if (Journal2Utils::getProperty($caption, 'start')) {
                     $caption_data[] = 'data-start="' . Journal2Utils::getProperty($caption, 'start') . '"';
                 }
                 if (Journal2Utils::getProperty($caption, 'endspeed')) {
                     $caption_data[] = 'data-endspeed="' . Journal2Utils::getProperty($caption, 'endspeed') . '"';
                 }
                 if (Journal2Utils::getProperty($caption, 'end')) {
                     $caption_data[] = 'data-end="' . Journal2Utils::getProperty($caption, 'end') . '"';
                 }
                 $caption_data[] = 'data-easing="' . Journal2Utils::getProperty($caption, 'easing', 'Expo.easeOut') . '"';
                 $caption_data[] = 'data-endeasing="' . Journal2Utils::getProperty($caption, 'endeasing', 'Expo.easeOut') . '"';
                 $content = '';
                 $css = array();
                 switch (Journal2Utils::getProperty($caption, 'type')) {
                     case 'image':
                         $image = Journal2Utils::getProperty($caption, 'image', 'no_image.jpg');
                         if (is_array($image)) {
                             $image = Journal2Utils::getProperty($image, $this->config->get('config_language_id'));
                         }
                         if (!$image || !file_exists(DIR_IMAGE . $image)) {
                             $image = 'no_image.jpg';
                         }
                         $image = Journal2Utils::resizeImage($this->model_tool_image, $image);
                         $alt = Journal2Utils::getProperty($caption, 'caption_name');
                         $content = '<img src="' . $image . '" alt="' . $alt . '" />';
                         break;
                     case 'text':
                         if (Journal2Utils::getProperty($caption, 'text_font.value.font_type') === 'google') {
                             $font_name = Journal2Utils::getProperty($caption, 'text_font.value.font_name');
                             $font_subset = Journal2Utils::getProperty($caption, 'text_font.value.font_subset');
                             $font_weight = Journal2Utils::getProperty($caption, 'text_font.value.font_weight');
                             $this->journal2->google_fonts->add($font_name, $font_subset, $font_weight);
                             $this->google_fonts[] = array('name' => $font_name, 'subset' => $font_subset, 'weight' => $font_weight);
                             $weight = filter_var(Journal2Utils::getProperty($caption, 'text_font.value.font_weight'), FILTER_SANITIZE_NUMBER_INT);
                             $css[] = 'font-weight: ' . ($weight ? $weight : 400);
                             $css[] = "font-family: '" . Journal2Utils::getProperty($caption, 'text_font.value.font_name') . "'";
                         }
                         if (Journal2Utils::getProperty($caption, 'text_font.value.font_type') === 'system') {
                             $css[] = 'font-weight: ' . Journal2Utils::getProperty($caption, 'text_font.value.font_weight');
                             $css[] = 'font-family: ' . Journal2Utils::getProperty($caption, 'text_font.value.font_family');
                         }
                         if (Journal2Utils::getProperty($caption, 'text_font.value.font_type') !== 'none') {
                             $css[] = 'font-size: ' . Journal2Utils::getProperty($caption, 'text_font.value.font_size');
                             $css[] = 'font-style: ' . Journal2Utils::getProperty($caption, 'text_font.value.font_style');
                             $css[] = 'text-transform: ' . Journal2Utils::getProperty($caption, 'text_font.value.text_transform');
                         }
                         if (Journal2Utils::getProperty($caption, 'text_font.value.color.value.color')) {
                             $css[] = 'color: ' . Journal2Utils::getColor(Journal2Utils::getProperty($caption, 'text_font.value.color.value.color'));
                         }
                         $css[] = 'text-align: ' . Journal2Utils::getProperty($caption, 'text_align', 'center');
                         if (Journal2Utils::getProperty($caption, 'text_bgcolor.value.color')) {
                             $css[] = 'background-color: ' . Journal2Utils::getColor(Journal2Utils::getProperty($caption, 'text_bgcolor.value.color'));
                         }
                         if (Journal2Utils::getProperty($caption, 'text_hover_color.value.color')) {
                             $this->data['global_style'][] = "#jcaption-{$module}-{$caption_id}:hover { color: " . Journal2Utils::getColor(Journal2Utils::getProperty($caption, 'text_hover_color.value.color')) . " !important; }";
                         }
                         if (Journal2Utils::getProperty($caption, 'text_hover_bg_color.value.color')) {
                             $this->data['global_style'][] = "#jcaption-{$module}-{$caption_id}:hover { background-color: " . Journal2Utils::getColor(Journal2Utils::getProperty($caption, 'text_hover_bg_color.value.color')) . " !important; }";
                         }
                         if (Journal2Utils::getProperty($caption, 'text_border')) {
                             $css = array_merge($css, Journal2Utils::getBorderCssProperties(Journal2Utils::getProperty($caption, 'text_border')));
                         }
                         if (Journal2Utils::getProperty($caption, 'text_hover_border_color.value.color')) {
                             $this->data['global_style'][] = "#jcaption-{$module}-{$caption_id}:hover { border-color: " . Journal2Utils::getColor(Journal2Utils::getProperty($caption, 'text_hover_border_color.value.color')) . " !important; }";
                         }
                         if (Journal2Utils::getProperty($caption, 'text_padding_top') !== null) {
                             $css[] = 'padding-top: ' . Journal2Utils::getProperty($caption, 'text_padding_top') . 'px';
                         }
                         if (Journal2Utils::getProperty($caption, 'text_padding_right') !== null) {
                             $css[] = 'padding-right: ' . Journal2Utils::getProperty($caption, 'text_padding_right') . 'px';
                         }
                         if (Journal2Utils::getProperty($caption, 'text_padding_bottom') !== null) {
                             $css[] = 'padding-bottom: ' . Journal2Utils::getProperty($caption, 'text_padding_bottom') . 'px';
                         }
                         if (Journal2Utils::getProperty($caption, 'text_padding_left') !== null) {
                             $css[] = 'padding-left: ' . Journal2Utils::getProperty($caption, 'text_padding_left') . 'px';
                         }
                         if (Journal2Utils::getProperty($caption, 'text_line_height')) {
                             $css[] = 'line-height: ' . Journal2Utils::getProperty($caption, 'text_line_height') . 'px';
                         }
                         $content = Journal2Utils::getProperty($caption, 'text.value.' . $this->config->get('config_language_id'));
                         break;
                     case 'video':
                         if (Journal2Utils::getProperty($caption, 'video_fullwidth')) {
                             $caption_classes[] = 'fullscreenvideo';
                             $caption_data[] = 'data-forceCover="1"';
                             $width = '100%';
                             $height = '100%';
                         } else {
                             $width = Journal2Utils::getProperty($caption, 'video_width', 100);
                             $height = Journal2Utils::getProperty($caption, 'video_height', 100);
                         }
                         switch (Journal2Utils::getProperty($caption, 'video_type')) {
                             case 'youtube':
                                 $video_id = Journal2Utils::getProperty($caption, 'video_yt_id');
                                 if (!$video_id) {
                                     continue;
                                 }
                                 $content = '<iframe src="//www.youtube.com/embed/' . $video_id . '?enablejsapi=1&html5=1&amp;hd=1&amp;wmode=opaque&amp;controls=1&amp;showinfo=0;rel=0;" width="' . $width . '" height="' . $height . '"></iframe>';
                                 break;
                             case 'vimeo':
                                 $video_id = Journal2Utils::getProperty($caption, 'video_vm_id');
                                 if (!$video_id) {
                                     continue;
                                 }
                                 $content = '<iframe src="//player.vimeo.com/video/' . $video_id . '?title=0&amp;byline=0&amp;portrait=0;api=1" width="' . $width . '" height="' . $height . '"></iframe>';
                                 break;
                             case 'local':
                                 $file_extensions = array('mp4', 'webm', 'ogg');
                                 $content = '<video class="" preload="none" width="' . $width . '" height="' . $height . '" data-setup="{}" controls';
                                 $poster_path = Journal2Utils::getProperty($caption, 'video_path') . '.png';
                                 if (file_exists(DIR_APPLICATION . '../' . $poster_path)) {
                                     $content .= ' poster="' . $poster_path . '" data-setup="{}"';
                                 }
                                 $content .= '>';
                                 foreach ($file_extensions as $file_extension) {
                                     $video_path = Journal2Utils::getProperty($caption, 'video_path') . '.' . $file_extension;
                                     if (file_exists(DIR_APPLICATION . '../' . $video_path)) {
                                         $content .= '<source src="' . $video_path . '" type="video/' . $file_extension . '" />';
                                     }
                                 }
                                 $content .= '</video>';
                                 break;
                         }
                         if (Journal2Utils::getProperty($caption, 'video_autoplay')) {
                             $caption_data[] = 'data-autoplay="true"';
                             $caption_data[] = 'data-forcerewind="on"';
                         } else {
                             $caption_data[] = 'data-autoplay="false"';
                         }
                         if (Journal2Utils::getProperty($caption, 'video_autoplayonlyfirsttime')) {
                             $caption_data[] = 'data-autoplayonlyfirsttime="true"';
                         } else {
                             $caption_data[] = 'data-autoplayonlyfirsttime="false"';
                         }
                         if (Journal2Utils::getProperty($caption, 'video_nextslideatend')) {
                             $caption_data[] = 'data-nextslideatend="true"';
                         } else {
                             $caption_data[] = 'data-nextslideatend="false"';
                         }
                         if (!Journal2Utils::getProperty($caption, 'video_volume')) {
                             $caption_data[] = 'data-volume="mute"';
                         }
                         break;
                 }
                 $caption_classes[] = Journal2Utils::getProperty($caption, 'animation_in', 'fade');
                 $caption_classes[] = Journal2Utils::getProperty($caption, 'animation_out', 'fadeout');
                 if (Journal2Utils::getProperty($caption, 'animation_in') === 'customin') {
                     $custom_in = array();
                     $custom_out = array();
                     // in
                     if (Journal2Utils::getProperty($caption, 'custom_in_transition_x') !== null) {
                         $custom_in[] = 'x:' . Journal2Utils::getProperty($caption, 'custom_in_transition_x');
                     }
                     if (Journal2Utils::getProperty($caption, 'custom_in_transition_y') !== null) {
                         $custom_in[] = 'y:' . Journal2Utils::getProperty($caption, 'custom_in_transition_y');
                     }
                     if (Journal2Utils::getProperty($caption, 'custom_in_scale_x') !== null) {
                         $custom_in[] = 'scaleX:' . Journal2Utils::getProperty($caption, 'custom_in_scale_x');
                     }
                     if (Journal2Utils::getProperty($caption, 'custom_in_scale_y') !== null) {
                         $custom_in[] = 'scaleY:' . Journal2Utils::getProperty($caption, 'custom_in_scale_y');
                     }
                     if (Journal2Utils::getProperty($caption, 'custom_in_rotation_x') !== null) {
                         $custom_in[] = 'rotationX:' . Journal2Utils::getProperty($caption, 'custom_in_rotation_x');
                     }
                     if (Journal2Utils::getProperty($caption, 'custom_in_rotation_y') !== null) {
                         $custom_in[] = 'rotationY:' . Journal2Utils::getProperty($caption, 'custom_in_rotation_y');
                     }
                     if (Journal2Utils::getProperty($caption, 'custom_in_rotation_z') !== null) {
                         $custom_in[] = 'rotationZ:' . Journal2Utils::getProperty($caption, 'custom_in_rotation_z');
                     }
                     if (Journal2Utils::getProperty($caption, 'custom_in_transform_perspective', '500') !== null) {
                         $custom_in[] = 'transformPerspective:' . Journal2Utils::getProperty($caption, 'custom_in_transform_perspective', '500');
                     }
                     $custom_in[] = 'opacity:' . Journal2Utils::getProperty($caption, 'custom_in_opacity');
                     $custom_in[] = 'transformOrigin:' . Journal2Utils::getProperty($caption, 'transformOriginXin', 'center') . ' ' . Journal2Utils::getProperty($caption, 'transformOriginYin', 'center');
                     // out
                     if (Journal2Utils::getProperty($caption, 'custom_out_transition_x') !== null) {
                         $custom_out[] = 'x:' . Journal2Utils::getProperty($caption, 'custom_out_transition_x');
                     }
                     if (Journal2Utils::getProperty($caption, 'custom_out_transition_y') !== null) {
                         $custom_out[] = 'y:' . Journal2Utils::getProperty($caption, 'custom_out_transition_y');
                     }
                     if (Journal2Utils::getProperty($caption, 'custom_out_scale_x') !== null) {
                         $custom_out[] = 'scaleX:' . Journal2Utils::getProperty($caption, 'custom_out_scale_x');
                     }
                     if (Journal2Utils::getProperty($caption, 'custom_out_scale_y') !== null) {
                         $custom_out[] = 'scaleY:' . Journal2Utils::getProperty($caption, 'custom_out_scale_y');
                     }
                     if (Journal2Utils::getProperty($caption, 'custom_out_rotation_x') !== null) {
                         $custom_out[] = 'rotationX:' . Journal2Utils::getProperty($caption, 'custom_out_rotation_x');
                     }
                     if (Journal2Utils::getProperty($caption, 'custom_out_rotation_y') !== null) {
                         $custom_out[] = 'rotationY:' . Journal2Utils::getProperty($caption, 'custom_out_rotation_y');
                     }
                     if (Journal2Utils::getProperty($caption, 'custom_out_rotation_z') !== null) {
                         $custom_out[] = 'rotationZ:' . Journal2Utils::getProperty($caption, 'custom_out_rotation_z');
                     }
                     if (Journal2Utils::getProperty($caption, 'custom_out_transform_perspective', '500') !== null) {
                         $custom_out[] = 'transformPerspective:' . Journal2Utils::getProperty($caption, 'custom_out_transform_perspective', '500');
                     }
                     $custom_out[] = 'opacity:' . Journal2Utils::getProperty($caption, 'custom_out_opacity');
                     $custom_out[] = 'transformOrigin:' . Journal2Utils::getProperty($caption, 'transformOriginXout', 'center') . ' ' . Journal2Utils::getProperty($caption, 'transformOriginYout', 'center');
                     $caption_data[] = 'data-customin="' . implode(';', $custom_in) . '"';
                     $caption_data[] = 'data-customout="' . implode(';', $custom_out) . '"';
                 }
                 $_captions[] = array('id' => "{$module}-{$caption_id}", 'content' => $content, 'data' => implode(' ', $caption_data), 'classes' => implode(' ', $caption_classes), 'css' => implode('; ', $css), 'link' => $this->model_journal2_menu->getLink(Journal2Utils::getProperty($caption, 'link')), 'target' => Journal2Utils::getProperty($caption, 'link_new_window') ? ' target="_blank"' : '');
             }
             $image = Journal2Utils::getProperty($slide, 'image');
             if (is_array($image)) {
                 $image = Journal2Utils::getProperty($image, $this->config->get('config_language_id'));
             }
             if (!file_exists(DIR_IMAGE . $image)) {
                 $image = 'no_image.jpg';
             }
             $thumb = Journal2Utils::getProperty($slide, 'thumb');
             if (is_array($thumb)) {
                 $thumb = Journal2Utils::getProperty($thumb, $this->config->get('config_language_id'));
             }
             if (!$thumb || !file_exists(DIR_IMAGE . $thumb)) {
                 $thumb = $image;
             }
             $slide_data[] = 'data-thumb="' . Journal2Utils::resizeImage($this->model_tool_image, $thumb, $this->data['js_options']['thumbWidth'], $this->data['js_options']['thumbHeight'], 'crop') . '"';
             $_slides[] = array('image' => Journal2Utils::resizeImage($this->model_tool_image, $image), 'name' => Journal2Utils::getProperty($slide, 'slide_name'), 'data' => implode(' ', $slide_data), 'captions' => $_captions);
         }
         $this->data['module'] = $module;
         $this->data['slides'] = $_slides;
         $this->data['js_options']['thumbAmount'] = min($this->data['js_options']['thumbAmount'], count($this->data['slides']));
         $this->data['timer'] = Journal2Utils::getProperty($module_data, 'timer');
         $this->data['preload_images'] = Journal2Utils::getProperty($module_data, 'preload_images', '1');
         $this->data['hide_on_mobile_class'] = Journal2Utils::getProperty($module_data, 'hideonmobile') ? 'hide-on-mobile' : '';
         $this->data['dummy_image'] = Journal2Utils::resizeImage($this->model_tool_image, 'data/journal2/transparent.png');
         $this->template = $this->config->get('config_template') . '/template/journal2/module/slider_advanced.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);
             $this->journal2->cache->set($cache_property . '_fonts', json_encode($this->google_fonts));
         }
     } else {
         if ($fonts = $this->journal2->cache->get($cache_property . '_fonts')) {
             $fonts = json_decode($fonts, true);
             if (is_array($fonts)) {
                 foreach ($fonts as $font) {
                     $this->journal2->google_fonts->add($font['name'], $font['subset'], $font['weight']);
                 }
             }
         }
         $this->template = $this->config->get('config_template') . '/template/journal2/cache/cache.tpl';
         $this->data['cache'] = $cache;
     }
     $this->document->addStyle('catalog/view/theme/journal2/lib/rs-plugin/css/settings.css');
     $this->document->addScript('catalog/view/theme/journal2/lib/rs-plugin/js/jquery.themepunch.tools.min.js');
     $this->document->addScript('catalog/view/theme/journal2/lib/rs-plugin/js/jquery.themepunch.revolution.min.js');
     $output = $this->render();
     Journal2::stopTimer(get_class($this));
     return $output;
 }
예제 #20
0
 public function add()
 {
     $this->load->language('product/compare');
     $json = array();
     if (!isset($this->session->data['compare'])) {
         $this->session->data['compare'] = array();
     }
     if (isset($this->request->post['product_id'])) {
         $product_id = $this->request->post['product_id'];
     } else {
         $product_id = 0;
     }
     $this->load->model('catalog/product');
     $this->load->model('journal2/product');
     $product_info = $this->model_catalog_product->getProduct($product_id);
     if ($product_info) {
         if (!in_array($this->request->post['product_id'], $this->session->data['compare'])) {
             if (count($this->session->data['compare']) >= 4) {
                 array_shift($this->session->data['compare']);
             }
             $this->session->data['compare'][] = $this->request->post['product_id'];
         }
         if (strpos($this->config->get('config_template'), 'journal2') === 0) {
             $this->load->model('tool/image');
             $json['image'] = Journal2Utils::resizeImage($this->model_tool_image, $product_info['image'], $this->config->get('config_image_cart_width'), $this->config->get('config_image_cart_height'));
         }
         $json['success'] = sprintf($this->language->get('text_success'), $this->url->link('product/product', 'product_id=' . $this->request->post['product_id']), $product_info['name'], $this->url->link('product/compare'));
         $json['total'] = sprintf($this->language->get('text_compare'), isset($this->session->data['compare']) ? count($this->session->data['compare']) : 0);
     }
     $this->response->addHeader('Content-Type: application/json');
     $this->response->setOutput(json_encode($json));
 }
 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;
 }
 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;
 }