private function printScript($src, $def = '') { $def = rtrim($def) . ' '; return '<script type="text/javascript"' . $def . 'src="' . Journal2Utils::staticAsset($this->addJournalVersion($src, $this->minify_css)) . '"></script>' . PHP_EOL; }
public function post() { $this->data['breadcrumbs'] = array(); $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home'), 'separator' => false); $this->data['breadcrumbs'][] = array('text' => $this->blog_title, 'href' => $this->url->link('journal2/blog'), 'separator' => $this->language->get('text_separator')); if (isset($this->request->get['journal_blog_category_id'])) { $category_id = $this->request->get['journal_blog_category_id']; } else { $category_id = 0; } $category_info = $this->model_journal2_blog->getCategory($category_id); if ($category_info) { $this->data['breadcrumbs'][] = array('text' => $category_info['name'], 'href' => $this->url->link('journal2/blog', 'journal_blog_category_id=' . $category_id), 'separator' => $this->language->get('text_separator')); } if (isset($this->request->get['journal_blog_post_id'])) { $post_id = $this->request->get['journal_blog_post_id']; } else { $post_id = 0; } $post_info = $this->model_journal2_blog->getPost($post_id); if ($post_info) { $this->data['breadcrumbs'][] = array('text' => $post_info['name'], 'href' => $this->url->link('journal2/blog/post', ($category_info ? 'journal_blog_category_id=' . $category_id . '&' : '') . 'journal_blog_post_id=' . $post_info['post_id']), 'separator' => $this->language->get('text_separator')); $this->data['text_tags'] = $this->language->get('text_tags'); $this->data['tab_related'] = $this->language->get(Front::$IS_OC2 ? 'text_related' : 'tab_related'); $this->data['button_cart'] = $this->language->get('button_cart'); $this->data['button_wishlist'] = $this->language->get('button_wishlist'); $this->data['button_compare'] = $this->language->get('button_compare'); $this->blog_title = $post_info['name']; $this->blog_heading_title = $post_info['name']; $this->blog_meta_title = $post_info['meta_title']; $this->blog_meta_description = $post_info['meta_description']; $this->blog_meta_keywords = $post_info['meta_keywords']; $this->data['post_id'] = $post_info['post_id']; $this->data['post_author'] = $this->model_journal2_blog->getAuthorName($post_info); $this->data['post_date'] = $post_info['date_created']; $this->data['post_content'] = $post_info['description']; $this->data['default_author_image'] = Journal2Utils::resizeImage($this->model_tool_image, 'data/journal2/misc/avatar.png', 70, 70); $this->data['post_tags'] = array(); foreach (explode(',', $post_info['tags']) as $tag) { $tag = trim($tag); if (!$tag) { continue; } $this->data['post_tags'][] = array('href' => $this->url->link('journal2/blog', 'journal_blog_tag=' . $tag), 'name' => $tag); } $results = $this->model_journal2_blog->getCategoriesByPostId($post_id); $this->data['post_categories'] = array(); foreach ($results as $result) { $this->data['post_categories'][] = array('href' => $this->url->link('journal2/blog', 'journal_blog_category_id=' . $result['category_id']), 'name' => $result['name']); } $this->data['grid_classes'] = Journal2Utils::getProductGridClasses($this->journal2->settings->get('config_blog_settings.related_products_per_row.value'), $this->journal2->settings->get('site_width', 1024), $this->journal2->settings->get('config_columns_count', 0)); $this->data['carousel'] = $this->journal2->settings->get('config_blog_settings.related_products_carousel'); $this->data['related_products'] = array(); if ($this->journal2->settings->get('config_blog_settings.related_products', '1')) { $results = $this->model_journal2_blog->getRelatedProducts($post_id); foreach ($results as $result) { $image = Journal2Utils::resizeImage($this->model_tool_image, $result['image'], $this->config->get('config_image_related_width'), $this->config->get('config_image_related_height'), 'fit'); if ($this->config->get('config_customer_price') && $this->customer->isLogged() || !$this->config->get('config_customer_price')) { $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax'))); } else { $price = false; } if ((double) $result['special']) { $special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax'))); } else { $special = false; } if ($this->config->get('config_review_status')) { $rating = (int) $result['rating']; } else { $rating = false; } $date_end = false; if (strpos($this->config->get('config_template'), 'journal2') === 0 && $special && $this->journal2->settings->get('show_countdown', 'never') !== 'never') { $this->load->model('journal2/product'); $date_end = $this->model_journal2_product->getSpecialCountdown($result['product_id']); if ($date_end === '0000-00-00') { $date_end = false; } } $additional_images = $this->model_catalog_product->getProductImages($result['product_id']); $image2 = false; if (count($additional_images) > 0) { $image2 = $this->model_tool_image->resize($additional_images[0]['image'], $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height')); } $this->data['related_products'][] = array('product_id' => $result['product_id'], 'thumb' => $image, 'thumb2' => $image2, 'labels' => $this->model_journal2_product->getLabels($result['product_id']), 'date_end' => $date_end, 'name' => $result['name'], 'price' => $price, 'special' => $special, 'rating' => $rating, 'reviews' => sprintf($this->language->get('text_reviews'), (int) $result['reviews']), 'href' => $this->url->link('product/product', 'product_id=' . $result['product_id'])); } } $this->data['allow_comments'] = $this->model_journal2_blog->getCommentsStatus($post_id); $this->data['comments'] = $this->model_journal2_blog->getComments($post_id); /* default comment fields */ if (version_compare(VERSION, '2.1', '<')) { $this->load->library('user'); } if ($this->customer->isLogged()) { $this->load->model('account/customer'); $customer_info = $this->model_account_customer->getCustomer($this->customer->getId()); $this->data['default_name'] = trim($customer_info['firstname'] . ' ' . $customer_info['lastname']); $this->data['default_email'] = $customer_info['email']; } else { if ($this->user->isLogged()) { $admin_info = $this->model_journal2_blog->getAdminInfo($this->user->getId()); $this->data['default_name'] = trim($admin_info['firstname'] . ' ' . $admin_info['lastname']); $this->data['default_email'] = $admin_info['email']; } else { $this->data['default_name'] = ''; $this->data['default_email'] = ''; } } $this->model_journal2_blog->updateViews($post_id); $this->data['heading_title'] = $this->blog_heading_title; $this->document->setTitle($this->blog_title); $this->document->setDescription($this->blog_meta_description); $this->document->setKeywords($this->blog_meta_keywords); $this->document->addLink($this->url->link('journal2/blog/post', 'journal_blog_post_id=' . $post_id), 'canonical'); $this->journal2->settings->set('blog_meta_title', $this->blog_meta_title); $this->journal2->settings->set('fb_meta_title', $this->blog_title); $this->journal2->settings->set('fb_meta_description', trim(utf8_substr(strip_tags(html_entity_decode($post_info['description'], ENT_QUOTES, 'UTF-8')), 0, 300)) . '...'); $this->journal2->settings->set('fb_meta_image', Journal2Utils::staticAsset('image/' . $post_info['image'])); $this->blog_template = $this->config->get('config_template') . '/template/journal2/blog/post.tpl'; } else { $this->language->load('error/not_found'); $this->document->setTitle($this->language->get('text_error')); $this->data['heading_title'] = $this->language->get('text_error'); $this->data['text_error'] = $this->language->get('text_error'); $this->data['button_continue'] = $this->language->get('button_continue'); $this->data['continue'] = $this->url->link('common/home'); $this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . '/1.1 404 Not Found'); if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/not_found.tpl')) { $this->blog_template = $this->config->get('config_template') . '/template/error/not_found.tpl'; } else { $this->blog_template = 'default/template/error/not_found.tpl'; } } if (Front::$IS_OC2) { $this->data['column_left'] = $this->load->controller('common/column_left'); $this->data['column_right'] = $this->load->controller('common/column_right'); $this->data['content_top'] = $this->load->controller('common/content_top'); $this->data['content_bottom'] = $this->load->controller('common/content_bottom'); $this->data['footer'] = $this->load->controller('common/footer'); $this->data['header'] = $this->load->controller('common/header'); } else { $this->children = array('common/column_left', 'common/column_right', 'common/content_top', 'common/content_bottom', 'common/footer', 'common/header'); } $this->response->setOutput($this->render()); }
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); }