//added warning domaine on dashboard && prestashop news improve
This commit is contained in:
@@ -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'}'
|
||||
</script>
|
||||
|
||||
<div class="page-head">
|
||||
@@ -39,6 +40,9 @@
|
||||
<div id="dashboard">
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
{if $warning}
|
||||
<div class="alert alert-warning">{$warning}</div>
|
||||
{/if}
|
||||
{include file="../../../../form_date_range_picker.tpl"}
|
||||
</div>
|
||||
</div>
|
||||
@@ -50,12 +54,8 @@
|
||||
{$hookDashboardZoneTwo}
|
||||
</div>
|
||||
<div class="col-lg-2">
|
||||
<section class="dash_version panel panel-success">
|
||||
<div class="panel-heading"><i class="icon-download-alt"></i> PrestaShop Version</div>
|
||||
<div class="panel-body">
|
||||
<i class="icon-check-sign"></i> PrestaShop VersionVous utilisez la dernière version
|
||||
</div>
|
||||
</section>
|
||||
<div id="new_version_container"></div>
|
||||
<iframe frameborder="no" src="{$new_version_url}"></iframe>
|
||||
<section class="dash_news panel">
|
||||
<h4><i class="icon-rss"></i> PrestaShop News</h4>
|
||||
</section>
|
||||
|
||||
@@ -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:').' <span style="color: #CC0000;">'.$_SERVER['HTTP_HOST'].'</span><br />';
|
||||
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}@', '<a href="index.php?controller=AdminShopUrl&id_shop_url='.(int)$shop->id.'&updateshop_url&token='.Tools::getAdminTokenLite('AdminShopUrl').'">$1</a>', $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}@', '<a href="index.php?controller=AdminMeta&token='.Tools::getAdminTokenLite('AdminMeta').'#conf_id_domain">$1</a>', $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));
|
||||
}
|
||||
|
||||
|
||||
@@ -206,7 +206,7 @@ function getBlogRss()
|
||||
{
|
||||
for (var article in jsonData.rss)
|
||||
{
|
||||
article_html = '<article><strong>'+jsonData.rss[article].title+'</strong><br>'+jsonData.rss[article].short_desc+'</article><br>';
|
||||
article_html = '<article><strong>'+jsonData.rss[article].title+'</strong><br>'+jsonData.rss[article].short_desc+'<br/><a href="'+jsonData.rss[article].link+'">'+read_more+'</a></article><br>';
|
||||
$('.dash_news h4').after(article_html);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user