first commit

This commit is contained in:
Konstantin
2026-05-30 09:27:58 +03:00
commit de0344d218
2371 changed files with 661486 additions and 0 deletions
+514
View File
@@ -0,0 +1,514 @@
<?php
// * @source See SOURCE.txt for source and other copyright.
// * @license GNU General Public License version 3; see LICENSE.txt
class ControllerBlogArticle extends Controller {
private $error = array();
public function index() {
$this->load->language('blog/article');
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home'),
'separator' => false
);
$configblog_name = $this->config->get('configblog_name');
if (!empty($configblog_name)) {
$name = $this->config->get('configblog_name');
} else {
$name = $this->language->get('text_blog');
}
$this->load->model('blog/category');
if (isset($this->request->get['blog_category_id'])) {
$blog_category_id = '';
foreach (explode('_', $this->request->get['blog_category_id']) as $path_id) {
if (!$blog_category_id) {
$blog_category_id = $path_id;
} else {
$blog_category_id .= '_' . $path_id;
}
$category_info = $this->model_blog_category->getCategory($path_id);
if ($category_info) {
$data['breadcrumbs'][] = array(
'text' => $category_info['name'],
'href' => $this->url->link('blog/category', 'blog_category_id=' . $blog_category_id)
);
}
}
}
if (isset($this->request->get['filter_name']) || isset($this->request->get['filter_tag'])) {
$url = '';
if (isset($this->request->get['filter_name'])) {
$url .= '&filter_name=' . $this->request->get['filter_name'];
}
if (isset($this->request->get['filter_tag'])) {
$url .= '&filter_tag=' . $this->request->get['filter_tag'];
}
if (isset($this->request->get['filter_description'])) {
$url .= '&filter_description=' . $this->request->get['filter_description'];
}
if (isset($this->request->get['filter_news_id'])) {
$url .= '&filter_news_id=' . $this->request->get['filter_news_id'];
}
}
if (isset($this->request->get['article_id'])) {
$article_id = (int)$this->request->get['article_id'];
} else {
$article_id = 0;
}
$this->load->model('blog/article');
$article_info = $this->model_blog_article->getArticle($article_id);
if ($article_info) {
$url = '';
if (isset($this->request->get['blog_category_id'])) {
$url .= '&blog_category_id=' . $this->request->get['blog_category_id'];
}
if (isset($this->request->get['filter_name'])) {
$url .= '&filter_name=' . $this->request->get['filter_name'];
}
if (isset($this->request->get['filter_tag'])) {
$url .= '&filter_tag=' . $this->request->get['filter_tag'];
}
if (isset($this->request->get['filter_description'])) {
$url .= '&filter_description=' . $this->request->get['filter_description'];
}
if (isset($this->request->get['filter_news_id'])) {
$url .= '&filter_news_id=' . $this->request->get['filter_news_id'];
}
$data['breadcrumbs'][] = array(
'text' => $article_info['name'],
'href' => $this->url->link('blog/article', 'article_id=' . $this->request->get['article_id'])
);
if ($article_info['meta_title']) {
$this->document->setTitle($article_info['meta_title']);
} else {
$this->document->setTitle($article_info['name']);
}
if ($article_info['noindex'] <= 0 && $this->config->get('config_noindex_status')) {
$this->document->setRobots('noindex,follow');
}
$this->document->setDescription($article_info['meta_description']);
$this->document->setKeywords($article_info['meta_keyword']);
$this->document->addLink($this->url->link('blog/article', 'article_id=' . $this->request->get['article_id']), 'canonical');
$this->document->addScript('store/view/javascript/jquery/magnific/jquery.magnific-popup.min.js');
$this->document->addStyle('store/view/javascript/jquery/magnific/magnific-popup.css');
$this->document->addScript('store/view/javascript/jquery/datetimepicker/moment.js');
$this->document->addScript('store/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.js');
$this->document->addStyle('store/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.css');
if ($article_info['meta_h1']) {
$data['heading_title'] = $article_info['meta_h1'];
} else {
$data['heading_title'] = $article_info['name'];
}
$data['text_select'] = $this->language->get('text_select');
$data['text_write'] = $this->language->get('text_write');
$data['text_login'] = sprintf($this->language->get('text_login'), $this->url->link('account/login', '', true), $this->url->link('account/register', '', true));
$data['text_loading'] = $this->language->get('text_loading');
$data['text_note'] = $this->language->get('text_note');
$data['text_share'] = $this->language->get('text_share');
$data['text_wait'] = $this->language->get('text_wait');
$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['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_continue'] = $this->language->get('button_continue');
$this->load->model('blog/review');
$data['text_related'] = $this->language->get('text_related');
$data['text_related_product'] = $this->language->get('text_related_product');
$data['article_id'] = $this->request->get['article_id'];
$data['review_status'] = $this->config->get('configblog_review_status');
if ($this->config->get('configblog_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'] = '';
}
// Captcha
if ($this->config->get($this->config->get('config_captcha') . '_status') && in_array('review', (array)$this->config->get('config_captcha_page'))) {
$data['captcha'] = $this->load->controller('extension/captcha/' . $this->config->get('config_captcha'));
} else {
$data['captcha'] = '';
}
$data['article_review'] = (int)$article_info['article_review'];
$data['reviews'] = sprintf($this->language->get('text_reviews'), (int)$article_info['reviews']);
$data['rating'] = (int)$article_info['rating'];
$data['gstatus'] = (int)$article_info['gstatus'];
$data['description'] = html_entity_decode($article_info['description'], ENT_QUOTES, 'UTF-8');
$data['articles'] = array();
$data['button_more'] = $this->language->get('button_more');
$data['text_views'] = $this->language->get('text_views');
$this->load->model('tool/image');
$results = $this->model_blog_article->getArticleRelated($this->request->get['article_id']);
foreach ($results as $result) {
if ($result['image']) {
$image = $this->model_tool_image->resize($result['image'], $this->config->get('configblog_image_related_width'), $this->config->get('configblog_image_related_height'));
} else {
$image = false;
}
if ($this->config->get('configblog_review_status')) {
$rating = (int)$result['rating'];
} else {
$rating = false;
}
$data['articles'][] = array(
'article_id' => $result['article_id'],
'thumb' => $image,
'name' => $result['name'],
'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('configblog_article_description_length')) . '..',
'rating' => $rating,
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
'viewed' => $result['viewed'],
'reviews' => sprintf($this->language->get('text_reviews'), (int)$result['reviews']),
'href' => $this->url->link('blog/article', 'article_id=' . $result['article_id']),
);
}
$this->load->model('tool/image');
$data['products'] = array();
$results = $this->model_blog_article->getArticleRelatedProduct($this->request->get['article_id']);
foreach ($results as $result) {
if ($result['image']) {
$image = $this->model_tool_image->resize($result['image'], $this->config->get('configblog_image_related_width'), $this->config->get('configblog_image_related_height'));
} else {
$image = false;
}
if ($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')), $this->session->data['currency']);
} else {
$price = false;
}
if ((float)$result['special']) {
$special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
} else {
$special = false;
}
if ($this->config->get('config_tax')) {
$tax = $this->currency->format((float)$result['special'] ? $result['special'] : $result['price'], $this->session->data['currency']);
} else {
$tax = false;
}
if ($this->config->get('configblog_review_status')) {
$rating = (int)$result['rating'];
} else {
$rating = false;
}
$data['text_tax'] = $this->language->get('text_tax');
$data['products'][] = array(
'product_id' => $result['product_id'],
'thumb' => $image,
'name' => $result['name'],
'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('configblog_article_description_length')) . '..',
'price' => $price,
'special' => $special,
'rating' => $rating,
'tax' => $tax,
'minimum' => $result['minimum'] > 0 ? $result['minimum'] : 1,
'reviews' => sprintf($this->language->get('text_reviews'), (int)$result['reviews']),
'href' => $this->url->link('product/product', 'product_id=' . $result['product_id']),
);
}
$data['download_status'] = $this->config->get('configblog_article_download');
$data['downloads'] = array();
$results = $this->model_blog_article->getDownloads($this->request->get['article_id']);
foreach ($results as $result) {
if (file_exists(DIR_DOWNLOAD . $result['filename'])) {
$size = filesize(DIR_DOWNLOAD . $result['filename']);
$i = 0;
$suffix = array(
'B',
'KB',
'MB',
'GB',
'TB',
'PB',
'EB',
'ZB',
'YB'
);
while (($size / 10024) > 1) {
$size = $size / 10024;
$i++;
}
$data['downloads'][] = array(
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
'name' => $result['name'],
'size' => round(substr($size, 0, strpos($size, '.') + 4), 2) . $suffix[$i],
'href' => $this->url->link('blog/article/download', '&article_id='. $this->request->get['article_id']. '&download_id=' . $result['download_id'])
);
}
}
$this->model_blog_article->updateViewed($this->request->get['article_id']);
$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');
$this->response->setOutput($this->load->view('blog/article', $data));
} else {
$url = '';
if (isset($this->request->get['blog_category_id'])) {
$url .= '&blog_category_id=' . $this->request->get['blog_category_id'];
}
if (isset($this->request->get['filter_name'])) {
$url .= '&filter_name=' . $this->request->get['filter_name'];
}
if (isset($this->request->get['filter_tag'])) {
$url .= '&filter_tag=' . $this->request->get['filter_tag'];
}
if (isset($this->request->get['filter_description'])) {
$url .= '&filter_description=' . $this->request->get['filter_description'];
}
if (isset($this->request->get['filter_news_id'])) {
$url .= '&filter_news_id=' . $this->request->get['filter_news_id'];
}
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_error'),
'href' => $this->url->link('product/product', $url . '&product_id=' . $article_id)
);
$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');
$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');
$this->response->setOutput($this->load->view('error/not_found', $data));
}
}
public function download() {
$this->load->model('blog/article');
if (isset($this->request->get['download_id'])) {
$download_id = $this->request->get['download_id'];
} else {
$download_id = 0;
}
if (isset($this->request->get['article_id'])) {
$article_id = $this->request->get['article_id'];
} else {
$article_id = 0;
}
$download_info = $this->model_blog_article->getDownload($article_id, $download_id);
if ($download_info) {
$file = DIR_DOWNLOAD . $download_info['filename'];
$mask = basename($download_info['mask']);
if (!headers_sent()) {
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . ($mask ? $mask : basename($file)) . '"');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
readfile($file, 'rb');
exit;
} else {
exit('Error: Could not find file ' . $file . '!');
}
} else {
exit('Error: Headers already sent out!');
}
} else {
$this->redirect(HTTP_SERVER . 'index.php?route=account/download');
}
}
public function review() {
$this->language->load('blog/article');
$this->load->model('blog/review');
$data['text_on'] = $this->language->get('text_on');
$data['text_no_reviews'] = $this->language->get('text_no_reviews');
if (isset($this->request->get['page'])) {
$page = $this->request->get['page'];
} else {
$page = 1;
}
$data['reviews'] = array();
$review_total = $this->model_blog_review->getTotalReviewsByArticleId($this->request->get['article_id']);
$results = $this->model_blog_review->getReviewsByArticleId($this->request->get['article_id'], ($page - 1) * 5, 5);
foreach ($results as $result) {
$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->url = $this->url->link('blog/article/review', 'article_id=' . $this->request->get['article_id'] . '&page={page}');
$data['pagination'] = $pagination->render();
$data['results'] = sprintf($this->language->get('text_pagination'), ($review_total) ? (($page - 1) * 5) + 1 : 0, ((($page - 1) * 5) > ($review_total - 5)) ? $review_total : ((($page - 1) * 5) + 5), $review_total, ceil($review_total / 5));
$this->response->setOutput($this->load->view('blog/review', $data));
}
public function write() {
$this->load->language('blog/article');
$json = array();
if ($this->request->server['REQUEST_METHOD'] == 'POST') {
if ((utf8_strlen($this->request->post['name']) < 3) || (utf8_strlen($this->request->post['name']) > 25)) {
$json['error'] = $this->language->get('error_name');
}
if ((utf8_strlen($this->request->post['text']) < 25) || (utf8_strlen($this->request->post['text']) > 1000)) {
$json['error'] = $this->language->get('error_text');
}
if (empty($this->request->post['rating']) || $this->request->post['rating'] < 0 || $this->request->post['rating'] > 5) {
$json['error'] = $this->language->get('error_rating');
}
// Captcha
if ($this->config->get($this->config->get('config_captcha') . '_status') && in_array('review', (array)$this->config->get('config_captcha_page'))) {
$captcha = $this->load->controller('extension/captcha/' . $this->config->get('config_captcha') . '/validate');
if ($captcha) {
$json['error'] = $captcha;
}
}
if (!isset($json['error'])) {
$this->load->model('blog/review');
$this->model_blog_review->addReview($this->request->get['article_id'], $this->request->post);
$json['success'] = $this->language->get('text_success');
}
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
}
?>
+417
View File
@@ -0,0 +1,417 @@
<?php
// * @source See SOURCE.txt for source and other copyright.
// * @license GNU General Public License version 3; see LICENSE.txt
class ControllerBlogCategory extends Controller {
public function index() {
$this->load->language('blog/category');
$this->load->model('blog/category');
$this->load->model('blog/article');
$this->load->model('tool/image');
if ($this->config->get('config_noindex_disallow_params')) {
$params = explode ("\r\n", $this->config->get('config_noindex_disallow_params'));
if(!empty($params)) {
$disallow_params = $params;
}
}
if (isset($this->request->get['sort'])) {
$sort = $this->request->get['sort'];
if (!in_array('sort', $disallow_params, true) && $this->config->get('config_noindex_status')) {
$this->document->setRobots('noindex,follow');
}
} else {
$sort = 'p.date_added';
}
if (isset($this->request->get['order'])) {
$order = $this->request->get['order'];
if (!in_array('order', $disallow_params, true) && $this->config->get('config_noindex_status')) {
$this->document->setRobots('noindex,follow');
}
} else {
$order = 'DESC';
}
if (isset($this->request->get['page'])) {
$page = $this->request->get['page'];
if (!in_array('page', $disallow_params, true) && $this->config->get('config_noindex_status')) {
$this->document->setRobots('noindex,follow');
}
} else {
$page = 1;
}
if (isset($this->request->get['limit'])) {
$limit = $this->request->get['limit'];
if (!in_array('limit', $disallow_params, true) && $this->config->get('config_noindex_status')) {
$this->document->setRobots('noindex,follow');
}
} else {
$limit = $this->config->get('configblog_article_limit');
}
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home')
);
$configblog_name = $this->config->get('configblog_name');
if (!empty($configblog_name)) {
$name = $this->config->get('configblog_name');
} else {
$name = $this->language->get('text_blog');
}
if (isset($this->request->get['blog_category_id'])) {
$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['limit'])) {
$url .= '&limit=' . $this->request->get['limit'];
}
$blog_category_id = '';
$parts = explode('_', (string)$this->request->get['blog_category_id']);
$blog_category_id = (int)array_pop($parts);
foreach ($parts as $blog_category_id_id) {
if (!$blog_category_id) {
$blog_category_id = (int)$blog_category_id_id;
} else {
$blog_category_id .= '_' . (int)$blog_category_id_id;
}
$category_info = $this->model_blog_category->getCategory($blog_category_id_id);
if ($category_info) {
$data['breadcrumbs'][] = array(
'text' => $category_info['name'],
'href' => $this->url->link('blog/category', 'blog_category_id=' . $blog_category_id . $url)
);
}
}
} else {
$blog_category_id = 0;
}
$category_info = $this->model_blog_category->getCategory($blog_category_id);
if ($category_info) {
if ($category_info['meta_title']) {
$this->document->setTitle($category_info['meta_title']);
} else {
$this->document->setTitle($category_info['name']);
}
if ($category_info['noindex'] <= 0 && $this->config->get('config_noindex_status')) {
$this->document->setRobots('noindex,follow');
}
if ($category_info['meta_h1']) {
$data['heading_title'] = $category_info['meta_h1'];
} else {
$data['heading_title'] = $category_info['name'];
}
$this->document->setDescription($category_info['meta_description']);
$this->document->setKeywords($category_info['meta_keyword']);
$this->document->addLink($this->url->link('blog/category', 'blog_category_id=' . $this->request->get['blog_category_id']), 'canonical');
$data['text_refine'] = $this->language->get('text_refine');
$data['text_empty'] = $this->language->get('text_empty');
$data['text_sort'] = $this->language->get('text_sort');
$data['text_limit'] = $this->language->get('text_limit');
$data['text_views'] = $this->language->get('text_views');
$data['button_continue'] = $this->language->get('button_continue');
$data['button_list'] = $this->language->get('button_list');
$data['button_grid'] = $this->language->get('button_grid');
$data['button_more'] = $this->language->get('button_more');
// Set the last category breadcrumb
$data['breadcrumbs'][] = array(
'text' => $category_info['name'],
'href' => $this->url->link('blog/category', 'blog_category_id=' . $this->request->get['blog_category_id'])
);
if ($category_info['image']) {
$data['thumb'] = $this->model_tool_image->resize($category_info['image'], $this->config->get('configblog_image_category_width'), $this->config->get('configblog_image_category_height'));
} else {
$data['thumb'] = '';
}
$data['description'] = html_entity_decode($category_info['description'], ENT_QUOTES, 'UTF-8');
$data['configblog_review_status'] = $this->config->get('configblog_review_status');
$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['limit'])) {
$url .= '&limit=' . $this->request->get['limit'];
}
$data['categories'] = array();
$results = $this->model_blog_category->getCategories($blog_category_id);
foreach ($results as $result) {
$filter_data = array(
'filter_blog_category_id' => $result['blog_category_id'],
'filter_sub_category' => true
);
$data['categories'][] = array(
'name' => $result['name'] . ($this->config->get('configblog_article_count') ? ' (' . $this->model_blog_article->getTotalArticles($filter_data) . ')' : ''),
'href' => $this->url->link('blog/category', 'blog_category_id=' . $this->request->get['blog_category_id'] . '_' . $result['blog_category_id'] . $url)
);
}
$data['articles'] = array();
$article_data = array(
'filter_blog_category_id' => $blog_category_id,
'sort' => $sort,
'order' => $order,
'start' => ($page - 1) * $limit,
'limit' => $limit
);
$article_total = $this->model_blog_article->getTotalArticles($article_data);
$results = $this->model_blog_article->getArticles($article_data);
foreach ($results as $result) {
if ($result['image']) {
$image = $this->model_tool_image->resize($result['image'], $this->config->get('configblog_image_article_width'), $this->config->get('configblog_image_article_height'));
} else {
$image = $this->model_tool_image->resize('placeholder.png', $this->config->get('configblog_image_article_width'), $this->config->get('configblog_image_article_height'));
}
if ($this->config->get('configblog_review_status')) {
$rating = (int)$result['rating'];
} else {
$rating = false;
}
$data['articles'][] = array(
'article_id' => $result['article_id'],
'thumb' => $image,
'name' => $result['name'],
'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('configblog_article_description_length')) . '..',
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
'viewed' => $result['viewed'],
'rating' => $result['rating'],
'href' => $this->url->link('blog/article', 'blog_category_id=' . $this->request->get['blog_category_id'] . '&article_id=' . $result['article_id'] . $url)
);
}
$url = '';
if (isset($this->request->get['limit'])) {
$url .= '&limit=' . $this->request->get['limit'];
}
$data['sorts'] = array();
$data['sorts'][] = array(
'text' => $this->language->get('text_default'),
'value' => 'p.sort_order-ASC',
'href' => $this->url->link('blog/category', 'blog_category_id=' . $this->request->get['blog_category_id'] . '&sort=p.sort_order&order=ASC' . $url)
);
$data['sorts'][] = array(
'text' => $this->language->get('text_name_asc'),
'value' => 'pd.name-ASC',
'href' => $this->url->link('blog/category', 'blog_category_id=' . $this->request->get['blog_category_id'] . '&sort=pd.name&order=ASC' . $url)
);
$data['sorts'][] = array(
'text' => $this->language->get('text_name_desc'),
'value' => 'pd.name-DESC',
'href' => $this->url->link('blog/category', 'blog_category_id=' . $this->request->get['blog_category_id'] . '&sort=pd.name&order=DESC' . $url)
);
$data['sorts'][] = array(
'text' => $this->language->get('text_date_asc'),
'value' => 'p.date_added-ASC',
'href' => $this->url->link('blog/category', 'blog_category_id=' . $this->request->get['blog_category_id'] . '&sort=p.date_added&order=ASC' . $url)
);
$data['sorts'][] = array(
'text' => $this->language->get('text_date_desc'),
'value' => 'p.date_added-DESC',
'href' => $this->url->link('blog/category', 'blog_category_id=' . $this->request->get['blog_category_id'] . '&sort=p.date_added&order=DESC' . $url)
);
if ($this->config->get('configblog_review_status')) {
$data['sorts'][] = array(
'text' => $this->language->get('text_rating_desc'),
'value' => 'rating-DESC',
'href' => $this->url->link('blog/category', 'blog_category_id=' . $this->request->get['blog_category_id'] . '&sort=rating&order=DESC' . $url)
);
$data['sorts'][] = array(
'text' => $this->language->get('text_rating_asc'),
'value' => 'rating-ASC',
'href' => $this->url->link('blog/category', 'blog_category_id=' . $this->request->get['blog_category_id'] . '&sort=rating&order=ASC' . $url)
);
}
//OCSTORE.COM sort viewed
$data['sorts'][] = array(
'text' => $this->language->get('text_viewed_asc'),
'value' => 'p.viewed-ASC',
'href' => $this->url->link('blog/category', 'blog_category_id=' . $this->request->get['blog_category_id'] . '&sort=p.viewed&order=ASC' . $url)
);
$data['sorts'][] = array(
'text' => $this->language->get('text_viewed_desc'),
'value' => 'p.viewed-DESC',
'href' => $this->url->link('blog/category', 'blog_category_id=' . $this->request->get['blog_category_id'] . '&sort=p.viewed&order=DESC' . $url)
);
//OCSTORE.COM sort viewed
$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'];
}
$data['limits'] = array();
$limits = array_unique(array($this->config->get('configblog_article_limit'), 25, 50, 75, 100));
sort($limits);
foreach($limits as $value) {
$data['limits'][] = array(
'text' => $value,
'value' => $value,
'href' => $this->url->link('blog/category', 'blog_category_id=' . $this->request->get['blog_category_id'] . $url . '&limit=' . $value)
);
}
$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['limit'])) {
$url .= '&limit=' . $this->request->get['limit'];
}
$pagination = new Pagination();
$pagination->total = $article_total;
$pagination->page = $page;
$pagination->limit = $limit;
$pagination->url = $this->url->link('blog/category', 'blog_category_id=' . $this->request->get['blog_category_id'] . $url . '&page={page}');
$data['pagination'] = $pagination->render();
$data['results'] = sprintf($this->language->get('text_pagination'), ($article_total) ? (($page - 1) * $limit) + 1 : 0, ((($page - 1) * $limit) > ($article_total - $limit)) ? $article_total : ((($page - 1) * $limit) + $limit), $article_total, ceil($article_total / $limit));
$data['sort'] = $sort;
$data['order'] = $order;
$data['limit'] = $limit;
$data['continue'] = $this->url->link('common/home');
$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');
$this->response->setOutput($this->load->view('blog/category', $data));
} else {
$url = '';
if (isset($this->request->get['blog_category_id'])) {
$url .= '&blog_category_id=' . $this->request->get['blog_category_id'];
}
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'];
}
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_error'),
'href' => $this->url->link('blog/category', $url)
);
$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');
$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');
$this->response->setOutput($this->load->view('error/not_found', $data));
}
}
}
+306
View File
@@ -0,0 +1,306 @@
<?php
// * @source See SOURCE.txt for source and other copyright.
// * @license GNU General Public License version 3; see LICENSE.txt
class ControllerBlogLatest extends Controller {
public function index() {
$this->load->language('blog/latest');
$this->load->model('blog/article');
$this->load->model('tool/image');
if ($this->config->get('config_noindex_disallow_params')) {
$params = explode ("\r\n", $this->config->get('config_noindex_disallow_params'));
if(!empty($params)) {
$disallow_params = $params;
}
}
if (isset($this->request->get['sort'])) {
$sort = $this->request->get['sort'];
if (!in_array('sort', $disallow_params, true) && $this->config->get('config_noindex_status')) {
$this->document->setRobots('noindex,follow');
}
} else {
$sort = 'p.date_added';
}
if (isset($this->request->get['order'])) {
$order = $this->request->get['order'];
if (!in_array('order', $disallow_params, true) && $this->config->get('config_noindex_status')) {
$this->document->setRobots('noindex,follow');
}
} else {
$order = 'DESC';
}
if (isset($this->request->get['page'])) {
$page = $this->request->get['page'];
if (!in_array('page', $disallow_params, true) && $this->config->get('config_noindex_status')) {
$this->document->setRobots('noindex,follow');
}
} else {
$page = 1;
}
if (isset($this->request->get['limit'])) {
$limit = $this->request->get['limit'];
if (!in_array('limit', $disallow_params, true) && $this->config->get('config_noindex_status')) {
$this->document->setRobots('noindex,follow');
}
} else {
$limit = $this->config->get('configblog_article_limit');
}
$configblog_html_h1 = $this->config->get('configblog_html_h1');
if (!empty($configblog_html_h1)) {
$data['heading_title'] = $this->config->get('configblog_html_h1');
} else {
$data['heading_title'] = $this->language->get('heading_title');
}
$configblog_meta_title = $this->config->get('configblog_meta_title');
if (!empty($configblog_meta_title)) {
$this->document->setTitle($this->config->get('configblog_meta_title'));
} else {
$this->document->setTitle($this->language->get('heading_title'));
}
$this->document->setDescription($this->config->get('configblog_meta_description'));
$this->document->setKeywords($this->config->get('configblog_meta_keyword'));
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home')
);
$configblog_name = $this->config->get('configblog_name');
if (!empty($configblog_name)) {
$name = $this->config->get('configblog_name');
} else {
$name = $this->language->get('heading_title');
}
$data['breadcrumbs'][] = array(
'text' => $name,
'href' => $this->url->link('blog/latest')
);
$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'];
}
$data['text_refine'] = $this->language->get('text_refine');
$data['text_views'] = $this->language->get('text_views');
$data['text_empty'] = $this->language->get('text_empty');
$data['text_display'] = $this->language->get('text_display');
$data['text_list'] = $this->language->get('text_list');
$data['text_grid'] = $this->language->get('text_grid');
$data['text_sort'] = $this->language->get('text_sort');
$data['text_limit'] = $this->language->get('text_limit');
$data['text_sort_by'] = $this->language->get('text_sort_by');
$data['text_sort_name'] = $this->language->get('text_sort_name');
$data['text_sort_date'] = $this->language->get('text_sort_date');
$data['text_sort_rated'] = $this->language->get('text_sort_rated');
$data['text_sort_viewed'] = $this->language->get('text_sort_viewed');
$data['button_more'] = $this->language->get('button_more');
$data['button_continue'] = $this->language->get('button_continue');
$data['configblog_review_status'] = $this->config->get('configblog_review_status');
$data['articles'] = array();
$article_data = array(
'sort' => $sort,
'order' => $order,
'start' => ($page - 1) * $limit,
'limit' => $limit
);
$article_total = $this->model_blog_article->getTotalArticles($article_data);
$results = $this->model_blog_article->getArticles($article_data);
foreach ($results as $result) {
if ($result['image']) {
$image = $this->model_tool_image->resize($result['image'], $this->config->get('configblog_image_article_width'), $this->config->get('configblog_image_article_height'));
} else {
$image = false;
}
if ($this->config->get('configblog_review_status')) {
$rating = (int)$result['rating'];
} else {
$rating = false;
}
$data['articles'][] = array(
'article_id' => $result['article_id'],
'thumb' => $image,
'name' => $result['name'],
'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('configblog_article_description_length')) . '..',
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
'viewed' => $result['viewed'],
'rating' => $rating,
'reviews' => sprintf($this->language->get('text_reviews'), (int)$result['reviews']),
'href' => $this->url->link('blog/article', '&article_id=' . $result['article_id'])
);
}
$url = '';
if (isset($this->request->get['limit'])) {
$url .= '&limit=' . $this->request->get['limit'];
}
$data['sorts'] = array();
$data['sorts'][] = array(
'text' => $this->language->get('text_default'),
'value' => 'p.sort_order-ASC',
'href' => $this->url->link('blog/latest', 'blog_category_id=' . '&sort=p.sort_order&order=ASC' . $url)
);
$data['sorts'][] = array(
'text' => $this->language->get('text_name_asc'),
'value' => 'pd.name-ASC',
'href' => $this->url->link('blog/latest', 'blog_category_id=' . '&sort=pd.name&order=ASC' . $url)
);
$data['sorts'][] = array(
'text' => $this->language->get('text_name_desc'),
'value' => 'pd.name-DESC',
'href' => $this->url->link('blog/latest', 'blog_category_id=' . '&sort=pd.name&order=DESC' . $url)
);
$data['sorts'][] = array(
'text' => $this->language->get('text_date_asc'),
'value' => 'p.date_added-ASC',
'href' => $this->url->link('blog/latest', '&sort=p.date_added&order=ASC' . $url)
);
$data['sorts'][] = array(
'text' => $this->language->get('text_date_desc'),
'value' => 'p.date_added-DESC',
'href' => $this->url->link('blog/latest', '&sort=p.date_added&order=DESC' . $url)
);
if ($this->config->get('configblog_review_status')) {
$data['sorts'][] = array(
'text' => $this->language->get('text_rating_desc'),
'value' => 'rating-DESC',
'href' => $this->url->link('blog/latest', '&sort=rating&order=DESC' . $url)
);
$data['sorts'][] = array(
'text' => $this->language->get('text_rating_asc'),
'value' => 'rating-ASC',
'href' => $this->url->link('blog/latest', '&sort=rating&order=ASC' . $url)
);
}
$data['sorts'][] = array(
'text' => $this->language->get('text_viewed_desc'),
'value' => 'p.viewed-DESC',
'href' => $this->url->link('blog/latest', '&sort=p.viewed&order=DESC' . $url)
);
$data['sorts'][] = array(
'text' => $this->language->get('text_viewed_asc'),
'value' => 'p.viewed-ASC',
'href' => $this->url->link('blog/latest', '&sort=p.viewed&order=ASC' . $url)
);
$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'];
}
$data['limits'] = array();
$limits = array_unique(array($this->config->get('configblog_article_limit'), 25, 50, 75, 100));
sort($limits);
foreach($limits as $value){
$data['limits'][] = array(
'text' => $value,
'value' => $value,
'href' => $this->url->link('blog/latest', $url . '&limit=' . $value)
);
}
$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['limit'])) {
$url .= '&limit=' . $this->request->get['limit'];
}
$pagination = new Pagination();
$pagination->total = $article_total;
$pagination->page = $page;
$pagination->limit = $limit;
$pagination->text = $this->language->get('text_pagination');
$pagination->url = $this->url->link('blog/latest', $url . '&page={page}');
$data['pagination'] = $pagination->render();
$data['article_total'] = $article_total;
$data['continue'] = $this->url->link('common/home');
$data['sort'] = $sort;
$data['order'] = $order;
$data['limit'] = $limit;
$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');
$this->response->setOutput($this->load->view('blog/latest', $data));
}
}
?>
+66
View File
@@ -0,0 +1,66 @@
<?php
// * @source See SOURCE.txt for source and other copyright.
// * @license GNU General Public License version 3; see LICENSE.txt
class ControllerBlogMenu extends Controller {
public function index() {
$this->load->language('blog/menu');
$configblog_name = $this->config->get('configblog_name');
if (!empty($configblog_name)) {
$data['text_blog'] = $this->config->get('configblog_name');
} else {
$data['text_blog'] = $this->language->get('text_blog');
}
$data['text_all'] = $this->language->get('text_all');
$data['blog'] = $this->url->link('blog/latest');
// Menu
$this->load->model('blog/category');
$this->load->model('blog/article');
$data['categories'] = array();
$categories = $this->model_blog_category->getCategories(0);
foreach ($categories as $category) {
if ($category['top']) {
// Level 2
$children_data = array();
$children = $this->model_blog_category->getCategories($category['blog_category_id']);
foreach ($children as $child) {
$filter_data = array(
'filter_blog_category_id' => $child['blog_category_id'],
'filter_sub_category' => true
);
$children_data[] = array(
'name' => $child['name'] . ($this->config->get('configblog_article_count') ? ' (' . $this->model_blog_article->getTotalArticles($filter_data) . ')' : ''),
'href' => $this->url->link('blog/category', 'blog_category_id=' . $category['blog_category_id'] . '_' . $child['blog_category_id'])
);
}
// Level 1
$filter_data = array(
'filter_blog_category_id' => $category['blog_category_id']
);
$data['categories'][] = array(
'name' => $category['name'] . ($this->config->get('configblog_article_count') ? ' (' . $this->model_blog_article->getTotalArticles($filter_data) . ')' : ''),
'children' => $children_data,
'column' => $category['column'] ? $category['column'] : 1,
'href' => $this->url->link('blog/category', 'blog_category_id=' . $category['blog_category_id'])
);
}
}
return $this->load->view('blog/menu', $data);
}
}