Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comply to validator.prestashop.com rules #18

Merged
merged 5 commits into from Aug 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
@@ -0,0 +1,3 @@
.idea
composer.lock
vendor/
2 changes: 1 addition & 1 deletion config.xml
Expand Up @@ -3,7 +3,7 @@
<name>dashproducts</name>
<displayName><![CDATA[Dashboard Products]]></displayName>
<version><![CDATA[2.0.3]]></version>
<description><![CDATA[Adds a block with a table of your latest orders and a ranking of your products.]]></description>
<description><![CDATA[Adds a block with a table of your latest orders and a ranking of your products]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[dashboard]]></tab>
<is_configurable>0</is_configurable>
Expand Down
69 changes: 43 additions & 26 deletions dashproducts.php
@@ -1,28 +1,28 @@
<?php
/*
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2015 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
/**
* 2007-2018 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

if (!defined('_PS_VERSION_')) {
exit;
Expand Down Expand Up @@ -320,7 +320,12 @@ public function getTableMostViewed($date_from, $date_to)
if (($row_image = Product::getCover($product_obj->id)) && $row_image['id_image']) {
$image = new Image($row_image['id_image']);
$path_to_image = _PS_PROD_IMG_DIR_.$image->getExistingImgPath().'.'.$this->context->controller->imageType;
$img = ImageManager::thumbnail($path_to_image, 'product_mini_'.$product_obj->id.'.'.$this->context->controller->imageType, 45, $this->context->controller->imageType);
$img = ImageManager::thumbnail(
$path_to_image,
'product_mini_'.$product_obj->id.'.'.$this->context->controller->imageType,
45,
$this->context->controller->imageType
);
}

$tr = array();
Expand Down Expand Up @@ -467,7 +472,19 @@ public function getTotalViewed($date_from, $date_to, $limit = 10)
if (Validate::isLoadedObject($gapi) && $gapi->isConfigured()) {
$products = array();
// Only works with the default product URL pattern at this time
if ($result = $gapi->requestReportData('ga:pagePath', 'ga:visits', $date_from, $date_to, '-ga:visits', 'ga:pagePath=~/([a-z]{2}/)?([a-z]+/)?[0-9][0-9]*\-.*\.html$', 1, 10)) {
$result = $gapi->requestReportData(
'ga:pagePath',
'ga:visits',
$date_from,
$date_to,
'-ga:visits',
'ga:pagePath=~/([a-z]{2}/)?([a-z]+/)?[0-9][0-9]*\-.*\.html$',
1,
10
);


if ($result) {
foreach ($result as $row) {
if (preg_match('@/([a-z]{2}/)?([a-z]+/)?([0-9]+)\-.*\.html$@', $row['dimensions']['pagePath'], $matches)) {
$products[] = array('id_object' => (int)$matches[3], 'counter' => $row['metrics']['visits']);
Expand Down
4 changes: 2 additions & 2 deletions index.php
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2016 PrestaShop
* 2007-2018 PrestaShop
*
* NOTICE OF LICENSE
*
Expand All @@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2016 PrestaShop SA
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
Expand Down
4 changes: 2 additions & 2 deletions translations/index.php
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2016 PrestaShop
* 2007-2018 PrestaShop
*
* NOTICE OF LICENSE
*
Expand All @@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2016 PrestaShop SA
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
Expand Down
4 changes: 2 additions & 2 deletions views/index.php
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2016 PrestaShop
* 2007-2018 PrestaShop
*
* NOTICE OF LICENSE
*
Expand All @@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2016 PrestaShop SA
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
Expand Down
10 changes: 5 additions & 5 deletions views/templates/hook/dashboard_zone_two.tpl
@@ -1,5 +1,5 @@
{*
* 2007-2016 PrestaShop
* 2007-2018 PrestaShop
*
* NOTICE OF LICENSE
*
Expand All @@ -18,7 +18,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2016 PrestaShop SA
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
Expand Down Expand Up @@ -84,7 +84,7 @@
<div class="tab-pane" id="dash_best_sellers">
<h3>
{l s='Top %d products' sprintf=$DASHPRODUCT_NBR_SHOW_BEST_SELLER|intval d='Modules.Dashproducts.Admin'}
<span>{l s="From" d='Modules.Dashproducts.Admin'} {$date_from} {l s="to" d='Modules.Dashproducts.Admin'} {$date_to}</span>
<span>{l s="From" d='Modules.Dashproducts.Admin'} {$date_from|escape:'htmlall':'UTF-8'} {l s="to" d='Modules.Dashproducts.Admin'} {$date_to|escape:'htmlall':'UTF-8'}</span>
</h3>
<div class="table-responsive">
<table class="table data_table" id="table_best_sellers">
Expand All @@ -96,7 +96,7 @@
<div class="tab-pane" id="dash_most_viewed">
<h3>
{l s="Most Viewed" d='Modules.Dashproducts.Admin'}
<span>{l s="From" d='Modules.Dashproducts.Admin'} {$date_from} {l s="to" d='Modules.Dashproducts.Admin'} {$date_to}</span>
<span>{l s="From" d='Modules.Dashproducts.Admin'} {$date_from|escape:'htmlall':'UTF-8'} {l s="to" d='Modules.Dashproducts.Admin'} {$date_to|escape:'htmlall':'UTF-8'}</span>
</h3>
<div class="table-responsive">
<table class="table data_table" id="table_most_viewed">
Expand All @@ -108,7 +108,7 @@
<div class="tab-pane" id="dash_top_search">
<h3>
{l s='Top %d most search terms' sprintf=$DASHPRODUCT_NBR_SHOW_TOP_SEARCH|intval d='Modules.Dashproducts.Admin'}
<span>{l s="From" d='Modules.Dashproducts.Admin'} {$date_from} {l s="to" d='Modules.Dashproducts.Admin'} {$date_to}</span>
<span>{l s="From" d='Modules.Dashproducts.Admin'} {$date_from|escape:'htmlall':'UTF-8'} {l s="to" d='Modules.Dashproducts.Admin'} {$date_to|escape:'htmlall':'UTF-8'}</span>
</h3>
<div class="table-responsive">
<table class="table data_table" id="table_top_10_most_search">
Expand Down
4 changes: 2 additions & 2 deletions views/templates/hook/index.php
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2016 PrestaShop
* 2007-2018 PrestaShop
*
* NOTICE OF LICENSE
*
Expand All @@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2016 PrestaShop SA
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
Expand Down
4 changes: 2 additions & 2 deletions views/templates/index.php
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2016 PrestaShop
* 2007-2018 PrestaShop
*
* NOTICE OF LICENSE
*
Expand All @@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2016 PrestaShop SA
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
Expand Down