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

Release 4.2.0 #139

Merged
merged 44 commits into from
Jun 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
6cf0e7a
Change include init.php place
arthtux Jan 29, 2019
4da39ca
Do not call getIsset with getValue
Quetzacoalt91 Feb 4, 2019
ddea096
Add all images of a product to the sitemap, instead of only the cover…
Pixep Feb 10, 2019
6950288
Use `array_merge` to concatenate image lists
Pixep Mar 13, 2019
7dfa8a1
Merge pull request #106 from Quetzacoalt91/remove-get-value-with-get-…
PierreRambaud Jul 7, 2019
dd810e8
Merge pull request #107 from Pixep/feature/multiple-images-for-products
PierreRambaud Jul 7, 2019
56a638a
Fix redirect link when generating sitemaps
Nov 13, 2019
e95262b
Add license file
Dec 31, 2019
6a39d74
Update readme
Dec 31, 2019
657f344
Merge pull request #127 from DavidBoone/fix-123
Progi1984 Jan 9, 2020
752e361
Update readme to add multistore compatibility
marionf Feb 24, 2020
b9a2fde
Merge pull request #131 from PrestaShop/marionf-multistore-compat
marionf Feb 25, 2020
7149b5c
Add Pull Request template for github
matks Mar 30, 2020
4ea5f23
Merge pull request #132 from matks/dev
PierreRambaud Mar 31, 2020
a25bcd2
Enable Release Drafter
matks Apr 1, 2020
f463b5b
Merge pull request #133 from matks/dev
Progi1984 Apr 2, 2020
de1680b
Merge pull request #104 from arthtux/dev
Progi1984 Apr 14, 2020
31924c7
Fixed the display & behavior for "Uncheck/Check All" button
Progi1984 Apr 14, 2020
2341c6e
Escape strings in javascript
Progi1984 Apr 14, 2020
7eef46d
Merge pull request #134 from Progi1984/issue18603
Progi1984 Apr 15, 2020
50ce018
Add CONTRIBUTORS file
matks Jun 5, 2020
9b1a55e
Merge pull request #136 from matks/dev
PierreRambaud Jun 5, 2020
2deef2b
Update license header file gsitemap-cron.php
matks Jun 9, 2020
3d877c8
Update license header file gsitemap.php
matks Jun 9, 2020
860b353
Update license header file index.php
matks Jun 9, 2020
4a847c9
Update license header file translations/index.php
matks Jun 9, 2020
116c498
Update license header file upgrade/index.php
matks Jun 9, 2020
23a88fb
Update license header file upgrade/install-2.2.php
matks Jun 9, 2020
91a210c
Update license header file views/img/index.php
matks Jun 9, 2020
bd464e5
Update license header file views/index.php
matks Jun 9, 2020
1bc05b5
Update license header file views/templates/admin/configuration.tpl
matks Jun 9, 2020
8b47bd3
Update license header file views/templates/admin/index.php
matks Jun 9, 2020
99c2939
Update license header file views/templates/index.php
matks Jun 9, 2020
dc08c79
Merge pull request #137 from matks/dev
PierreRambaud Jun 9, 2020
799961f
Revert "Use meta description instead of description"
PierreRambaud Dec 5, 2018
52e42fd
Rename README.md
Progi1984 Jun 1, 2020
3202e52
Add composer.lock
Progi1984 Jun 1, 2020
3577084
Add .gitignore
Progi1984 Jun 1, 2020
06d3bbb
Add CI
Progi1984 Jun 1, 2020
db9338d
Bump version to 4.2.0
Progi1984 Jun 1, 2020
c0db36e
Update license headers
Progi1984 Jun 1, 2020
6287455
Merge pull request #135 from Progi1984/improveAndBump
PierreRambaud Jun 19, 2020
e7c59c2
Merge remote-tracking branch 'upstream/master' into mergeMaster
Progi1984 Jun 19, 2020
ba911de
Merge pull request #138 from Progi1984/mergeMaster
PierreRambaud Jun 19, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!-----------------------------------------------------------------------------
Thank you for contributing to the PrestaShop project!

Please take the time to edit the "Answers" rows below with the necessary information.

Check out our contribution guidelines to find out how to complete it:
https://devdocs.prestashop.com/1.7/contribute/contribution-guidelines/#pull-requests
------------------------------------------------------------------------------>

| Questions | Answers
| ------------- | -------------------------------------------------------
| Description? | Please be specific when describing the PR. <br> Every detail helps: versions, browser/server configuration, specific module/theme, etc. Feel free to add more information below this table.
| Type? | bug fix / improvement / new feature / refacto / critical
| BC breaks? | yes / no
| Deprecations? | yes / no
| Fixed ticket? | Fixes PrestaShop/Prestashop#{issue number here}.
| How to test? | Please indicate how to best verify that this PR is correct.

<!-- Click the form's "Preview" button to make sure the table is functional in GitHub. Thank you! -->
14 changes: 14 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
branches:
- master
name-template: v$NEXT_PATCH_VERSION
tag-template: v$NEXT_PATCH_VERSION
categories:
- title: 🚀 Improvements
label: enhancement
- title: 🐛 Bug Fixes
label: bug
change-template: '- #$NUMBER: $TITLE by @$AUTHOR'
template: |
# Changes

$CHANGES
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/vendor
69 changes: 69 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
language: node_js

notifications:
email:
on_success: never

jobs:
include:
- stage: "PHP"
name: "PHPStan on PS nightly and unit tests"
language: php
php: 7.2
script:
- composer install
# PHP syntax check
- bash -c '! (find . -name "*.php" ! -path "./vendor/*" -print0 | xargs -0 -n1 -P4 php -l | grep "Parse error")'
# PHP cs fixer
# - composer run lint
# PHP Unit
# - composer run test
# PHP Stan
- docker run -tid --rm -v ps-volume:/var/www/html --name temp-ps prestashop/prestashop:nightly
# - docker exec -ti temp-ps rm -rf /var/www/html/modules/gsitemap
# - docker run --rm --volumes-from temp-ps -v $PWD:/var/www/html/modules/gsitemap -e _PS_ROOT_DIR_=/var/www/html quetzacoalt/phpstan analyse --configuration=/var/www/html/modules/gsitemap/tests/php/phpstan/phpstan.neon
- stage: "PHP"
name: "PHPStan on PS 1.7.5.2"
language: php
php: 7.2
script:
- composer install
- docker run -tid --rm -v ps-volume:/var/www/html --name temp-ps prestashop/prestashop:1.7.5.1
# - docker exec -ti temp-ps rm -rf /var/www/html/modules/gsitemap
# - docker run --rm --volumes-from temp-ps -v $PWD:/var/www/html/modules/gsitemap -e _PS_ROOT_DIR_=/var/www/html quetzacoalt/phpstan analyse --configuration=/var/www/html/modules/gsitemap/tests/php/phpstan/phpstan.neon
- stage: "PHP"
name: "PHPStan on PS 1.7.4.4"
language: php
php: 7.2
script:
- composer install
- docker run -tid --rm -v ps-volume:/var/www/html --name temp-ps prestashop/prestashop:1.7.4.4
# - docker exec -ti temp-ps rm -rf /var/www/html/modules/gsitemap
# - docker run --rm --volumes-from temp-ps -v $PWD:/var/www/html/modules/gsitemap -e _PS_ROOT_DIR_=/var/www/html quetzacoalt/phpstan analyse --configuration=/var/www/html/modules/gsitemap/tests/php/phpstan/phpstan.neon
- stage: "PHP"
name: "PHPStan on PS 1.7.3.4"
language: php
php: 7.2
script:
- composer install
- docker run -tid --rm -v ps-volume:/var/www/html --name temp-ps prestashop/prestashop:1.7.3.4
# - docker exec -ti temp-ps rm -rf /var/www/html/modules/gsitemap
# - docker run --rm --volumes-from temp-ps -v $PWD:/var/www/html/modules/gsitemap -e _PS_ROOT_DIR_=/var/www/html quetzacoalt/phpstan analyse --configuration=/var/www/html/modules/gsitemap/tests/php/phpstan/phpstan.neon
- stage: "PHP"
name: "PHPStan on PS 1.7.2.5"
language: php
php: 7.2
script:
- composer install
- docker run -tid --rm -v ps-volume:/var/www/html --name temp-ps prestashop/prestashop:1.7.2.5
#- docker exec -ti temp-ps rm -rf /var/www/html/modules/gsitemap
#- docker run --rm --volumes-from temp-ps -v $PWD:/var/www/html/modules/gsitemap -e _PS_ROOT_DIR_=/var/www/html quetzacoalt/phpstan analyse --configuration=/var/www/html/modules/gsitemap/tests/php/phpstan/phpstan.neon
- stage: "PHP"
name: "PHPStan on PS 1.7.1.2"
language: php
php: 7.2
script:
- composer install
- docker run -tid --rm -v ps-volume:/var/www/html --name temp-ps prestashop/prestashop:1.7.1.2
# - docker exec -ti temp-ps rm -rf /var/www/html/modules/gsitemap
# - docker run --rm --volumes-from temp-ps -v $PWD:/var/www/html/modules/gsitemap -e _PS_ROOT_DIR_=/var/www/html quetzacoalt/phpstan analyse --configuration=/var/www/html/modules/gsitemap/tests/php/phpstan/phpstan.neon
24 changes: 24 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
GitHub contributors:
--------------------------------
- Caleydon
- Francois Gaillard
- Gregory Roussac
- Jerome Nadaud
- Jerome Nadaud
- Jérôme Nadaud
- MathiasReker
- Maxime Biloé
- PierreRambaud
- Quetzacoalt91
- Shagshag
- TrogloGeek
- chellem
- eternoendless
- gRoussac
- gaillafr
- jeromenadaud
- julienbourdeau
- kermes
- massimonicoli
- maximebiloe
- xBorderie
7 changes: 7 additions & 0 deletions Readme.md → README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@

Generate your Google sitemap file

## Multistore compatibility

This module is compatible with the multistore :heavy_check_mark: <br/>
It can be configured differently from one store to another.<br/>
It can be configured quickly in the same way on all stores thanks to the all shops context or the group of shops.<br/>
It can be activated on one store and deactivated on another

## Reporting issues

You can report issues with this module in the main PrestaShop repository. [Click here to report an issue][report-issue].
Expand Down
19 changes: 19 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<module>
<name>gsitemap</name>
<displayName><![CDATA[Google sitemap]]></displayName>
<version><![CDATA[4.1.0]]></version>
<version><![CDATA[4.2.0]]></version>
<description><![CDATA[Generate your Google sitemap file]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[seo]]></tab>
Expand Down
23 changes: 12 additions & 11 deletions gsitemap-cron.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php
/**
* 2007-2018 PrestaShop.
* 2007-2020 PrestaShop SA and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
Expand All @@ -16,11 +16,11 @@
*
* 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 https://www.prestashop.com for more information.
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License (AFL 3.0)
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

Expand All @@ -29,10 +29,11 @@
*/

include(dirname(__FILE__) . '/../../config/config.inc.php');
include(dirname(__FILE__) . '/../../init.php');

/* Check security token */
if (!Tools::isPHPCLI()) {
include(dirname(__FILE__) . '/../../init.php');

if (Tools::substr(Tools::encrypt('gsitemap/cron'), 0, 10) != Tools::getValue('token') || !Module::isInstalled('gsitemap')) {
die('Bad token');
}
Expand All @@ -48,15 +49,15 @@
foreach ($shops as $shop) {
$list_id_shop[] = (int) $shop['id_shop'];
}
$id_shop = (Tools::getIsset(Tools::getValue('id_shop')) && in_array(Tools::getValue('id_shop'), $list_id_shop)) ? (int) Tools::getValue('id_shop') : (int) Configuration::get('PS_SHOP_DEFAULT');

$id_shop = (Tools::getIsset('id_shop') && in_array(Tools::getValue('id_shop'), $list_id_shop)) ? (int) Tools::getValue('id_shop') : (int) Configuration::get('PS_SHOP_DEFAULT');
$gsitemap->cron = true;

/* for the main run initiat the sitemap's files name stored in the database */
if (!Tools::getIsset(Tools::getValue('continue'))) {
if (!Tools::getIsset('continue')) {
$gsitemap->emptySitemap((int) $id_shop);
}

/* Create the Google sitemap's files */
$gsitemap->createSitemap((int) $id_shop);
}
74 changes: 42 additions & 32 deletions gsitemap.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php
/**
* 2007-2018 PrestaShop.
* 2007-2020 PrestaShop SA and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
Expand All @@ -16,11 +16,11 @@
*
* 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 https://www.prestashop.com for more information.
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License (AFL 3.0)
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

Expand All @@ -39,7 +39,7 @@ public function __construct()
{
$this->name = 'gsitemap';
$this->tab = 'seo';
$this->version = '4.1.0';
$this->version = '4.2.0';
$this->author = 'PrestaShop';
$this->need_instance = 0;
$this->bootstrap = true;
Expand Down Expand Up @@ -293,6 +293,7 @@ public function addLinkToSitemap(&$link_sitemap, $new_link, $lang, &$index, &$i,
Tools::redirectAdmin($this->context->link->getAdminLink('AdminModules', true, array(), array(
'tab_module' => $this->tab,
'module_name' => $this->name,
'configure' => $this->name,
'continue' => 1,
'type' => $new_link['type'],
'lang' => $lang,
Expand Down Expand Up @@ -390,37 +391,38 @@ protected function getProductLink(&$link_sitemap, $lang, &$index, &$i, $id_produ

$url = $link->getProductLink($product, $product->link_rewrite, htmlspecialchars(strip_tags($product->category)), $product->ean13, (int) $lang['id_lang'], (int) $this->context->shop->id, 0);

$id_image = Product::getCover((int) $product_id['id_product']);
if (isset($id_image['id_image'])) {
$image_link = $this->context->link->getImageLink($product->link_rewrite, $product->id . '-' . (int) $id_image['id_image'], ImageType::getFormattedName('large'));
$image_link = (!in_array(rtrim(Context::getContext()->shop->virtual_uri, '/'), explode('/', $image_link))) ? str_replace(array(
'https',
Context::getContext()->shop->domain . Context::getContext()->shop->physical_uri,
), array(
'http',
Context::getContext()->shop->domain . Context::getContext()->shop->physical_uri . Context::getContext()->shop->virtual_uri,
), $image_link) : $image_link;
}
$file_headers = (Configuration::get('GSITEMAP_CHECK_IMAGE_FILE')) ? @get_headers($image_link) : true;
$image_product = array();
if (isset($image_link) && ($file_headers[0] != 'HTTP/1.1 404 Not Found' || $file_headers === true)) {
$image_product = array(
'title_img' => htmlspecialchars(strip_tags($product->name)),
'caption' => htmlspecialchars(strip_tags($product->description_short)),
'link' => $image_link,
);
$images_product = array();
foreach($product->getImages($lang) as $id_image) {
if (isset($id_image['id_image'])) {
$image_link = $this->context->link->getImageLink($product->link_rewrite, $product->id . '-' . (int) $id_image['id_image'], ImageType::getFormattedName('large'));
$image_link = (!in_array(rtrim(Context::getContext()->shop->virtual_uri, '/'), explode('/', $image_link))) ? str_replace(array(
'https',
Context::getContext()->shop->domain . Context::getContext()->shop->physical_uri,
), array(
'http',
Context::getContext()->shop->domain . Context::getContext()->shop->physical_uri . Context::getContext()->shop->virtual_uri,
), $image_link) : $image_link;
}
$file_headers = (Configuration::get('GSITEMAP_CHECK_IMAGE_FILE')) ? @get_headers($image_link) : true;
if (isset($image_link) && ($file_headers[0] != 'HTTP/1.1 404 Not Found' || $file_headers === true)) {
$images_product[] = array(
'title_img' => htmlspecialchars(strip_tags($product->name)),
'caption' => htmlspecialchars(strip_tags($product->meta_description)),
'link' => $image_link,
);
}
unset($image_link);
}

if (!$this->addLinkToSitemap($link_sitemap, array(
'type' => 'product',
'page' => 'product',
'lastmod' => $product->date_upd,
'link' => $url,
'image' => $image_product,
'images' => $images_product,
), $lang['iso_code'], $index, $i, $product_id['id_product'])) {
return false;
}

unset($image_link);
}

return true;
Expand Down Expand Up @@ -666,16 +668,24 @@ protected function recursiveSitemapCreator($link_sitemap, $lang, &$index)
fwrite($write_fd, '<url>' . PHP_EOL);
$lastmod = (isset($file['lastmod']) && !empty($file['lastmod'])) ? date('c', strtotime($file['lastmod'])) : null;
$this->addSitemapNode($write_fd, htmlspecialchars(strip_tags($file['link'])), $this->getPriorityPage($file['page']), Configuration::get('GSITEMAP_FREQUENCY'), $lastmod);
if ($file['image']) {
$this->addSitemapNodeImage($write_fd, htmlspecialchars(strip_tags($file['image']['link'])), isset($file['image']['title_img']) ? htmlspecialchars(str_replace(array(

$images = array();
if (isset($file['image']) && $file['image']) {
$images[] = $file['image'];
}
if (isset($file['images']) && $file['images']) {
$images = array_merge($images, $file['images']);
}
foreach($images as $image) {
$this->addSitemapNodeImage($write_fd, htmlspecialchars(strip_tags($image['link'])), isset($image['title_img']) ? htmlspecialchars(str_replace(array(
"\r\n",
"\r",
"\n",
), '', $this->removeControlCharacters(strip_tags($file['image']['title_img'])))) : '', isset($file['image']['caption']) ? htmlspecialchars(str_replace(array(
), '', $this->removeControlCharacters(strip_tags($image['title_img'])))) : '', isset($image['caption']) ? htmlspecialchars(str_replace(array(
"\r\n",
"\r",
"\n",
), '', strip_tags($file['image']['caption']))) : '');
), '', strip_tags($image['caption']))) : '');
}
fwrite($write_fd, '</url>' . PHP_EOL);
}
Expand Down
Loading