first commit
This commit is contained in:
@@ -0,0 +1,243 @@
|
||||
<?php
|
||||
class ControllerExtensionFeedGoogleBase extends Controller {
|
||||
private $error = array();
|
||||
|
||||
public function index() {
|
||||
$this->load->language('extension/feed/google_base');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$this->load->model('setting/setting');
|
||||
|
||||
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
|
||||
$this->model_setting_setting->editSetting('feed_google_base', $this->request->post);
|
||||
|
||||
$this->session->data['success'] = $this->language->get('text_success');
|
||||
|
||||
$this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=feed', true));
|
||||
}
|
||||
|
||||
if (isset($this->error['warning'])) {
|
||||
$data['error_warning'] = $this->error['warning'];
|
||||
} else {
|
||||
$data['error_warning'] = '';
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = array();
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
|
||||
);
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('text_extension'),
|
||||
'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=feed', true)
|
||||
);
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('extension/feed/google_base', 'user_token=' . $this->session->data['user_token'], true)
|
||||
);
|
||||
|
||||
$data['action'] = $this->url->link('extension/feed/google_base', 'user_token=' . $this->session->data['user_token'], true);
|
||||
|
||||
$data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=feed', true);
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$data['data_feed'] = HTTP_CATALOG . 'index.php?route=extension/feed/google_base';
|
||||
|
||||
if (isset($this->request->post['feed_google_base_status'])) {
|
||||
$data['feed_google_base_status'] = $this->request->post['feed_google_base_status'];
|
||||
} else {
|
||||
$data['feed_google_base_status'] = $this->config->get('feed_google_base_status');
|
||||
}
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('extension/feed/google_base', $data));
|
||||
}
|
||||
|
||||
protected function validate() {
|
||||
if (!$this->user->hasPermission('modify', 'extension/feed/google_base')) {
|
||||
$this->error['warning'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
return !$this->error;
|
||||
}
|
||||
|
||||
public function install() {
|
||||
$this->load->model('extension/feed/google_base');
|
||||
|
||||
$this->model_extension_feed_google_base->install();
|
||||
}
|
||||
|
||||
public function uninstall() {
|
||||
$this->load->model('extension/feed/google_base');
|
||||
|
||||
$this->model_extension_feed_google_base->uninstall();
|
||||
}
|
||||
|
||||
public function import() {
|
||||
$this->load->language('extension/feed/google_base');
|
||||
|
||||
$json = array();
|
||||
|
||||
// Check user has permission
|
||||
if (!$this->user->hasPermission('modify', 'extension/feed/google_base')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
if (!empty($this->request->files['file']['name']) && is_file($this->request->files['file']['tmp_name'])) {
|
||||
// Sanitize the filename
|
||||
$filename = basename(html_entity_decode($this->request->files['file']['name'], ENT_QUOTES, 'UTF-8'));
|
||||
|
||||
// Allowed file extension types
|
||||
if (utf8_strtolower(utf8_substr(strrchr($filename, '.'), 1)) != 'txt') {
|
||||
$json['error'] = $this->language->get('error_filetype');
|
||||
}
|
||||
|
||||
// Allowed file mime types
|
||||
if ($this->request->files['file']['type'] != 'text/plain') {
|
||||
$json['error'] = $this->language->get('error_filetype');
|
||||
}
|
||||
|
||||
// Return any upload error
|
||||
if ($this->request->files['file']['error'] != UPLOAD_ERR_OK) {
|
||||
$json['error'] = $this->language->get('error_upload_' . $this->request->files['file']['error']);
|
||||
}
|
||||
} else {
|
||||
$json['error'] = $this->language->get('error_upload');
|
||||
}
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
|
||||
$this->load->model('extension/feed/google_base');
|
||||
|
||||
// Get the contents of the uploaded file
|
||||
$content = file_get_contents($this->request->files['file']['tmp_name']);
|
||||
|
||||
$this->model_extension_feed_google_base->import($content);
|
||||
|
||||
unlink($this->request->files['file']['tmp_name']);
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
|
||||
public function category() {
|
||||
$this->load->language('extension/feed/google_base');
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$data['google_base_categories'] = array();
|
||||
|
||||
$this->load->model('extension/feed/google_base');
|
||||
|
||||
$results = $this->model_extension_feed_google_base->getCategories(($page - 1) * 10, 10);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$data['google_base_categories'][] = array(
|
||||
'google_base_category_id' => $result['google_base_category_id'],
|
||||
'google_base_category' => $result['google_base_category'],
|
||||
'category_id' => $result['category_id'],
|
||||
'category' => $result['category']
|
||||
);
|
||||
}
|
||||
|
||||
$category_total = $this->model_extension_feed_google_base->getTotalCategories();
|
||||
|
||||
$pagination = new Pagination();
|
||||
$pagination->total = $category_total;
|
||||
$pagination->page = $page;
|
||||
$pagination->limit = 10;
|
||||
$pagination->url = $this->url->link('extension/feed/google_base/category', 'user_token=' . $this->session->data['user_token'] . '&page={page}', true);
|
||||
|
||||
$data['pagination'] = $pagination->render();
|
||||
|
||||
$data['results'] = sprintf($this->language->get('text_pagination'), ($category_total) ? (($page - 1) * 10) + 1 : 0, ((($page - 1) * 10) > ($category_total - 10)) ? $category_total : ((($page - 1) * 10) + 10), $category_total, ceil($category_total / 10));
|
||||
|
||||
$this->response->setOutput($this->load->view('extension/feed/google_base_category', $data));
|
||||
}
|
||||
|
||||
public function addCategory() {
|
||||
$this->load->language('extension/feed/google_base');
|
||||
|
||||
$json = array();
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'extension/feed/google_base')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
} elseif (!empty($this->request->post['google_base_category_id']) && !empty($this->request->post['category_id'])) {
|
||||
$this->load->model('extension/feed/google_base');
|
||||
|
||||
$this->model_extension_feed_google_base->addCategory($this->request->post);
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
|
||||
public function removeCategory() {
|
||||
$this->load->language('extension/feed/google_base');
|
||||
|
||||
$json = array();
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'extension/feed/google_base')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
} else {
|
||||
$this->load->model('extension/feed/google_base');
|
||||
|
||||
$this->model_extension_feed_google_base->deleteCategory($this->request->post['category_id']);
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
|
||||
public function autocomplete() {
|
||||
$json = array();
|
||||
|
||||
if (isset($this->request->get['filter_name'])) {
|
||||
$this->load->model('extension/feed/google_base');
|
||||
|
||||
if (isset($this->request->get['filter_name'])) {
|
||||
$filter_name = $this->request->get['filter_name'];
|
||||
} else {
|
||||
$filter_name = '';
|
||||
}
|
||||
|
||||
$filter_data = array(
|
||||
'filter_name' => html_entity_decode($filter_name, ENT_QUOTES, 'UTF-8'),
|
||||
'start' => 0,
|
||||
'limit' => $this->config->get('config_limit_autocomplete')
|
||||
);
|
||||
|
||||
$results = $this->model_extension_feed_google_base->getGoogleBaseCategories($filter_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$json[] = array(
|
||||
'google_base_category_id' => $result['google_base_category_id'],
|
||||
'name' => strip_tags(html_entity_decode($result['name'], ENT_QUOTES, 'UTF-8'))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
class ControllerExtensionFeedGoogleSitemap extends Controller {
|
||||
private $error = array();
|
||||
|
||||
public function index() {
|
||||
$this->load->language('extension/feed/google_sitemap');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$this->load->model('setting/setting');
|
||||
|
||||
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
|
||||
$this->model_setting_setting->editSetting('feed_google_sitemap', $this->request->post);
|
||||
|
||||
$this->session->data['success'] = $this->language->get('text_success');
|
||||
|
||||
$this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=feed', true));
|
||||
}
|
||||
|
||||
if (isset($this->error['warning'])) {
|
||||
$data['error_warning'] = $this->error['warning'];
|
||||
} else {
|
||||
$data['error_warning'] = '';
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = array();
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
|
||||
);
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('text_extension'),
|
||||
'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=feed', true)
|
||||
);
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('extension/feed/google_sitemap', 'user_token=' . $this->session->data['user_token'], true)
|
||||
);
|
||||
|
||||
$data['action'] = $this->url->link('extension/feed/google_sitemap', 'user_token=' . $this->session->data['user_token'], true);
|
||||
|
||||
$data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=feed', true);
|
||||
|
||||
if (isset($this->request->post['feed_google_sitemap_status'])) {
|
||||
$data['feed_google_sitemap_status'] = $this->request->post['feed_google_sitemap_status'];
|
||||
} else {
|
||||
$data['feed_google_sitemap_status'] = $this->config->get('feed_google_sitemap_status');
|
||||
}
|
||||
|
||||
$data['data_feed'] = HTTP_CATALOG . 'index.php?route=extension/feed/google_sitemap';
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('extension/feed/google_sitemap', $data));
|
||||
}
|
||||
|
||||
protected function validate() {
|
||||
if (!$this->user->hasPermission('modify', 'extension/feed/google_sitemap')) {
|
||||
$this->error['warning'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
return !$this->error;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
class ControllerExtensionFeedGoogleSitemapFast extends Controller {
|
||||
private $error = array();
|
||||
|
||||
public function index() {
|
||||
$this->load->language('extension/feed/google_sitemap_fast');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$this->load->model('setting/setting');
|
||||
|
||||
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
|
||||
$this->model_setting_setting->editSetting('feed_google_sitemap_fast', $this->request->post);
|
||||
|
||||
$this->session->data['success'] = $this->language->get('text_success');
|
||||
|
||||
$this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=feed', true));
|
||||
}
|
||||
|
||||
if (isset($this->error['warning'])) {
|
||||
$data['error_warning'] = $this->error['warning'];
|
||||
} else {
|
||||
$data['error_warning'] = '';
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = array();
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
|
||||
);
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('text_extension'),
|
||||
'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=feed', true)
|
||||
);
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('extension/feed/google_sitemap_fast', 'user_token=' . $this->session->data['user_token'], true)
|
||||
);
|
||||
|
||||
$data['action'] = $this->url->link('extension/feed/google_sitemap_fast', 'user_token=' . $this->session->data['user_token'], true);
|
||||
|
||||
$data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=feed', true);
|
||||
|
||||
if (isset($this->request->post['feed_google_sitemap_fast_status'])) {
|
||||
$data['feed_google_sitemap_fast_status'] = $this->request->post['feed_google_sitemap_fast_status'];
|
||||
} else {
|
||||
$data['feed_google_sitemap_fast_status'] = $this->config->get('feed_google_sitemap_fast_status');
|
||||
}
|
||||
|
||||
$data['data_feed'] = HTTP_CATALOG . 'index.php?route=extension/feed/google_sitemap_fast';
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('extension/feed/google_sitemap_fast', $data));
|
||||
}
|
||||
|
||||
protected function validate() {
|
||||
if (!$this->user->hasPermission('modify', 'extension/feed/google_sitemap_fast')) {
|
||||
$this->error['warning'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
return !$this->error;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
<?php
|
||||
/**
|
||||
* Модуль интеграции с Unisender http://www.unisender.com/?a=opencart
|
||||
*
|
||||
* Александр Топорков
|
||||
* toporchillo@gmail.com
|
||||
*/
|
||||
class ControllerExtensionFeedUnisender extends Controller {
|
||||
private $error = array();
|
||||
private $form;
|
||||
private $tdata = array();
|
||||
|
||||
public function subscribtions() {
|
||||
$key = $this->request->get['key'];
|
||||
$ch = curl_init ('https://api.unisender.com/ru/api/getLists?format=json&api_key='.$key) ;
|
||||
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1) ;
|
||||
$res = curl_exec ($ch) ;
|
||||
curl_close ($ch) ;
|
||||
echo $res;
|
||||
}
|
||||
|
||||
public function index() {
|
||||
$this->load->language('extension/feed/unisender');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$this->load->model('setting/setting');
|
||||
|
||||
if ($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
if ($this->validate($this->request->post)) {
|
||||
$this->model_setting_setting->editSetting('feed_unisender', $this->request->post);
|
||||
|
||||
$this->session->data['success'] = $this->language->get('text_success');
|
||||
|
||||
$this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=feed', 'SSL'));
|
||||
}
|
||||
}
|
||||
|
||||
$this->tdata['heading_title'] = $this->language->get('heading_title');
|
||||
$this->tdata['breadcrumbs'] = $this->getBreadCrumbs();
|
||||
$this->tdata['button_save'] = $this->language->get('button_save');
|
||||
$this->tdata['button_cancel'] = $this->language->get('button_cancel');
|
||||
$this->tdata['text_enabled'] = $this->language->get('text_enabled');
|
||||
$this->tdata['text_disabled'] = $this->language->get('text_disabled');
|
||||
$this->tdata['text_export'] = $this->language->get('text_export');
|
||||
$this->tdata['user_token'] = $this->session->data['user_token'];
|
||||
$this->tdata['text_edit'] = $this->language->get('text_edit');
|
||||
$this->tdata['text_get_key'] = $this->language->get('text_get_key');
|
||||
$this->tdata['text_unselect'] = $this->language->get('text_unselect');
|
||||
|
||||
if (isset($this->error['warning'])) {
|
||||
$this->tdata['error_warning'] = $this->error['warning'];
|
||||
} else {
|
||||
$this->tdata['error_warning'] = '';
|
||||
}
|
||||
$this->tdata['_error'] = $this->error;
|
||||
|
||||
$this->tdata['action'] = $this->url->link('extension/feed/unisender', 'user_token=' . $this->session->data['user_token'], 'SSL');
|
||||
|
||||
$this->tdata['export'] = $this->url->link('extension/feed/unisender/export', 'user_token=' . $this->session->data['user_token'], 'SSL');
|
||||
|
||||
$this->tdata['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=feed', 'SSL');
|
||||
|
||||
$defaults = array(
|
||||
'feed_unisender_key' => '',
|
||||
'feed_unisender_subscribtion' => array(),
|
||||
'feed_unisender_status' => '',
|
||||
'feed_unisender_ignore' => '',
|
||||
);
|
||||
foreach ($defaults as $key=>$value) {
|
||||
if (isset($this->request->post[$key])) {
|
||||
$defautls[$key] = $this->request->post[$key];
|
||||
}
|
||||
else {
|
||||
$defautls[$key] = $this->config->get($key);
|
||||
}
|
||||
$this->tdata[$key] = $defautls[$key];
|
||||
$this->tdata['entry_'.$key] = $this->language->get('entry_'.$key);
|
||||
if ($this->language->get('entry_'.$key.'_help')) {
|
||||
$this->tdata['entry_'.$key.'_help'] = $this->language->get('entry_'.$key.'_help');
|
||||
}
|
||||
}
|
||||
|
||||
$template = 'extension/feed/unisender';
|
||||
$this->children = array(
|
||||
'common/header',
|
||||
'common/footer'
|
||||
);
|
||||
|
||||
$this->tdata['header'] = $this->load->controller('common/header');
|
||||
$this->tdata['column_left'] = $this->load->controller('common/column_left');
|
||||
$this->tdata['footer'] = $this->load->controller('common/footer');
|
||||
$this->response->setOutput($this->load->view($template, $this->tdata));
|
||||
}
|
||||
|
||||
public function export() {
|
||||
header( 'Content-Type: text/csv' );
|
||||
header( 'Content-Disposition: attachment;filename=unisender_contacts.csv');
|
||||
$fp = fopen('php://output', 'w');
|
||||
|
||||
$query = $this->db->query("SELECT CONCAT_WS(' ', firstname, lastname), email, telephone FROM `" . DB_PREFIX . "order` ORDER BY order_id");
|
||||
foreach ($query->rows as $row) {
|
||||
fputcsv($fp, $row);
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
public function install() {
|
||||
$this->load->model('setting/event');
|
||||
$this->model_setting_event->addEvent('unisender_subscribe', 'catalog/model/account/customer/addCustomer/after', 'extension/feed/unisender/subscribe_customer');
|
||||
$this->model_setting_event->addEvent('unisender_update', 'catalog/model/account/customer/editNewsletter/after', 'extension/feed/unisender/update');
|
||||
$this->model_setting_event->addEvent('unisender_guest', 'catalog/model/checkout/order/addOrderHistory/before', 'extension/feed/unisender/subscribe_guest');
|
||||
}
|
||||
|
||||
public function uninstall() {
|
||||
$this->load->model('setting/event');
|
||||
$this->model_setting_event->deleteEvent('unisender_subscribe');
|
||||
$this->model_setting_event->deleteEvent('unisender_update');
|
||||
$this->model_setting_event->deleteEvent('unisender_guest');
|
||||
}
|
||||
|
||||
private function validate($post_data) {
|
||||
if (!$this->user->hasPermission('modify', 'extension/feed/unisender')) {
|
||||
$this->error['warning'] = $this->language->get('error_permission');
|
||||
}
|
||||
if (!$post_data['feed_unisender_key']) {
|
||||
$this->error['warning'] = $this->language->get('error_form');
|
||||
$this->error['unisender_key'] = $this->language->get('error_empty_field');
|
||||
}
|
||||
|
||||
if (!$this->error || !sizeof($this->error)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private function getBreadCrumbs() {
|
||||
$breadcrumbs = array();
|
||||
|
||||
$breadcrumbs[] = array(
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/home', 'user_token=' . $this->session->data['user_token'], 'SSL'),
|
||||
'separator' => false
|
||||
);
|
||||
|
||||
$breadcrumbs[] = array(
|
||||
'text' => $this->language->get('text_module'),
|
||||
'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=feed', 'SSL'),
|
||||
'separator' => ' :: '
|
||||
);
|
||||
|
||||
$breadcrumbs[] = array(
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('extension/feed/unisender', 'user_token=' . $this->session->data['user_token'], 'SSL'),
|
||||
'separator' => ' :: '
|
||||
);
|
||||
|
||||
return $breadcrumbs;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,311 @@
|
||||
<?php
|
||||
// * @source See SOURCE.txt for source and other copyright.
|
||||
// * @license GNU General Public License version 3; see LICENSE.txt
|
||||
|
||||
class ControllerExtensionFeedYandexMarket extends Controller {
|
||||
private $error = array();
|
||||
|
||||
public function index() {
|
||||
$this->load->language('extension/feed/yandex_market');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$this->load->model('setting/setting');
|
||||
|
||||
if (($this->request->server['REQUEST_METHOD'] == 'POST') && ($this->validate())) {
|
||||
if (isset($this->request->post['feed_yandex_market_categories'])) {
|
||||
$this->request->post['feed_yandex_market_categories'] = implode(',', $this->request->post['feed_yandex_market_categories']);
|
||||
}
|
||||
|
||||
if (isset($this->request->post['feed_yandex_market_manufacturers'])) {
|
||||
$this->request->post['feed_yandex_market_manufacturers'] = implode(',', $this->request->post['feed_yandex_market_manufacturers']);
|
||||
}
|
||||
|
||||
$this->model_setting_setting->editSetting('feed_yandex_market', $this->request->post);
|
||||
|
||||
$this->session->data['success'] = $this->language->get('text_success');
|
||||
|
||||
$this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=feed', true));
|
||||
}
|
||||
|
||||
if (isset($this->error['warning'])) {
|
||||
$data['error_warning'] = $this->error['warning'];
|
||||
} else {
|
||||
$data['error_warning'] = '';
|
||||
}
|
||||
|
||||
if (isset($this->error['error_image_width'])) {
|
||||
$data['error_image_width'] = $this->error['error_image_width'];
|
||||
} else {
|
||||
$data['error_image_width'] = '';
|
||||
}
|
||||
|
||||
if (isset($this->error['error_image_height'])) {
|
||||
$data['error_image_height'] = $this->error['error_image_height'];
|
||||
} else {
|
||||
$data['error_image_height'] = '';
|
||||
}
|
||||
|
||||
if (isset($this->error['error_image_width_min'])) {
|
||||
$data['error_image_width_min'] = $this->error['error_image_width_min'];
|
||||
} else {
|
||||
$data['error_image_width_min'] = '';
|
||||
}
|
||||
|
||||
if (isset($this->error['error_image_height_min'])) {
|
||||
$data['error_image_height_min'] = $this->error['error_image_height_min'];
|
||||
} else {
|
||||
$data['error_image_height_min'] = '';
|
||||
}
|
||||
|
||||
if (isset($this->error['error_image_width_max'])) {
|
||||
$data['error_image_width_max'] = $this->error['error_image_width_max'];
|
||||
} else {
|
||||
$data['error_image_width_max'] = '';
|
||||
}
|
||||
|
||||
if (isset($this->error['error_image_height_max'])) {
|
||||
$data['error_image_height_max'] = $this->error['error_image_height_max'];
|
||||
} else {
|
||||
$data['error_image_height_max'] = '';
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = array();
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
|
||||
);
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('text_extension'),
|
||||
'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'], true)
|
||||
);
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('text_feed'),
|
||||
'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=feed', true)
|
||||
);
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('extension/feed/yandex_market', 'user_token=' . $this->session->data['user_token'], true)
|
||||
);
|
||||
|
||||
$data['action'] = $this->url->link('extension/feed/yandex_market', 'user_token=' . $this->session->data['user_token'], true);
|
||||
|
||||
$data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=feed', true);
|
||||
|
||||
if (isset($this->request->post['feed_yandex_market_status'])) {
|
||||
$data['feed_yandex_market_status'] = $this->request->post['feed_yandex_market_status'];
|
||||
} else {
|
||||
$data['feed_yandex_market_status'] = $this->config->get('feed_yandex_market_status');
|
||||
}
|
||||
|
||||
if (isset($this->request->post['feed_yandex_market_secret_key'])) {
|
||||
$data['feed_yandex_market_secret_key'] = $this->request->post['feed_yandex_market_secret_key'];
|
||||
} else {
|
||||
$data['feed_yandex_market_secret_key'] = $this->config->get('feed_yandex_market_secret_key');
|
||||
}
|
||||
|
||||
if (isset($this->request->post['feed_yandex_market_shopname'])) {
|
||||
$data['feed_yandex_market_shopname'] = $this->request->post['feed_yandex_market_shopname'];
|
||||
} else {
|
||||
$data['feed_yandex_market_shopname'] = $this->config->get('feed_yandex_market_shopname');
|
||||
}
|
||||
|
||||
if (isset($this->request->post['feed_yandex_market_company'])) {
|
||||
$data['feed_yandex_market_company'] = $this->request->post['feed_yandex_market_company'];
|
||||
} else {
|
||||
$data['feed_yandex_market_company'] = $this->config->get('feed_yandex_market_company');
|
||||
}
|
||||
|
||||
if (isset($this->request->post['feed_yandex_market_id'])) {
|
||||
$data['feed_yandex_market_id'] = $this->request->post['feed_yandex_market_id'];
|
||||
} elseif ($this->config->has('feed_yandex_market_id')) {
|
||||
$data['feed_yandex_market_id'] = $this->config->get('feed_yandex_market_id');
|
||||
} else {
|
||||
$data['feed_yandex_market_id'] = 'product_id';
|
||||
}
|
||||
|
||||
if (isset($this->request->post['feed_yandex_market_type'])) {
|
||||
$data['feed_yandex_market_type'] = $this->request->post['feed_yandex_market_type'];
|
||||
} else {
|
||||
$data['feed_yandex_market_type'] = $this->config->get('feed_yandex_market_type');
|
||||
}
|
||||
|
||||
$data['code_man'] = array('not_unload', 'name', 'meta_h1', 'meta_title', 'meta_keyword', 'meta_description', 'model', 'sku', 'upc', 'ean', 'jan', 'isbn', 'mpn', 'location');
|
||||
|
||||
if (isset($this->request->post['feed_yandex_market_name'])) {
|
||||
$data['feed_yandex_market_name'] = $this->request->post['feed_yandex_market_name'];
|
||||
} elseif ($this->config->has('feed_yandex_market_name')) {
|
||||
$data['feed_yandex_market_name'] = $this->config->get('feed_yandex_market_name');
|
||||
} else {
|
||||
$data['feed_yandex_market_name'] = 'name';
|
||||
}
|
||||
|
||||
if (isset($this->request->post['feed_yandex_market_model'])) {
|
||||
$data['feed_yandex_market_model'] = $this->request->post['feed_yandex_market_model'];
|
||||
} elseif ($this->config->has('feed_yandex_market_model')) {
|
||||
$data['feed_yandex_market_model'] = $this->config->get('feed_yandex_market_model');
|
||||
} else {
|
||||
$data['feed_yandex_market_model'] = 'model';
|
||||
}
|
||||
|
||||
if (isset($this->request->post['feed_yandex_market_vendorcode'])) {
|
||||
$data['feed_yandex_market_vendorcode'] = $this->request->post['feed_yandex_market_vendorcode'];
|
||||
} elseif ($this->config->has('feed_yandex_market_vendorcode')) {
|
||||
$data['feed_yandex_market_vendorcode'] = $this->config->get('feed_yandex_market_vendorcode');
|
||||
} else {
|
||||
$data['feed_yandex_market_vendorcode'] = 'sku';
|
||||
}
|
||||
|
||||
if (isset($this->request->post['feed_yandex_market_image'])) {
|
||||
$data['feed_yandex_market_image'] = $this->request->post['feed_yandex_market_image'];
|
||||
} elseif ($this->config->has('feed_yandex_market_image')) {
|
||||
$data['feed_yandex_market_image'] = $this->config->get('feed_yandex_market_image');
|
||||
} else {
|
||||
$data['feed_yandex_market_image'] = '1';
|
||||
}
|
||||
|
||||
if (isset($this->request->post['feed_yandex_market_image_width'])) {
|
||||
$data['feed_yandex_market_image_width'] = $this->request->post['feed_yandex_market_image_width'];
|
||||
} elseif ($this->config->has('feed_yandex_market_image_width')) {
|
||||
$data['feed_yandex_market_image_width'] = $this->config->get('feed_yandex_market_image_width');
|
||||
} else {
|
||||
$data['feed_yandex_market_image_width'] = '600';
|
||||
}
|
||||
|
||||
if (isset($this->request->post['feed_yandex_market_image_height'])) {
|
||||
$data['feed_yandex_market_image_height'] = $this->request->post['feed_yandex_market_image_height'];
|
||||
} elseif ($this->config->has('feed_yandex_market_image_height')) {
|
||||
$data['feed_yandex_market_image_height'] = $this->config->get('feed_yandex_market_image_height');
|
||||
} else {
|
||||
$data['feed_yandex_market_image_height'] = '600';
|
||||
}
|
||||
|
||||
if (isset($this->request->post['feed_yandex_market_image_quantity'])) {
|
||||
$data['feed_yandex_market_image_quantity'] = $this->request->post['feed_yandex_market_image_quantity'];
|
||||
} elseif ($this->config->has('feed_yandex_market_image_quantity')) {
|
||||
$data['feed_yandex_market_image_quantity'] = $this->config->get('feed_yandex_market_image_quantity');
|
||||
} else {
|
||||
$data['feed_yandex_market_image_quantity'] = '10';
|
||||
}
|
||||
|
||||
if (isset($this->request->post['feed_yandex_market_main_category'])) {
|
||||
$data['feed_yandex_market_main_category'] = $this->request->post['feed_yandex_market_main_category'];
|
||||
} elseif ($this->config->has('feed_yandex_market_main_category')) {
|
||||
$data['feed_yandex_market_main_category'] = $this->config->get('feed_yandex_market_main_category');
|
||||
} else {
|
||||
$data['feed_yandex_market_main_category'] = '1';
|
||||
}
|
||||
|
||||
$this->load->model('catalog/category');
|
||||
|
||||
$data['categories'] = $this->model_catalog_category->getCategories(0);
|
||||
|
||||
if (isset($this->request->post['feed_yandex_market_categories'])) {
|
||||
$data['feed_yandex_market_categories'] = $this->request->post['feed_yandex_market_categories'];
|
||||
} elseif ($this->config->has('feed_yandex_market_categories')) {
|
||||
$data['feed_yandex_market_categories'] = explode(',', $this->config->get('feed_yandex_market_categories'));
|
||||
} else {
|
||||
$data['feed_yandex_market_categories'] = array();
|
||||
}
|
||||
|
||||
$this->load->model('catalog/manufacturer');
|
||||
|
||||
$data['manufacturers'] = $this->model_catalog_manufacturer->getManufacturers(0);
|
||||
|
||||
if (isset($this->request->post['feed_yandex_market_manufacturers'])) {
|
||||
$data['feed_yandex_market_manufacturers'] = $this->request->post['feed_yandex_market_manufacturers'];
|
||||
} elseif ($this->config->has('feed_yandex_market_manufacturers')) {
|
||||
$data['feed_yandex_market_manufacturers'] = explode(',', $this->config->get('feed_yandex_market_manufacturers'));
|
||||
} else {
|
||||
$data['feed_yandex_market_manufacturers'] = array();
|
||||
}
|
||||
|
||||
$this->load->model('localisation/currency');
|
||||
|
||||
$currencies = $this->model_localisation_currency->getCurrencies();
|
||||
|
||||
$allowed_currencies = array_flip(array('RUR', 'RUB', 'USD', 'BYN', 'BYR', 'KZT', 'EUR', 'UAH'));
|
||||
|
||||
$data['currencies'] = array_intersect_key($currencies, $allowed_currencies);
|
||||
|
||||
if (isset($this->request->post['feed_yandex_market_currency'])) {
|
||||
$data['feed_yandex_market_currency'] = $this->request->post['feed_yandex_market_currency'];
|
||||
} else {
|
||||
$data['feed_yandex_market_currency'] = $this->config->get('feed_yandex_market_currency');
|
||||
}
|
||||
|
||||
$this->load->model('localisation/stock_status');
|
||||
|
||||
$data['stock_statuses'] = $this->model_localisation_stock_status->getStockStatuses();
|
||||
|
||||
if (isset($this->request->post['feed_yandex_market_in_stock'])) {
|
||||
$data['feed_yandex_market_in_stock'] = $this->request->post['feed_yandex_market_in_stock'];
|
||||
} elseif ($this->config->get('feed_yandex_market_in_stock')) {
|
||||
$data['feed_yandex_market_in_stock'] = $this->config->get('feed_yandex_market_in_stock');
|
||||
} else {
|
||||
$data['feed_yandex_market_in_stock'] = 7;
|
||||
}
|
||||
|
||||
if (isset($this->request->post['feed_yandex_market_out_of_stock'])) {
|
||||
$data['feed_yandex_market_out_of_stock'] = $this->request->post['feed_yandex_market_out_of_stock'];
|
||||
} elseif ($this->config->get('feed_yandex_market_out_of_stock')) {
|
||||
$data['feed_yandex_market_out_of_stock'] = $this->config->get('feed_yandex_market_out_of_stock');
|
||||
} else {
|
||||
$data['feed_yandex_market_out_of_stock'] = 5;
|
||||
}
|
||||
|
||||
if (isset($this->request->post['feed_yandex_market_quantity_status'])) {
|
||||
$data['feed_yandex_market_quantity_status'] = $this->request->post['feed_yandex_market_quantity_status'];
|
||||
} else {
|
||||
$data['feed_yandex_market_quantity_status'] = $this->config->get('feed_yandex_market_quantity_status');
|
||||
}
|
||||
|
||||
$data['data_feed'] = HTTP_CATALOG . 'index.php?route=extension/feed/yandex_market' . ($this->config->get('feed_yandex_market_secret_key') ? '&secret_key=' . $this->config->get('feed_yandex_market_secret_key') : false);
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('extension/feed/yandex_market', $data));
|
||||
}
|
||||
|
||||
private function validate() {
|
||||
if (!$this->user->hasPermission('modify', 'extension/feed/yandex_market')) {
|
||||
$this->error['warning'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if (!$this->request->post['feed_yandex_market_image_width']) {
|
||||
$this->error['error_image_width'] = $this->language->get('error_image_width');
|
||||
}
|
||||
|
||||
if (!$this->request->post['feed_yandex_market_image_height']) {
|
||||
$this->error['error_image_height'] = $this->language->get('error_image_height');
|
||||
}
|
||||
|
||||
if ($this->request->post['feed_yandex_market_image_width'] < 250) {
|
||||
$this->error['error_image_width_min'] = $this->language->get('error_image_width_min');
|
||||
}
|
||||
|
||||
if ($this->request->post['feed_yandex_market_image_height'] < 250) {
|
||||
$this->error['error_image_height_min'] = $this->language->get('error_image_height_min');
|
||||
}
|
||||
|
||||
if ($this->request->post['feed_yandex_market_image_width'] > 3500) {
|
||||
$this->error['error_image_width_max'] = $this->language->get('error_image_width_max');
|
||||
}
|
||||
|
||||
if ($this->request->post['feed_yandex_market_image_height'] > 3500) {
|
||||
$this->error['error_image_height_max'] = $this->language->get('error_image_height_max');
|
||||
}
|
||||
|
||||
if (!$this->error) {
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
class ControllerExtensionFeedYandexTurbo extends Controller {
|
||||
private $error = array();
|
||||
|
||||
private $allowed = array('RUR', 'RUB', 'USD', 'EUR', 'BYR', 'BYN', 'KZT', 'UAH');
|
||||
|
||||
public function index() {
|
||||
$this->load->language('extension/feed/yandex_turbo');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$this->load->model('setting/setting');
|
||||
|
||||
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
|
||||
$this->model_setting_setting->editSetting('feed_yandex_turbo', $this->request->post);
|
||||
|
||||
$this->session->data['success'] = $this->language->get('text_success');
|
||||
|
||||
$this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=feed', true));
|
||||
}
|
||||
|
||||
if (isset($this->error['warning'])) {
|
||||
$data['error_warning'] = $this->error['warning'];
|
||||
} else {
|
||||
$data['error_warning'] = '';
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = array();
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
|
||||
);
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('text_extension'),
|
||||
'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=feed', true)
|
||||
);
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('extension/feed/yandex_turbo', 'user_token=' . $this->session->data['user_token'], true)
|
||||
);
|
||||
|
||||
$data['action'] = $this->url->link('extension/feed/yandex_turbo', 'user_token=' . $this->session->data['user_token'], true);
|
||||
|
||||
$data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=feed', true);
|
||||
|
||||
$this->load->model('localisation/currency');
|
||||
$currencies = $this->model_localisation_currency->getCurrencies();
|
||||
$allowed_currencies = array_flip($this->allowed);
|
||||
$data['currencies'] = array_intersect_key($currencies, $allowed_currencies);
|
||||
|
||||
if (isset($this->request->post['feed_yandex_turbo_status'])) {
|
||||
$data['feed_yandex_turbo_status'] = $this->request->post['feed_yandex_turbo_status'];
|
||||
} else {
|
||||
$data['feed_yandex_turbo_status'] = $this->config->get('feed_yandex_turbo_status');
|
||||
}
|
||||
|
||||
if (isset($this->request->post['feed_yandex_turbo_currency'])) {
|
||||
$data['feed_yandex_turbo_currency'] = $this->request->post['feed_yandex_turbo_currency'];
|
||||
} else {
|
||||
$data['feed_yandex_turbo_currency'] = $this->config->get('feed_yandex_turbo_currency');
|
||||
}
|
||||
|
||||
$data['entry_currency'] = $this->language->get('entry_currency');
|
||||
$data['entry_made'] = $this->language->get('entry_made');
|
||||
|
||||
$data['data_feed'] = HTTP_CATALOG . 'index.php?route=extension/feed/yandex_turbo';
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('extension/feed/yandex_turbo', $data));
|
||||
}
|
||||
|
||||
protected function validate() {
|
||||
if (!$this->user->hasPermission('modify', 'extension/feed/yandex_turbo')) {
|
||||
$this->error['warning'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
return !$this->error;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user