private function getRecordImages($record_id, $settings) { $images = array(); if (!isset($settings['width']) || $settings['width'] == '') { $settings['width'] = $this->config->get('config_image_additional_width'); } if (!isset($settings['height']) || $settings['height'] == '') { $settings['height'] = $this->config->get('config_image_additional_height'); } $width = $settings['width']; $height = $settings['height']; $results = $this->model_catalog_record->getRecordImages($record_id); foreach ($results as $res) { $image_options = unserialize(base64_decode($res['options'])); if (isset($image_options['title'][$this->config->get('config_language_id')])) { $image_title = html_entity_decode($image_options['title'][$this->config->get('config_language_id')], ENT_QUOTES, 'UTF-8'); } else { $image_title = getHttpImage($this) . $res['image']; } if (isset($image_options['description'][$this->config->get('config_language_id')])) { $image_description = $description = html_entity_decode($image_options['description'][$this->config->get('config_language_id')], ENT_QUOTES, 'UTF-8'); } else { $image_description = ""; } if (isset($image_options['url'][$this->config->get('config_language_id')])) { $image_url = $image_options['url'][$this->config->get('config_language_id')]; } else { $image_url = ""; } $images[] = array('popup' => getHttpImage($this) . $res['image'], 'title' => $image_title, 'description' => $image_description, 'url' => $image_url, 'options' => $image_options, 'thumb' => $this->model_tool_image->resize($res['image'], $width, $height)); } return $images; }
public function write() { $this->request->post['rating_mark'] = 0; $this->data['settings'] = array(); $this->data['mark'] = false; $product_id = 0; $this->data['config_language_id'] = $this->config->get('config_language_id'); $this->data['http_image'] = getHttpImage($this); if (isset($this->request->get['product_id'])) { $this->data['mark'] = 'product_id'; $mark_route = 'product/product'; $product_id = $this->request->get['product_id']; } if (isset($this->request->get['record_id'])) { $this->data['mark'] = 'record_id'; $mark_route = 'record/record'; $product_id = $this->request->get['record_id']; $this->load->model('catalog/blog'); $blog_info = $this->model_catalog_blog->getPathByrecord($product_id); $this->request->get['blog_id'] = $blog_info['path']; if (isset($blog_info['path'])) { $path = ''; foreach (explode('_', $blog_info['path']) as $path_id) { $blog_id = $path_id; } $blog_info = $this->model_catalog_blog->getBlog($blog_id); } else { $blog_id = false; } if (isset($blog_info['design']) && $blog_info['design'] != '') { $this->data['settings_blog'] = unserialize($blog_info['design']); } else { $this->data['settings_blog'] = array(); } $this->load->model('catalog/record'); $record_info = $this->model_catalog_record->getRecord($product_id); if ($record_info) { $this->data['settings_record'] = unserialize($record_info['comment']); } else { $this->data['settings_record'] = array(); } $this->data['settings'] = array_merge($this->data['settings_blog'], $this->data['settings_record']); } $json = array(); $html = "<script>var wdata = new Array()\n\t\t\t\t\t\t\twdata['code'] \t = 'error'\n\t\t\t\t\t\t\twdata['message'] = 'Error'</script>"; $this->load->model('catalog/treecomments'); if (isset($this->request->get['parent'])) { if ($this->request->get['parent'] == '') { $this->request->get['parent'] = 0; } } else { $this->request->get['parent'] = 0; } if (isset($this->request->get['sort'])) { $sort = $this->request->get['sort']; } else { $sort = 'p.sort_order'; } if (isset($this->request->get['order'])) { $order = $this->request->get['order']; } else { $order = 'DESC'; } if (isset($this->request->get['page'])) { $page = $this->request->get['page']; } else { $page = 1; } if (isset($this->request->get['limit'])) { $limit = $this->request->get['limit']; } else { $limit = $this->config->get('config_catalog_limit'); } if (SCP_VERSION > 1) { $get_Customer_GroupId = 'getGroupId'; } else { $get_Customer_GroupId = 'getCustomerGroupId'; } if ($this->customer->isLogged()) { $customer_group_id = $this->customer->{$get_Customer_GroupId}(); $captcha_status = false; $customer_id = $this->customer->getId(); } else { $customer_group_id = $this->config->get('config_customer_group_id'); $captcha_status = true; $customer = false; $customer_id = false; } $this->data['ascp_widgets'] = $this->config->get('ascp_widgets'); if (isset($this->request->get['ascp_widgets_position'])) { $ascp_widgets_position = $this->request->get['ascp_widgets_position']; } else { $ascp_widgets_position = 0; } if (isset($this->request->get['ascp_widgets_position'])) { $this->data['cmswidget'] = $this->request->get['cmswidget'] = (int) $this->request->get['ascp_widgets_position']; } $set_thislist = array('status' => '1', 'status_reg' => '0', 'status_now' => '0'); if (isset($this->data['ascp_widgets'][$ascp_widgets_position]) && !empty($this->data['ascp_widgets'][$ascp_widgets_position])) { $thislist = $this->data['ascp_widgets'][$ascp_widgets_position]; } else { $thislist = array('status' => '1', 'status_reg' => '0', 'status_now' => '0', 'rating_must' => '1'); } $thislist = $thislist + $set_thislist; $thislist['comment_signer'] = $thislist['status_now']; $thislist = $this->data['settings'] + $thislist; $k = serialize($thislist); $this->data['comment_status'] = $thislist['status']; $this->data['comment_status_reg'] = $thislist['status_reg']; $this->data['comment_status_now'] = $thislist['status_now']; $this->data['comment'] = $thislist; $this->request->post['comment']['status'] = $thislist['status']; $this->request->post['comment']['status_reg'] = $thislist['status_reg']; $this->request->post['comment']['status_now'] = $thislist['status_now']; $this->request->post['status'] = $thislist['status_now']; $this->language->load('record/record'); $this->language->load('product/product'); if (isset($thislist['langfile']) && $thislist['langfile'] != '') { $this->language->load($thislist['langfile']); } else { $this->language->load('record/blog'); } if (isset($thislist['fields_view'])) { $this->data['fields_view'] = $thislist['fields_view']; } else { $this->data['fields_view'] = 0; } if (isset($thislist['addfields'])) { usort($thislist['addfields'], 'comp_field'); $this->data['fields'] = $thislist['addfields']; } else { $this->data['fields'] = array(); } $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 { } } } } } if (isset($this->request->post['email_ghost']) && $this->request->post['email_ghost'] != '') { if (preg_match("|^[-0-9a-z_\\.]+@[-0-9a-z_^\\.]+\\.[a-z]{2,6}\$|i", $this->request->post['email_ghost'])) { } else { $json['error'] = $this->language->get('text_error_email'); $html = "<script>var wdata = new Array()\n\t\t\t\t\t\t\t\twdata['code'] \t = 'error'\n\t\t\t\t\t\t\t\twdata['message'] = '" . $this->language->get('text_error_email') . "'</script>"; } } if (!isset($this->request->post['name']) || (utf8_strlen($this->request->post['name']) < 3 || utf8_strlen($this->request->post['name']) > 33)) { $json['error'] = $this->language->get('error_name'); $html = "<script>var wdata = new Array()\n\t\t\t\t\t\t\twdata['code'] \t = 'error'\n\t\t\t\t\t\t\twdata['message'] = '" . $this->language->get('error_name') . "'</script>"; } else { $json['login'] = $this->request->post['name']; } if (isset($thislist['comment_must']) && $thislist['comment_must'] || !isset($thislist['comment_must'])) { if (!isset($this->request->post['text']) || (utf8_strlen($this->request->post['text']) < 3 || utf8_strlen($this->request->post['text']) > 1000)) { $json['error'] = $this->language->get('error_text'); $html = "<script>var wdata = new Array()\n\t\t\t\t\t\t\t\twdata['code'] \t = 'error'\n\t\t\t\t\t\t\t\twdata['message'] = '" . $this->language->get('error_text') . "'</script>"; } } if (!isset($this->request->post['rating']) && $thislist['rating_must'] == 1) { $json['error'] = $this->language->get('error_rating'); $html = "<script>var wdata = new Array()\n\t\t\t\t\t\t\twdata['code'] \t = 'error'\n\t\t\t\t\t\t\twdata['message'] = '" . $this->language->get('error_rating') . "'</script>"; } if (isset($thislist['rating_must']) && $thislist['rating_must'] == 0 && !isset($this->request->post['rating'])) { $this->request->post['rating'] = 5; $this->request->post['rating_mark'] = 1; } if (!isset($this->session->data['captcha']) || isset($this->request->post['captcha']) && strtolower($this->session->data['captcha']) != strtolower($this->request->post['captcha'])) { if ($captcha_status) { $json['error'] = $this->language->get('error_captcha'); $html = "<script>var wdata = new Array()\n\t\t\t\t\t\t\twdata['code'] \t = 'error'\n\t\t\t\t\t\t\twdata['message'] = '" . $this->language->get('error_captcha') . "'</script>"; } } if ($thislist['status_reg'] && !$this->customer->isLogged()) { $error_reg = sprintf($this->language->get('error_reg'), $this->url->link('account/login'), $this->url->link('account/register')); $json['error'] = $error_reg; $html = "<script>var wdata = new Array()\n\t\t\t\t\t\t\twdata['code'] \t = 'error'\n\t\t\t\t\t\t\twdata['message'] = '" . $error_reg . "'</script>"; } $error = ''; foreach ($this->data['fields'] as $num => $field) { if (isset($this->request->post['af'][$field['field_name']]) && $this->request->post['af'][$field['field_name']] == '' && isset($field['field_must']) && $field['field_must']) { if (isset($field['field_error'][$this->config->get('config_language_id')])) { $error = $error . preg_replace("/(\r\n)+/i", "", html_entity_decode($field['field_error'][$this->config->get('config_language_id')], ENT_QUOTES, 'UTF-8')) . "<br>"; $error = preg_replace("/(\\')+/i", '"', $error); } $json['error'] = $error; $html = "<script>var wdata = new Array()\n\t\t\t\t\t\t\twdata['code'] \t = 'error'\n\t\t\t\t\t\t\twdata['message'] = '" . $error . "'</script>"; } } if (!isset($json['login']) || $json['login'] == '') { if ($this->customer->isLogged()) { $json['login'] = $this->customer->getFirstName() . " " . $this->customer->getLastName(); $json['customer_id'] = $this->data['customer_id'] = $this->customer->getId(); } else { $json['login'] = $this->language->get('text_anonymus'); $json['customer_id'] = false; } } $this->load->model('catalog/treecomments'); $this->data['karma_voted'] = false; if ($this->request->server['REQUEST_METHOD'] == 'POST' && !isset($json['error'])) { /*********************************************************************************************************************/ $this->request->post['cmswidget'] = $ascp_widgets_position; $comment_id = $this->model_catalog_treecomments->addComment($this->request->get[$this->data['mark']], $this->request->post, $this->request->get, $this->data['mark']); if (!$customer_id) { if (isset($_COOKIE["karma_" . $this->data['mark']])) { $karma_cookie = unserialize(base64_decode($_COOKIE["karma_" . $this->data['mark']])); } else { $karma_cookie = array(); } $karma_cookie[$comment_id]['id'] = $product_id; foreach ($karma_cookie as $id => $mark_id) { if ($mark_id['id'] == $product_id) { $this->data['karma_voted'] = true; } } setcookie("karma_" . $this->data['mark'], base64_encode(serialize($karma_cookie)), time() + 60 * 60 * 24 * 555, '/', $this->request->server['HTTP_HOST']); } $this->data['comment_count'] = $this->model_catalog_treecomments->getTotalCommentsByMarkId($product_id, $this->data['mark'], $thislist); if ($this->data['mark'] == 'product_id') { $this->load->model('catalog/product'); $mark_info = $this->model_catalog_product->getProduct($product_id); } if ($this->data['mark'] == 'record_id') { $this->load->model('catalog/record'); $mark_info = $this->model_catalog_record->getRecord($product_id); } $mark_info['comment_id'] = $comment_id; $this->cont('record/signer'); $subscribeAnswerStatus = $this->controller_record_signer->subscribe($comment_id, $this->data['mark']); $this->controller_record_signer->signer($product_id, $mark_info, $thislist, $this->data['mark']); if (isset($thislist['langfile']) && $thislist['langfile'] != '') { $this->language->load($thislist['langfile']); } else { $this->language->load('record/blog'); } $review_count = sprintf($this->language->get('tab_review'), $this->data['comment_count']); if ($thislist['status_now']) { $json['success'] = $this->language->get('text_success_now'); $html = "<script>var wdata = new Array();\n\t\t\t\t\t\t\twdata['code'] \t = 'success';\n\t\t\t\t\t\t\twdata['message'] = '" . $this->language->get('text_success_now') . "';\n\t\t\t\t\t\t\twdata['login'] = '******'login'] . "';\n\t\t\t\t\t\t\twdata['review_count'] = '" . $review_count . "';\n\t\t\t\t\t\t\t</script>"; } else { $json['success'] = $this->language->get('text_success'); $html = "<script>var wdata = new Array();\n\t\t\t\t\t\t\twdata['code'] \t = 'success';\n\t\t\t\t\t\t\twdata['message'] = '" . $this->language->get('text_success') . "';\n\t\t\t\t\t\t\twdata['login'] = '******'login'] . "';\n\t\t\t\t\t\t\twdata['review_count'] = '" . $review_count . "';\n\t\t\t\t\t\t\t</script>"; } } $this->response->setOutput($html); }