protected function index() { $this->load->helper('widgets'); $widgets = new NecoWidget($this->registry, $this->Route); foreach ($widgets->getWidgets('column_left') as $widget) { $settings = (array) unserialize($widget['settings']); if ($settings['asyn']) { $url = Url::createUrl("{$settings['route']}", $settings['params']); $scripts[$widget['name']] = array('id' => $widget['name'], 'method' => 'ready', 'script' => "\$(document.createElement('div'))\n .attr({\n id:'" . $widget['name'] . "'\n })\n .html(makeWaiting())\n .load('" . $url . "')\n .appendTo('" . $settings['target'] . "');"); } else { if (isset($settings['route'])) { if ($this->browser->isMobile() && $settings['showonmobile'] || !$this->browser->isMobile() && $settings['showondesktop']) { if ($settings['autoload']) { $this->data['widgets'][] = $widget['name']; } $this->children[$widget['name']] = $settings['route']; $this->widget[$widget['name']] = $widget; } } } } $this->id = 'column_left'; if ($this->data['widgets']) { if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/common/column_left.tpl')) { $this->template = $this->config->get('config_template') . '/common/column_left.tpl'; } else { $this->template = 'choroni/common/column_left.tpl'; } $this->render(); } }
protected function loadWidgets() { $this->load->helper('widgets'); $widgets = new NecoWidget($this->registry, $this->Route); foreach ($widgets->getWidgets('main') as $widget) { $settings = (array) unserialize($widget['settings']); if ($settings['asyn']) { $url = Url::createUrl("{$settings['route']}", $settings['params']); $scripts[$widget['name']] = array('id' => $widget['name'], 'method' => 'ready', 'script' => "\$(document.createElement('div'))\r\n .attr({\r\n id:'" . $widget['name'] . "'\r\n })\r\n .html(makeWaiting())\r\n .load('" . $url . "')\r\n .appendTo('" . $settings['target'] . "');"); } else { if (isset($settings['route'])) { if ($this->browser->isMobile() && $settings['showonmobile'] || !$this->browser->isMobile() && $settings['showondesktop']) { if ($settings['autoload']) { $this->data['widgets'][] = $widget['name']; } $this->children[$widget['name']] = $settings['route']; $this->widget[$widget['name']] = $widget; } } } } foreach ($widgets->getWidgets('featuredContent') as $widget) { $settings = (array) unserialize($widget['settings']); if ($settings['asyn']) { $url = Url::createUrl("{$settings['route']}", $settings['params']); $scripts[$widget['name']] = array('id' => $widget['name'], 'method' => 'ready', 'script' => "\$(document.createElement('div'))\r\n .attr({\r\n id:'" . $widget['name'] . "'\r\n })\r\n .html(makeWaiting())\r\n .load('" . $url . "')\r\n .appendTo('" . $settings['target'] . "');"); } else { if (isset($settings['route'])) { if ($this->browser->isMobile() && $settings['showonmobile'] || !$this->browser->isMobile() && $settings['showondesktop']) { if ($settings['autoload']) { $this->data['featuredWidgets'][] = $widget['name']; } $this->children[$widget['name']] = $settings['route']; $this->widget[$widget['name']] = $widget; } } } } foreach ($widgets->getWidgets('featuredFooter') as $widget) { $settings = (array) unserialize($widget['settings']); if ($settings['asyn']) { $url = Url::createUrl("{$settings['route']}", $settings['params']); $scripts[$widget['name']] = array('id' => $widget['name'], 'method' => 'ready', 'script' => "\$(document.createElement('div'))\r\n .attr({\r\n id:'" . $widget['name'] . "'\r\n })\r\n .html(makeWaiting())\r\n .load('" . $url . "')\r\n .appendTo('" . $settings['target'] . "');"); } else { if (isset($settings['route'])) { if ($this->browser->isMobile() && $settings['showonmobile'] || !$this->browser->isMobile() && $settings['showondesktop']) { if ($settings['autoload']) { $this->data['featuredFooterWidgets'][] = $widget['name']; } $this->children[$widget['name']] = $settings['route']; $this->widget[$widget['name']] = $widget; } } } } }
protected function index($widget = null) { if (!$this->session->has($widget['name'])) { if (isset($widget)) { $this->data['settings'] = $settings = (array) unserialize($widget['settings']); $this->data['widget_hook'] = $this->data['widgetName'] = $widget['name']; } if (isset($settings['title'])) { $this->data['heading_title'] = $settings['title']; } else { $this->data['heading_title'] = $this->language->get('heading_title'); } if ((int) $settings['page_id']) { $this->load->model('content/page'); $this->data['page'] = $this->modelPage->getById($settings['page_id']); } $this->request->setCookie($widget['name'], true); $this->session->set($widget['name'], true); $this->load->helper('widgets'); $widgets = new NecoWidget($this->registry, $this->Route); foreach ($widgets->getWidgets('main') as $w) { $settings = (array) unserialize($w['settings']); if (isset($settings['route']) && strpos(html_entity_decode($this->data['page']['description']), $w['code']) > 0) { $this->children[$w['name']] = $settings['route']; $this->widget[$w['name']] = $w; } } $this->loadAssets(); if ($scripts) { $this->scripts = array_merge($this->scripts, $scripts); } $this->id = 'lightbox'; if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/module/lightbox.tpl')) { $this->template = $this->config->get('config_template') . '/module/lightbox.tpl'; } else { $this->template = 'choroni/module/lightbox.tpl'; } $this->render(); } }
/** * ControllerModuleCategoryWidget::index() * * @return */ public function index() { if (!$this->request->hasQuery('name')) { return false; } $this->load->language('module/category'); $this->load->helper('widgets'); $widget = new NecoWidget($this->registry); if ($this->request->server['REQUEST_METHOD'] == 'POST') { $widget_name = $this->request->getQuery('name'); $data = $this->request->post['Widgets'][$widget_name]; $settings = new stdClass(); foreach ($data['settings'] as $key => $value) { $settings->{$key} = $value; } $data['settings'] = $settings; if ($widget->save($data)) { $json['success'] = 1; } else { $json['error'] = 1; $json['msg'] = $this->language->get('error_saving_widget'); } } else { $data['name'] = $this->request->hasQuery('name') ? $this->request->getQuery('name') : null; $data['landing_page'] = 'all'; $data['position'] = $this->request->hasQuery('position') ? $this->request->getQuery('position') : null; $data['extension'] = $this->request->hasQuery('extension') ? $this->request->getQuery('extension') : null; $data['app'] = $this->request->hasQuery('app') ? $this->request->getQuery('app') : 'shop'; $data['order'] = $this->request->hasQuery('order') ? $this->request->getQuery('order') : 0; $data['store_id'] = $this->request->hasQuery('store_id') ? $this->request->getQuery('store_id') : 0; if ($this->request->hasQuery('w')) { $this->load->model('style/widget'); $widget_info = $this->modelWidget->getByName($data['name']); $this->setvar('widget_id', $widget_info); $this->setvar('code', $widget_info); $this->setvar('name', $widget_info); $this->setvar('position', $widget_info); $this->setvar('extension', $widget_info); $this->setvar('status', $widget_info); $this->setvar('app', $widget_info); $this->setvar('order', $widget_info); $this->setvar('store_id', $widget_info); $landing_pages = array(); foreach ($widget_info['landing_pages'] as $lp) { $landing_pages[] = $lp['landing_page']; } $this->data['landing_pages'] = $landing_pages; $this->data['settings'] = (array) unserialize($widget_info['settings']); } else { $settings = new stdClass(); $settings->route = 'module/category'; $settings->autoload = 1; $data['settings'] = $settings; $widget->save($data); $this->setvar('name'); } $this->data['routes'] = $widget->getRoutes(); foreach ($this->data['routes'] as $text_var => $landing_page) { $json['routes'][] = array('landing_page' => $landing_page, 'title' => $this->language->get($text_var)); } $this->template = 'module/category/widget.tpl'; $json['html'] = $this->render(true); } $this->load->library('json'); $this->response->setOutput(Json::encode($json), $this->config->get('config_compression')); }
protected function index() { $this->language->load('common/footer'); $this->load->library('user'); $this->data['config_js_security'] = $this->config->get('config_js_security'); $this->data['text_powered_by'] = sprintf($this->language->get('text_powered_by'), $this->config->get('config_name')); $this->id = 'footer'; $this->load->helper('widgets'); $widgets = new NecoWidget($this->registry, $this->Route); foreach ($widgets->getWidgets('footer') as $widget) { $settings = (array) unserialize($widget['settings']); if ($settings['asyn']) { $url = Url::createUrl("{$settings['route']}", $settings['params']); $scripts[$widget['name']] = array('id' => $widget['name'], 'method' => 'ready', 'script' => "\$(document.createElement('div'))\r\n .attr({\r\n id:'" . $widget['name'] . "'\r\n })\r\n .html(makeWaiting())\r\n .load('" . $url . "')\r\n .appendTo('" . $settings['target'] . "');"); } else { if (isset($settings['route'])) { if ($this->browser->isMobile() && $settings['showonmobile'] || !$this->browser->isMobile() && $settings['showondesktop']) { if ($settings['autoload']) { $this->data['widgets'][] = $widget['name']; } $this->children[$widget['name']] = $settings['route']; $this->widget[$widget['name']] = $widget; } } } } // SCRIPTS if ($this->config->get('config_seo_url')) { $urlBase = HTTP_HOME . 'buscar/'; } else { $urlBase = HTTP_HOME . 'index.php?r=store/search&q='; } $scripts[] = array('id' => 'search', 'method' => 'function', 'script' => "function moduleSearch(keyword) {\r\n var url = '" . $urlBase . "';\r\n var form = \$(keyword).closest('form');\r\n var category = \$('#'+ \$(keyword).attr('id').replace('Keyword','Category')).val();\r\n var store = \$('#'+ \$(keyword).attr('id').replace('Keyword','Store')).val();\r\n var zone = \$('#'+ \$(keyword).attr('id').replace('Keyword','Zone')).val();\r\n \r\n url += \$(keyword).val()\r\n .replace(/_/g,'-')\r\n .replace('+','-')\r\n .replace(/\\s+/g,'-');\r\n \r\n if (typeof category != 'undefined') {\r\n url += '_Cat_'+ category\r\n .replace(/_/g,'-')\r\n .replace('+','-')\r\n .replace(/\\s+/g,'-');\r\n }\r\n \r\n if (typeof zone != 'undefined') {\r\n url += '_Estado_'+ zone\r\n .replace(/_/g,'-')\r\n .replace('+','-')\r\n .replace(/\\s+/g,'-');\r\n }\r\n \r\n if (typeof store != 'undefined') {\r\n url += '_Tienda_'+ store\r\n .replace(/_/g,'-')\r\n .replace('+','-')\r\n .replace(/\\s+/g,'-');\r\n }\r\n \r\n window.location = url;\r\n }"); $this->scripts = array_merge($this->scripts, $scripts); $r_output = $w_output = $s_output = $f_output = ""; $script_keys = array(); foreach ($this->scripts as $k => $script) { if (in_array($script['id'], $script_keys)) { continue; } $script_keys[$k] = $script['id']; switch ($script['method']) { case 'ready': default: $r_output .= $script['script']; break; case 'window': $w_output .= $script['script']; break; case 'function': $f_output .= $script['script']; break; } } $jspath = defined("CDN") ? CDN_JS : HTTP_THEME_JS; if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/common/header.tpl')) { $jspath = str_replace("%theme%", $this->config->get('config_template'), $jspath); $jsFolder = str_replace("%theme%", $this->config->get('config_template'), DIR_THEME_JS); } else { $jspath = str_replace("%theme%", "choroni", $jspath); $jsFolder = str_replace("%theme%", "choroni", DIR_THEME_JS); } if (file_exists($jsFolder . str_replace('/', '', strtolower($this->Route) . '.js'))) { $javascripts[] = $jspath . str_replace('/', '', strtolower($this->Route) . '.js'); } if (count($javascripts)) { $this->javascripts = array_merge($this->javascripts, $javascripts); } foreach ($this->javascripts as $key => $js) { $f_output .= file_get_contents($js); unset($this->javascripts[$key]); } if (file_exists(str_replace('%theme%', $this->config->get('config_template'), DIR_THEME_JS) . 'theme.js')) { $f_output .= file_get_contents(str_replace('%theme%', $this->config->get('config_template'), DIR_THEME_JS) . 'theme.js'); } $this->data['scripts'] = $s_output; $this->data['scripts'] .= $r_output ? "<script> \n \$(function(){" . $r_output . "}); </script>" : ""; $this->data['scripts'] .= $w_output ? "<script> \n (function(\$){ \$(window).load(function(){ " . $w_output . " }); })(jQuery);</script>" : ""; $this->data['scripts'] .= $f_output ? "<script> \n " . $f_output . " </script>" : ""; $jspath = defined("CDN_JS") ? CDN_JS : HTTP_JS; // javascript files if ($this->user->getId()) { $javascripts[] = HTTP_ADMIN . "js/front/admin.js"; if ($this->request->hasQuery('theme_editor') && $this->request->hasQuery('theme_id') && (int) $this->request->getQuery('theme_id') > 0) { $javascripts[] = $jspath . "vendor/jquery-ui.min.js"; $javascripts[] = $jspath . "necojs/neco.css.js"; $javascripts[] = $jspath . "necojs/neco.colorpicker.js"; $javascripts[] = HTTP_ADMIN . "js/front/theme_editor.js"; } } if ($javascripts) { $this->data['javascripts'] = $this->javascripts = array_merge($this->javascripts, $javascripts); } if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/common/footer.tpl')) { $this->template = $this->config->get('config_template') . '/common/footer.tpl'; } else { $this->template = 'choroni/common/footer.tpl'; } $this->data['google_analytics_code'] = $this->config->get('google_analytics_code'); $this->data['live_client_id'] = $this->config->get('social_live_client_id'); $this->data['facebook_app_id'] = $this->config->get('social_facebook_app_id'); $this->data['google_client_id'] = $this->config->get('social_google_client_id'); $this->data['twitter_oauth_token_secret'] = $this->config->get('social_twitter_oauth_token_secret'); $this->render(); }
protected function index() { $this->load->library('browser'); $Url = new Url($this->registry); $browser = new Browser(); if ($browser->getBrowser() == 'Internet Explorer' && $browser->getVersion() <= 9) { $this->redirect($Url::createUrl("page/deprecated")); } if ($this->request->hasQuery('hl') || $this->request->hasQuery('cc')) { if ($this->request->hasQuery('_route_')) { $this->session->set('redirect', HTTP_HOME . $this->request->getQuery('_route_')); } elseif ($this->request->hasQuery('r')) { $data = $this->request->get; unset($data['_route_']); $route = $data['r']; unset($data['r']); unset($data['cc']); unset($data['hl']); $url = ''; if ($data) { $url = '&' . urldecode(http_build_query($data)); } $this->session->set('redirect', $Url::createUrl($route, $url)); } else { $this->session->set('redirect', HTTP_HOME); } } if ($this->request->hasQuery('hl')) { $this->session->set('language', $this->request->getQuery('hl')); if (!$this->request->hasQuery('cc')) { if ($this->session->has('redirect')) { $this->redirect($this->session->get('redirect')); } else { $this->redirect(HTTP_HOME); } } } if ($this->request->hasQuery('cc')) { $this->currency->set($this->request->getQuery('cc')); $this->session->clear('shipping_methods'); $this->session->clear('shipping_method'); if ($this->session->has('redirect')) { $this->redirect($this->session->get('redirect')); } else { $this->redirect(HTTP_HOME); } } if ($this->request->server['REQUEST_METHOD'] == 'POST' && isset($this->request->post['currency_code'])) { } if (!$this->session->has('token')) { $this->session->set('token', md5(rand())); } $this->data['token'] = $this->session->get('token'); if (isset($this->request->server['HTTPS']) && ($this->request->server['HTTPS'] == 'on' || $this->request->server['HTTPS'] == '1')) { $this->data['base'] = HTTPS_HOME; } else { $this->data['base'] = HTTP_HOME; } if ($this->config->get('config_icon') && file_exists(DIR_IMAGE . $this->config->get('config_icon'))) { $this->data['icon'] = HTTP_IMAGE . $this->config->get('config_icon'); } else { $this->data['icon'] = ''; } if ($this->config->get('config_logo') && file_exists(DIR_IMAGE . $this->config->get('config_logo'))) { $this->data['logo'] = HTTP_IMAGE . $this->config->get('config_logo'); } else { $this->data['logo'] = ''; } $this->data['title'] = $this->document->title; $this->data['keywords'] = $this->document->keywords; $this->data['description'] = $this->document->description; $this->data['template'] = $this->config->get('config_template'); $this->data['charset'] = $this->language->get('charset'); $this->data['lang'] = $this->language->get('code'); $this->data['direction'] = $this->language->get('direction'); $this->data['links'] = $this->document->links; $this->data['breadcrumbs'] = $this->document->breadcrumbs; $this->load->library('user'); if ($this->user->getId()) { $this->data['is_admin'] = true; $this->language->load('common/admin'); if ($this->request->hasQuery('theme_editor')) { $this->data['theme_editor'] = true; if ($this->request->hasQuery('template') && file_exists(DIR_TEMPLATE . $this->request->getQuery('template') . '/common/header.tpl')) { $this->config->set('config_template', $this->request->getQuery('template')); } } } $this->loadCss(); $this->data['store'] = $this->config->get('config_name'); $this->data['isLogged'] = $this->customer->isLogged(); if ($this->customer->isLogged()) { $this->data['greetings'] = 'Bienvenido(a), ' . ucwords($this->customer->getFirstName() . ' ' . $this->customer->getLastName()); } if (isset($this->request->get['q'])) { $this->data['q'] = $this->request->get['q']; } else { $this->data['q'] = ''; } if (isset($this->request->get['category_id'])) { $this->data['category_id'] = $this->request->get['category_id']; } elseif (isset($this->request->get['path'])) { $path = explode('_', $this->request->get['path']); $this->data['category_id'] = end($path); } else { $this->data['category_id'] = 0; } if (isset($this->request->get['product_id'])) { $this->data['product_id'] = $this->request->get['product_id']; } else { $this->data['product_id'] = 0; } if (isset($this->request->get['manufacturer_id'])) { $this->data['manufacturer_id'] = $this->request->get['manufacturer_id']; } else { $this->data['manufacturer_id'] = 0; } /* // Auto suggest through email and while is online $this->track->autoSuggest(array( 'category_id' =>$this->data['category_id'], 'product_id' =>$this->data['product_id'], 'manufacturer_id' =>$this->data['manufacturer_id'], 'q' =>$this->data['q'] )); */ if (!isset($this->request->get['r'])) { $this->session->set('redirect', HTTP_HOME); } else { $data = $this->request->get; unset($data['_route_']); $route = $data['r']; unset($data['r']); $url = ''; if ($data) { $url = '&' . urldecode(http_build_query($data)); } $this->session->set('redirect', Url::createUrl($route, $url)); } $this->data['current_url'] = $this->session->get('redirect'); $this->data['language_code'] = $this->session->get('language'); $this->data['languages'] = array(); $results = $this->modelLanguage->getLanguages(); foreach ($results as $result) { if ($result['status']) { $this->data['languages'][] = array('name' => $result['name'], 'code' => $result['code'], 'image' => HTTP_IMAGE . "flags/" . $result['image']); } } $this->data['currency_code'] = $this->currency->getCode(); $this->data['currencies'] = array(); $results = $this->modelCurrency->getCurrencies(); foreach ($results as $result) { if ($result['status']) { $this->data['currencies'][] = array('title' => $result['title'], 'code' => $result['code']); } } $this->session->set('state', md5(rand())); $this->data['live_client_id'] = $this->config->get('social_live_client_id'); $this->data['google_client_id'] = $this->config->get('social_google_client_id'); $this->data['facebook_app_id'] = $this->config->get('social_facebook_app_id'); $this->data['twitter_oauth_token_secret'] = $this->config->get('social_twitter_oauth_token_secret'); $this->load->helper('widgets'); $widgets = new NecoWidget($this->registry, $this->Route); foreach ($widgets->getWidgets('main') as $widget) { $settings = (array) unserialize($widget['settings']); if ($settings['asyn']) { $url = Url::createUrl("{$settings['route']}", $settings['params']); $scripts[$widget['name']] = array('id' => $widget['name'], 'method' => 'ready', 'script' => "\$(document.createElement('div'))\r\n .attr({\r\n id:'" . $widget['name'] . "'\r\n })\r\n .html(makeWaiting())\r\n .load('" . $url . "')\r\n .appendTo('" . $settings['target'] . "');"); } else { if (isset($settings['route'])) { if ($this->browser->isMobile() && $settings['showonmobile'] || !$this->browser->isMobile() && $settings['showondesktop']) { if ($settings['autoload']) { $this->data['widgets'][] = $widget['name']; } $this->children[$widget['name']] = $settings['route']; $this->widget[$widget['name']] = $widget; } } } } $this->id = 'header'; if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/common/header.tpl')) { $this->template = $this->config->get('config_template') . '/common/header.tpl'; } else { $this->template = 'choroni/common/header.tpl'; } $this->render(); }
protected function loadWidgets() { $csspath = defined("CDN") ? CDN_CSS : HTTP_THEME_CSS; $jspath = defined("CDN") ? CDN_JS : HTTP_THEME_JS; if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/common/header.tpl')) { $csspath = str_replace("%theme%", $this->config->get('config_template'), $csspath); $cssFolder = str_replace("%theme%", $this->config->get('config_template'), DIR_THEME_CSS); $jspath = str_replace("%theme%", $this->config->get('config_template'), $jspath); $jsFolder = str_replace("%theme%", $this->config->get('config_template'), DIR_THEME_JS); } else { $csspath = str_replace("%theme%", "default", $csspath); $cssFolder = str_replace("%theme%", "default", DIR_THEME_CSS); $jspath = str_replace("%theme%", "default", $jspath); $jsFolder = str_replace("%theme%", "default", DIR_THEME_JS); } if (file_exists($cssFolder . str_replace('controller', '', strtolower(__CLASS__) . '.css'))) { $styles[] = array('media' => 'all', 'href' => $csspath . str_replace('controller', '', strtolower(__CLASS__) . '.css')); } if (count($styles)) { $this->data['styles'] = $this->styles = array_merge($this->styles, $styles); } if (file_exists($jsFolder . str_replace('controller', '', strtolower(__CLASS__) . '.js'))) { $javascripts[] = $jspath . str_replace('controller', '', strtolower(__CLASS__) . '.js'); } if (count($javascripts)) { $this->javascripts = array_merge($this->javascripts, $javascripts); } $this->load->helper('widgets'); $widgets = new NecoWidget($this->registry, $this->Route); foreach ($widgets->getWidgets('main') as $widget) { $settings = (array) unserialize($widget['settings']); if ($settings['asyn']) { $url = Url::createUrl("{$settings['route']}", $settings['params']); $scripts[$widget['name']] = array('id' => $widget['name'], 'method' => 'ready', 'script' => "\$(document.createElement('div'))\r\n .attr({\r\n id:'" . $widget['name'] . "'\r\n })\r\n .html(makeWaiting())\r\n .load('" . $url . "')\r\n .appendTo('" . $settings['target'] . "');"); } else { if (isset($settings['route'])) { if ($settings['autoload']) { $this->data['widgets'][] = $widget['name']; } $this->children[$widget['name']] = $settings['route']; $this->widget[$widget['name']] = $widget; } } } foreach ($widgets->getWidgets('featuredContent') as $widget) { $settings = (array) unserialize($widget['settings']); if ($settings['asyn']) { $url = Url::createUrl("{$settings['route']}", $settings['params']); $scripts[$widget['name']] = array('id' => $widget['name'], 'method' => 'ready', 'script' => "\$(document.createElement('div'))\r\n .attr({\r\n id:'" . $widget['name'] . "'\r\n })\r\n .html(makeWaiting())\r\n .load('" . $url . "')\r\n .appendTo('" . $settings['target'] . "');"); } else { if (isset($settings['route'])) { if ($settings['autoload']) { $this->data['featuredWidgets'][] = $widget['name']; } $this->children[$widget['name']] = $settings['route']; $this->widget[$widget['name']] = $widget; } } } }