From 636c4575f7eb2ae6684a4f540abeec459364a6d9 Mon Sep 17 00:00:00 2001 From: Vincent Augagneur Date: Mon, 16 Sep 2013 10:59:42 +0200 Subject: [PATCH] //added warning domaine on dashboard && prestashop news improve --- .../dashboard/helpers/view/view.tpl | 12 +-- .../admin/AdminDashboardController.php | 26 ++++- js/admin-dashboard.js | 2 +- modules/dashactivity/dashactivity.php | 95 ++++++++----------- 4 files changed, 72 insertions(+), 63 deletions(-) diff --git a/admin-dev/themes/default/template/controllers/dashboard/helpers/view/view.tpl b/admin-dev/themes/default/template/controllers/dashboard/helpers/view/view.tpl index b8d0ae8d2..5d7bff5fd 100644 --- a/admin-dev/themes/default/template/controllers/dashboard/helpers/view/view.tpl +++ b/admin-dev/themes/default/template/controllers/dashboard/helpers/view/view.tpl @@ -28,6 +28,7 @@ var adminstats_ajax_url = '{$link->getAdminLink('AdminStats')}'; var no_results_translation = '{l s='No result'}'; var dashboard_use_push = '{$dashboard_use_push|intval}'; + var read_more = '{l s='Read more'}'
@@ -39,6 +40,9 @@
+ {if $warning} +
{$warning}
+ {/if} {include file="../../../../form_date_range_picker.tpl"}
@@ -50,12 +54,8 @@ {$hookDashboardZoneTwo}
-
-
PrestaShop Version
-
- PrestaShop VersionVous utilisez la dernière version -
-
+
+

PrestaShop News

diff --git a/controllers/admin/AdminDashboardController.php b/controllers/admin/AdminDashboardController.php index 0970bfe25..e6e247b26 100644 --- a/controllers/admin/AdminDashboardController.php +++ b/controllers/admin/AdminDashboardController.php @@ -66,13 +66,35 @@ class AdminDashboardControllerCore extends AdminController 'hookDashboardZoneTwo' => Hook::exec('dashboardZoneTwo'), 'translations' => $translations, 'action' => '#', + 'warning' => $this->getWarningDomainName(), + 'new_version_url' => Tools::getCurrentUrlProtocolPrefix().'api.dev.prestashop.com/version/check_version.php?v='._PS_VERSION_.'&l='.$this->context->language->iso_code, 'dashboard_use_push' => Configuration::get('PS_DASHBOARD_USE_PUSH'), 'datepickerFrom' => Tools::getValue('datepickerFrom', $this->context->employee->stats_date_from), 'datepickerTo' => Tools::getValue('datepickerTo', $this->context->employee->stats_date_to) ); return parent::renderView(); } + + protected function getWarningDomainName() + { + $warning = false; + if (Shop::isFeatureActive()) + return; + $shop = Context::getContext()->shop; + if ($_SERVER['HTTP_HOST'] != $shop->domain && $_SERVER['HTTP_HOST'] != $shop->domain_ssl && Tools::getValue('ajax') == false) + { + $warning = $this->l('You are currently connected under the following domain name:').' '.$_SERVER['HTTP_HOST'].'
'; + if (Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE')) + $warning .= sprintf($this->l('This is different from the shop domain name set in the Multistore settings: "%s".'), $shop->domain).' + '.preg_replace('@{link}(.*){/link}@', '$1', $this->l('If this is your main domain, please {link}change it now{/link}.')); + else + $warning .= $this->l('This is different from the domain name set in the "SEO & URLs" tab.').' + '.preg_replace('@{link}(.*){/link}@', '$1', $this->l('If this is your main domain, please {link}change it now{/link}.')); + } + return $warning; + } + public function ajaxProcessRefreshDashboard() { $id_module = null; @@ -108,14 +130,14 @@ class AdminDashboardControllerCore extends AdminController if ($articles_limit > 0 && Validate::isCleanHtml((string)$item->title) && Validate::isCleanHtml((string)$item->description)) $return['rss'][] = array( 'title' => (string)$item->title, - 'short_desc' => (string)$item->description + 'short_desc' => substr((string)$item->description, 0, 100).'...', + 'link' => (string)$item->link, ); else break; $articles_limit --; } } - die(Tools::jsonEncode($return)); } diff --git a/js/admin-dashboard.js b/js/admin-dashboard.js index 9ba5c74ef..7b4da5273 100644 --- a/js/admin-dashboard.js +++ b/js/admin-dashboard.js @@ -206,7 +206,7 @@ function getBlogRss() { for (var article in jsonData.rss) { - article_html = '
'+jsonData.rss[article].title+'
'+jsonData.rss[article].short_desc+'

'; + article_html = '
'+jsonData.rss[article].title+'
'+jsonData.rss[article].short_desc+'
'+read_more+'

'; $('.dash_news h4').after(article_html); } } diff --git a/modules/dashactivity/dashactivity.php b/modules/dashactivity/dashactivity.php index 53e240d2b..9002f4112 100644 --- a/modules/dashactivity/dashactivity.php +++ b/modules/dashactivity/dashactivity.php @@ -79,14 +79,12 @@ class Dashactivity extends Module $gapi = Module::isInstalled('gapi') ? Module::getInstanceByName('gapi') : false; if (Validate::isLoadedObject($gapi) && $gapi->isConfigured()) { - $visits = $unique_visitors = $online_visitor = 0; + $visits = $unique_visitors = 0; if ($result = $gapi->requestReportData('', 'ga:visits,ga:visitors', $params['date_from'], $params['date_to'], null, null, 1, 1)) { $visits = $result[0]['metrics']['visits']; $unique_visitors = $result[0]['metrics']['visitors']; } - if ($result = $gapi->requestReportData('', 'ga:activeVisitors', null, null, null, null, 1, 1)) - $online_visitor = $result[0]['metrics']['activeVisitors']; } else { @@ -96,24 +94,6 @@ class Dashactivity extends Module WHERE `date_add` BETWEEN "'.pSQL($params['date_from']).'" AND "'.pSQL($params['date_to']).'" '.Shop::addSqlRestriction(false)); extract($row); - - if ($maintenance_ips = Configuration::get('PS_MAINTENANCE_IP')) - $maintenance_ips = implode(',', array_map('ip2long', array_map('trim', explode(',', $maintenance_ips)))); - if (Configuration::get('PS_STATSDATA_CUSTOMER_PAGESVIEWS')) - $sql = 'SELECT COUNT(DISTINCT c.id_connections) - FROM `'._DB_PREFIX_.'connections` c - LEFT JOIN `'._DB_PREFIX_.'connections_page` cp ON c.id_connections = cp.id_connections - WHERE TIME_TO_SEC(TIMEDIFF(NOW(), cp.`time_start`)) < 900 - AND cp.`time_end` IS NULL - '.Shop::addSqlRestriction(false, 'c').' - '.($maintenance_ips ? 'AND c.ip_address NOT IN ('.preg_replace('/[^,0-9]/', '', $maintenance_ips).')' : ''); - else - $sql = 'SELECT COUNT(*) - FROM `'._DB_PREFIX_.'connections` - WHERE TIME_TO_SEC(TIMEDIFF(NOW(), `date_add`)) < 900 - '.Shop::addSqlRestriction(false).' - '.($maintenance_ips ? 'AND ip_address NOT IN ('.preg_replace('/[^,0-9]/', '', $maintenance_ips).')' : ''); - $online_visitor = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); } $order_nbr = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(' @@ -156,7 +136,25 @@ class Dashactivity extends Module LEFT JOIN `'._DB_PREFIX_.'customer_message` cm ON ct.id_customer_thread = cm.id_customer_thread WHERE cm.`date_add` BETWEEN "'.pSQL($params['date_from']).'" AND "'.pSQL($params['date_to']).'" '.Shop::addSqlRestriction(false, 'ct')); - + + if ($maintenance_ips = Configuration::get('PS_MAINTENANCE_IP')) + $maintenance_ips = implode(',', array_map('ip2long', array_map('trim', explode(',', $maintenance_ips)))); + if (Configuration::get('PS_STATSDATA_CUSTOMER_PAGESVIEWS')) + $sql = 'SELECT COUNT(DISTINCT c.id_connections) + FROM `'._DB_PREFIX_.'connections` c + LEFT JOIN `'._DB_PREFIX_.'connections_page` cp ON c.id_connections = cp.id_connections + WHERE TIME_TO_SEC(TIMEDIFF(NOW(), cp.`time_start`)) < 900 + AND cp.`time_end` IS NULL + '.Shop::addSqlRestriction(false, 'c').' + '.($maintenance_ips ? 'AND c.ip_address NOT IN ('.preg_replace('/[^,0-9]/', '', $maintenance_ips).')' : ''); + else + $sql = 'SELECT COUNT(*) + FROM `'._DB_PREFIX_.'connections` + WHERE TIME_TO_SEC(TIMEDIFF(NOW(), `date_add`)) < 900 + '.Shop::addSqlRestriction(false).' + '.($maintenance_ips ? 'AND ip_address NOT IN ('.preg_replace('/[^,0-9]/', '', $maintenance_ips).')' : ''); + $online_visitor = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); + $active_shopping_cart = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(' SELECT COUNT(*) FROM `'._DB_PREFIX_.'cart` @@ -230,7 +228,7 @@ class Dashactivity extends Module 'orders_trends' => array('way' => 'down', 'value' => 0.42), ), 'data_list_small' => array( - 'dash_traffic_source' => $this->getReferer($params['date_from'], $params[ 'date_to']), + 'dash_traffic_source' => $this->getReferer($params['date_from'], $params['date_to']), ), 'data_chart' => array( 'dash_trends_chart1' => $this->getChartTrafficSource($params['date_from'], $params['date_to']), @@ -250,42 +248,31 @@ class Dashactivity extends Module public function getReferer($date_from, $date_to, $limit = 10) { - $gapi = Module::isInstalled('gapi') ? Module::getInstanceByName('gapi') : false; - if (Validate::isLoadedObject($gapi) && $gapi->isConfigured()) + $directLink = $this->l('Direct link'); + $sql = 'SELECT http_referer + FROM '._DB_PREFIX_.'connections + WHERE 1 + '.Shop::addSqlRestriction().' + AND date_add BETWEEN '.$date_from.' AND '.$date_to.' + LIMIT 0, '.(int)$limit; + + $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->query($sql); + $websites = array($directLink => 0); + + while ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->nextRow($result)) { - $websites = array(); - if ($result = $gapi->requestReportData('ga:source', 'ga:visitors', $date_from, $date_to, '-ga:visitors', null, 1, 3)) - foreach ($result as $row) - $websites[$row['dimensions']['source']] = $row['metrics']['visitors']; - } - else - { - $directLink = $this->l('Direct link'); - $sql = 'SELECT http_referer - FROM '._DB_PREFIX_.'connections - WHERE 1 - '.Shop::addSqlRestriction().' - AND date_add BETWEEN '.$date_from.' AND '.$date_to.' - LIMIT 0, '.(int)$limit; - - $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->query($sql); - $websites = array($directLink => 0); - - while ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->nextRow($result)) + if (!isset($row['http_referer']) || empty($row['http_referer'])) + ++$websites[$directLink]; + else { - if (!isset($row['http_referer']) || empty($row['http_referer'])) - ++$websites[$directLink]; + $website = preg_replace('/^www./', '', parse_url($row['http_referer'], PHP_URL_HOST)); + if (!isset($websites[$website])) + $websites[$website] = 1; else - { - $website = preg_replace('/^www./', '', parse_url($row['http_referer'], PHP_URL_HOST)); - if (!isset($websites[$website])) - $websites[$website] = 1; - else - ++$websites[$website]; - } + ++$websites[$website]; } - arsort($websites); } + arsort($websites); return $websites; }