예제 #1
0
파일: record.php 프로젝트: BulatSa/Ctex
 public function index()
 {
     $ver = VERSION;
     if (!defined('SCP_VERSION')) {
         define('SCP_VERSION', $ver[0]);
     }
     $this->config->set("blog_work", true);
     $this->load->model('setting/setting');
     $this->data['blog_version'] = '';
     $this->data['blog_version_model'] = '';
     $settings_admin = $this->model_setting_setting->getSetting('ascp_version', 'ascp_version');
     foreach ($settings_admin as $key => $value) {
         $this->data['blog_version'] = $value;
     }
     $settings_admin_model = $this->model_setting_setting->getSetting('ascp_version_model', 'ascp_version_model');
     foreach ($settings_admin_model as $key => $value) {
         $this->data['blog_version_model'] = $value;
     }
     $this->data['blog_version'] = $this->data['blog_version'] . ' ' . $this->data['blog_version_model'];
     $this->data['config_template'] = $this->config->get('config_template');
     if (file_exists(DIR_APPLICATION . 'view/javascript/jquery/tabs.js')) {
         $this->document->addScript('catalog/view/javascript/jquery/tabs.js');
     } else {
         if (file_exists(DIR_APPLICATION . 'view/javascript/blog/tabs/tabs.js')) {
             $this->document->addScript('catalog/view/javascript/blog/tabs/tabs.js');
         }
     }
     $this->document->addScript('catalog/view/javascript/blog/blog.comment.js');
     require_once DIR_SYSTEM . 'helper/utf8blog.php';
     if (isset($this->request->get['ajax']) && $this->request->get['ajax'] == 2 || isset($this->request->post['ajax']) && $this->request->post['ajax'] == 1) {
         $this->data['ajax'] = true;
     } else {
         $this->data['ajax'] = false;
     }
     $this->language->load('record/record');
     $this->data['breadcrumbs'] = array();
     $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home'), 'separator' => false);
     if ($this->config->get('ascp_settings') != '') {
         $this->data['settings_general'] = $this->config->get('ascp_settings');
     } else {
         $this->data['settings_general'] = array();
     }
     if (!isset($this->data['settings_general']['colorbox_theme'])) {
         $this->data['settings_general']['colorbox_theme'] = 0;
     }
     $this->cont('module/blog');
     $this->data = $this->controller_module_blog->ColorboxLoader($this->data['settings_general']['colorbox_theme'], $this->data);
     $http_image = getHttpImage($this);
     $this->load->model('catalog/blog');
     if (isset($this->request->get['record_id'])) {
         $record_id = $this->request->get['record_id'];
         $blog_info = $this->model_catalog_blog->getPathByrecord($record_id);
         $this->request->get['blog_id'] = $blog_info['path'];
     } else {
         $record_id = false;
     }
     if (isset($blog_info['path'])) {
         $path = '';
         foreach (explode('_', $blog_info['path']) as $path_id) {
             $blog_id = $path_id;
         }
     } else {
         $blog_id = 0;
     }
     if (isset($this->request->get['blog_id'])) {
         $path = '';
         foreach (explode('_', $this->request->get['blog_id']) as $path_id) {
             if (!$path) {
                 $path = $path_id;
             } else {
                 $path .= '_' . $path_id;
             }
             $path_id . "->" . $this->request->get['blog_id'];
             $blog_info = $this->model_catalog_blog->getBlog($path_id);
             if ($blog_info) {
                 $this->data['breadcrumbs'][] = array('text' => $blog_info['name'], 'href' => $this->url->link('record/blog', 'blog_id=' . $path), 'separator' => $this->language->get('text_separator'));
             }
             //$blog_info
         }
         //explode('_', $this->request->get['blog_id']) as $path_id
     } else {
         $path = '';
     }
     $sort_data = array('rating', 'comments', 'popular', 'latest', 'sort');
     if (isset($blog_info['design']) && $blog_info['design'] != '') {
         $this->data['blog_design'] = unserialize($blog_info['design']);
     } else {
         $this->data['blog_design'] = array();
     }
     $sort = 'p.sort_order';
     if (isset($this->data['blog_design']['order']) && in_array($this->data['blog_design']['order'], $sort_data)) {
         if ($this->data['blog_design']['order'] == 'rating') {
             $sort = 'rating';
         }
         //$this->data['blog_design']['order'] == 'rating'
         if ($this->data['blog_design']['order'] == 'comments') {
             $sort = 'comments';
         }
         //$this->data['blog_design']['order'] == 'comments'
         if ($this->data['blog_design']['order'] == 'latest') {
             $sort = 'p.date_available';
         }
         //$this->data['blog_design']['order'] == 'latest'
         if ($this->data['blog_design']['order'] == 'sort') {
             $sort = 'p.sort_order';
         }
         //$this->data['blog_design']['order'] == 'sort'
         if ($this->data['blog_design']['order'] == 'popular') {
             $sort = 'p.viewed';
         }
         //$this->data['blog_design']['order'] == 'popular'
     }
     //isset($this->data['blog_design']['order']) && in_array($this->data['blog_design']['order'], $sort_data)
     $order = 'DESC';
     if (isset($this->data['blog_design']['order_ad'])) {
         if (strtoupper($this->data['blog_design']['order_ad']) == 'ASC') {
             $order = 'ASC';
         }
         //strtoupper($this->data['blog_design']['order_ad']) == 'ASC'
         if (strtoupper($this->data['blog_design']['order']) == 'DESC') {
             $order = 'DESC';
         }
         //strtoupper($this->data['blog_design']['order']) == 'DESC'
     }
     //isset($this->data['blog_design']['order_ad'])
     $this->load->model('catalog/record');
     $data = array('filter_blog_id' => $blog_id, 'sort' => $sort, 'order' => $order);
     $result_blog_records = $this->model_catalog_record->getRecords($data);
     if ($result_blog_records) {
         $previousKey = false;
         $nextKey = false;
         $next_flag = false;
         $this->data['record_previous']['url'] = '';
         $this->data['record_previous']['name'] = '';
         $this->data['record_next']['url'] = '';
         $this->data['record_next']['name'] = '';
         foreach ($result_blog_records as $num => $rec) {
             if ($next_flag) {
                 $this->data['record_next']['url'] = $this->url->link('record/record', '&record_id=' . $result_blog_records[$num]['record_id']);
                 $this->data['record_next']['name'] = $result_blog_records[$num]['name'];
                 $next_flag = false;
             }
             //$next_flag
             if ($rec['record_id'] == $record_id) {
                 $next_flag = true;
                 if ($previousKey) {
                     if (isset($result_blog_records[$previousKey])) {
                         $this->data['record_previous']['url'] = $this->url->link('record/record', '&record_id=' . $result_blog_records[$previousKey]['record_id']);
                         $this->data['record_previous']['name'] = $result_blog_records[$previousKey]['name'];
                     }
                     //isset($result_blog_records[$previousKey])
                 }
                 //$previousKey
             }
             //$rec['record_id'] == $record_id
             $previousKey = $num;
         }
         //$result_blog_records as $num => $rec
     }
     //$result_blog_records
     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'];
         }
         //isset($this->request->get['filter_name'])
         if (isset($this->request->get['filter_tag'])) {
             $url .= '&filter_tag=' . $this->request->get['filter_tag'];
         }
         //isset($this->request->get['filter_tag'])
         if (isset($this->request->get['filter_description'])) {
             $url .= '&filter_description=' . $this->request->get['filter_description'];
         }
         //isset($this->request->get['filter_description'])
         if (isset($this->request->get['filter_blog_id'])) {
             $url .= '&filter_blog_id=' . $this->request->get['filter_blog_id'];
         }
         //isset($this->request->get['filter_blog_id'])
         $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_search'), 'href' => $this->url->link('record/blog', $url), 'separator' => $this->language->get('text_separator'));
     }
     //isset($this->request->get['filter_name']) || isset($this->request->get['filter_tag'])
     if (isset($this->request->get['record_id'])) {
         $record_id = $this->request->get['record_id'];
     } else {
         $record_id = 0;
     }
     $this->load->model('catalog/record');
     $record_info = $this->model_catalog_record->getRecord($record_id);
     if ($record_info) {
         $url = '';
         if (isset($this->request->get['blog_id'])) {
             $url .= '&blog_id=' . $this->request->get['blog_id'];
         }
         //isset($this->request->get['blog_id'])
         if (isset($this->request->get['filter_name'])) {
             $url .= '&filter_name=' . $this->request->get['filter_name'];
         }
         //isset($this->request->get['filter_name'])
         if (isset($this->request->get['filter_tag'])) {
             $url .= '&filter_tag=' . $this->request->get['filter_tag'];
         }
         //isset($this->request->get['filter_tag'])
         if (isset($this->request->get['filter_description'])) {
             $url .= '&filter_description=' . $this->request->get['filter_description'];
         }
         //isset($this->request->get['filter_description'])
         if (isset($this->request->get['filter_blog_id'])) {
             $url .= '&filter_blog_id=' . $this->request->get['filter_blog_id'];
         }
         //isset($this->request->get['filter_blog_id'])
         $this->data['breadcrumbs'][] = array('text' => $record_info['name'], 'href' => $this->url->link('record/record', '&record_id=' . $this->request->get['record_id']), 'separator' => $this->language->get('text_separator'));
         if (isset($record_info['meta_title']) && $record_info['meta_title'] != '') {
             $this->document->setTitle($record_info['meta_title']);
         } else {
             $this->document->setTitle($record_info['name'] . " - " . $this->config->get('config_title'));
         }
         if (isset($record_info['meta_h1']) && $record_info['meta_h1'] != '') {
             $this->data['heading_title'] = $record_info['meta_h1'];
         } else {
             $this->data['heading_title'] = $record_info['name'];
         }
         $this->data['name'] = $record_info['name'];
         $this->document->setDescription($record_info['meta_description']);
         $this->document->setKeywords($record_info['meta_keyword']);
         $this->load->model('catalog/comment');
         $this->data['text_welcome'] = sprintf($this->language->get('text_welcome'), $this->url->link('account/login', '', 'SSL'), $this->url->link('account/register', '', 'SSL'));
         $this->data['text_select'] = $this->language->get('text_select');
         $this->data['text_or'] = $this->language->get('text_or');
         $this->data['text_write'] = $this->language->get('text_write');
         $this->data['text_note'] = $this->language->get('text_note');
         $this->data['text_share'] = $this->language->get('text_share');
         $this->data['text_wait'] = $this->language->get('text_wait');
         $this->data['text_tags'] = $this->language->get('text_tags');
         $this->data['text_viewed'] = $this->language->get('text_viewed');
         $this->data['entry_name'] = $this->language->get('entry_name');
         $this->data['entry_comment'] = $this->language->get('entry_comment');
         $this->data['entry_rating'] = $this->language->get('entry_rating');
         $this->data['entry_good'] = $this->language->get('entry_good');
         $this->data['entry_bad'] = $this->language->get('entry_bad');
         $this->data['entry_captcha'] = $this->language->get('entry_captcha');
         $this->data['entry_captcha_title'] = $this->language->get('entry_captcha_title');
         $this->data['entry_captcha_update'] = $this->language->get('entry_captcha_update');
         $this->data['button_cart'] = $this->language->get('button_cart');
         $this->data['button_wishlist'] = $this->language->get('button_wishlist');
         $this->data['button_compare'] = $this->language->get('button_compare');
         $this->data['button_upload'] = $this->language->get('button_upload');
         $this->data['button_write'] = $this->language->get('button_write');
         $this->data['tab_description'] = $this->language->get('tab_description');
         $this->data['tab_attribute'] = $this->language->get('tab_attribute');
         $this->data['tab_advertising'] = $this->language->get('tab_advertising');
         $this->data['tab_comment'] = $this->language->get('tab_comment');
         $this->data['tab_images'] = $this->language->get('tab_images');
         $this->data['tab_related'] = $this->language->get('tab_related');
         $this->data['tab_product_related'] = $this->language->get('tab_product_related');
         $this->data['text_author'] = $this->language->get('text_author');
         $this->data['record_id'] = $this->request->get['record_id'];
         /*
         			$this->data['model']                = $record_info['model'];
         			$this->data['reward']               = $record_info['reward'];
         			$this->data['points']               = $record_info['points'];
         			$this->data['text_model']           = $this->language->get('text_model');
         			$this->data['text_reward']          = $this->language->get('text_reward');
         			$this->data['text_points']          = $this->language->get('text_points');
         			$this->data['text_stock']           = $this->language->get('text_stock');
         			$this->data['text_price']           = $this->language->get('text_price');
         			$this->data['text_tax']             = $this->language->get('text_tax');
         			$this->data['text_option']          = $this->language->get('text_option');
         			$this->data['text_qty']             = $this->language->get('text_qty');
         */
         $this->data['comment_count'] = $this->model_catalog_comment->getTotalCommentsByRecordId($this->request->get['record_id']);
         $this->load->model('tool/image');
         if ($record_info['image']) {
             $this->data['popup'] = $http_image . $record_info['image'];
         } else {
             $this->data['popup'] = '';
         }
         if ($record_info['image']) {
             if (isset($this->data['blog_design']['thumb_image']['width']) && $this->data['blog_design']['thumb_image']['width'] != '') {
                 $width = $this->data['blog_design']['thumb_image']['width'];
             } else {
                 $width = $this->config->get('config_image_thumb_width');
             }
             if (isset($this->data['blog_design']['thumb_image']['height']) && $this->data['blog_design']['thumb_image']['height'] != '') {
                 $height = $this->data['blog_design']['thumb_image']['height'];
             } else {
                 $height = $this->config->get('config_image_thumb_height');
             }
             $this->data['thumb'] = $this->model_tool_image->resize($record_info['image'], $width, $height);
         } else {
             $this->data['thumb'] = '';
         }
         $this->data['href'] = $this->url->link('record/record', 'record_id=' . $this->request->get['record_id']);
         $this->load->library('document');
         if (method_exists($this->document, 'setOgImage') && $this->data['thumb'] != '') {
             $this->document->setOgImage($this->data['thumb']);
         }
         if (method_exists($this->document, 'setOgTitle')) {
             $this->document->setOgTitle($this->document->getTitle());
         }
         if (method_exists($this->document, 'setOgDescription')) {
             $this->document->setOgDescription($this->document->getDescription());
         }
         if (method_exists($this->document, 'setOgUrl')) {
             $this->document->setOgUrl($this->data['href']);
         }
         $this->document->addLink($this->data['thumb'], 'image_src');
         $this->data['images'] = array();
         if (!isset($this->data['blog_design']['images'])) {
             $this->data['blog_design']['images'] = array();
         }
         if (!isset($this->data['blog_design']['product_image'])) {
             $this->data['blog_design']['product_image'] = $this->data['blog_design']['images'];
         }
         if (!isset($this->data['blog_design']['gallery_image'])) {
             $this->data['blog_design']['gallery_image'] = $this->data['blog_design']['product_image'];
         }
         $this->data['images'] = $this->getRecordImages($this->request->get['record_id'], $this->data['blog_design']['gallery_image']);
         if (isset($this->data['settings_general']['box_share']) && $this->data['settings_general']['box_share'] != '') {
             $this->data['box_share'] = html_entity_decode($this->data['settings_general']['box_share']);
         } else {
             $this->data['box_share'] = '';
         }
         $this->data['options'] = array();
         $this->data['text_comments'] = sprintf($this->language->get('text_comments'), (int) $record_info['comments']);
         $this->data['comments'] = (int) $record_info['comments'];
         $record_comment = unserialize($record_info['comment']);
         $this->data['record_comment'] = $record_comment;
         $this->data['comment_status'] = $record_comment['status'];
         if ($this->customer->isLogged()) {
             $this->data['text_login'] = $this->customer->getFirstName() . " " . $this->customer->getLastName();
             $this->data['captcha_status'] = false;
             $this->data['customer_id'] = $this->customer->getId();
         } else {
             $this->data['text_login'] = $this->language->get('text_anonymus');
             $this->data['captcha_status'] = true;
             $this->data['customer_id'] = false;
             $this->data['signer_code'] = 'customer_id';
             $this->language->load('account/login');
             $this->data['text_new_customer'] = $this->language->get('text_new_customer');
             $this->data['text_register'] = $this->language->get('text_register');
             $this->data['text_register_account'] = $this->language->get('text_register_account');
             $this->data['text_returning_customer'] = $this->language->get('text_returning_customer');
             $this->data['text_i_am_returning_customer'] = $this->language->get('text_i_am_returning_customer');
             $this->data['text_forgotten'] = $this->language->get('text_forgotten');
             $this->data['entry_email'] = $this->language->get('entry_email');
             $this->data['entry_password'] = $this->language->get('entry_password');
             $this->data['button_continue'] = $this->language->get('button_continue');
             $this->data['button_login'] = $this->language->get('button_login');
             if (isset($this->error['warning'])) {
                 $this->data['error_warning'] = $this->error['warning'];
             } else {
                 $this->data['error_warning'] = '';
             }
             if (isset($this->session->data['success'])) {
                 $this->data['success'] = $this->session->data['success'];
                 unset($this->session->data['success']);
             } else {
                 $this->data['success'] = '';
             }
             if (isset($this->request->post['email'])) {
                 $this->data['email'] = $this->request->post['email'];
             } else {
                 $this->data['email'] = '';
             }
             if (isset($this->request->post['password'])) {
                 $this->data['password'] = $this->request->post['password'];
             } else {
                 $this->data['password'] = '';
             }
             $this->data['action'] = $this->url->link('account/login', '', 'SSL');
             $this->data['register'] = $this->url->link('account/register', '', 'SSL');
             $this->data['forgotten'] = $this->url->link('account/forgotten', '', 'SSL');
             if (isset($this->request->post['redirect']) && (strpos($this->request->post['redirect'], $this->config->get('config_url')) !== false || strpos($this->request->post['redirect'], $this->config->get('config_ssl')) !== false)) {
                 $this->data['redirect'] = $this->request->post['redirect'];
             } elseif (isset($this->session->data['redirect'])) {
                 $this->data['redirect'] = $this->session->data['redirect'];
                 unset($this->session->data['redirect']);
             } else {
                 $this->data['redirect'] = $this->data['href'];
             }
         }
         $this->language->load('record/signer');
         $this->data['pointer'] = 'record_id';
         $this->load->model('agoo/signer/signer');
         if (isset($_COOKIE['email_subscribe_record_id']) && isset($this->data['pointer'])) {
             $email_subscribe = unserialize(base64_decode($_COOKIE['email_subscribe_' . $this->data['pointer']]));
             if (isset($email_subscribe[$this->data['record_id']])) {
                 $email_subscribe = $email_subscribe[$this->data['record_id']];
             } else {
                 $email_subscribe = '';
             }
         } else {
             $email_subscribe = false;
         }
         $this->data['signer_status'] = $this->model_agoo_signer_signer->getStatus($this->request->get['record_id'], $this->data['customer_id'], 'record_id', $email_subscribe);
         $this->data['viewed'] = $record_info['viewed'];
         if (!isset($record_info['date_available'])) {
             $this->data['date'] = $record_info['date_available'] = $record_info['date_added'];
         } else {
             $this->data['date'] = $record_info['date_available'];
         }
         $this->data['author'] = $record_info['author'];
         $this->data['author_customer_id'] = $record_info['customer_id'];
         /*
         
         			if (rdate($this,$this->language->get('text_date')) == rdate($this,$this->language->get('text_date'), strtotime($record_info['date_available']))) {
         				$date_str = $this->language->get('text_today');
         			} //rdate($this,$this->language->get('text_date')) == rdate($this,$this->language->get('text_date'), strtotime($record_info['date_available']))
         			else {
         				$date_str = rdate($this,$this->language->get('text_date'), strtotime($record_info['date_available']));
         			}
         			$date_available = $date_str.(rdate($this,  $this->language->get('text_hours'), strtotime($record_info['date_available'])));
         */
         if (isset($this->data['settings_general']['format_date'])) {
         } else {
             $this->data['settings_general']['format_date'] = $this->language->get('text_date');
         }
         if (isset($this->data['settings_general']['format_hours'])) {
         } else {
             $this->data['settings_general']['format_hours'] = $this->language->get('text_hours');
         }
         if (isset($this->data['settings_general']['format_time']) && $this->data['settings_general']['format_time'] && date($this->data['settings_general']['format_date']) == date($this->data['settings_general']['format_date'], strtotime($record_info['date_available']))) {
             $date_str = $this->language->get('text_today');
         } else {
             $date_str = rdate($this, $this->data['settings_general']['format_date'], strtotime($record_info['date_available']));
         }
         $date_available = $date_str . rdate($this, $this->data['settings_general']['format_hours'], strtotime($record_info['date_available']));
         if (!isset($this->data['blog_design']['view_date'])) {
             $this->data['blog_design']['view_date'] = 1;
         }
         //!isset($this->data['blog_design']['view_date'])
         if (!isset($this->data['blog_design']['view_share'])) {
             $this->data['blog_design']['view_share'] = 1;
         }
         //!isset($this->data['blog_design']['view_share'])
         if (!isset($this->data['blog_design']['view_viewed'])) {
             $this->data['blog_design']['view_viewed'] = 1;
         }
         //!isset($this->data['blog_design']['view_viewed'])
         if (!isset($this->data['blog_design']['view_rating'])) {
             $this->data['blog_design']['view_rating'] = 1;
         }
         //!isset($this->data['blog_design']['view_rating'])
         if (!isset($this->data['blog_design']['view_comments'])) {
             $this->data['blog_design']['view_comments'] = 1;
         }
         //!isset($this->data['blog_design']['view_comments'])
         if (isset($this->data['blog_design']['view_captcha']) && !$this->data['blog_design']['view_captcha']) {
             $this->data['captcha_status'] = false;
         }
         //isset($this->data['blog_design']['view_captcha']) && !$this->data['blog_design']['view_captcha']
         $date_added = $date_available;
         $this->data['date_added'] = $date_added;
         $this->data['rating'] = (int) $record_info['rating'];
         $this->data['description'] = html_entity_decode($record_info['description'], ENT_QUOTES, 'UTF-8');
         $this->data['attribute_groups'] = $this->model_catalog_record->getRecordAttributes($this->request->get['record_id']);
         $this->data['products'] = array();
         $results = $this->model_catalog_record->getProductRelated($this->request->get['record_id'], 'product_id');
         foreach ($results as $result) {
             if ($result['image']) {
                 if (isset($this->data['blog_design']['product_image']['width']) && $this->data['blog_design']['product_image']['width'] != '') {
                     $width = $this->data['blog_design']['product_image']['width'];
                 } else {
                     $this->data['blog_design']['product_image']['width'] = $width = $this->config->get('config_image_related_width');
                 }
                 if (isset($this->data['blog_design']['product_image']['height']) && $this->data['blog_design']['product_image']['height'] != '') {
                     $height = $this->data['blog_design']['product_image']['height'];
                 } else {
                     $this->data['blog_design']['product_image']['height'] = $height = $this->config->get('config_image_related_height');
                 }
                 $image = $this->model_tool_image->resize($result['image'], $width, $height);
             } else {
                 $image = false;
             }
             if ($this->config->get('config_customer_price') && $this->customer->isLogged() || !$this->config->get('config_customer_price')) {
                 $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
             } else {
                 $price = false;
             }
             if ((double) $result['special']) {
                 $special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')));
             } else {
                 $special = false;
             }
             if ($this->config->get('config_review_status')) {
                 $rating = (int) $result['rating'];
             } else {
                 $rating = false;
             }
             //for future
             if (isset($result['description_blog']) && $result['description_blog']) {
                 $flag_desc = 'pred';
                 $amount = 1;
                 if (isset($this->data['blog_design']['blog_num_desc'])) {
                     $this->data['blog_num_desc'] = $this->data['blog_design']['blog_num_desc'];
                 } else {
                     $this->data['blog_num_desc'] = $this->data['settings_general']['blog_num_desc'];
                 }
                 if ($this->data['blog_num_desc'] == '') {
                     $this->data['blog_num_desc'] = 50;
                 } else {
                     $amount = $this->data['blog_num_desc'];
                     $flag_desc = 'symbols';
                 }
                 if (isset($this->data['blog_design']['blog_num_desc_words'])) {
                     $this->data['blog_num_desc_words'] = $this->data['blog_design']['blog_num_desc_words'];
                 } else {
                     $this->data['blog_num_desc_words'] = $this->data['settings_general']['blog_num_desc_words'];
                 }
                 if ($this->data['blog_num_desc_words'] == '') {
                     $this->data['blog_num_desc_words'] = 10;
                 } else {
                     $amount = $this->data['blog_num_desc_words'];
                     $flag_desc = 'words';
                 }
                 if (isset($this->data['blog_design']['blog_num_desc_pred'])) {
                     $this->data['blog_num_desc_pred'] = $this->data['blog_design']['blog_num_desc_pred'];
                 } else {
                     $this->data['blog_num_desc_pred'] = $this->data['settings_general']['blog_num_desc_pred'];
                 }
                 if ($this->data['blog_num_desc_pred'] == '') {
                     $this->data['blog_num_desc_pred'] = 3;
                 } else {
                     $amount = $this->data['blog_num_desc_pred'];
                     $flag_desc = 'pred';
                 }
                 switch ($flag_desc) {
                     case 'symbols':
                         $pattern = '/((.*?)\\S){0,' . $amount . '}/isu';
                         preg_match_all($pattern, strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), $out);
                         $description = $out[0][0];
                         break;
                     case 'words':
                         $pattern = '/((.*?)\\x20){0,' . $amount . '}/isu';
                         preg_match_all($pattern, strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), $out);
                         $description = $out[0][0];
                         break;
                     case 'pred':
                         $pattern = '/((.*?)\\.){0,' . $amount . '}/isu';
                         preg_match_all($pattern, strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), $out);
                         $description = $out[0][0];
                         break;
                 }
                 //$flag_desc
             } else {
                 $description = false;
             }
             if ($this->config->get('config_product_description_length')) {
                 $how = $this->config->get('config_product_description_length');
             } else {
                 $how = 100;
             }
             $description = utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $how);
             unset($result['description']);
             $this->data['products'][] = array('product_id' => $result['product_id'], 'thumb' => $image, 'name' => $result['name'], 'description' => $description . '..', 'price' => $price, 'special' => $special, 'rating' => $rating, 'href' => $this->url->link('product/product', 'product_id=' . $result['product_id']));
         }
         $this->data['records'] = array();
         $results = $this->model_catalog_record->getRecordRelated($this->request->get['record_id']);
         foreach ($results as $result) {
             if ($result['image']) {
                 if (isset($this->data['blog_design']['product_image']['width']) && $this->data['blog_design']['product_image']['width'] != '') {
                     $width = $this->data['blog_design']['product_image']['width'];
                 } else {
                     $this->data['blog_design']['product_image']['width'] = $width = $this->config->get('config_image_related_width');
                 }
                 if (isset($this->data['blog_design']['product_image']['height']) && $this->data['blog_design']['product_image']['height'] != '') {
                     $height = $this->data['blog_design']['product_image']['height'];
                 } else {
                     $this->data['blog_design']['product_image']['height'] = $height = $this->config->get('config_image_related_height');
                 }
                 $image = $this->model_tool_image->resize($result['image'], $width, $height);
             } else {
                 $image = false;
             }
             if ($result['comment']) {
                 $rating = (int) $result['rating'];
             } else {
                 $rating = false;
             }
             $record_comment_info = unserialize($result['comment']);
             if ($this->config->get('config_product_description_length')) {
                 $how = $this->config->get('config_product_description_length');
             } else {
                 $how = 100;
             }
             $rdescription = utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $how);
             unset($result['description']);
             $this->data['records'][] = array('record_id' => $result['record_id'], 'thumb' => $image, 'name' => $result['name'], 'description' => $rdescription . '..', 'author' => $result['author'], 'customer_id' => $result['customer_id'], 'viewed' => $result['viewed'], 'rating' => $rating, 'comment_status' => $record_comment_info['status'], 'comments' => sprintf($this->language->get('text_comments'), (int) $result['comments']), 'href' => $this->url->link('record/record', 'record_id=' . $result['record_id']));
         }
         $this->data['tags'] = array();
         if (isset($this->data['settings_general']['blog_search']) && $this->data['settings_general']['blog_search']) {
             $this->data['blog_search']['href'] = $this->data['settings_general']['blog_search'];
         } else {
             $this->data['blog_search']['href'] = false;
         }
         $results = $this->model_catalog_record->getRecordTags($this->request->get['record_id']);
         foreach ($results as $result) {
             $this->data['tags'][] = array('tag' => trim($result['tag']), 'href' => $this->url->link('record/blog', 'blog_id=' . $this->data['blog_search']['href'] . '&filter_tag=' . $result['tag']));
         }
         $this->model_catalog_record->updateViewed($this->request->get['record_id']);
         if (isset($this->data['blog_design']['blog_template_record']) && $this->data['blog_design']['blog_template_record'] != '') {
             $template = $this->data['blog_design']['blog_template_record'];
         } else {
             $template = 'record.tpl';
         }
         if (isset($this->request->get['template_modal']) && $this->request->get['template_modal'] != '') {
             $template = $this->request->get['template_modal'];
         }
         if (isset($this->request->get['cmswidget']) && $this->request->get['cmswidget'] != '') {
             $this->data['cmswidget'] = (int) $this->request->get['cmswidget'];
             $this->data['ascp_widgets'] = $this->config->get('ascp_widgets');
             $this->data['settings_widget'] = $this->data['ascp_widgets'][$this->data['cmswidget']];
         }
         if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/agootemplates/record/' . $template)) {
             $this_template = $this->config->get('config_template') . '/template/agootemplates/record/' . $template;
         } else {
             if (file_exists(DIR_TEMPLATE . 'default/template/agootemplates/record/' . $template)) {
                 $this_template = 'default/template/agootemplates/record/' . $template;
             } else {
                 $this_template = 'default/template/agootemplates/record/record.tpl';
             }
         }
         $this->data['settings_blog'] = $this->data['blog_design'];
         $this->children = array();
         if ($this->data['ajax']) {
             $this->data['header'] = '';
             $this->data['column_left'] = '';
             $this->data['column_right'] = '';
             $this->data['content_top'] = '';
             $this->data['content_bottom'] = '';
             $this->data['footer'] = '';
             if (isset($this->data['settings_widget']['positions']) && $this->data['settings_widget']['positions'] != '') {
                 foreach ($this->data['settings_widget']['positions'] as $num => $position) {
                     if (SCP_VERSION > 1) {
                         $this->data[$position] = $this->load->controller('common/' . $position);
                     } else {
                         array_push($this->children, 'common/' . $position);
                     }
                 }
             }
         } else {
             if (SCP_VERSION < 2) {
                 $this->children = array('common/column_left', 'common/column_right', 'common/content_top', 'common/content_bottom', 'common/footer', 'common/header');
             } else {
                 $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');
             }
         }
         $this->data['language'] = $this->language;
         $this->data['theme'] = $this->config->get('config_template');
         $this->config->set("blog_work", false);
         $this->data['theme_stars'] = $this->getThemeStars('image/blogstars-1.png');
         $this->template = $this_template;
         if (SCP_VERSION < 2) {
             $html = $this->render();
         } else {
             $html = $this->load->view($this->template, $this->data);
         }
         return $html;
         /*******************************************************************************************************************************************/
     } else {
         $url = '';
         if (isset($this->request->get['blog_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_blog_id'])) {
             $url .= '&filter_blog_id=' . $this->request->get['filter_blog_id'];
         }
         $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_error'), 'href' => $this->url->link('record/record', $url . '&record_id=' . $record_id), 'separator' => $this->language->get('text_separator'));
         $this->document->setTitle($this->language->get('text_error'));
         $this->data['heading_title'] = $this->language->get('text_error');
         $this->data['text_error'] = $this->language->get('text_error');
         $this->data['button_continue'] = $this->language->get('button_continue');
         $this->data['continue'] = $this->url->link('common/home');
         if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/not_found.tpl')) {
             $this_template = $this->config->get('config_template') . '/template/error/not_found.tpl';
         } else {
             $this_template = 'default/template/error/not_found.tpl';
         }
         $this->children = array('common/column_left', 'common/column_right', 'common/content_top', 'common/content_bottom', 'common/footer', 'common/header');
         $this->data['language'] = $this->language;
         if (!isset($this->request->get['ajax_file'])) {
             $this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . '/1.1 404 Not Found');
         }
         if (SCP_VERSION > 1) {
             $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');
         }
         $this->config->set("blog_work", false);
         $this->template = $this_template;
         if (!isset($this->request->get['ajax_file'])) {
             if (SCP_VERSION < 2) {
                 $html_record = $this->render();
             } else {
                 $html_record = $this->load->view($this->template, $this->data);
             }
             return $html_record;
         }
     }
 }
예제 #2
0
 public function comment()
 {
     $ver = VERSION;
     if (!defined('SCP_VERSION')) {
         define('SCP_VERSION', $ver[0]);
     }
     $this->config->set("blog_work", true);
     if (SCP_VERSION > 1) {
         $this->load->controller('common/seoblog');
     } else {
         $this->getChild('common/seoblog');
     }
     if (isset($this->request->get['prefix'])) {
         $this->data['prefix'] = $this->request->get['prefix'];
     } else {
         if ($this->registry->get("prefix") != '') {
             $this->data['prefix'] = $this->registry->get("prefix");
         } else {
             $this->data['prefix'] = '';
         }
     }
     $this->load->model('setting/setting');
     if (isset($this->request->server['HTTPS']) && ($this->request->server['HTTPS'] == 'on' || $this->request->server['HTTPS'] == '1')) {
         $settings_admin = $this->model_setting_setting->getSetting('ascp_admin', 'ascp_admin_https_admin_path');
     } else {
         $settings_admin = $this->model_setting_setting->getSetting('ascp_admin', 'ascp_admin_http_admin_path');
     }
     foreach ($settings_admin as $key => $value) {
         $this->data['admin_path'] = $value;
     }
     /* ??????????????????????????????????????
     		$this->load->model('setting/setting');
     		if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
     			$settings_admin = $this->model_setting_setting->getSetting('ascp_admin', 'ascp_admin_https_admin_path');
     		} else {
     			$settings_admin = $this->model_setting_setting->getSetting('ascp_admin', 'ascp_admin_http_admin_path');
     		}
     		foreach ($settings_admin as $key => $value) {
     			$this->data['admin_path'] = $value;
     		}
     		*/
     /*
     if (!class_exists('User')) {
     	require_once(DIR_SYSTEM . 'library/user.php');
     	$this->registry->set('user', new User($this->registry));
     }
     */
     $this->load->library('user');
     $this->user = new User($this->registry);
     if ($this->user->isLogged()) {
         $this->data['userLogged'] = true;
     } else {
         $this->data['userLogged'] = false;
     }
     if (isset($this->request->get['ascp_widgets_position'])) {
         $this->data['cmswidget'] = $this->request->get['cmswidget'] = (int) $this->request->get['ascp_widgets_position'];
     }
     if (isset($this->request->post['thislist']) || isset($this->request->get['thislist'])) {
         if (isset($this->request->get['thislist'])) {
             $str = base64_decode($this->request->get['thislist']);
         } else {
             $str = base64_decode($this->request->post['thislist']);
         }
         //$this->data['cmswidget'] = unserialize($str);
     } else {
         $numargs = func_num_args();
         if ($numargs >= 1) {
             $this->data['cmswidget'] = func_get_arg(0);
         } else {
             $this->data['cmswidget'] = false;
         }
     }
     $this->data['http_image'] = getHttpImage($this);
     $this->data['config_language_id'] = $this->config->get('config_language_id');
     $this->data['ascp_widgets'] = $this->config->get('ascp_widgets');
     $this->data['thislist'] = $this->data['ascp_widgets'][$this->data['cmswidget']];
     $this->language->load('product/product');
     $this->language->load('record/blog');
     $this->language->load('record/record');
     if (isset($this->data['thislist']['langfile']) && $this->data['thislist']['langfile'] != '') {
         $this->language->load($this->data['thislist']['langfile']);
     }
     if (isset($this->request->get['product_id']) || isset($this->request->get['record_id']) || isset($this->data['thislist']['recordid'])) {
         $comments_settings = array();
         $record_info = array();
         $record_info['comment'] = array();
         $this->data['mark'] = false;
         if (isset($this->request->get['product_id'])) {
             $this->data['mark'] = 'product_id';
             $this->data['product_id'] = $this->request->get['product_id'];
             $mark_route = 'product/product';
         }
         if (isset($this->request->get['record_id'])) {
             $this->data['mark'] = 'record_id';
             $this->data['product_id'] = $this->request->get['record_id'];
             $mark_route = 'record/record';
         }
         if (isset($this->data['thislist']['recordid']) && $this->data['thislist']['recordid'] != '') {
             $this->data['mark'] = 'record_id';
             $this->data['product_id'] = $this->data['thislist']['recordid'];
             $mark_route = 'record/record';
             $this->load->model('catalog/record');
             $this->data['record'] = $this->data['mark_info'] = $this->model_catalog_record->getRecord($this->data['product_id']);
         } else {
             $this->data['record'] = '';
         }
         $this->data['url'] = $this->url->link($mark_route, $this->data['mark'] . '=' . $this->data['product_id']);
         $this->data['mark_id'] = $this->data['product_id'];
         $this->data['entry_sorting'] = $this->language->get('entry_sorting');
         $this->data['text_sorting_desc'] = $this->language->get('text_sorting_desc');
         $this->data['text_sorting_asc'] = $this->language->get('text_sorting_asc');
         $this->data['text_rollup'] = $this->language->get('text_rollup');
         $this->data['text_rollup_down'] = $this->language->get('text_rollup_down');
         $this->data['text_no_comments'] = $this->language->get('text_no_comments');
         $this->data['text_reply_button'] = $this->language->get('text_reply_button');
         $this->data['text_signer_answer'] = $this->language->get('text_signer_answer');
         $this->data['text_signer_answer_email'] = $this->language->get('text_signer_answer_email');
         /*  todo
         			$this->data['text_edit_button']   = $this->language->get('text_edit_button');
         			$this->data['text_delete_button'] = $this->language->get('text_delete_button');
                      */
         if ($this->customer->isLogged()) {
             $this->data['text_login'] = $this->customer->getFirstName() . " " . $this->customer->getLastName();
             $this->data['captcha_status'] = false;
             $this->data['customer_id'] = $this->customer->getId();
         } else {
             $this->data['text_login'] = $this->language->get('text_anonymus');
             $this->data['captcha_status'] = true;
             $this->data['customer_id'] = false;
         }
         $this->load->model('catalog/treecomments');
         $this->load->model('catalog/product');
         $this->load->model('catalog/record');
         $this->load->model('catalog/blog');
         if ($this->data['mark'] == 'product_id') {
             $mark_path = $this->model_catalog_treecomments->getPathByProduct($this->data['mark_id']);
             $mark_info = $this->model_catalog_product->getProduct($this->data['mark_id']);
         }
         if ($this->data['mark'] == 'record_id') {
             $mark_path = $this->model_catalog_blog->getPathByRecord($this->data['mark_id']);
             $record_info = $mark_info = $this->model_catalog_record->getRecord($this->data['mark_id']);
         }
         $category_path = $mark_path['path'];
         if (isset($category_path)) {
             $array_path = explode('_', $category_path);
             $category_id = end($array_path);
         }
         if (!isset($category_id)) {
             $category_id = 0;
         }
         $category_info = $this->model_catalog_treecomments->getCategory($category_id, $this->data['mark']);
         if ($this->config->get('ascp_settings') != '') {
             $this->data['settings_general'] = $this->config->get('ascp_settings');
         } else {
             $this->data['settings_general'] = array();
         }
         if (isset($category_info['design']) && $category_info['design'] != '') {
             $this->data['category_design'] = unserialize($category_info['design']);
         } else {
             $this->data['category_design'] = array();
         }
         if (!isset($this->data['settings_general']['colorbox_theme'])) {
             $this->data['settings_general']['colorbox_theme'] = 0;
         }
         $get = $this->request->get;
         if (isset($this->data['settings_general']['get_pagination'])) {
             $get_pagination = $this->data['settings_general']['get_pagination'];
         } else {
             $get_pagination = 'tracking';
         }
         if (isset($get['ascp_widgets_position'])) {
             $this->data['ascp_widgets_position'] = $get['ascp_widgets_position'];
         } else {
             $this->data['ascp_widgets_position'] = $this->registry->get('ascp_widgets_position');
         }
         $cmswidget = $this->data['ascp_widgets_position'];
         $cmswidget_flag = false;
         if (isset($get[$get_pagination])) {
             $tracking = $get[$get_pagination];
         } else {
             $tracking = '';
         }
         if ($tracking != '') {
             $parts = explode('_', trim(utf8_strtolower($tracking)));
             foreach ($parts as $num => $val) {
                 $aval = explode("-", $val);
                 if (isset($aval[0]) && $aval[0] == 'cmswidget') {
                     if (isset($aval[1]) && $aval[1] == $cmswidget) {
                         $cmswidget_flag = true;
                     }
                 }
             }
             if ($cmswidget_flag) {
                 foreach ($parts as $num => $val) {
                     $aval = explode("-", $val);
                     if (isset($aval[0])) {
                         $getquery = $aval[0];
                         if (isset($aval[1])) {
                             $getpar = $aval[1];
                             $get[$getquery] = $getpar;
                         }
                     }
                 }
             }
         }
         if (isset($get['wpage']) && isset($get['cmswidget']) && $get['cmswidget'] == $cmswidget) {
             $page = $get['wpage'];
         } else {
             $page = 1;
         }
         if (isset($get['ajax']) && $get['ajax'] == '1' && isset($get['page'])) {
             $page = $get['wpage'] = $get['page'];
         }
         $this->data['wpage'] = $this->data['page'] = $page;
         if (isset($record_info['comment']) && !empty($record_info['comment'])) {
             $comments_settings_record = unserialize($record_info['comment']);
         } else {
             $comments_settings_record = array();
         }
         $comments_settings = $comments_settings_record + $this->data['thislist'];
         $this->data['sorting'] = 'desc';
         $comments_order = 'comment_id';
         if (isset($comments_settings['order_ad']) && $comments_settings['order_ad'] != '') {
             $this->data['sorting'] = strtolower($comments_settings['order_ad']);
         }
         if (isset($comments_settings['order']) && $comments_settings['order'] != '') {
             $this->data['order'] = strtolower($comments_settings['order']);
         }
         if (isset($this->data['order']) && $this->data['order'] == 'sort') {
             $comments_order = 'comment_id';
         }
         if (isset($this->data['order']) && $this->data['order'] == 'date') {
             $comments_order = 'date_available';
         }
         if (isset($this->data['order']) && $this->data['order'] == 'rating') {
             $comments_order = 'rating';
         }
         if (isset($this->data['order']) && $this->data['order'] == 'rate') {
             $comments_order = 'delta';
         }
         if (isset($get['sorting'])) {
             if ($get['sorting'] == 'none') {
                 $this->data['sorting'] = $this->data['sorting'];
             } else {
                 $this->data['sorting'] = $get['sorting'];
             }
         }
         if (isset($this->data['thislist']['view_captcha']) && $this->data['thislist']['view_captcha'] == 0) {
             $this->data['captcha_status'] = false;
         }
         if (isset($this->data['thislist']['visual_editor']) && isset($this->data['thislist']['comment_must']) && $this->data['thislist']['comment_must'] && $this->data['thislist']['visual_editor'] || !isset($this->data['thislist']['visual_editor'])) {
             $this->data['visual_editor'] = true;
             $this->document->addScript('catalog/view/javascript/wysibb/jquery.wysibb.min.js');
             $this->document->addStyle('catalog/view/javascript/wysibb/theme/default/wbbtheme.css');
             $this->document->addScript('catalog/view/javascript/blog/blog.bbimage.js');
             $this->document->addScript('catalog/view/javascript/blog/rating/jquery.rating.js');
             $this->document->addStyle('catalog/view/javascript/blog/rating/jquery.rating.css');
         } else {
             $this->data['visual_editor'] = false;
         }
         $thislist = $this->data['thislist'];
         $this->data['record_comment'] = $thislist;
         if (isset($thislist['order_ad']) && $thislist['order_ad'] != '') {
             $this->data['sorting'] = strtolower($thislist['order_ad']);
         }
         if (isset($get['sorting'])) {
             if ($get['sorting'] == 'none') {
                 $this->data['sorting'] = $this->data['sorting'];
             } else {
                 $this->data['sorting'] = $get['sorting'];
             }
         }
         $this->data['comments'] = array();
         if (isset($thislist['status_language'])) {
             if ($thislist['status_language']) {
                 $this->registry->set("status_language", true);
             } else {
                 $this->registry->set("status_language", false);
             }
         } else {
             $this->registry->set("status_language", true);
         }
         $this->data['comment_total'] = $comment_total = $this->model_catalog_treecomments->getTotalCommentsByMarkId($this->data['mark_id'], $this->data['mark'], $this->data['thislist']);
         if (isset($thislist['number_comments'])) {
             $this->data['number_comments'] = $thislist['number_comments'];
         } else {
             $this->data['number_comments'] = '';
         }
         if ($this->data['number_comments'] == '') {
             $this->data['number_comments'] = 10;
         }
         if (isset($_COOKIE["karma_" . $this->data['mark']])) {
             $karma_cookie = unserialize(base64_decode($_COOKIE["karma_" . $this->data['mark']]));
         } else {
             $karma_cookie = array();
         }
         $mark = $this->data['mark'];
         if (!isset($this->data['settings_general']['complete_status'])) {
             $this->data['settings_general']['complete_status'] = false;
         }
         $data = array('status' => $this->data['settings_general']['complete_status'], $mark => $this->data['mark_id'], 'start' => ($page - 1) * $this->data['number_comments'], 'limit' => $this->data['number_comments']);
         /***********************************************************************************************************/
         $results = $this->model_catalog_treecomments->getCommentsByMarkId($data, $mark, $this->data['thislist']);
         if (isset($this->data['thislist']['admin_name']) && $this->data['thislist']['admin_name'] != '') {
             $this->data['admin_name'] = array_flip(explode(";", trim($this->data['thislist']['admin_name'])));
         } else {
             $this->data['admin_name'] = array();
         }
         if ($this->customer->isLogged()) {
             $customer_id = $this->customer->getId();
         } else {
             $customer_id = false;
         }
         $this->data[$this->data['mark']] = $this->data['mark_id'];
         $results_rates = $this->model_catalog_treecomments->getRatesByMarkId($this->data['mark_id'], $customer_id, $this->data['mark']);
         if (!$customer_id == -1) {
             $customer_id = false;
         }
         if (count($results) > 0) {
             $resa = NULL;
             foreach ($results as $num => $res1) {
                 $resa[$num] = $res1;
                 if (isset($results_rates[$res1['review_id']])) {
                     $resa[$num]['delta'] = $results_rates[$res1['review_id']]['rate_delta'];
                     $resa[$num]['rate_count'] = $results_rates[$res1['review_id']]['rate_count'];
                     $resa[$num]['rate_count_blog_plus'] = $results_rates[$res1['review_id']]['rate_delta_blog_plus'];
                     $resa[$num]['rate_count_blog_minus'] = $results_rates[$res1['review_id']]['rate_delta_blog_minus'];
                     $resa[$num]['customer_delta'] = $results_rates[$res1['review_id']]['customer_delta'];
                 } else {
                     $resa[$num]['customer_delta'] = 0;
                     $resa[$num]['delta'] = 0;
                     $resa[$num]['rate_count'] = 0;
                     $resa[$num]['rate_count_blog_plus'] = 0;
                     $resa[$num]['rate_count_blog_minus'] = 0;
                 }
                 $resa[$num]['hsort'] = '';
                 $mmm = NULL;
                 $kkk = '';
                 $wh = strlen($res1['sorthex']) / 4;
                 for ($i = 0; $i < $wh; $i++) {
                     $mmm[$i] = str_pad(dechex(65535 - hexdec(substr($res1['sorthex'], $i * 4, 4))), 4, "F", STR_PAD_LEFT);
                     $sortmy = substr($res1['sorthex'], $i * 4, 4);
                     $kkk = $kkk . $sortmy;
                 }
                 $ssorthex = '';
                 if (is_array($mmm)) {
                     foreach ($mmm as $num1 => $val) {
                         $ssorthex = $ssorthex . $val;
                     }
                 }
                 if ($this->data['sorting'] != 'asc') {
                     $resa[$num]['sorthex'] = $ssorthex;
                 } else {
                     $resa[$num]['sorthex'] = $kkk;
                 }
                 $resa[$num]['hsort'] = $kkk;
             }
             $results = NULL;
             $results = $resa;
             uasort($results, 'sdesc');
             $this->data['fields'] = array();
             if (isset($thislist['addfields'])) {
                 usort($thislist['addfields'], 'comp_field');
                 $this->data['fields'] = $thislist['addfields'];
             }
             $this->load->model('catalog/fields');
             $fields_db = $this->model_catalog_fields->getFieldsDBlang();
             foreach ($this->data['fields'] as $num => $field) {
                 foreach ($fields_db as $num_db => $field_db) {
                     if ($field['field_name'] == $field_db['field_name']) {
                         foreach ($field_db as $num_1 => $field_1) {
                             if (!isset($this->data['fields'][$num][$num_1]) || $field_db[$num_1] == '') {
                                 $this->data['fields'][$num][$num_1] = $field_1;
                             } else {
                             }
                         }
                     }
                 }
             }
             $i = 0;
             foreach ($results as $num => $result) {
                 $f = 0;
                 $addfields = array();
                 foreach ($result as $field_key => $field) {
                     foreach ($this->data['fields'] as $num_db => $field_db) {
                         if (trim($field_key) == trim($field_db['field_name'])) {
                             $field_db['value'] = $field_db['text'] = $result[$field_key];
                             $addfields[$f] = $field_db;
                             break;
                         } else {
                         }
                     }
                     $f++;
                 }
                 usort($addfields, 'comp_field');
                 if (!isset($result['date_available'])) {
                     $result['date_available'] = $result['date_added'];
                 }
                 if (isset($this->data['settings_general']['format_date'])) {
                 } else {
                     $this->data['settings_general']['format_date'] = $this->language->get('text_date');
                 }
                 if (isset($this->data['settings_general']['format_hours'])) {
                 } else {
                     $this->data['settings_general']['format_hours'] = $this->language->get('text_hours');
                 }
                 if (isset($this->data['settings_general']['format_time']) && $this->data['settings_general']['format_time'] && date($this->data['settings_general']['format_date']) == date($this->data['settings_general']['format_date'], strtotime($result['date_added']))) {
                     $date_str = $this->language->get('text_today');
                 } else {
                     $date_str = rdate($this, $this->data['settings_general']['format_date'], strtotime($result['date_added']));
                 }
                 $date_added = $date_str . rdate($this, $this->data['settings_general']['format_hours'], strtotime($result['date_added']));
                 $text = strip_tags($result['text']);
                 $text = nl2br($text);
                 if ($this->data['visual_editor']) {
                     if (isset($this->data['thislist']['bbwidth']) && $this->data['thislist']['bbwidth'] != '') {
                         $width = $this->data['thislist']['bbwidth'];
                     } else {
                         $width = '160px';
                     }
                     require_once DIR_SYSTEM . 'library/bbcode/Parser.php';
                     $parser = new JBBCode\Parser();
                     $parser->addBBCode("quote", '<div class="quote">{param}</div>', true, true);
                     $parser->addBBCode("quote", '<div class="quote">{param}</div>', false, false);
                     $parser->addBBCode("size", '<span style="font-size:{option}%;">{param}</span>', true, true);
                     $parser->addBBCode("code", '<pre class="code">{param}</pre>', false, false, 1);
                     $parser->addBBCode("video", '<div style="overflow:hidden; "><iframe width="300" height="200" src="http://www.youtube.com/embed/{param}" frameborder="0" allowfullscreen></iframe></div>', false, false, 1);
                     $parser->addBBCode("img", '<a href="{param}" class="imagebox" rel="imagebox" style="overflow: hidden;"><img class="bbimage" alt="" width="' . $width . '" src="{param}"></a>');
                     $parser->addBBCode("url", '<a href="{param}" target="_blank" rel="nofollow">{param}</a>', false, false);
                     $parser->addBBCode("url", '<a href="{option}" target="_blank" rel="nofollow">{param}</a>', true, true);
                     $parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
                     $parser->parse($text);
                     $text = $parser->getAsHtml();
                 }
                 $this->data['voted'] = false;
                 if (!$customer_id) {
                     if (!empty($karma_cookie)) {
                         if (isset($karma_cookie[$result['review_id']])) {
                             $this->data['voted'] = true;
                         }
                     }
                 }
                 if ($customer_id) {
                     $this->data['voted'] = $result['customer_delta'];
                 }
                 if (!isset($result['buyproduct'])) {
                     $result['buyproduct'] = false;
                 }
                 if (isset($result['avatar'])) {
                     $this->data['avatar'] = $result['avatar'];
                 } else {
                     $this->data['avatar'] = '';
                 }
                 if (isset($this->data['thislist']['avatar_width']) && $this->data['thislist']['avatar_width'] != '') {
                     $width = $this->data['thislist']['avatar_width'];
                 } else {
                     if (isset($this->data['settings_general']['avatar_width']) && $this->data['settings_general']['avatar_width'] != '') {
                         $width = $this->data['settings_general']['avatar_width'];
                     } else {
                         $width = '100';
                     }
                 }
                 if (isset($this->data['thislist']['avatar_height']) && $this->data['thislist']['avatar_height'] != '') {
                     $height = $this->data['thislist']['avatar_height'];
                 } else {
                     if (isset($this->data['settings_general']['avatar_height']) && $this->data['settings_general']['avatar_height'] != '') {
                         $height = $this->data['settings_general']['avatar_height'];
                     } else {
                         $height = '100';
                     }
                 }
                 $this->data['avatar_width'] = $width;
                 $this->data['avatar_height'] = $height;
                 $this->load->model('tool/image');
                 if ($this->data['avatar'] == '') {
                     if (file_exists(DIR_IMAGE . 'no_image.jpg')) {
                         $no_image = 'no_image.jpg';
                     }
                     if (file_exists(DIR_IMAGE . 'no_image.png')) {
                         $no_image = 'no_image.png';
                     }
                     if (isset($this->data['settings_general']['avatar_admin']) && $this->data['settings_general']['avatar_admin'] != '' && isset($this->data['admin_name'][trim($result['author'])])) {
                         $this->data['avatar'] = $this->model_tool_image->resizeme($this->data['settings_general']['avatar_admin'], $this->data['avatar_width'], $this->data['avatar_height']);
                     } else {
                         if (isset($this->data['settings_general']['avatar_buyproduct']) && $this->data['settings_general']['avatar_buyproduct'] != '' && isset($result['buyproduct']) && $result['buyproduct'] != '') {
                             $this->data['avatar'] = $this->model_tool_image->resizeme($this->data['settings_general']['avatar_buyproduct'], $this->data['avatar_width'], $this->data['avatar_height']);
                         } else {
                             if (isset($this->data['settings_general']['avatar_buy']) && $this->data['settings_general']['avatar_buy'] != '' && isset($result['buy']) && $result['buy'] != '') {
                                 $this->data['avatar'] = $this->model_tool_image->resizeme($this->data['settings_general']['avatar_buy'], $this->data['avatar_width'], $this->data['avatar_height']);
                             } else {
                                 if (isset($this->data['settings_general']['avatar_reg']) && $this->data['settings_general']['avatar_reg'] != '' && isset($result['customer_id']) && $result['customer_id'] > 0) {
                                     $this->data['avatar'] = $this->model_tool_image->resizeme($this->data['settings_general']['avatar_reg'], $this->data['avatar_width'], $this->data['avatar_height']);
                                 } else {
                                     if (isset($this->data['settings_general']['avatar_default']) && $this->data['settings_general']['avatar_default'] != '') {
                                         $this->data['avatar'] = $this->model_tool_image->resizeme($this->data['settings_general']['avatar_default'], $this->data['avatar_width'], $this->data['avatar_height']);
                                     } else {
                                         $this->data['avatar'] = $this->model_tool_image->resizeme($no_image, $this->data['avatar_width'], $this->data['avatar_height']);
                                     }
                                 }
                             }
                         }
                     }
                 } else {
                     $this->data['avatar'] = $this->model_tool_image->resizeme($this->data['avatar'], $this->data['avatar_width'], $this->data['avatar_height']);
                 }
                 if ($result['rating_mark'] != '0') {
                     $result['rating'] = 0;
                 }
                 $this->data['comments'][] = array('comment_id' => $result['review_id'], 'avatar' => $this->data['avatar'], 'sorthex' => $result['sorthex'], 'buy' => $result['buy'], 'buyproduct' => $result['buyproduct'], 'customer_id' => $result['customer_id'], 'customer' => $customer_id, 'voted' => $this->data['voted'], 'customer_delta' => $result['customer_delta'], 'level' => strlen($result['sorthex']) / 4 - 1, 'parent_id' => $result['parent_id'], 'author' => $result['author'], 'text' => $text, 'rating' => (int) $result['rating'], 'rating_mark' => (int) $result['rating_mark'], 'hsort' => $result['hsort'], 'myarray' => $mmm, 'fields' => $addfields, 'delta' => $result['delta'], 'rate_count' => $result['rate_count'], 'rate_count_blog_plus' => $result['rate_count_blog_plus'], 'rate_count_blog_minus' => $result['rate_count_blog_minus'], 'comments' => sprintf($this->language->get('text_comments'), (int) $comment_total), 'date_added' => $date_added, 'date_available' => $result['date_available']);
                 $i++;
             }
         }
         if (!function_exists('my_sort_div_mark')) {
             function my_sort_div_mark($data, $parent = 0, $sorting, $field, $lev = -1)
             {
                 $arr = $data[$parent];
                 usort($arr, array(new cmp_my_comment($field, $sorting), "my_cmp"));
                 $lev = $lev + 1;
                 for ($i = 0; $i < count($arr); $i++) {
                     $arr[$i]['level'] = $lev;
                     $z[] = $arr[$i];
                     $z[count($z) - 1]['flag_start'] = 1;
                     $z[count($z) - 1]['flag_end'] = 0;
                     if (isset($data[$arr[$i]['comment_id']])) {
                         $m = my_sort_div_mark($data, $arr[$i]['comment_id'], $sorting, $field, $lev);
                         $z = array_merge($z, $m);
                     }
                     if (isset($z[count($z) - 1]['flag_end'])) {
                         $z[count($z) - 1]['flag_end']++;
                     } else {
                         $z[count($z) - 1]['flag_end'] = 1;
                     }
                 }
                 return $z;
             }
         }
         if (count($this->data['comments']) > 0) {
             for ($i = 0, $c = count($this->data['comments']); $i < $c; $i++) {
                 $new_arr[$this->data['comments'][$i]['parent_id']][] = $this->data['comments'][$i];
             }
             $mycomments = my_sort_div_mark($new_arr, 0, $this->data['sorting'], $comments_order);
             $i = 0;
             foreach ($mycomments as $num => $result) {
                 if ($i >= ($page - 1) * $this->data['number_comments'] && $i < ($page - 1) * $this->data['number_comments'] + $this->data['number_comments']) {
                     $this->data['mycomments'][$i] = $result;
                 }
                 $i++;
             }
         } else {
             $this->data['mycomments'] = array();
         }
         if (!isset($this->data['mycomments'])) {
             $this->data['mycomments'] = array();
         }
         $this->data['karma_voted'] = false;
         if (!$customer_id) {
             if (isset($_COOKIE["karma_" . $this->data['mark']])) {
                 $karma_cookie = unserialize(base64_decode($_COOKIE["karma_" . $this->data['mark']]));
             } else {
                 $karma_cookie = array();
             }
             if (!empty($karma_cookie)) {
                 foreach ($karma_cookie as $id => $mark_id) {
                     if (isset($mark_id['id'])) {
                         if ($mark_id['id'] == $this->data['mark_id']) {
                             $this->data['karma_voted'] = true;
                         }
                     } else {
                         setcookie("karma_" . $this->data['mark'], '', time() + 60 * 60 * 24 * 555, '/', $this->request->server['HTTP_HOST']);
                     }
                 }
             }
         } else {
             $check_rate_num = $this->model_catalog_treecomments->checkRateNum($this->data, $this->data['mark']);
             foreach ($check_rate_num as $id => $mark_id) {
                 if ($id == $this->data['mark'] && $mark_id == $this->data['mark_id']) {
                     $this->data['karma_voted'] = true;
                 }
             }
         }
         $url_end = "";
         foreach ($this->request->get as $get_key => $get_val) {
             if ($get_key != 'route' && $get_key != 'prefix' && $get_key != '_route_' && $get_key != 'wpage' && $get_key != 'cmswidget' && $get_key != $get_pagination) {
                 $url_end .= "&" . (string) $get_key . "=" . (string) $get_val;
             }
         }
         $this->data['cmswidget'] = $cmswidget;
         $link_url = $this->url->link($mark_route, $this->data['mark'] . '=' . $this->data['mark_id'] . '&' . $get_pagination . '=cmswidget-' . $cmswidget . '_sorting-' . $this->data['sorting'] . '_wpage-{page}' . '#cmswidget-' . $cmswidget);
         $pagination = new Pagination();
         $pagination->total = $comment_total;
         $pagination->page = $page;
         $pagination->limit = $this->data['number_comments'];
         $pagination->text = $this->language->get('text_pagination');
         $pagination->url = $link_url;
         $this->data['pagination'] = $pagination->render();
         $data_statistics = $this->ratingStatistics($this->data);
         $template = 'rozetka.tpl';
         if (isset($thislist['blog_template_comment']) && $thislist['blog_template_comment'] != '') {
             $template = $thislist['blog_template_comment'];
         }
         if (isset($this->data['category_design']['blog_template_comment']) && $this->data['category_design']['blog_template_comment'] != '') {
             $template = $this->data['category_design']['blog_template_comment'];
         }
         if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/agootemplates/module/treecomments/' . $template)) {
             $this_template = $this->config->get('config_template') . '/template/agootemplates/module/treecomments/' . $template;
         } else {
             if (file_exists(DIR_TEMPLATE . 'default/template/agootemplates/module/treecomments/' . $template)) {
                 $this_template = 'default/template/agootemplates/module/treecomments/' . $template;
             } else {
                 $this_template = 'default/template/agootemplates/module/treecomments/rozetka.tpl';
             }
         }
         $this->data['text_signer_answer'] = $this->language->get('text_signer_answer');
         $this->data['text_signer_answer_email'] = $this->language->get('text_signer_answer_email');
         $this->data['text_signer'] = $this->language->get('text_signer');
         $this->data['text_write_review'] = $this->language->get('text_write_review');
         $this->data['text_write'] = $this->language->get('text_write');
         $this->data['hide_block'] = $this->language->get('hide_block');
         $this->data['error_register'] = $this->language->get('error_register');
         $this->data['entry_name'] = $this->language->get('entry_name');
         $this->data['text_customer_enter'] = $this->language->get('text_customer_enter');
         $this->data['entry_comment'] = $this->language->get('entry_comment');
         $this->data['text_note'] = $this->language->get('text_note');
         $this->data['entry_rating_review'] = $this->language->get('entry_rating_review');
         $this->data['entry_bad'] = $this->language->get('entry_bad');
         $this->data['entry_good'] = $this->language->get('entry_good');
         $this->data['entry_captcha_title'] = $this->language->get('entry_captcha_title');
         $this->data['entry_captcha'] = $this->language->get('entry_captcha');
         $this->data['text_voted_blog_plus'] = $this->language->get('text_voted_blog_plus');
         $this->data['text_voted_blog_minus'] = $this->language->get('text_voted_blog_minus');
         $this->data['text_vote_will_reg'] = $this->language->get('text_vote_will_reg');
         $this->data['text_vote_blog_plus'] = $this->language->get('text_vote_blog_plus');
         $this->data['text_vote_blog_minus'] = $this->language->get('text_vote_blog_minus');
         $this->data['text_review_yes'] = $this->language->get('text_review_yes');
         $this->data['text_review_no'] = $this->language->get('text_review_no');
         $this->data['text_review_karma'] = $this->language->get('text_review_karma');
         $this->data['tab_review'] = $this->language->get('tab_review');
         $this->data['text_all'] = $this->language->get('text_all');
         $this->data['text_admin'] = $this->language->get('text_admin');
         $this->data['text_buyproduct'] = $this->language->get('text_buyproduct');
         $this->data['text_buy'] = $this->language->get('text_buy');
         $this->data['text_registered'] = $this->language->get('text_registered');
         $this->data['text_buy_ghost'] = $this->language->get('text_buy_ghost');
         $this->data['button_write'] = $this->language->get('button_write');
         $this->data['text_wait'] = $this->language->get('text_wait');
         $this->data['theme'] = $this->config->get('config_template');
         $this->data['ascp_widgets'] = $this->config->get('ascp_widgets');
         $this->data['settings_widget'] = $this->data['thislist'];
         $this->data['theme_stars'] = $this->getThemeStars('image/blogstars-1.png');
         if (isset($this->session->data['token'])) {
             $this->data['token'] = $this->session->data['token'];
         } else {
             $this->data['token'] = '';
         }
         $this->template = $this_template;
         $this->data['language'] = $this->language;
         if (SCP_VERSION < 2) {
             $html = $this->render();
         } else {
             if (!is_array($this->data)) {
                 $this->data = array();
             }
             $html = $this->load->view($this->template, $this->data);
         }
         if (isset($get['ajax']) && $get['ajax'] == 1) {
             $this->response->setOutput($html);
             //return $html;
         } else {
             return $html;
         }
     }
 }
예제 #3
0
파일: blog.php 프로젝트: BulatSa/Ctex
 public function index()
 {
     $ver = VERSION;
     if (!defined('SCP_VERSION')) {
         define('SCP_VERSION', $ver[0]);
     }
     $this->config->set("blog_work", true);
     if ($this->config->get('ascp_settings') != '') {
         $this->data['settings_general'] = $this->config->get('ascp_settings');
     } else {
         $this->data['settings_general'] = array();
         $this->config->set('ascp_settings', $this->data['settings_general']);
     }
     if (SCP_VERSION > 1) {
         $this->load->controller('common/seoblog');
     } else {
         $this->getChild('common/seoblog');
     }
     $this->language->load('record/blog');
     $this->data['text_refine'] = $this->language->get('text_refine');
     $this->data['text_empty'] = $this->language->get('text_empty');
     $this->data['text_quantity'] = $this->language->get('text_quantity');
     $this->data['text_model'] = $this->language->get('text_model');
     $this->data['text_price'] = $this->language->get('text_price');
     $this->data['text_tax'] = $this->language->get('text_tax');
     $this->data['text_points'] = $this->language->get('text_points');
     $this->data['text_display'] = $this->language->get('text_display');
     $this->data['text_list'] = $this->language->get('text_list');
     $this->data['text_grid'] = $this->language->get('text_grid');
     $this->data['text_sort'] = $this->language->get('text_sort');
     $this->data['text_limit'] = $this->language->get('text_limit');
     $this->data['text_comments'] = $this->language->get('text_comments');
     $this->data['text_viewed'] = $this->language->get('text_viewed');
     $this->data['button_cart'] = $this->language->get('button_cart');
     $this->data['button_wishlist'] = $this->language->get('button_wishlist');
     $this->data['button_continue'] = $this->language->get('button_continue');
     $this->data['text_author'] = $this->language->get('text_author');
     $this->data['text_limit'] = $this->language->get('text_limit');
     $this->data['text_sort'] = $this->language->get('text_sort');
     $this->load->model('catalog/blog');
     $this->load->model('catalog/record');
     $this->load->model('tool/image');
     $this->load->model('setting/setting');
     if (!isset($this->data['settings_general']['colorbox_theme'])) {
         $this->data['settings_general']['colorbox_theme'] = 0;
     }
     $this->data['config_template'] = $this->config->get('config_template');
     $this->cont('module/blog');
     $this->data = $this->controller_module_blog->ColorboxLoader($this->data['settings_general']['colorbox_theme'], $this->data);
     /*
     if (!class_exists('User')) {
     	require_once(DIR_SYSTEM . 'library/user.php');
     	$this->registry->set('user', new User($this->registry));
     }
     */
     if (file_exists(DIR_APPLICATION . 'view/javascript/blog/blog.blog.js')) {
         $this->document->addScript('catalog/view/javascript/blog/blog.blog.js');
     }
     $this->load->library('user');
     $this->user = new User($this->registry);
     if ($this->user->isLogged()) {
         $this->data['userLogged'] = true;
         $this->data['token'] = $this->session->data['token'];
     } else {
         $this->data['userLogged'] = false;
     }
     if (isset($this->request->server['HTTPS']) && ($this->request->server['HTTPS'] == 'on' || $this->request->server['HTTPS'] == '1')) {
         $settings_admin = $this->model_setting_setting->getSetting('ascp_admin', 'ascp_admin_https_admin_path');
     } else {
         $settings_admin = $this->model_setting_setting->getSetting('ascp_admin', 'ascp_admin_http_admin_path');
     }
     foreach ($settings_admin as $key => $value) {
         $this->data['admin_path'] = $value;
     }
     $sort_data = array('rating', 'comments', 'popular', 'latest', 'sort');
     $sort = 'p.sort_order';
     if (isset($this->data['settings_general']['order']) && in_array($this->data['settings_general']['order'], $sort_data)) {
         if ($this->data['settings_general']['order'] == 'rating') {
             $sort = 'rating';
         }
         //$this->data['settings_general']['order'] == 'rating'
         if ($this->data['settings_general']['order'] == 'comments') {
             $sort = 'comments';
         }
         //$this->data['settings_general']['order'] == 'comments'
         if ($this->data['settings_general']['order'] == 'latest') {
             $sort = 'p.date_available';
         }
         //$this->data['settings_general']['order'] == 'latest'
         if ($this->data['settings_general']['order'] == 'sort') {
             $sort = 'p.sort_order';
         }
         //$this->data['settings_general']['order'] == 'sort'
         if ($this->data['settings_general']['order'] == 'popular') {
             $sort = 'p.viewed';
         }
         //$this->data['settings_general']['order'] == 'popular'
     }
     //isset($this->data['settings_general']['order']) && in_array($this->data['settings_general']['order'], $sort_data)
     $order = 'DESC';
     if (isset($this->data['settings_general']['order_ad'])) {
         if (strtoupper($this->data['settings_general']['order_ad']) == 'ASC') {
             $order = 'ASC';
         }
         //strtoupper($this->data['settings_general']['order_ad']) == 'ASC'
         if (strtoupper($this->data['settings_general']['order']) == 'DESC') {
             $order = 'DESC';
         }
         //strtoupper($this->data['settings_general']['order']) == 'DESC'
     }
     //isset($this->data['settings_general']['order_ad'])
     if (isset($this->request->get['sort'])) {
         $sort = $this->request->get['sort'];
     }
     //isset($this->request->get['sort'])
     if (isset($this->request->get['order'])) {
         $order = $this->request->get['order'];
     }
     //isset($this->request->get['order'])
     if (isset($this->request->get['page'])) {
         $page = $this->request->get['page'];
     } else {
         $page = 1;
     }
     if (SCP_VERSION > 1) {
         $config_catalog_limit = 'config_product_limit';
     } else {
         $config_catalog_limit = 'config_catalog_limit';
     }
     if (isset($this->request->get['limit'])) {
         $limit = $this->request->get['limit'];
     } else {
         if ($this->data['settings_general']['blog_num_records'] != '') {
             $limit = $this->data['settings_general']['blog_num_records'];
         } else {
             $limit = $this->config->get($config_catalog_limit);
             $this->config->set('blog_num_records', $limit);
         }
     }
     $this->data['breadcrumbs'] = array();
     $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home'), 'separator' => false);
     if (isset($this->request->get['blog_id'])) {
         $path = '';
         $parts = explode('_', (string) $this->request->get['blog_id']);
         foreach ($parts as $path_id) {
             if (!$path) {
                 $path = $path_id;
             } else {
                 $path .= '_' . $path_id;
             }
             $blog_info = $this->model_catalog_blog->getBlog($path_id);
             if ($blog_info) {
                 $this->data['breadcrumbs'][] = array('text' => $blog_info['name'], 'href' => $this->url->link('record/blog', 'blog_id=' . $path), 'separator' => $this->language->get('text_separator'));
             }
             //$blog_info
         }
         //$parts as $path_id
         $blog_id = array_pop($parts);
     } else {
         $blog_id = 0;
     }
     $blog_info = $this->model_catalog_blog->getBlog($blog_id);
     if ($blog_info) {
         // from seoblog
         $blog_page = $this->config->get('blog_page');
         if ($blog_page) {
             $paging = " " . $this->language->get('text_blog_page') . " " . $blog_page;
         } else {
             $paging = '';
         }
         if (isset($blog_info['meta_title']) && $blog_info['meta_title'] != '') {
             $this->document->setTitle($blog_info['meta_title'] . $paging);
         } else {
             $this->document->setTitle($blog_info['name'] . $paging . " - " . $this->config->get('config_title'));
         }
         if (isset($blog_info['meta_h1']) && $blog_info['meta_h1'] != '') {
             $this->data['heading_title'] = $blog_info['meta_h1'];
         } else {
             $this->data['heading_title'] = $blog_info['name'];
         }
         $this->data['name'] = $blog_info['name'];
         $this->document->setDescription($blog_info['meta_description'] . $paging);
         $this->document->setKeywords($blog_info['meta_keyword']);
         $this->data['blog_href'] = $this->url->link('record/blog', 'blog_id=' . $blog_id);
         if ($blog_info['design'] != '') {
             $this->data['blog_design'] = unserialize($blog_info['design']);
         } else {
             $this->data['blog_design'] = array();
         }
         $this->registry->set('blog_design', $this->data['blog_design']);
         if (isset($this->data['blog_design']['order']) && in_array($this->data['blog_design']['order'], $sort_data)) {
             if ($this->data['blog_design']['order'] == 'rating') {
                 $sort = 'rating';
             }
             //$this->data['blog_design']['order'] == 'rating'
             if ($this->data['blog_design']['order'] == 'comments') {
                 $sort = 'comments';
             }
             //$this->data['blog_design']['order'] == 'comments'
             if ($this->data['blog_design']['order'] == 'latest') {
                 $sort = 'p.date_available';
             }
             //$this->data['blog_design']['order'] == 'latest'
             if ($this->data['blog_design']['order'] == 'sort') {
                 $sort = 'p.sort_order';
             }
             //$this->data['blog_design']['order'] == 'sort'
             if ($this->data['blog_design']['order'] == 'popular') {
                 $sort = 'p.viewed';
             }
             //$this->data['blog_design']['order'] == 'popular'
         }
         //isset($this->data['blog_design']['order']) && in_array($this->data['blog_design']['order'], $sort_data)
         if (isset($this->data['blog_design']['order_ad'])) {
             if (strtoupper($this->data['blog_design']['order_ad']) == 'ASC') {
                 $order = 'ASC';
             }
             //strtoupper($this->data['blog_design']['order_ad']) == 'ASC'
             if (strtoupper($this->data['blog_design']['order']) == 'DESC') {
                 $order = 'DESC';
             }
             //strtoupper($this->data['blog_design']['order']) == 'DESC'
         }
         //isset($this->data['blog_design']['order_ad'])
         if ($blog_info['image']) {
             if (isset($this->data['blog_design']['blog_big']) && $this->data['blog_design']['blog_big']['width'] != '' && $this->data['blog_design']['blog_big']['height'] != '') {
                 $dimensions = $this->data['blog_design']['blog_big'];
             } else {
                 $dimensions = $this->data['settings_general']['blog_big'];
             }
             if (!isset($dimensions['width']) || $dimensions['width'] == '') {
                 $dimensions['width'] = 300;
             }
             if (!isset($dimensions['height']) || $dimensions['height'] == '') {
                 $dimensions['height'] = 200;
             }
             $this->data['thumb'] = $this->model_tool_image->resize($blog_info['image'], $dimensions['width'], $dimensions['height']);
             $this->data['popup'] = getHttpImage($this) . $blog_info['image'];
             $this->data['thumb_dim'] = $dimensions;
         } else {
             $this->data['popup'] = '';
             $this->data['thumb'] = '';
             $this->data['thumb_dim'] = false;
         }
         if ($blog_info['description']) {
             $this->data['description'] = html_entity_decode($blog_info['description'], ENT_QUOTES, 'UTF-8');
         } else {
             $this->data['description'] = false;
         }
         if (isset($blog_info['sdescription']) && $blog_info['sdescription'] != '') {
             $this->data['sdescription'] = html_entity_decode($blog_info['sdescription'], ENT_QUOTES, 'UTF-8');
         } else {
             $this->data['sdescription'] = false;
         }
         $this->load->library('document');
         if (method_exists($this->document, 'setOgImage') && $this->data['thumb'] != '') {
             $this->document->setOgImage($this->data['thumb']);
         }
         if (method_exists($this->document, 'setOgTitle')) {
             $this->document->setOgTitle($this->document->getTitle());
         }
         if (method_exists($this->document, 'setOgDescription')) {
             $this->document->setOgDescription($this->document->getDescription());
         }
         if (method_exists($this->document, 'setOgUrl')) {
             $this->document->setOgUrl($this->data['blog_href']);
         }
         $url = '';
         if (isset($this->request->get['sort'])) {
             $url .= '&sort=' . $this->request->get['sort'];
             $sort = $this->request->get['sort'];
         }
         //isset($this->request->get['sort'])
         if (isset($this->request->get['order'])) {
             $url .= '&order=' . $this->request->get['order'];
             $order = $this->request->get['order'];
         }
         //isset($this->request->get['order'])
         if (isset($this->request->get['limit'])) {
             $url .= '&limit=' . $this->request->get['limit'];
         }
         //isset($this->request->get['limit'])
         $this->data['categories'] = array();
         $image = '';
         $this->data['image_dim'] = false;
         $results = $this->model_catalog_blog->getBlogies($blog_id);
         foreach ($results as $result) {
             $data = array('filter_blog_id' => $result['blog_id'], 'filter_sub_blog' => true);
             $record_total = $this->model_catalog_record->getTotalRecords($data);
             if ($result['image']) {
                 if (isset($this->data['blog_design']['blog_subcategory']) && $this->data['blog_design']['blog_subcategory']['width'] != '' && $this->data['blog_design']['blog_subcategory']['height'] != '') {
                     $dimensions = $this->data['blog_design']['blog_subcategory'];
                 } else {
                     if (isset($this->data['blog_design']['blog_small']) && $this->data['blog_design']['blog_small']['width'] != '' && $this->data['blog_design']['blog_small']['height'] != '') {
                         $dimensions = $this->data['blog_design']['blog_small'];
                     } else {
                         $dimensions = $this->data['settings_general']['blog_small'];
                     }
                 }
                 if (!isset($dimensions['width']) || $dimensions['width'] == '') {
                     if ($this->config->get('config_image_category_width') != '') {
                         $dimensions['width'] = $this->config->get('config_image_category_width');
                     } else {
                         $dimensions['width'] = 100;
                     }
                 }
                 if (!isset($dimensions['height']) || $dimensions['height'] == '') {
                     if ($this->config->get('config_image_category_height') != '') {
                         $dimensions['height'] = $this->config->get('config_image_category_height');
                     } else {
                         $dimensions['height'] = 100;
                     }
                 }
                 $image = $this->model_tool_image->resize($result['image'], $dimensions['width'], $dimensions['height']);
                 $this->data['image_dim'] = $dimensions;
             } else {
                 $image = '';
                 $this->data['image_dim'] = false;
             }
             $this->data['categories'][] = array('name' => $result['name'], 'meta_description' => $result['meta_description'], 'total' => $record_total, 'thumb' => $image, 'popup' => getHttpImage($this) . $result['image'], 'href' => $this->url->link('record/blog', 'blog_id=' . $this->request->get['blog_id'] . '_' . $result['blog_id'] . $url));
         }
         if (isset($this->data['blog_design']['blog_num_records']) && $this->data['blog_design']['blog_num_records'] != '' && !isset($this->request->get['limit'])) {
             $limit = $this->data['blog_design']['blog_num_records'];
         }
         //isset($this->data['blog_design']['blog_num_records']) && $this->data['blog_design']['blog_num_records'] != '' && !isset($this->request->get['limit'])
         $this->data['records'] = array();
         if (isset($this->data['settings_general']['blog_search']) && (int) $this->data['settings_general']['blog_search'] == $blog_id) {
             $filter_blog_id = false;
         } else {
             $filter_blog_id = $blog_id;
         }
         $url_search = '';
         if (isset($this->request->get['filter_name'])) {
             $filter_name = $this->request->get['filter_name'];
             $url_search .= '&filter_name=' . $this->request->get['filter_name'];
         } else {
             $filter_name = '';
         }
         if (isset($this->request->get['filter_tag'])) {
             $filter_tag = $this->request->get['filter_tag'];
             $url_search .= '&filter_tag=' . $this->request->get['filter_tag'];
         } elseif (isset($this->request->get['filter_name'])) {
             $filter_tag = $this->request->get['filter_name'];
             $url_search .= '&filter_name=' . $this->request->get['filter_name'];
         } else {
             $filter_tag = '';
         }
         if (isset($this->request->get['filter_description'])) {
             $filter_description = $this->request->get['filter_description'];
             $url_search .= '&filter_description=' . $this->request->get['filter_description'];
         } else {
             $filter_description = '';
         }
         if (isset($this->request->get['filter_blog_id'])) {
             $filter_blog_id = $this->request->get['filter_blog_id'];
             $url_search .= '&filter_blog_id=' . $this->request->get['filter_blog_id'];
         }
         if (isset($this->request->get['filter_sub_blog'])) {
             $filter_sub_blog = $this->request->get['filter_sub_blog'];
             $url_search .= '&filter_sub_blog=' . $this->request->get['filter_sub_blog'];
         } else {
             $filter_sub_blog = '';
         }
         if ($filter_sub_blog == '' && $filter_description == '' && $filter_tag == '' && $filter_name == '' && !isset($this->request->get['filter_blog_id'])) {
             $filter_blog_id = $blog_id;
         }
         $data = array('filter_blog_id' => $filter_blog_id, 'filter_name' => $filter_name, 'filter_tag' => $filter_tag, 'filter_description' => $filter_description, 'filter_sub_blog' => $filter_sub_blog, 'sort' => $sort, 'order' => $order, 'start' => ($page - 1) * $limit, 'limit' => $limit);
         if (isset($this->data['blog_design'])) {
             $this->data['settings_blog'] = $this->data['blog_design'];
         }
         $record_total = $this->model_catalog_record->getTotalRecords($data);
         $results = $this->model_catalog_record->getRecords($data);
         if (isset($this->data['settings_blog']['records_more']) && $this->data['settings_blog']['records_more'] != '') {
             $more = $record_total - $page * $limit;
             if ($more > $limit) {
                 $more = $limit;
             }
             if (($page - 1) * $limit + $limit < $record_total) {
                 $this->data['entry_records_more'] = $this->language->get('entry_records_more') . $more . $this->language->get('entry_records_more_end');
             } else {
                 $this->data['entry_records_more'] = '';
             }
         }
         foreach ($results as $result) {
             if ($result['image']) {
                 if (isset($this->data['blog_design']['blog_small']) && $this->data['blog_design']['blog_small']['width'] != '' && $this->data['blog_design']['blog_small']['height'] != '') {
                     $dimensions = $this->data['blog_design']['blog_small'];
                 } else {
                     $dimensions = $this->data['settings_general']['blog_small'];
                 }
                 if (!isset($this->data['blog_design']['images'])) {
                     $this->data['blog_design']['images'] = array();
                 }
                 if (!isset($dimensions['width']) || $dimensions['width'] == '') {
                     $dimensions['width'] = 300;
                 }
                 if (!isset($dimensions['height']) || $dimensions['height'] == '') {
                     $dimensions['height'] = 200;
                 }
                 $image = $this->model_tool_image->resize($result['image'], $dimensions['width'], $dimensions['height']);
                 $this->data['image_dim'] = $dimensions;
             } else {
                 $image = false;
                 $this->data['image_dim'] = false;
             }
             if ($this->config->get('config_comment_status')) {
                 $rating = (int) $result['rating'];
             } else {
                 $rating = false;
             }
             if ($result['description'] && isset($this->data['blog_design']['description_full']) && $this->data['blog_design']['description_full']) {
                 $result['description_full'] = html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8');
             } else {
                 $result['description_full'] = false;
             }
             if (!isset($result['sdescription'])) {
                 $result['sdescription'] = '';
             }
             //!isset($result['sdescription'])
             if ($result['description'] && $result['sdescription'] == '') {
                 $flag_desc = 'pred';
                 $amount = 1;
                 if (isset($this->data['blog_design']['blog_num_desc'])) {
                     $this->data['blog_num_desc'] = $this->data['blog_design']['blog_num_desc'];
                 } else {
                     $this->data['blog_num_desc'] = $this->data['settings_general']['blog_num_desc'];
                 }
                 if ($this->data['blog_num_desc'] == '') {
                     $this->data['blog_num_desc'] = 50;
                 } else {
                     $amount = $this->data['blog_num_desc'];
                     $flag_desc = 'symbols';
                 }
                 if (isset($this->data['blog_design']['blog_num_desc_words'])) {
                     $this->data['blog_num_desc_words'] = $this->data['blog_design']['blog_num_desc_words'];
                 } else {
                     $this->data['blog_num_desc_words'] = $this->data['settings_general']['blog_num_desc_words'];
                 }
                 if ($this->data['blog_num_desc_words'] == '') {
                     $this->data['blog_num_desc_words'] = 10;
                 } else {
                     $amount = $this->data['blog_num_desc_words'];
                     $flag_desc = 'words';
                 }
                 if (isset($this->data['blog_design']['blog_num_desc_pred'])) {
                     $this->data['blog_num_desc_pred'] = $this->data['blog_design']['blog_num_desc_pred'];
                 } else {
                     $this->data['blog_num_desc_pred'] = $this->data['settings_general']['blog_num_desc_pred'];
                 }
                 if ($this->data['blog_num_desc_pred'] == '') {
                     $this->data['blog_num_desc_pred'] = 3;
                 } else {
                     $amount = $this->data['blog_num_desc_pred'];
                     $flag_desc = 'pred';
                 }
                 switch ($flag_desc) {
                     case 'symbols':
                         $pattern = '/((.*?)\\S){0,' . $amount . '}/isu';
                         preg_match_all($pattern, strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), $out);
                         $description = $out[0][0];
                         break;
                     case 'words':
                         $pattern = '/((.*?)\\x20){0,' . $amount . '}/isu';
                         preg_match_all($pattern, strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), $out);
                         $description = $out[0][0];
                         break;
                     case 'pred':
                         $pattern = '/((.*?)\\.){0,' . $amount . '}/isu';
                         preg_match_all($pattern, strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), $out);
                         $description = $out[0][0];
                         break;
                 }
                 //$flag_desc
             } else {
                 $description = false;
             }
             if (isset($result['sdescription']) && $result['sdescription'] != '') {
                 $description = html_entity_decode($result['sdescription'], ENT_QUOTES, 'UTF-8');
             }
             //isset($result['sdescription']) && $result['sdescription'] != ''
             unset($result['sdescription']);
             unset($result['description']);
             if (!isset($this->data['settings_general']['format_date'])) {
                 $this->data['settings_general']['format_date'] = $this->language->get('text_date');
             }
             if (!isset($this->data['settings_general']['format_hours'])) {
                 $this->data['settings_general']['format_hours'] = $this->language->get('text_hours');
             }
             if (isset($this->data['settings_general']['format_time']) && $this->data['settings_general']['format_time'] && date($this->data['settings_general']['format_date']) == date($this->data['settings_general']['format_date'], strtotime($result['date_available']))) {
                 $date_str = $this->language->get('text_today');
             } else {
                 $date_str = rdate($this, $this->data['settings_general']['format_date'], strtotime($result['date_available']));
             }
             $date_available = $date_str . rdate($this, $this->data['settings_general']['format_hours'], strtotime($result['date_available']));
             $blog_href = $this->model_catalog_blog->getPathByrecord($result['record_id']);
             $http_image = getHttpImage($this);
             $popup = $http_image . $result['image'];
             if (!isset($this->data['blog_design']['category_status'])) {
                 $this->data['blog_design']['category_status'] = 0;
             }
             //!isset($this->data['blog_design']['category_status'])
             if (!isset($this->data['blog_design']['view_date'])) {
                 $this->data['blog_design']['view_date'] = 1;
             }
             //!isset($this->data['blog_design']['view_date'])
             if (!isset($this->data['blog_design']['view_share'])) {
                 $this->data['blog_design']['view_share'] = 1;
             }
             //!isset($this->data['blog_design']['view_share'])
             if (!isset($this->data['blog_design']['view_viewed'])) {
                 $this->data['blog_design']['view_viewed'] = 1;
             }
             //!isset($this->data['blog_design']['view_viewed'])
             if (!isset($this->data['blog_design']['view_rating'])) {
                 $this->data['blog_design']['view_rating'] = 1;
             }
             //!isset($this->data['blog_design']['view_rating'])
             if (!isset($this->data['blog_design']['view_comments'])) {
                 $this->data['blog_design']['view_comments'] = 1;
             }
             //!isset($this->data['blog_design']['view_comments'])
             if (!isset($this->data['blog_design']['images'])) {
                 $this->data['blog_design']['images'] = array();
             }
             $this->data['records'][] = array('record_id' => $result['record_id'], 'thumb' => $image, 'images' => $this->getRecordImages($result['record_id'], $this->data['blog_design']['images']), 'popup' => $popup, 'name' => $result['name'], 'author' => $result['author'], 'customer_id' => $result['customer_id'], 'description' => $description, 'description_full' => $result['description_full'], 'attribute_groups' => $this->model_catalog_record->getRecordAttributes($result['record_id']), 'rating' => $result['rating'], 'date_added' => $result['date_added'], 'date_available' => $date_available, 'datetime_available' => $result['date_available'], 'date_end' => $result['date_end'], 'viewed' => $result['viewed'], 'comments' => (int) $result['comments'], 'href' => $this->url->link('record/record', 'record_id=' . $result['record_id']), 'blog_href' => $this->url->link('record/blog', 'blog_id=' . $blog_href['path']), 'blog_name' => $blog_href['name'], 'settings' => $this->data['settings_general'], 'settings_blog' => $this->data['blog_design'], 'settings_comment' => unserialize($result['comment']));
         }
         $url = '';
         if (isset($this->request->get['limit'])) {
             $url .= '&limit=' . $this->request->get['limit'] . $url_search;
         }
         $this->data['sorts'] = array();
         $this->data['sorts'][] = array('text' => $this->language->get('text_default'), 'value' => 'p.sort_order-ASC', 'href' => $this->url->link('record/blog', 'blog_id=' . $this->request->get['blog_id'] . '&sort=p.sort_order&order=ASC' . $url . $url_search));
         $this->data['sorts'][] = array('text' => $this->language->get('text_date_added_desc'), 'value' => 'p.date_available-DESC', 'href' => $this->url->link('record/blog', 'blog_id=' . $this->request->get['blog_id'] . '&sort=p.date_available&order=DESC' . $url . $url_search));
         $this->data['sorts'][] = array('text' => $this->language->get('text_date_added_asc'), 'value' => 'p.date_available-ASC', 'href' => $this->url->link('record/blog', 'blog_id=' . $this->request->get['blog_id'] . '&sort=p.date_available&order=ASC' . $url . $url_search));
         $this->data['sorts'][] = array('text' => $this->language->get('text_name_asc'), 'value' => 'pd.name-ASC', 'href' => $this->url->link('record/blog', 'blog_id=' . $this->request->get['blog_id'] . '&sort=pd.name&order=ASC' . $url . $url_search));
         $this->data['sorts'][] = array('text' => $this->language->get('text_name_desc'), 'value' => 'pd.name-DESC', 'href' => $this->url->link('record/blog', 'blog_id=' . $this->request->get['blog_id'] . '&sort=pd.name&order=DESC' . $url . $url_search));
         $this->data['sorts'][] = array('text' => $this->language->get('text_rating_desc'), 'value' => 'rating-DESC', 'href' => $this->url->link('record/blog', 'blog_id=' . $this->request->get['blog_id'] . '&sort=rating&order=DESC' . $url . $url_search));
         $this->data['sorts'][] = array('text' => $this->language->get('text_rating_asc'), 'value' => 'rating-ASC', 'href' => $this->url->link('record/blog', 'blog_id=' . $this->request->get['blog_id'] . '&sort=rating&order=ASC' . $url . $url_search));
         $url = '';
         if (isset($this->request->get['sort'])) {
             $url .= '&sort=' . $this->request->get['sort'] . $url_search;
         }
         if (isset($this->request->get['order'])) {
             $url .= '&order=' . $this->request->get['order'] . $url_search;
         }
         $this->data['limits'] = array();
         $this->data['limits'][] = array('text' => $limit, 'value' => $limit, 'href' => $this->url->link('record/blog', 'blog_id=' . $this->request->get['blog_id'] . $url . $url_search . '&limit=' . $limit));
         $this->data['limits'][] = array('text' => 25, 'value' => 25, 'href' => $this->url->link('record/blog', 'blog_id=' . $this->request->get['blog_id'] . $url . $url_search . '&limit=25'));
         $this->data['limits'][] = array('text' => 50, 'value' => 50, 'href' => $this->url->link('record/blog', 'blog_id=' . $this->request->get['blog_id'] . $url . $url_search . '&limit=50'));
         $this->data['limits'][] = array('text' => 75, 'value' => 75, 'href' => $this->url->link('record/blog', 'blog_id=' . $this->request->get['blog_id'] . $url . $url_search . '&limit=75'));
         $this->data['limits'][] = array('text' => 100, 'value' => 100, 'href' => $this->url->link('record/blog', 'blog_id=' . $this->request->get['blog_id'] . $url . $url_search . '&limit=100'));
         $url = '';
         if (isset($this->request->get['sort'])) {
             $url .= '&sort=' . $this->request->get['sort'] . $url_search;
         }
         if (isset($this->request->get['order'])) {
             $url .= '&order=' . $this->request->get['order'] . $url_search;
         }
         if (isset($this->request->get['limit'])) {
             $url .= '&limit=' . $this->request->get['limit'] . $url_search;
         }
         $this->data['sort'] = $sort;
         $this->data['order'] = $order;
         $this->data['limit'] = $limit;
         $this->data['continue'] = $this->url->link('common/home');
         $pagination = new Pagination();
         $pagination->total = $record_total;
         $pagination->page = $page;
         $pagination->limit = $limit;
         $pagination->text = $this->language->get('text_pagination');
         $pagination->url = $this->url->link('record/blog', 'blog_id=' . $this->request->get['blog_id'] . $url . $url_search . '&page={page}');
         $this->data['pagination'] = $pagination->render();
         if (isset($this->data['blog_design']['blog_template']) && $this->data['blog_design']['blog_template'] != '') {
             $template = $this->data['blog_design']['blog_template'];
         } else {
             $template = 'blog.tpl';
         }
         if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/agootemplates/blog/' . $template)) {
             $this_template = $this->config->get('config_template') . '/template/agootemplates/blog/' . $template;
         } else {
             if (file_exists(DIR_TEMPLATE . 'default/template/agootemplates/blog/' . $template)) {
                 $this_template = 'default/template/agootemplates/blog/' . $template;
             } else {
                 $this_template = 'default/template/agootemplates/blog/blog.tpl';
             }
         }
         $this->children = array('common/column_left', 'common/column_right', 'common/content_top', 'common/content_bottom', 'common/footer', 'common/header');
         if (isset($this->data['blog_design']['further'][$this->config->get('config_language_id')]) && $this->data['blog_design']['further'][$this->config->get('config_language_id')] != '') {
             $this->data['settings_general']['further'][$this->config->get('config_language_id')] = $this->data['blog_design']['further'][$this->config->get('config_language_id')];
         }
         if (isset($this->data['settings_general']['box_share_list']) && $this->data['settings_general']['box_share_list'] != '') {
             $this->data['box_share_list'] = html_entity_decode($this->data['settings_general']['box_share_list']);
         } else {
             $this->data['box_share_list'] = '';
         }
         $this->data['language'] = $this->language;
         if (SCP_VERSION > 1) {
             $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');
         }
         $this->data['url_rss'] = $this->url->link('record/blog', 'blog_id=' . $this->request->get['blog_id'] . '&rss=2.0');
         if (isset($this->request->get['rss'])) {
             $this->response->addHeader("Content-type: text/xml");
             $this->data['url_self'] = $this->url->link('record/blog', 'blog_id=' . $this->request->get['blog_id']);
             if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/agootemplates/blog/blogrss.tpl')) {
                 $this_template = $this->config->get('config_template') . '/template/agootemplates/blog/blogrss.tpl';
             } else {
                 if (file_exists(DIR_TEMPLATE . 'default/template/agootemplates/blog/blogrss.tpl')) {
                     $this_template = 'default/template/agootemplates/blog/blogrss.tpl';
                 } else {
                     $this_template = '';
                 }
             }
             $this->children = array();
             $this->data['header'] = '';
             $this->data['column_left'] = '';
             $this->data['column_right'] = '';
             $this->data['content_top'] = '';
             $this->data['footer'] = '';
             $this->data['lang'] = $this->config->get('config_language');
             $this->data['config_name'] = $this->config->get('config_name');
             $this->data['config_meta_description'] = $this->config->get('config_meta_description');
         }
         $this->data['theme'] = $this->config->get('config_template');
         $this->config->set("blog_work", false);
         $this->data['config_language_id'] = $this->config->get('config_language_id');
         $image_rss = '/image/rss24.png';
         if (file_exists(DIR_TEMPLATE . $this->data['theme'] . $image_rss)) {
             $this->data['image_rss'] = 'catalog/view/theme/' . $this->data['theme'] . $image_rss;
         } else {
             $this->data['image_rss'] = 'catalog/view/theme/default' . $image_rss;
         }
         $this->data['theme_stars'] = $this->getThemeStars('image/blogstars-1.png');
         $this->template = $this_template;
         if (SCP_VERSION < 2) {
             $html = $this->render();
         } else {
             $html = $this->load->view($this->template, $this->data);
         }
         return $html;
     } else {
         $url = '';
         if (isset($this->request->get['blog_id'])) {
             $url .= '&blog_id=' . $this->request->get['blog_id'];
         }
         //isset($this->request->get['blog_id'])
         if (isset($this->request->get['sort'])) {
             $url .= '&sort=' . $this->request->get['sort'];
         }
         //isset($this->request->get['sort'])
         if (isset($this->request->get['order'])) {
             $url .= '&order=' . $this->request->get['order'];
         }
         //isset($this->request->get['order'])
         if (isset($this->request->get['page'])) {
             $url .= '&page=' . $this->request->get['page'];
         }
         //isset($this->request->get['page'])
         if (isset($this->request->get['limit'])) {
             $url .= '&limit=' . $this->request->get['limit'];
         }
         //isset($this->request->get['limit'])
         $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_error'), 'href' => $this->url->link('record/blog', $url), 'separator' => $this->language->get('text_separator'));
         $this->document->setTitle($this->language->get('text_error'));
         $this->data['heading_title'] = $this->language->get('text_error');
         $this->data['text_error'] = $this->language->get('text_error');
         $this->data['button_continue'] = $this->language->get('button_continue');
         $this->data['continue'] = $this->url->link('common/home');
         if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/not_found.tpl')) {
             $this_template = $this->config->get('config_template') . '/template/error/not_found.tpl';
         } else {
             $this_template = 'default/template/error/not_found.tpl';
         }
         $this->children = array('common/column_left', 'common/column_right', 'common/content_top', 'common/content_bottom', 'common/footer', 'common/header');
         if (!isset($this->request->get['ajax_file'])) {
             $this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . '/1.1 404 Not Found');
         }
         if (SCP_VERSION > 1) {
             $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');
         }
         $this->config->set("blog_work", false);
         $this->template = $this_template;
         if (!isset($this->request->get['ajax_file'])) {
             if (SCP_VERSION < 2) {
                 $html_record = $this->render();
             } else {
                 $html_record = $this->load->view($this->template, $this->data);
             }
             return $html_record;
         }
     }
 }
예제 #4
0
파일: signer.php 프로젝트: BulatSa/Ctex
 public function signer($product_id, $record_info, $settings, $mark_id)
 {
     $record_settings = $settings;
     $pointer_answer = '';
     $this->load->model('agoo/signer/signer');
     $this->load->model('catalog/fields');
     if ($this->config->get('ascp_settings') != '') {
         $this->data['settings_general'] = $this->config->get('ascp_settings');
     } else {
         $this->data['settings_general'] = array();
     }
     if (!isset($record_info['name'])) {
         $record_info['name'] = '';
     }
     if (isset($record_info['comment_id'])) {
         $comment_info = $this->model_agoo_signer_signer->getComment($record_info['comment_id'], $mark_id);
     } else {
         $comment_info = array();
     }
     if (isset($this->request->post['notify']) && $this->request->post['notify'] && $this->validateDelete()) {
         $notify_status = true;
     } else {
         $notify_status = false;
     }
     $this->data['comment_id'] = $record_info['comment_id'];
     if ($settings['signer'] || $settings['signer_answer'] || $notify_status || $settings['comments_email'] != '') {
         $this->data['product_id'] = $product_id;
         $this->data['record_info'] = $record_info;
         if ($mark_id == 'product_id') {
             $route = 'product/product';
             if ($settings['signer_answer']) {
                 $pointer_answer = 'review_id';
                 $pointer_id = $comment_info['parent_id'];
             }
         }
         if ($mark_id == 'record_id') {
             $route = 'record/record';
             if ($settings['signer_answer']) {
                 $pointer_answer = 'comment_id';
                 $pointer_id = $comment_info['parent_id'];
             }
         }
         if ($this->registry->get('admin_work')) {
             if ($mark_id == 'record_id') {
                 require_once DIR_CATALOG . 'controller/common/seoblog.php';
                 $seoUrl = new ControllerCommonSeoBlog($this->registry);
             } else {
                 $seo_type = $this->config->get('config_seo_url_type');
                 if (!$seo_type) {
                     $seo_type = 'seo_url';
                 }
                 require_once DIR_CATALOG . 'controller/common/' . $seo_type . '.php';
                 $classSeo = 'ControllerCommon' . str_replace('_', '', $seo_type);
                 $seoUrl = new $classSeo($this->registry);
             }
             $urlToCatalog = new Url(HTTP_CATALOG, $this->config->get('config_secure') ? HTTPS_CATALOG : HTTP_CATALOG);
             $urlToCatalog->addRewrite($seoUrl);
             $correct_URL = $urlToCatalog->link($route, '&' . $mark_id . '=' . $this->data['product_id']);
             $pos = strpos($correct_URL, 'http');
             if ($pos === false) {
                 $correct_URL = ($this->config->get('config_secure') ? HTTPS_CATALOG : HTTP_CATALOG) . $correct_URL;
             }
             $this->data['record_info']['link'] = $correct_URL;
         } else {
             if (SCP_VERSION > 1) {
                 $this->load->controller('common/seoblog');
             } else {
                 $this->getChild('common/seoblog');
             }
             $this->data['record_info']['link'] = $this->url->link($route, '&' . $mark_id . '=' . $this->data['product_id']);
         }
         if (!class_exists('Customer')) {
             require_once DIR_SYSTEM . 'library/customer.php';
         }
         $obj = $this->registry->get('customer');
         if (!is_object($obj)) {
             $this->registry->set('customer', new Customer($this->registry));
         }
         unset($obj);
         $this->language->load('agoo/signer/signer');
         if (isset($settings['langfile']) && $settings['langfile'] != '') {
             $this->language->load($settings['langfile']);
         }
         $this->data['login'] = $this->customer->getFirstName() . " " . $this->customer->getLastName();
         $this->data['customer_id'] = $this->customer->getId();
         if ($this->config->get('config_logo') && file_exists(DIR_IMAGE . $this->config->get('config_logo'))) {
             $this->data['logo'] = $this->getHttpImage() . $this->config->get('config_logo');
         } else {
             $this->data['logo'] = false;
         }
         if (isset($this->request->post['text'])) {
             $this->request->post['text'] = strip_tags($this->request->post['text']);
         } else {
             $this->request->post['text'] = '';
         }
         $text = $this->request->post['text'];
         $text = nl2br(strip_tags($text));
         $width = '160px';
         require_once DIR_SYSTEM . 'library/bbcode/Parser.php';
         $parser = new JBBCode\Parser();
         $parser->addBBCode("quote", '<div class="quote">{param}</div>', true, true);
         $parser->addBBCode("quote", '<div class="quote">{param}</div>', false, false);
         $parser->addBBCode("size", '<span style="font-size:{option}%;">{param}</span>', true, true);
         $parser->addBBCode("code", '<pre class="code">{param}</pre>', false, false, 1);
         $parser->addBBCode("video", '<div style="overflow:hidden; "><iframe width="300" height="200" src="http://www.youtube.com/embed/{param}" frameborder="0" allowfullscreen></iframe></div>', false, false, 1);
         $parser->addBBCode("img", '<a href="{param}" class="imagebox" rel="imagebox" style="overflow: hidden;"><img class="bbimage" alt="" width="' . $width . '" src="{param}"></a>');
         $parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
         $parser->parse($text);
         $text = $parser->getAsHtml();
         /*
         					if (rdate($this,$this->language->get('text_date')) == rdate($this,$this->language->get('text_date'), strtotime(date($this->language->get('text_date').$this->language->get('text_hours'))))) {
         						$date_str = $this->language->get('text_today');
         					} else {
         						$date_str = rdate($this,$this->language->get('text_date'), strtotime(date($this->language->get('text_date').$this->language->get('text_hours'))));
         					}
         					$date_added = $date_str.(rdate($this, $this->language->get('text_hours'), strtotime(date($this->language->get('text_date').$this->language->get('text_hours')))));
         */
         if (isset($this->data['settings_general']['format_date'])) {
         } else {
             $this->data['settings_general']['format_date'] = $this->language->get('text_date');
         }
         if (isset($this->data['settings_general']['format_hours'])) {
         } else {
             $this->data['settings_general']['format_hours'] = $this->language->get('text_hours');
         }
         if (isset($this->data['settings_general']['format_time']) && $this->data['settings_general']['format_time']) {
             $date_str = $this->language->get('text_today');
         } else {
             $date_str = rdate($this, $this->data['settings_general']['format_date'], strtotime(date($this->data['settings_general']['format_date'] . $this->data['settings_general']['format_hours'])));
         }
         $date_added = $date_str . rdate($this, $this->data['settings_general']['format_hours'], strtotime(date($this->data['settings_general']['format_date'] . $this->data['settings_general']['format_hours'])));
         $fields = array();
         if (isset($this->request->post['af'])) {
             /*
                                                 print_r("<PRE>");
             print_r($this->request->post['af']);
             print_r("</PRE>");
             */
             $addfields = $this->model_catalog_fields->getFieldsDesc();
             $f_name = '';
             foreach ($this->request->post['af'] as $num => $value) {
                 if (trim($value) != '') {
                     if (trim($value) != '0') {
                         if (isset($record_settings['addfields'])) {
                             foreach ($addfields as $nm => $vl) {
                                 if ($vl['field_name'] == $num) {
                                     $f_name = $vl['field_description'];
                                 }
                             }
                         } else {
                             $field_info = $this->model_catalog_fields->getFieldByName($num);
                             $f_name = $field_info['field_description'];
                         }
                         $fields[$this->db->escape(strip_tags($num))]['field_name'] = $f_name;
                         $fields[$this->db->escape(strip_tags($num))]['text'] = $this->db->escape(strip_tags($value));
                     }
                 }
             }
         }
         $subject = sprintf($this->language->get('text_subject'), $this->config->get('config_name'));
         $answer_signers = array();
         $record_signers = array();
         $admin_signers = array();
         if (isset($record_settings['status_now']) && $record_settings['status_now'] || $notify_status) {
             $record_signers = $this->model_agoo_signer_signer->getStatusId($this->data['product_id'], $mark_id);
             if ($settings['signer_answer']) {
                 $answer_signers = $this->model_agoo_signer_signer->getStatusId($pointer_id, $pointer_answer);
             }
             $record_signers = array_merge($record_signers, $answer_signers);
         } else {
             $record_signers = array();
         }
         $this->data['answer_signers'] = $answer_signers;
         $this->data['record_signers'] = $record_signers;
         if (isset($settings['comments_email']) && $settings['comments_email'] != '') {
             $comments_email = explode(";", $settings['comments_email']);
             foreach ($comments_email as $num => $email) {
                 $email = trim($email);
                 array_push($admin_signers, array('id' => $this->data['product_id'], 'pointer' => $mark_id, 'customer_id' => $email, 'admin' => true));
             }
         }
         if (!empty($admin_signers)) {
             foreach ($admin_signers as $par => $singers) {
                 $template = '/template/agootemplates/module/blog_signer_mail.tpl';
                 if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . $template)) {
                     $this->template = $this->config->get('config_template') . $template;
                 } else {
                     $this->template = 'default' . $template;
                 }
                 $this->data['theme'] = $this->config->get('config_template');
                 if (isset($singers['admin']) && $singers['admin']) {
                     $customer['email'] = $singers['customer_id'];
                     $customer['firstname'] = 'admin';
                     $customer['lastname'] = '';
                 } else {
                     $customer['email'] = '';
                     $customer['firstname'] = '';
                     $customer['lastname'] = '';
                 }
                 $this->data['data'] = array('text' => $text, 'settings' => $record_settings, 'fields' => $fields, 'comment' => $this->request->post, 'comment_db' => $comment_info, 'record' => $this->data['record_info'], 'date' => $date_added, 'shop' => $this->config->get('config_name'), 'signers' => serialize($singers), 'signer_customer' => $customer);
                 $this->data['language'] = $this->language;
                 if (SCP_VERSION < 2) {
                     $html = $this->render();
                 } else {
                     if (!is_array($this->data)) {
                         $this->data = array();
                     }
                     $html = $this->load->view($this->template, $this->data);
                 }
                 $message = $html;
                 $data_mail['customer_email'] = $customer['email'];
                 $data_mail['message'] = $message;
                 $data_mail['subject'] = $subject;
                 $this->send_mail($data_mail);
                 unset($data_mail);
             }
         }
         if (!empty($record_signers)) {
             $customer_email_array = array();
             foreach ($record_signers as $par => $singers) {
                 $template = '/template/agootemplates/module/blog_signer_mail.tpl';
                 if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . $template)) {
                     $this->template = $this->config->get('config_template') . $template;
                 } else {
                     $this->template = 'default' . $template;
                 }
                 $this->data['theme'] = $this->config->get('config_template');
                 if ($singers['customer_id'] == "0") {
                     $customer['email'] = $singers['email'];
                     $customer['firstname'] = $this->language->get('text_ghost');
                     $customer['lastname'] = '';
                 } else {
                     $customer = $this->model_agoo_signer_signer->getCustomer($singers['customer_id']);
                 }
                 $this->data['data'] = array('text' => $text, 'settings' => $record_settings, 'fields' => $fields, 'comment' => $this->request->post, 'comment_db' => $comment_info, 'record' => $this->data['record_info'], 'date' => $date_added, 'shop' => $this->config->get('config_name'), 'signers' => serialize($singers), 'signer_customer' => $customer);
                 $this->data['language'] = $this->language;
                 if (SCP_VERSION < 2) {
                     $html = $this->render();
                 } else {
                     if (!is_array($this->data)) {
                         $this->data = array();
                     }
                     $html = $this->load->view($this->template, $this->data);
                 }
                 $message = $html;
                 $subject = sprintf($this->language->get('text_subject'), $this->config->get('config_name'));
                 if (isset($comment_info['status']) && $comment_info['status'] && (isset($record_settings['comment_signer']) && $record_settings['comment_signer']) && $singers['customer_id'] != $this->data['customer_id'] && isset($customer['email']) || $notify_status) {
                     if (!isset($customer_email_array[$customer['email']])) {
                         $data_mail['customer_email'] = $customer['email'];
                         $data_mail['message'] = $message;
                         $data_mail['subject'] = $subject;
                         $this->send_mail($data_mail);
                         unset($data_mail);
                         $customer_email_array[$customer['email']] = $customer['email'];
                     }
                 }
             }
         }
     }
 }
예제 #5
0
 public function idAction()
 {
     echo 'date:', date('Y-m-d H:i:s'), '<br/>';
     echo 'rdate:', rdate('Y-m-d H:i:s'), '<br/>';
 }
예제 #6
0
파일: blog.php 프로젝트: BulatSa/Ctex
 private function getBlogsRecords($thislist, $type = 'latest')
 {
     $this->language->load('record/blog');
     $this->load->model('catalog/record');
     $this->load->model('tool/image');
     $this->data['text_comments'] = $this->language->get('text_comments');
     $this->data['text_author'] = $this->language->get('text_author');
     $this->data['text_viewed'] = $this->language->get('text_viewed');
     if (isset($thislist['title_list_latest'][$this->config->get('config_language_id')]) && $thislist['title_list_latest'][$this->config->get('config_language_id')] != '') {
         $this->data['heading_title'] = $thislist['title_list_latest'][$this->config->get('config_language_id')];
     } else {
         $this->data['heading_title'] = '';
     }
     //$this->data['settings_general'] = $thislist;
     $page = 1;
     if (isset($thislist['number_per_widget']) && $thislist['number_per_widget'] != '') {
         $limit = $thislist['number_per_widget'];
     } else {
         $limit = 20;
     }
     if (isset($thislist['order']) && $thislist['order'] != '') {
         $sort = $thislist['order'];
     } else {
         $sort = 'latest';
     }
     if (isset($thislist['blogs'])) {
         $this->data['blogs'] = $thislist['blogs'];
     } else {
         $this->data['blogs'] = 0;
     }
     if (isset($thislist['related'])) {
         $this->data['related'] = $thislist['related'];
     } else {
         $this->data['related'] = array();
     }
     if (isset($thislist['order_ad'])) {
         $this->data['order_ad'] = $thislist['order_ad'];
     } else {
         $this->data['order_ad'] = 'DESC';
     }
     if (!isset($thislist['images'])) {
         $thislist['images'] = array();
     }
     if (isset($thislist['pointer']) && $thislist['pointer'] != '') {
         $pointer = $thislist['pointer'];
     } else {
         $pointer = 'product_id';
     }
     $amount = 0;
     $order = $this->data['order_ad'];
     $this->data['records'] = array();
     if (isset($thislist['pagination']) && $thislist['pagination']) {
         $pagination_records = true;
     } else {
         $pagination_records = false;
     }
     //$url = '';
     if (isset($this->data['request_get']['wsort'])) {
         //$url .= '&sort=' . $this->data['request_get']['sort'];
         $sort = $this->data['request_get']['wsort'];
     }
     //isset($this->data['request_get']['sort'])
     if (isset($this->data['request_get']['worder'])) {
         //$url .= '&order=' . $this->data['request_get']['order'];
         $order = $this->data['request_get']['worder'];
     }
     //isset($this->data['request_get']['order'])
     if (isset($this->data['request_get']['wlimit'])) {
         //$url .= '&limit=' . $this->data['request_get']['limit'];
         $limit = $this->data['request_get']['wlimit'];
     }
     //isset($this->data['request_get']['limit'])
     if (!isset($thislist['paging'])) {
         $thislist['paging'] = 0;
     }
     $data = array('settings' => $thislist, 'filter_blogs' => $this->data['blogs'], 'sort' => $sort, 'order' => $order, 'pagination' => $pagination_records, 'start' => $thislist['paging'], 'limit' => $limit);
     $results = false;
     $total_records = false;
     if ($type == 'latest') {
         $results = $this->model_catalog_record->getBlogsRecords($data);
         foreach ($results as $nm => $res) {
             $total_records = $res['total'];
         }
     }
     $this->data['total'] = $total_records;
     if ($type == 'records') {
         if (isset($this->data['related']) && !empty($this->data['related'])) {
             foreach ($this->data['related'] as $related_id) {
                 $results[$related_id] = $this->model_catalog_record->getRecord($related_id);
             }
         }
     }
     if ($type == 'related') {
         $pointer_id = false;
         $blog_id = false;
         $category_id = false;
         $related_id = false;
         if (isset($this->request->get['product_id']) && $pointer == 'product_id') {
             $pointer_id = $this->request->get['product_id'];
         }
         if (isset($this->request->get['blog_id']) && $pointer == 'blog_id') {
             $parts = array();
             $path = '';
             if (isset($this->request->get['blog_id'])) {
                 $parts = explode('_', (string) $this->request->get['blog_id']);
             }
             foreach ($parts as $path_id) {
                 if (!$path) {
                     $pointer_id = (int) $path_id;
                 }
             }
         }
         if (isset($this->request->get['path']) && $pointer == 'category_id') {
             $parts = array();
             $path = '';
             if (isset($this->request->get['path'])) {
                 $parts = explode('_', (string) $this->request->get['path']);
             }
             foreach ($parts as $path_id) {
                 if (!$path) {
                     $pointer_id = (int) $path_id;
                 }
             }
         }
         if ($pointer_id) {
             $this->data['related'] = $this->model_catalog_record->getRelatedRecords($pointer_id, $data, $pointer);
             foreach ($this->data['related'] as $nm => $res) {
                 $total_records = $res['total'];
             }
             $this->data['total'] = $total_records;
             if (isset($this->data['related']) && !empty($this->data['related'])) {
                 foreach ($this->data['related'] as $num => $related) {
                     $related_id = $related['record_id'];
                     $results[$related_id] = $this->model_catalog_record->getRecord($related_id);
                 }
             }
         }
     }
     if ($results) {
         $array_dir_image = str_split(DIR_IMAGE);
         $array_dir_app = str_split(DIR_APPLICATION);
         $i = 0;
         $dir_root = '';
         while ($array_dir_image[$i] == $array_dir_app[$i]) {
             $dir_root .= $array_dir_image[$i];
             $i++;
         }
         $dir_image = str_replace($dir_root, '', DIR_IMAGE);
         if (isset($this->request->server['HTTPS']) && ($this->request->server['HTTPS'] == 'on' || $this->request->server['HTTPS'] == '1')) {
             $http_image = HTTPS_SERVER . $dir_image;
         } else {
             $http_image = HTTP_SERVER . $dir_image;
         }
         foreach ($results as $result) {
             if ($result != '') {
                 if ($result['image']) {
                     $dimensions = $thislist['avatar'];
                     if ($dimensions['width'] == '') {
                         $dimensions['width'] = 200;
                     }
                     if ($dimensions['height'] == '') {
                         $dimensions['height'] = 100;
                     }
                     $image = $this->model_tool_image->resize($result['image'], $dimensions['width'], $dimensions['height']);
                     $popup = $http_image . $result['image'];
                 } else {
                     $image = false;
                     $popup = false;
                 }
                 if ($this->config->get('config_comment_status')) {
                     $rating = (int) $result['rating'];
                 } else {
                     $rating = false;
                 }
                 if (!isset($result['sdescription'])) {
                     $result['sdescription'] = '';
                 }
                 $description = false;
                 if (isset($result['sdescription']) && $result['sdescription'] != '') {
                     $description = html_entity_decode($result['sdescription'], ENT_QUOTES, 'UTF-8');
                 }
                 if ($result['description'] && $result['sdescription'] == '') {
                     $flag_desc = 'pred';
                     $this->data['blog_num_desc'] = $thislist['desc_symbols'];
                     if ($this->data['blog_num_desc'] == '') {
                         $this->data['blog_num_desc'] = 50;
                     } else {
                         $amount = $this->data['blog_num_desc'];
                         $flag_desc = 'symbols';
                     }
                     $this->data['blog_num_desc_words'] = $thislist['desc_words'];
                     if ($this->data['blog_num_desc_words'] == '') {
                         $this->data['blog_num_desc_words'] = 10;
                     } else {
                         $amount = $this->data['blog_num_desc_words'];
                         $flag_desc = 'words';
                     }
                     $this->data['blog_num_desc_pred'] = $thislist['desc_pred'];
                     if ($this->data['blog_num_desc_pred'] == '') {
                         $this->data['blog_num_desc_pred'] = 3;
                     } else {
                         $amount = $this->data['blog_num_desc_pred'];
                         $flag_desc = 'pred';
                     }
                     switch ($flag_desc) {
                         case 'symbols':
                             $pattern = '/((.*?)\\S){0,' . $amount . '}/isu';
                             preg_match_all($pattern, strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), $out);
                             $description = $out[0][0];
                             break;
                         case 'words':
                             $pattern = '/((.*?)\\x20){0,' . $amount . '}/isu';
                             preg_match_all($pattern, strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), $out);
                             $description = $out[0][0];
                             break;
                         case 'pred':
                             $pattern = '/((.*?)\\.){0,' . $amount . '}/isu';
                             preg_match_all($pattern, strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), $out);
                             $description = $out[0][0];
                             break;
                     }
                 }
                 if (isset($this->data['settings_general']['format_date'])) {
                 } else {
                     $this->data['settings_general']['format_date'] = $this->language->get('text_date');
                 }
                 if (isset($this->data['settings_general']['format_hours'])) {
                 } else {
                     $this->data['settings_general']['format_hours'] = $this->language->get('text_hours');
                 }
                 if (isset($this->data['settings_general']['format_time']) && $this->data['settings_general']['format_time'] && date($this->data['settings_general']['format_date']) == date($this->data['settings_general']['format_date'], strtotime($result['date_available']))) {
                     $date_str = $this->language->get('text_today');
                 } else {
                     $date_str = rdate($this, $this->data['settings_general']['format_date'], strtotime($result['date_available']));
                 }
                 $date_available = $date_str . rdate($this, $this->data['settings_general']['format_hours'], strtotime($result['date_available']));
                 $this->load->model('catalog/blog');
                 $blog_href = $this->model_catalog_blog->getPathByrecord($result['record_id']);
                 if (strpos($blog_href['path'], '_') !== false) {
                     $abid = explode('_', $blog_href['path']);
                     $blog_id = $abid[count($abid) - 1];
                 } else {
                     $blog_id = (int) $blog_href['path'];
                 }
                 $blog_id = (int) $blog_id;
                 $blog_info = $this->model_catalog_blog->getBlog($blog_id);
                 $this->data['blog_design'] = array();
                 if ($blog_info) {
                     if ($blog_info['design'] != '') {
                         $this->data['blog_design'] = unserialize($blog_info['design']);
                     } else {
                         $this->data['blog_design'] = array();
                     }
                 }
                 if (isset($this->request->get['record_id']) && $result['record_id'] == $this->request->get['record_id']) {
                     $active = true;
                 } else {
                     $active = false;
                 }
                 $this->data['records'][] = array('record_id' => $result['record_id'], 'thumb' => $image, 'popup' => $popup, 'images' => $this->getRecordImages($result['record_id'], $thislist['images']), 'name' => $result['name'], 'author' => $result['author'], 'customer_id' => $result['customer_id'], 'description' => $description, 'rating' => $result['rating'], 'date_added' => $result['date_added'], 'date_available' => $date_available, 'date_end' => $result['date_end'], 'viewed' => $result['viewed'], 'comments' => (int) $result['comments'], 'href' => $this->url->link('record/record', 'record_id=' . $result['record_id']), 'blog_id' => $blog_id, 'blog_href' => $this->url->link('record/blog', 'blog_id=' . $blog_href['path']), 'blog_name' => $blog_href['name'], 'category' => $blog_info, 'settings' => $thislist, 'settings_blog' => $this->data['blog_design'], 'active' => $active, 'settings_comment' => unserialize($result['comment']));
             }
         }
     }
     return $this->data;
 }