From 20c76c0c31fa953ce04f4c86d504db6624d9a43e Mon Sep 17 00:00:00 2001 From: JoseNOM <103456499+JoseNOM@users.noreply.github.com> Date: Fri, 9 Jun 2023 22:02:51 +0200 Subject: [PATCH 01/13] Remove useless Google Analytics parameters --- ps_imageslider.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ps_imageslider.php b/ps_imageslider.php index 99eea5b..ce42ddb 100644 --- a/ps_imageslider.php +++ b/ps_imageslider.php @@ -143,9 +143,7 @@ protected function installSamples() $slide->description[$language['id_lang']] = '

EXCEPTEUR OCCAECAT

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin tristique in tortor et dignissim. Quisque non tempor leo. Maecenas egestas sem elit

'; $slide->legend[$language['id_lang']] = 'sample-' . $i; - $slide->url[$language['id_lang']] = 'https://www.prestashop-project.org?utm_source=back-office&utm_medium=v17_homeslider' - . '&utm_campaign=back-office-' . Tools::strtoupper($this->context->language->iso_code) - . '&utm_content=' . (defined('_PS_HOST_MODE_') ? 'ondemand' : 'download'); + $slide->url[$language['id_lang']] = 'https://www.prestashop-project.org'; $rtlSuffix = $language['is_rtl'] ? '_rtl' : ''; $slide->image[$language['id_lang']] = sprintf('sample-%d%s.jpg', $i, $rtlSuffix); } From 254b2039b11e4d2d560c1bf394450f5a1c0ab181 Mon Sep 17 00:00:00 2001 From: JoseNOM <103456499+JoseNOM@users.noreply.github.com> Date: Fri, 9 Jun 2023 22:04:44 +0200 Subject: [PATCH 02/13] Delete PULL_REQUEST_TEMPLATE.md --- .github/PULL_REQUEST_TEMPLATE.md | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index fffa067..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,19 +0,0 @@ - - -| Questions | Answers -| ------------- | ------------------------------------------------------- -| Description? | Please be specific when describing the PR.
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. - - From 75aac7fa552f4b47e5b2ef16965a24dd58b17036 Mon Sep 17 00:00:00 2001 From: leemyongpakvn <3759923+leemyongpakvn@users.noreply.github.com> Date: Mon, 12 Jun 2023 17:38:31 +0700 Subject: [PATCH 03/13] Update build-release.yml --- .github/workflows/build-release.yml | 59 ++--------------------------- 1 file changed, 3 insertions(+), 56 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 2479b9d..28ba23f 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -2,59 +2,6 @@ name: Build on: [push, pull_request] jobs: - deploy: - name: build dependencies & create artifact - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2.0.0 - - name: Install composer dependencies - run: composer install --no-dev -o - - name: Clean-up project - uses: PrestaShopCorp/github-action-clean-before-deploy@v1.0 - - name: Prepare auto-index tool - run: composer global require prestashop/autoindex - - name: Generate index.php - run: ~/.composer/vendor/bin/autoindex - - name: Create & upload artifact - uses: actions/upload-artifact@v1 - with: - name: ${{ github.event.repository.name }} - path: ../ - update_release_draft: - runs-on: ubuntu-latest - needs: [deploy] - if: github.event_name == 'push' && github.event.ref == 'refs/heads/master' - steps: - - name: Download artifact - uses: actions/download-artifact@v1 - with: - name: ${{ github.event.repository.name }} - - id: release_info - uses: toolmantim/release-drafter@v5 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Prepare for Release - run: | - cd ${{ github.event.repository.name }} - zip -r ${{ github.event.repository.name }}.zip ${{ github.event.repository.name }} - - name: Clean existing assets - shell: bash - run: | - curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.1 - assets=`bin/hub api -t repos/${{ github.repository }}/releases/${{ steps.release_info.outputs.id }}/assets | awk '/\].url/ { print $2 }'` - for asset in $assets - do - bin/hub api -X DELETE $asset - done - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Publish to GitHub Release - uses: actions/upload-release-asset@v1.0.1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.release_info.outputs.upload_url }} - asset_path: ./${{ github.event.repository.name }}/${{ github.event.repository.name }}.zip - asset_name: ${{ github.event.repository.name }}.zip - asset_content_type: application/zip + build-and-release-draft: + name: Build & Release draft + uses: PrestaShop/.github/.github/workflows/build-release.yml@master From 68fbbb9faf357ee265b418e958ef01af7069a3d1 Mon Sep 17 00:00:00 2001 From: florine2623 <16019289+florine2623@users.noreply.github.com> Date: Thu, 6 Jul 2023 14:57:36 +0200 Subject: [PATCH 04/13] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index d4275e6..7984d2a 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,10 @@ Add sliding images to your homepage to welcome your visitors in a visual and friendly way. +## Compatibility + +PrestaShop: `1.7.4.0` or later + ## Multistore compatibility This module is not compatible with the multistore :x:
From 9c572ef76feb54d9bdcbce79d0648df09c315fba Mon Sep 17 00:00:00 2001 From: florine2623 <16019289+florine2623@users.noreply.github.com> Date: Thu, 3 Aug 2023 16:42:05 +0200 Subject: [PATCH 05/13] Update README.md --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 7984d2a..c70719a 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,17 @@ PrestaShop: `1.7.4.0` or later This module is not compatible with the multistore :x:
It means that its configuration applies for all stores. +## How to test + +Link to specs : https://docs.prestashop-project.org/functional-documentation/functional-documentation/ux-ui/back-office/improve/modules/image-slider-ps_imageslider + +Settings +- Configure Settings and check the results on FO +Slides list +- CRUD +- Enable/disable +- Reposition + ## Reporting issues You can report issues with this module in the main PrestaShop repository. [Click here to report an issue][report-issue]. From ecd8131180d0af402205912a33f8aee7e722ff65 Mon Sep 17 00:00:00 2001 From: tblivet Date: Tue, 17 Oct 2023 10:38:19 +0200 Subject: [PATCH 06/13] feat: remove mobile desactivation --- ps_imageslider.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/ps_imageslider.php b/ps_imageslider.php index ce42ddb..861c0b3 100644 --- a/ps_imageslider.php +++ b/ps_imageslider.php @@ -119,9 +119,6 @@ public function install() $this->installSamples(); } - // Disable on mobiles and tablets - $this->disableDevice(Context::DEVICE_MOBILE); - return (bool) $res; } From 8eeda06149508ba8b00585b1609165061ac95cb4 Mon Sep 17 00:00:00 2001 From: tblivet Date: Wed, 10 Jan 2024 15:22:39 +0100 Subject: [PATCH 07/13] Release 3.1.4 --- config.xml | 2 +- ps_imageslider.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config.xml b/config.xml index f94a30e..49fe122 100644 --- a/config.xml +++ b/config.xml @@ -2,7 +2,7 @@ ps_imageslider - + diff --git a/ps_imageslider.php b/ps_imageslider.php index 861c0b3..3dbbf28 100644 --- a/ps_imageslider.php +++ b/ps_imageslider.php @@ -52,7 +52,7 @@ public function __construct() { $this->name = 'ps_imageslider'; $this->tab = 'front_office_features'; - $this->version = '3.1.3'; + $this->version = '3.1.4'; $this->author = 'PrestaShop'; $this->need_instance = 0; $this->secure_key = Tools::hash($this->name); From 040ffc526f26c790c946709ddb8049b2caa7b67c Mon Sep 17 00:00:00 2001 From: Codencode Date: Thu, 21 Mar 2024 13:26:07 +0100 Subject: [PATCH 08/13] Update ps_imageslider.php It is also necessary to check the case of creating a new slide (addSlide) --- ps_imageslider.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ps_imageslider.php b/ps_imageslider.php index 3dbbf28..0b03bfa 100644 --- a/ps_imageslider.php +++ b/ps_imageslider.php @@ -615,7 +615,8 @@ public function headerHTML() { if ('AdminModules' !== Tools::getValue('controller') || Tools::getValue('configure') !== $this->name || - Tools::getIsset('id_slide')) { + Tools::getIsset('id_slide') || + Tools::getIsset('addSlide')) { return; } From c4d8a451b2e983815f0735a6e3defe1ebf07226c Mon Sep 17 00:00:00 2001 From: Krystian Podemski Date: Thu, 13 Jun 2024 12:20:25 +0200 Subject: [PATCH 09/13] Show all slides in back office --- ps_imageslider.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/ps_imageslider.php b/ps_imageslider.php index 0b03bfa..2a8c29f 100644 --- a/ps_imageslider.php +++ b/ps_imageslider.php @@ -215,7 +215,7 @@ protected function createTables() */ protected function deleteTables() { - $slides = $this->getSlides(); + $slides = $this->getSlides(null, true); foreach ($slides as $slide) { $to_del = new Ps_HomeSlide($slide['id_slide']); $to_del->delete(); @@ -655,7 +655,15 @@ public function getNextPosition() return ++$row['next_position']; } - public function getSlides($active = null) + /** + * Get slides + * + * @param bool $active + * @param bool $forceShowAll Include all slides, even those without image for a given language + * + * @return array + */ + public function getSlides($active = null, $forceShowAll = false) { $this->context = Context::getContext(); $id_shop = $this->context->shop->id; @@ -668,8 +676,8 @@ public function getSlides($active = null) LEFT JOIN ' . _DB_PREFIX_ . 'homeslider_slides hss ON (hs.id_homeslider_slides = hss.id_homeslider_slides) LEFT JOIN ' . _DB_PREFIX_ . 'homeslider_slides_lang hssl ON (hss.id_homeslider_slides = hssl.id_homeslider_slides) WHERE id_shop = ' . (int) $id_shop . ' - AND hssl.id_lang = ' . (int) $id_lang . ' - AND hssl.`image` <> ""' . + AND hssl.id_lang = ' . (int) $id_lang . + ($forceShowAll ? '' : ' AND hssl.`image` <> ""') . ($active ? ' AND hss.`active` = 1' : ' ') . ' ORDER BY hss.position' ); @@ -732,7 +740,7 @@ public function slideExists($id_slide) public function renderList() { - $slides = $this->getSlides(); + $slides = $this->getSlides(null, true); foreach ($slides as $key => $slide) { $slides[$key]['status'] = $this->displayStatus($slide['id_slide'], $slide['active']); $associated_shop_ids = Ps_HomeSlide::getAssociatedIdsShop((int) $slide['id_slide']); From 780534355d842c5f69f5f0753cc2705bd1a1cfb9 Mon Sep 17 00:00:00 2001 From: matks Date: Tue, 28 Nov 2023 21:51:24 +0100 Subject: [PATCH 10/13] Use admin controller for updating slides with ajax --- ajax_ps_imageslider.php | 42 ---------------- .../admin/AdminConfigureSlidesController.php | 50 +++++++++++++++++++ controllers/admin/index.php | 28 +++++++++++ controllers/index.php | 28 +++++++++++ ps_imageslider.php | 21 +++++++- 5 files changed, 125 insertions(+), 44 deletions(-) delete mode 100644 ajax_ps_imageslider.php create mode 100644 controllers/admin/AdminConfigureSlidesController.php create mode 100644 controllers/admin/index.php create mode 100644 controllers/index.php diff --git a/ajax_ps_imageslider.php b/ajax_ps_imageslider.php deleted file mode 100644 index deb8871..0000000 --- a/ajax_ps_imageslider.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ -include_once '../../config/config.inc.php'; -include_once '../../init.php'; -include_once 'ps_imageslider.php'; - -$home_slider = new Ps_ImageSlider(); -$slides = []; - -if (!Tools::isSubmit('secure_key') || Tools::getValue('secure_key') != $home_slider->secure_key || !Tools::getValue('action')) { - exit(1); -} - -if (Tools::getValue('action') == 'updateSlidesPosition' && Tools::getValue('slides')) { - $slides = Tools::getValue('slides'); - - foreach ($slides as $position => $id_slide) { - $res = Db::getInstance()->execute(' - UPDATE `' . _DB_PREFIX_ . 'homeslider_slides` SET `position` = ' . (int) $position . ' - WHERE `id_homeslider_slides` = ' . (int) $id_slide - ); - } - - $home_slider->clearCache(); -} diff --git a/controllers/admin/AdminConfigureSlidesController.php b/controllers/admin/AdminConfigureSlidesController.php new file mode 100644 index 0000000..13a9954 --- /dev/null +++ b/controllers/admin/AdminConfigureSlidesController.php @@ -0,0 +1,50 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ +class AdminConfigureSlidesController extends ModuleAdminController +{ + public $module; + + /** + * This function allow to delete users + */ + public function ajaxProcessUpdateSlidesPosition() + { + $home_slider = $this->module; + $slides = []; + + if (!Tools::isSubmit('secure_key') || Tools::getValue('secure_key') != $home_slider->secure_key || !Tools::getValue('action')) { + $this->ajaxDie(json_encode(['error' => true])); + } + + if (Tools::getValue('action') == 'updateSlidesPosition' && Tools::getValue('slides')) { + $slides = Tools::getValue('slides'); + + foreach ($slides as $position => $id_slide) { + $res = Db::getInstance()->execute(' + UPDATE `' . _DB_PREFIX_ . 'homeslider_slides` SET `position` = ' . (int) $position . ' + WHERE `id_homeslider_slides` = ' . (int) $id_slide + ); + } + + $home_slider->clearCache(); + } + $this->ajaxDie(json_encode(['success' => true])); + } +} diff --git a/controllers/admin/index.php b/controllers/admin/index.php new file mode 100644 index 0000000..36c7d1f --- /dev/null +++ b/controllers/admin/index.php @@ -0,0 +1,28 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) + */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); + +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); + +header('Location: ../'); +exit; diff --git a/controllers/index.php b/controllers/index.php new file mode 100644 index 0000000..36c7d1f --- /dev/null +++ b/controllers/index.php @@ -0,0 +1,28 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) + */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); + +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); + +header('Location: ../'); +exit; diff --git a/ps_imageslider.php b/ps_imageslider.php index 2a8c29f..27cf27c 100644 --- a/ps_imageslider.php +++ b/ps_imageslider.php @@ -48,6 +48,10 @@ class Ps_ImageSlider extends Module implements WidgetInterface */ public $secure_key; + public $adminControllers = [ + 'adminConfigureSlides' => 'AdminConfigureSlides', + ]; + public function __construct() { $this->name = 'ps_imageslider'; @@ -628,8 +632,21 @@ public function headerHTML() new Sortable($mySlides[0], { animation: 150, onUpdate: function(event) { - var order = this.toArray().join("&") + "&action=updateSlidesPosition"; - $.post("' . $this->context->shop->physical_uri . $this->context->shop->virtual_uri . 'modules/' . $this->name . '/ajax_' . $this->name . '.php?secure_key=' . $this->secure_key . '", order); + var sortableIdsAsTableString = this.toArray(); + var sortableIdsAsData = sortableIdsAsTableString.map((x) => x.slice(-1)); + var ajaxCallParameters = { + ajax: true, + action: "updateSlidesPosition", + secure_key: "'.$this->secure_key.'", + token: "'.Tools::getAdminTokenLite('AdminConfigureSlides') .'", + slides: sortableIdsAsData + }; + $.ajax({ + type: "POST", + cache: false, + url: "'.$this->context->link->getAdminLink('AdminConfigureSlides', false).'", + data: ajaxCallParameters + }); } }); $mySlides.hover(function() { From 9c1d1e107ff4b6a828fac1bf325f46d6f5f57dbb Mon Sep 17 00:00:00 2001 From: Hlavtox Date: Wed, 11 Sep 2024 16:05:44 +0200 Subject: [PATCH 11/13] Register controller --- config.xml | 2 +- .../admin/AdminConfigureSlidesController.php | 40 ++++++++--------- controllers/index.php | 28 ------------ ps_imageslider.php | 43 +++++++++++++++---- .../index.php => upgrade/upgrade-3.2.0.php | 17 ++++---- 5 files changed, 63 insertions(+), 67 deletions(-) delete mode 100644 controllers/index.php rename controllers/admin/index.php => upgrade/upgrade-3.2.0.php (66%) diff --git a/config.xml b/config.xml index 49fe122..cf023f0 100644 --- a/config.xml +++ b/config.xml @@ -2,7 +2,7 @@ ps_imageslider - + diff --git a/controllers/admin/AdminConfigureSlidesController.php b/controllers/admin/AdminConfigureSlidesController.php index 13a9954..5abef0f 100644 --- a/controllers/admin/AdminConfigureSlidesController.php +++ b/controllers/admin/AdminConfigureSlidesController.php @@ -19,32 +19,30 @@ */ class AdminConfigureSlidesController extends ModuleAdminController { - public $module; - - /** - * This function allow to delete users - */ public function ajaxProcessUpdateSlidesPosition() { - $home_slider = $this->module; - $slides = []; - - if (!Tools::isSubmit('secure_key') || Tools::getValue('secure_key') != $home_slider->secure_key || !Tools::getValue('action')) { - $this->ajaxDie(json_encode(['error' => true])); - } + if (empty(Tools::getValue('action')) || Tools::getValue('action') != 'updateSlidesPosition' || empty(Tools::getValue('slides'))) { + ob_end_clean(); + header('Content-Type: application/json'); + $this->ajaxRender(json_encode(['error' => true])); + exit; + } - if (Tools::getValue('action') == 'updateSlidesPosition' && Tools::getValue('slides')) { - $slides = Tools::getValue('slides'); - - foreach ($slides as $position => $id_slide) { - $res = Db::getInstance()->execute(' + // Get slides and update their position + $slides = Tools::getValue('slides'); + foreach ($slides as $position => $id_slide) { + Db::getInstance()->execute(' UPDATE `' . _DB_PREFIX_ . 'homeslider_slides` SET `position` = ' . (int) $position . ' WHERE `id_homeslider_slides` = ' . (int) $id_slide - ); - } + ); + } + + // Wipe module cache + $this->module->clearCache(); - $home_slider->clearCache(); - } - $this->ajaxDie(json_encode(['success' => true])); + ob_end_clean(); + header('Content-Type: application/json'); + $this->ajaxRender(json_encode(['success' => true])); + exit; } } diff --git a/controllers/index.php b/controllers/index.php deleted file mode 100644 index 36c7d1f..0000000 --- a/controllers/index.php +++ /dev/null @@ -1,28 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - */ -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -exit; diff --git a/ps_imageslider.php b/ps_imageslider.php index 27cf27c..5d4e5e7 100644 --- a/ps_imageslider.php +++ b/ps_imageslider.php @@ -48,15 +48,11 @@ class Ps_ImageSlider extends Module implements WidgetInterface */ public $secure_key; - public $adminControllers = [ - 'adminConfigureSlides' => 'AdminConfigureSlides', - ]; - public function __construct() { $this->name = 'ps_imageslider'; $this->tab = 'front_office_features'; - $this->version = '3.1.4'; + $this->version = '3.2.0'; $this->author = 'PrestaShop'; $this->need_instance = 0; $this->secure_key = Tools::hash($this->name); @@ -79,6 +75,7 @@ public function install() /* Adds Module */ if ( parent::install() && + $this->installTab() && $this->registerHook('displayHeader') && $this->registerHook('displayHome') && $this->registerHook('actionShopDataDuplication') @@ -129,6 +126,21 @@ public function install() return false; } + public function installTab() + { + $tab = new Tab(); + $tab->class_name = 'AdminConfigureSlides'; + $tab->module = $this->name; + $tab->active = true; + $tab->id_parent = -1; + $tab->name = array_fill_keys( + Language::getIDs(false), + $this->displayName + ); + + return $tab->add(); + } + /** * Adds samples */ @@ -162,6 +174,9 @@ public function uninstall() /* Deletes tables */ $res = $this->deleteTables(); + /* Delete hidden tab */ + $res &= $this->uninstallTab(); + /* Unsets configuration */ $res &= Configuration::deleteByName('HOMESLIDER_SPEED'); $res &= Configuration::deleteByName('HOMESLIDER_PAUSE_ON_HOVER'); @@ -173,6 +188,18 @@ public function uninstall() return false; } + public function uninstallTab() + { + $result = true; + $id_tab = (int) Tab::getIdFromClassName('AdminConfigureSlides'); + $tab = new Tab($id_tab); + if (Validate::isLoadedObject($tab)) { + $result = $tab->delete(); + } + + return $result; + } + /** * Creates tables */ @@ -617,6 +644,7 @@ public function hookActionShopDataDuplication($params) public function headerHTML() { + // Run only on module configuration page if ('AdminModules' !== Tools::getValue('controller') || Tools::getValue('configure') !== $this->name || Tools::getIsset('id_slide') || @@ -625,6 +653,7 @@ public function headerHTML() } $this->context->controller->addJS($this->_path . 'js/Sortable.min.js'); + /* Style & js for fieldset 'slides configuration' */ $html = '';