本文整理汇总了PHP中Journal2Utils::sortArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Journal2Utils::sortArray方法的具体用法?PHP Journal2Utils::sortArray怎么用?PHP Journal2Utils::sortArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Journal2Utils
的用法示例。
在下文中一共展示了Journal2Utils::sortArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
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;
}
示例2: 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'];
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')) {
//.........这里部分代码省略.........
示例3: index
//.........这里部分代码省略.........
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;
}
示例4: 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_cms_blocks_' . $setting['module_id'], implode('; ', $css));
$this->journal2->settings->set('module_journal2_cms_blocks_' . $setting['module_id'] . '_classes', implode(' ', $this->data['disable_on_classes']));
/* inner css */
$css = array();
if (Journal2Utils::getProperty($module_data, 'fullwidth')) {
$css[] = 'max-width: 100%';
$css[] = 'padding-left: ' . $padding;
$css[] = 'padding-right: ' . $padding;
} else {
$css[] = 'max-width: ' . $this->journal2->settings->get('site_width', 1024) . 'px';
$css = array_merge($css, Journal2Utils::getBackgroundCssProperties(Journal2Utils::getProperty($module_data, 'module_background')));
if (Journal2Utils::getProperty($module_data, 'module_padding')) {
$this->data['gutter_on_class'] = 'gutter-on';
$css[] = 'padding: 20px';
}
}
$this->data['css'] = implode('; ', $css);
}
$cache_property = "module_journal_cms_blocks_{$setting['module_id']}_{$setting['layout_id']}_{$setting['position']}";
$cache = $this->journal2->cache->get($cache_property);
if ($cache === null || self::$CACHEABLE !== true) {
$module = mt_rand();
/* set global module properties */
$this->data['module'] = $module;
$this->data['title'] = Journal2Utils::getProperty($module_data, 'module_title.value.' . $this->config->get('config_language_id'), '');
/* sort sections */
$sections = Journal2Utils::getProperty($module_data, 'sections', array());
$sections = Journal2Utils::sortArray($sections);
/* generate sections */
$this->data['sections'] = array();
foreach ($sections as $section) {
if (!$section['status']) {
continue;
}
$css = array();
if (Journal2Utils::getColor(Journal2Utils::getProperty($section, 'icon_bg_color.value.color'))) {
$css[] = 'background-color: ' . Journal2Utils::getColor(Journal2Utils::getProperty($section, 'icon_bg_color.value.color'));
}
if (Journal2Utils::getProperty($section, 'icon_width')) {
$css[] = 'width: ' . Journal2Utils::getProperty($section, 'icon_width') . 'px';
}
if (Journal2Utils::getProperty($section, 'icon_height')) {
$css[] = 'height: ' . Journal2Utils::getProperty($section, 'icon_height') . 'px';
$css[] = 'line-height: ' . Journal2Utils::getProperty($section, 'icon_height') . 'px';
}
if (Journal2Utils::getProperty($section, 'icon_border')) {
$css = array_merge($css, Journal2Utils::getBorderCssProperties(Journal2Utils::getProperty($section, 'icon_border')));
}
if ($color = Journal2Utils::getProperty($section, 'bg_color.value.color')) {
$color = 'background-color: ' . Journal2Utils::getColor($color);
} else {
$color = null;
}
$this->data['sections'][] = array('css' => $color, 'has_icon' => Journal2Utils::getProperty($section, 'icon_status'), 'icon_position' => Journal2Utils::getProperty($section, 'icon_position', 'top'), 'icon' => Journal2Utils::getIconOptions2(Journal2Utils::getProperty($section, 'icon')), 'icon_css' => implode('; ', $css), 'type' => 'html', 'title' => Journal2Utils::getProperty($section, 'section_title.value.' . $this->config->get('config_language_id'), ''), 'content_align' => Journal2Utils::getProperty($section, 'text_align', 'left'), 'content' => Journal2Utils::getProperty($section, 'text.' . $this->config->get('config_language_id'), 'Not Translated'));
//.........这里部分代码省略.........
示例5: 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'];
$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;
}
//.........这里部分代码省略.........
示例6: 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;
}
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_side_category_{$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['class'] = $setting['position'] === 'column_right' ? 'side-category-right' : 'side-category-left';
$this->data['type'] = Journal2Utils::getProperty($module_data, 'module_data.type');
switch ($this->data['type']) {
case 'accordion':
$this->data['class'] .= ' side-category-accordion';
break;
case 'dropdown':
$this->data['class'] .= ' side-category-dropdown';
break;
}
$this->language->load('module/category');
$this->data['heading_title'] = Journal2Utils::getProperty($module_data, 'module_data.title.value.' . $this->config->get('config_language_id'), $this->language->get('heading_title'));
$tree = array();
if (Journal2Utils::getProperty($module_data, 'module_data.show_categories')) {
if (isset($this->request->get['path'])) {
$parts = explode('_', (string) $this->request->get['path']);
} else {
$parts = array();
}
$sql = "SELECT c.category_id, c.parent_id, cd.name ";
if ($this->config->get('config_product_count')) {
$sql .= ", (SELECT COUNT(p.product_id) FROM " . DB_PREFIX . "product_to_category p2c LEFT JOIN " . DB_PREFIX . "product p ON (p.product_id = p2c.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int) $this->config->get('config_store_id') . "' AND p2c.category_id = c.category_id) as total ";
}
$sql .= "FROM " . DB_PREFIX . "category c LEFT JOIN " . DB_PREFIX . "category_description cd ON (c.category_id = cd.category_id) LEFT JOIN " . DB_PREFIX . "category_to_store c2s ON (c.category_id = c2s.category_id) WHERE cd.language_id = '" . (int) $this->config->get('config_language_id') . "' AND c2s.store_id = '" . (int) $this->config->get('config_store_id') . "' AND c.status = '1' ORDER BY c.sort_order, LCASE(cd.name)";
$query = $this->db->query($sql);
$results = array();
foreach ($query->rows as $row) {
$results[$row['parent_id']][] = $row;
}
if (is_array($results) && isset($results['0'])) {
$tree = $this->generateMultiLevelCategoryMenu($results, $results[0], '', $parts);
if ($this->config->get('config_product_count')) {
for ($i = 0; $i < count($tree); $i++) {
$this->sum($tree[$i]);
}
}
}
}
$top_items = array();
$bottom_items = array();
foreach (Journal2Utils::getProperty($module_data, 'module_data.sections', array()) as $item_data) {
$item = array('name' => Journal2Utils::getProperty($item_data, 'name.value.' . $this->config->get('config_language_id'), 'Not translated'), 'href' => $this->model_journal2_menu->getLink(Journal2Utils::getProperty($item_data, 'link')), 'target' => Journal2Utils::getProperty($item_data, 'new_window') ? 'target="_blank"' : '', 'sort_order' => Journal2Utils::getProperty($item_data, 'sort_order'));
$item['class'] = $this->isActive($item['href']);
if (Journal2Utils::getProperty($item_data, 'position') === 'top') {
$top_items[] = $item;
} else {
$bottom_items[] = $item;
}
}
$top_items = Journal2Utils::sortArray($top_items);
$bottom_items = Journal2Utils::sortArray($bottom_items);
$this->data['categories'] = $tree;
$this->data['top_items'] = $top_items;
$this->data['bottom_items'] = $bottom_items;
$this->data['show_total'] = $this->config->get('config_product_count');
$this->template = $this->config->get('config_template') . '/template/journal2/module/side_category.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;
}
示例7: index
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';
//.........这里部分代码省略.........
示例8: 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'];
/* hide on mobile */
$disable_mobile = Journal2Utils::getProperty($module_data, 'disable_mobile') && $this->journal2->settings->get('responsive_design');
if ($disable_mobile && (Journal2Cache::$mobile_detect->isMobile() && !Journal2Cache::$mobile_detect->isTablet())) {
return;
}
/* hide on desktop */
if (Journal2Utils::getProperty($module_data, 'disable_desktop') && !Journal2Cache::$mobile_detect->isMobile()) {
return;
}
$this->data['disable_mobile'] = $disable_mobile ? 'hide-on-mobile' : '';
$this->data['height'] = Journal2Utils::getProperty($module_data, 'height');
$this->data['css'] = array();
/* 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_carousel_grid_' . $setting['module_id'], implode('; ', $css));
/* 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'] = $css;
}
$module_spacing = Journal2Utils::getProperty($module_data, 'module_spacing');
$this->data['module_spacing'] = $module_spacing !== null ? $module_spacing . 'px' : null;
$this->data['css'] = implode('; ', $this->data['css']);
$cache_property = "module_journal_carousel_grid_{$setting['module_id']}_{$setting['layout_id']}_{$setting['position']}";
$cache = $this->journal2->cache->get($cache_property);
if ($cache === null || self::$CACHEABLE !== true) {
$this->data['module'] = mt_rand();
$columns = Journal2Utils::getProperty($module_data, 'columns', array());
$columns = Journal2Utils::sortArray($columns);
$this->data['columns'] = array();
foreach ($columns as $column) {
if (!$column['status']) {
continue;
}
$module_disable_mobile = Journal2Utils::getProperty($column, 'disable_mobile') && $this->journal2->settings->get('responsive_design');
if ($module_disable_mobile && (Journal2Cache::$mobile_detect->isMobile() && !Journal2Cache::$mobile_detect->isTablet())) {
continue;
}
/* hide on desktop */
if (Journal2Utils::getProperty($column, 'disable_desktop') && !Journal2Cache::$mobile_detect->isMobile()) {
return;
}
$size = floor($column['width']);
$this->data['columns'][] = array('classes' => "xs-{$size} sm-{$size} md-{$size} lg-{$size} xl-{$size}", 'content' => $this->getChild('module/journal2_carousel', array('module_id' => Journal2Utils::getProperty($column, 'module_id'), 'layout_id' => -1, 'position' => 'multi_module')));
}
$this->template = $this->config->get('config_template') . '/template/journal2/module/carousel_grid.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;
}
示例9: generateMenuItem
//.........这里部分代码省略.........
$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());
}
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':
示例10: 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';
}
}
}
/* 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 {
//.........这里部分代码省略.........
示例11: getFilters
//.........这里部分代码省略.........
foreach ($results as $result) {
$this->data['categories'][] = array('category_id' => $result['category_id'], 'name' => trim($result['name']) . ($show_product_count ? ' (' . $result['total'] . ')' : ''), 'image' => $this->model_tool_image->resize($result['image'] ? $result['image'] : (Front::$IS_OC2 ? 'placeholder.png' : 'no_image.jpg'), self::$IMG_WIDTH, self::$IMG_HEIGHT), 'keyword' => $this->keyword($result['name']));
}
if ($this->data['categories']) {
$this->template = $this->config->get('config_template') . '/template/journal2/module/super_filter_categories.tpl';
$filter_groups[] = array('sort_order' => Journal2Utils::getProperty($module_data, 'sort_orders.c'), 'html' => $this->render());
}
}
/* manufacturers */
$this->data['manufacturer_display_mode'] = $module_data['manufacturer'];
$this->data['manufacturer_type'] = $module_data['manufacturer_type'];
$this->data['manufacturers'] = array();
if ($module_data['manufacturer'] !== 'off' && $data['route'] !== 'product/manufacturer/info') {
$results = $this->model_journal2_super_filter->getManufacturers($data);
foreach ($results as $result) {
$this->data['manufacturers'][] = array('manufacturer_id' => $result['manufacturer_id'], 'name' => trim($result['name']) . ($show_product_count ? ' (' . $result['total'] . ')' : ''), 'image' => $this->model_tool_image->resize($result['image'] ? $result['image'] : (Front::$IS_OC2 ? 'placeholder.png' : 'no_image.jpg'), self::$IMG_WIDTH, self::$IMG_HEIGHT), 'keyword' => $this->keyword($result['name']));
}
if ($this->data['manufacturers']) {
$this->template = $this->config->get('config_template') . '/template/journal2/module/super_filter_manufacturers.tpl';
$filter_groups[] = array('sort_order' => Journal2Utils::getProperty($module_data, 'sort_orders.m'), 'html' => $this->render());
}
}
/* attributes */
$results = $this->model_journal2_super_filter->getAttributes($data);
foreach ($results as $key => $result) {
$display_mode = Journal2Utils::getProperty($module_data, 'attributes.' . $key, 'on');
if ($display_mode === 'off') {
continue;
}
$values = array();
foreach ($result['values'] as $value) {
$values[] = array('text' => rawurlencode(trim($value['text'])), 'name' => trim($value['text']) . ($show_product_count ? ' (' . $value['total'] . ')' : ''), 'keyword' => $this->keyword($result['attribute_name'] . " " . $value['text']));
}
$this->data['attribute'] = array('attribute_id' => $result['attribute_id'], 'attribute_name' => $result['attribute_name'], 'display_mode' => $display_mode, 'type' => Journal2Utils::getProperty($module_data, 'attributes_type.' . $key, 'single'), 'values' => $values);
$this->template = $this->config->get('config_template') . '/template/journal2/module/super_filter_attributes.tpl';
$filter_groups[] = array('sort_order' => Journal2Utils::getProperty($module_data, 'sort_orders.a_' . $result['attribute_id']), 'html' => $this->render());
}
/* options */
$results = $this->model_journal2_super_filter->getOptions($data);
$this->data['options'] = array();
foreach ($results as $key => $result) {
$display_mode = Journal2Utils::getProperty($module_data, 'options.' . $key, 'list');
if ($display_mode === 'off') {
continue;
}
$values = array();
foreach ($result['values'] as $value) {
$values[] = array('option_value_id' => $value['option_value_id'], 'option_value_name' => trim($value['option_value_name']) . ($show_product_count ? ' (' . $value['total'] . ')' : ''), 'image' => $this->model_tool_image->resize($value['image'] ? $value['image'] : (Front::$IS_OC2 ? 'placeholder.png' : 'no_image.jpg'), self::$IMG_WIDTH, self::$IMG_HEIGHT), 'keyword' => $this->keyword($result['option_name'] . " " . $value['option_value_name']));
}
$this->data['option'] = array('option_id' => $result['option_id'], 'option_name' => $result['option_name'], 'display_mode' => $display_mode, 'type' => Journal2Utils::getProperty($module_data, 'options_type.' . $key, 'single'), 'values' => $values);
$this->template = $this->config->get('config_template') . '/template/journal2/module/super_filter_options.tpl';
$filter_groups[] = array('sort_order' => Journal2Utils::getProperty($module_data, 'sort_orders.o_' . $result['option_id']), 'html' => $this->render());
}
if (Journal2Utils::getProperty($module_data, 'tags') && !isset($this->request->get['tag'])) {
$results = $this->model_journal2_super_filter->getTags($data);
foreach ($results as $result) {
$this->data['tags'][] = array('text' => trim($result['name']), 'name' => trim($result['name']) . ($show_product_count ? ' (' . $result['total'] . ')' : ''), 'keyword' => $this->keyword($result['name']));
}
if (isset($this->data['tags'])) {
$this->template = $this->config->get('config_template') . '/template/journal2/module/super_filter_tags.tpl';
$filter_groups[] = array('sort_order' => Journal2Utils::getProperty($module_data, 'sort_orders.t'), 'html' => $this->render());
}
}
// Availability
if (Journal2Utils::getProperty($module_data, 'availability')) {
$this->template = $this->config->get('config_template') . '/template/journal2/module/super_filter_availability.tpl';
$this->data['availability_yes'] = false;
$this->data['availability_no'] = false;
$filter_groups[] = array('sort_order' => Journal2Utils::getProperty($module_data, 'sort_orders.a'), 'html' => $this->render());
}
// Price
$results = $this->model_journal2_super_filter->getPrice($data);
if ($results) {
if ($this->config->get('config_customer_price') && $this->customer->isLogged() || !$this->config->get('config_customer_price')) {
$this->data['min_price'] = floor($this->tax->calculate($results['min'], $module_data['tax_class_id'], $this->config->get('config_tax')) * $this->currency->getValue());
$this->data['max_price'] = ceil($this->tax->calculate($results['max'], $module_data['tax_class_id'], $this->config->get('config_tax')) * $this->currency->getValue());
} else {
$this->data['price_filter'] = false;
$this->data['min_price'] = false;
$this->data['max_price'] = false;
}
}
if ($this->data['min_price'] == $this->data['max_price']) {
$this->data['price_filter'] = false;
}
if ($this->data['price_filter']) {
$this->template = $this->config->get('config_template') . '/template/journal2/module/super_filter_price.tpl';
$filter_groups[] = array('sort_order' => Journal2Utils::getProperty($module_data, 'sort_orders.p'), 'html' => $this->render());
}
if (!count($filter_groups) && $this->data['price_filter'] === false) {
return;
}
$this->data['filter_groups'] = Journal2Utils::sortArray($filter_groups);
$this->template = $this->config->get('config_template') . '/template/journal2/module/super_filter.tpl';
if ($ajax) {
$this->response->setOutput($this->render());
} else {
return $this->render();
}
}
示例12: processFooter
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));
}
示例13: index
public function index()
{
if ($this->journal2->page->getType() !== 'product' && $this->journal2->page->getType() !== 'quickview') {
return;
}
Journal2::startTimer('ProductTabs');
$product_id = $this->journal2->page->getId();
/* recently viewed */
$recently_viewed = isset($this->request->cookie['jrv']) && $this->request->cookie['jrv'] ? explode(',', $this->request->cookie['jrv']) : array();
$recently_viewed = array_diff($recently_viewed, array($product_id));
array_unshift($recently_viewed, $product_id);
$recently_viewed = array_splice($recently_viewed, 0, 10);
setcookie('jrv', implode(',', $recently_viewed), time() + 60 * 60 * 24 * 30, '/', $this->request->server['HTTP_HOST']);
$tabs = $this->model_journal2_module->getProductTabs($product_id);
$tabs = Journal2Utils::sortArray($tabs);
$product_info = $this->model_catalog_product->getProduct($product_id);
$tab_tab = array();
$tab_desc_top = array();
$tab_desc_bottom = array();
$tab_image = array();
$tab_enquiry = array();
foreach ($tabs as $tab) {
if (!$tab['status']) {
continue;
}
$css = array();
if (Journal2Utils::getColor(Journal2Utils::getProperty($tab, 'icon_bg_color.value.color'))) {
$css[] = 'background-color: ' . Journal2Utils::getColor(Journal2Utils::getProperty($tab, 'icon_bg_color.value.color'));
}
if (Journal2Utils::getProperty($tab, 'icon_width')) {
$css[] = 'width: ' . Journal2Utils::getProperty($tab, 'icon_width') . 'px';
}
if (Journal2Utils::getProperty($tab, 'icon_height')) {
$css[] = 'height: ' . Journal2Utils::getProperty($tab, 'icon_height') . 'px';
$css[] = 'line-height: ' . Journal2Utils::getProperty($tab, 'icon_height') . 'px';
}
if (Journal2Utils::getProperty($tab, 'icon_border')) {
$css = array_merge($css, Journal2Utils::getBorderCssProperties(Journal2Utils::getProperty($tab, 'icon_border')));
}
$position = Journal2Utils::getProperty($tab, 'position');
$name = Journal2Utils::getProperty($tab, 'name.value.' . $this->config->get('config_language_id'));
$has_icon = Journal2Utils::getProperty($tab, 'icon_status');
$icon = Journal2Utils::getIconOptions2(Journal2Utils::getProperty($tab, 'icon'));
$icon_css = implode('; ', $css);
switch (Journal2Utils::getProperty($tab, 'content_type', 'custom')) {
case 'custom':
$content = Journal2Utils::getProperty($tab, 'content.' . $this->config->get('config_language_id'));
break;
case 'description':
$content = html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8');
$this->journal2->settings->set('hide_product_description', true);
break;
case 'enquiry':
$position = 'enquiry';
$this->journal2->settings->set('hide_add_to_cart_button', true);
$href = "javascript:Journal.openPopup('" . (int) Journal2Utils::getProperty($tab, 'popup') . "', '" . $product_id . "')";
$content = "<a class=\"button enquiry-button\" href=\"{$href}\">{$icon}{$name}</a>";
break;
}
$position_desc = $position === 'desc' ? '_' . Journal2Utils::getProperty($tab, 'option_position') : '';
$data = array('name' => $name, 'has_icon' => $has_icon, 'icon' => $icon, 'icon_css' => $icon_css, 'content' => $content);
$var = 'tab_' . $position . $position_desc;
array_push(${$var}, $data);
}
$this->journal2->settings->set('additional_product_tabs', $tab_tab);
$this->journal2->settings->set('additional_product_description_top', $tab_desc_top);
$this->journal2->settings->set('additional_product_description_bottom', $tab_desc_bottom);
$this->journal2->settings->set('additional_product_description_image', $tab_image);
$this->journal2->settings->set('additional_product_enquiry', $tab_enquiry);
Journal2::stopTimer('ProductTabs');
}
示例14: 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['height'] = Journal2Utils::getProperty($module_data, 'height');
$this->data['css'] = array();
$this->data['is_top_bottom'] = false;
/* 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_advanced_grid_' . $setting['module_id'], implode('; ', $css));
$this->journal2->settings->set('module_journal2_advanced_grid_' . $setting['module_id'] . '_classes', implode(' ', $this->data['disable_on_classes']));
$this->data['is_top_bottom'] = true;
/* 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'] = $css;
}
$module_spacing = Journal2Utils::getProperty($module_data, 'module_spacing');
$this->data['module_spacing'] = $module_spacing !== null ? $module_spacing . 'px' : null;
$this->data['grid_dimensions'] = (int) Journal2Utils::getProperty($module_data, 'grid_dimensions', '1');
$this->data['css'] = implode('; ', $this->data['css']);
$cache_property = "module_journal_advanced_grid_{$setting['module_id']}_{$setting['layout_id']}_{$setting['position']}";
$cache = $this->journal2->cache->get($cache_property);
if ($cache === null || self::$CACHEABLE !== true) {
$this->data['module'] = mt_rand();
$columns = Journal2Utils::getProperty($module_data, 'columns', array());
$columns = Journal2Utils::sortArray($columns);
$this->data['columns'] = array();
foreach ($columns as $column) {
if (!$column['status']) {
continue;
}
$modules = Journal2Utils::getProperty($column, 'modules', array());
$modules = Journal2Utils::sortArray($modules);
$rendered_modules = array();
$size = floor($column['width']);
foreach ($modules as $module) {
if (!$module['status']) {
continue;
}
/* device detection */
$disable_on_classes = array();
if ($this->journal2->settings->get('responsive_design')) {
$device = Journal2Utils::getDevice();
if (Journal2Utils::getProperty($module, 'enable_on_phone', '1') == '0') {
if ($device === 'phone') {
continue;
} else {
$disable_on_classes[] = 'hide-on-phone';
}
//.........这里部分代码省略.........
示例15: generateProductSections
private function generateProductSections($sections_data)
{
$section_index = 0;
$product_id = isset($this->request->get['product_id']) ? $this->request->get['product_id'] : null;
foreach ($sections_data as $section) {
if (!$section['status']) {
continue;
}
$products = array();
$section_products = array();
$section_name = Journal2Utils::getProperty($section, 'section_title.value.' . $this->config->get('config_language_id'), 'Not Translated');
$todays_specials = Journal2Utils::getProperty($section, 'section_type') === 'module' && Journal2Utils::getProperty($section, 'module_type') === 'specials' && Journal2Utils::getProperty($section, 'todays_specials_only') === '1';
$limit = $todays_specials ? PHP_INT_MAX : Journal2Utils::getProperty($section, 'items_limit', 5);
switch (Journal2Utils::getProperty($section, 'section_type')) {
case 'module':
switch (Journal2Utils::getProperty($section, 'module_type')) {
case 'featured':
$products = $this->model_journal2_product->getFeatured($limit, Journal2Utils::getProperty($section, 'featured_module_id'), Journal2Utils::getProperty($section, 'filter_category', 0) !== null);
break;
case 'bestsellers':
$products = $this->model_journal2_product->getBestsellers($limit, Journal2Utils::getProperty($section, 'filter_category', 0) !== null);
break;
case 'specials':
$products = $this->model_journal2_product->getSpecials($limit, Journal2Utils::getProperty($section, 'filter_category', 0) !== null);
break;
case 'latest':
$products = $this->model_journal2_product->getLatest($limit, Journal2Utils::getProperty($section, 'filter_category', 0) !== null);
break;
case 'related':
$products = $this->model_journal2_product->getProductRelated($product_id, $limit);
break;
case 'people-also-bought':
$products = $this->model_journal2_product->getPeopleAlsoBought($product_id, $limit);
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($section, '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($section, 'manufacturer.data.id'));
if (!$manufacturer) {
continue;
}
$products = $this->model_journal2_product->getProductsByManufacturer($manufacturer['manufacturer_id'], $limit);
break;
case 'custom':
foreach (Journal2Utils::sortArray(Journal2Utils::getProperty($section, 'products', array())) as $product) {
$result = $this->model_catalog_product->getProduct(Journal2Utils::getProperty($product, 'data.id'));
if (!$result) {
continue;
}
$products[] = $result;
}
break;
case 'random':
$this->has_random_products = true;
$random_type = Journal2Utils::getProperty($section, 'random_from', 'all');
$category_id = $random_type === 'category' ? Journal2Utils::getProperty($section, '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;
}
foreach ($products as $product) {
$this->has_items = true;
$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')) {
//.........这里部分代码省略.........