Initial commit

This commit is contained in:
2020-10-07 10:37:15 +02:00
commit ce5f440392
28157 changed files with 4429172 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
GitHub contributors:
--------------------------------
- Abdelaziz JRIBI
- Alex Even
- Alex Sampaio
- Dídac Rios
- Francois Gaillard
- GoT
- Gregory Roussac
- GuillaumeKadolis
- Jerome Nadaud
- Jonathan Lelievre
- Julien Bourdeau
- Jérôme Nadaud
- Krystian Podemski
- Mathieu Ferment
- Maxime Biloé
- Michel ANTOINE
- Mickaël Andrieu
- Pablo Borowicz
- Pierre RAMBAUD
- PrestaEdit
- Progi1984
- Quetzacoalt91
- Sacha Froment
- Thierry Marianne
- Thomas N
- Thomas Nabord
- Xavier
- emilien-puget
- fojtcz
- gRoussac
- jolelievre
- marionf
- matks

View File

@@ -0,0 +1,47 @@
Academic Free License ("AFL") v. 3.0
This Academic Free License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work:
Licensed under the Academic Free License version 3.0
1) Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following:
a) to reproduce the Original Work in copies, either alone or as part of a collective work;
b) to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work;
c) to distribute or communicate copies of the Original Work and Derivative Works to the public, under any license of your choice that does not contradict the terms and conditions, including Licensor's reserved rights and remedies, in this Academic Free License;
d) to perform the Original Work publicly; and
e) to display the Original Work publicly.
2) Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works.
3) Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work.
4) Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license.
5) External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c).
6) Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work.
7) Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer.
8) Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation.
9) Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including "fair use" or "fair dealing"). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c).
10) Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware.
11) Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License.
12) Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License.
13) Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable.
14) Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
15) Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You.
16) Modification of This License. This License is Copyright © 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Academic Free License" or "AFL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under <insert your license name here>" or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process.

View File

@@ -0,0 +1,75 @@
# Link list
## About
Adds a block with several links.
## Multistore compatibility
This module is not compatible with the multistore :x: <br/>
It means that its configuration applies for all stores.<br/>
## Building assets
If you need to change the javascript code you have to compile the assets, this operation is done
via command line. You can get base information and requirements in the dev doc (be careful with the
node version):
(https://devdocs.prestashop.com/1.7/development/compile-assets/)
Then the operations to compile assets are:
```$xslt
cd ps_linklist/views
npm install
npm run build
```
This will update the files in the `ps_linklist/view/public` folder.
During development you can build automatically the assets (in dev mode) when you modify them by using this command:
```
npm run watch
```
## Reporting issues
You can report issues with this module in the main PrestaShop repository. [Click here to report an issue][report-issue].
## Contributing
PrestaShop modules are open source extensions to the PrestaShop e-commerce solution. Everyone is welcome and even encouraged to contribute with their own improvements.
### Requirements
Contributors **must** follow the following rules:
* **Make your Pull Request on the "dev" branch**, NOT the "master" branch.
* Do not update the module's version number.
* Follow [the coding standards][1].
### Process in details
Contributors wishing to edit a module's files should follow the following process:
1. Create your GitHub account, if you do not have one already.
2. Fork this project to your GitHub account.
3. Clone your fork to your local machine in the ```/modules``` directory of your PrestaShop installation.
4. Create a branch in your local clone of the module for your changes.
5. Change the files in your branch. Be sure to follow the [coding standards][1]!
6. Push your changed branch to your fork in your GitHub account.
7. Create a pull request for your changes **on the _'dev'_ branch** of the module's project. Be sure to follow the [contribution guidelines][2] in your pull request. If you need help to make a pull request, read the [GitHub help page about creating pull requests][3].
8. Wait for one of the core developers either to include your change in the codebase, or to comment on possible improvements you should make to your code.
That's it: you have contributed to this open source project! Congratulations!
## License
This module is released under the [Academic Free License 3.0][AFL-3.0]
[report-issue]: https://github.com/PrestaShop/PrestaShop/issues/new/choose
[1]: https://devdocs.prestashop.com/1.7/development/coding-standards/
[2]: https://devdocs.prestashop.com/1.7/contribute/contribution-guidelines/
[3]: https://help.github.com/articles/using-pull-requests
[AFL-3.0]: https://opensource.org/licenses/AFL-3.0

View File

@@ -0,0 +1,30 @@
{
"name": "prestashop/ps_linklist",
"description": "PrestaShop - Link list",
"homepage": "https://github.com/PrestaShop/ps_linklist",
"license": "AFL-3.0",
"authors": [
{
"name": "PrestaShop SA",
"email": "contact@prestashop.com"
}
],
"require": {
"php": ">=5.6.0"
},
"require-dev": {
"prestashop/php-dev-tools": "^3.4"
},
"autoload": {
"psr-4": {
"PrestaShop\\Module\\LinkList\\": "src/"
},
"classmap": ["ps_linklist.php"],
"exclude-from-classmap": []
},
"config": {
"preferred-install": "dist",
"prepend-autoloader": false
},
"type": "prestashop-module"
}

1698
modules/ps_linklist/composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>ps_linklist</name>
<displayName><![CDATA[Link List]]></displayName>
<version><![CDATA[3.2.0]]></version>
<description><![CDATA[Adds a block with several links.]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[front_office_features]]></tab>
<is_configurable>1</is_configurable>
<need_instance>0</need_instance>
<limited_countries></limited_countries>
</module>

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
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;

View File

@@ -0,0 +1,53 @@
admin_link_block_list:
path: /link-widget/list
methods: [GET]
defaults:
_controller: 'PrestaShop\Module\LinkList\Controller\Admin\Improve\Design\LinkBlockController::listAction'
_legacy_controller: AdminLinkWidget
_legacy_link: AdminLinkWidget
admin_link_block_create:
path: /link-widget/create
methods: [GET]
defaults:
_controller: 'PrestaShop\Module\LinkList\Controller\Admin\Improve\Design\LinkBlockController::createAction'
_legacy_controller: AdminLinkWidget
admin_link_block_create_process:
path: /link-widget/create
methods: [POST]
defaults:
_controller: 'PrestaShop\Module\LinkList\Controller\Admin\Improve\Design\LinkBlockController::createProcessAction'
_legacy_controller: AdminLinkWidget
admin_link_block_edit:
path: /link-widget/edit/{linkBlockId}
methods: [GET]
defaults:
_controller: 'PrestaShop\Module\LinkList\Controller\Admin\Improve\Design\LinkBlockController::editAction'
_legacy_controller: AdminLinkWidget
admin_link_block_edit_process:
path: /link-widget/edit/{linkBlockId}
methods: [POST]
defaults:
_controller: 'PrestaShop\Module\LinkList\Controller\Admin\Improve\Design\LinkBlockController::editProcessAction'
_legacy_controller: AdminLinkWidget
admin_link_block_delete:
path: /link-widget/delete/{linkBlockId}
methods: [POST]
defaults:
_controller: 'PrestaShop\Module\LinkList\Controller\Admin\Improve\Design\LinkBlockController::deleteAction'
_legacy_controller: AdminLinkWidget
requirements:
linkBlockId: \d+
admin_link_block_update_positions:
path: /link-widget/update-positions/{hookId}
methods: [POST]
defaults:
_controller: 'PrestaShop\Module\LinkList\Controller\Admin\Improve\Design\LinkBlockController::updatePositionsAction'
_legacy_controller: AdminLinkWidget
requirements:
hookId: \d+

View File

@@ -0,0 +1,141 @@
services:
_defaults:
public: true
prestashop.module.link_block.cache:
class: PrestaShop\Module\LinkList\Cache\LegacyLinkBlockCache
arguments:
$moduleRepository: '@prestashop.core.admin.module.repository'
prestashop.module.link_block.repository:
class: PrestaShop\Module\LinkList\Repository\LinkBlockRepository
arguments:
$connection: '@doctrine.dbal.default_connection'
$dbPrefix: '%database_prefix%'
$languages: '@=service("prestashop.adapter.legacy.context").getLanguages(true, service("prestashop.adapter.shop.context").getContextShopID())'
$translator: '@translator'
# Grid data query builder
prestashop.module.link_block.grid.query_builder:
class: PrestaShop\Module\LinkList\Core\Grid\Query\LinkBlockQueryBuilder
arguments:
$connection: '@doctrine.dbal.default_connection'
$dbPrefix: '%database_prefix%'
# Grid Data Factory
prestashop.module.link_block.grid.data_factory:
class: '%prestashop.core.grid.data.factory.doctrine_grid_data_factory%'
arguments:
$gridQueryBuilder: '@prestashop.module.link_block.grid.query_builder'
$hookDispatcher: '@prestashop.core.hook.dispatcher'
$queryParser: '@prestashop.core.grid.query.doctrine_query_parser'
$gridId: 'link_block'
# Link block grid Factory
prestashop.module.link_block.grid.factory:
class: PrestaShop\Module\LinkList\Core\Grid\LinkBlockGridFactory
arguments:
$translator: '@translator'
$hookDispatcher: '@prestashop.core.hook.dispatcher'
$dataFactory: '@prestashop.module.link_block.grid.data_factory'
$filterFormFactory: '@prestashop.core.grid.filter.form_factory'
# Grid position definition
prestashop.module.link_block.grid.position_definition:
class: 'PrestaShop\PrestaShop\Core\Grid\Position\PositionDefinition'
arguments:
$table: 'link_block'
$idField: 'id_link_block'
$positionField: 'position'
$parentIdField: 'id_hook'
# Link block form data provider
prestashop.module.link_block.form_provider:
class: PrestaShop\Module\LinkList\Form\LinkBlockFormDataProvider
arguments:
$repository: '@prestashop.module.link_block.repository'
$cache: '@prestashop.module.link_block.cache'
$moduleRepository: '@prestashop.core.admin.module.repository'
$languages: '@=service("prestashop.adapter.legacy.context").getLanguages(true, service("prestashop.adapter.shop.context").getContextShopID())'
$shopId: '@=service("prestashop.adapter.shop.context").getContextShopID()'
# Form choices providers
prestashop.module.link_block.choice_provider.hook:
class: PrestaShop\Module\LinkList\Form\ChoiceProvider\HookChoiceProvider
arguments:
$connection: '@doctrine.dbal.default_connection'
$dbPrefix: '%database_prefix%'
prestashop.module.link_block.choice_provider.cms_category:
class: PrestaShop\Module\LinkList\Form\ChoiceProvider\CMSCategoryChoiceProvider
arguments:
$connection: '@doctrine.dbal.default_connection'
$dbPrefix: '%database_prefix%'
$idLang: '@=service("prestashop.adapter.legacy.context").getLanguage().id'
$shopIds: '@=service("prestashop.adapter.shop.context").getContextListShopID()'
prestashop.module.link_block.choice_provider.cms_page:
class: PrestaShop\Module\LinkList\Form\ChoiceProvider\CMSPageChoiceProvider
arguments:
$connection: '@doctrine.dbal.default_connection'
$dbPrefix: '%database_prefix%'
$categories: '@=service("prestashop.module.link_block.choice_provider.cms_category").getChoices()'
$idLang: '@=service("prestashop.adapter.legacy.context").getLanguage().id'
$shopIds: '@=service("prestashop.adapter.shop.context").getContextListShopID()'
prestashop.module.link_block.choice_provider.product_page:
class: PrestaShop\Module\LinkList\Form\ChoiceProvider\PageChoiceProvider
arguments:
$connection: '@doctrine.dbal.default_connection'
$dbPrefix: '%database_prefix%'
$idLang: '@=service("prestashop.adapter.legacy.context").getLanguage().id'
$shopIds: '@=service("prestashop.adapter.shop.context").getContextListShopID()'
$pageNames:
- 'prices-drop'
- 'new-products'
- 'best-sales'
prestashop.module.link_block.choice_provider.static_page:
class: PrestaShop\Module\LinkList\Form\ChoiceProvider\PageChoiceProvider
arguments:
$connection: '@doctrine.dbal.default_connection'
$dbPrefix: '%database_prefix%'
$idLang: '@=service("prestashop.adapter.legacy.context").getLanguage().id'
$shopIds: '@=service("prestashop.adapter.shop.context").getContextListShopID()'
$pageNames:
- 'contact'
- 'sitemap'
- 'stores'
- 'authentication'
- 'my-account'
# Form types
prestashop.module.link_block.form_type:
class: PrestaShop\Module\LinkList\Form\Type\LinkBlockType
parent: 'form.type.translatable.aware'
public: true
arguments:
$hookChoices: '@=service("prestashop.module.link_block.choice_provider.hook").getChoices()'
$cmsPageChoices: '@=service("prestashop.module.link_block.choice_provider.cms_page").getChoices()'
$productPageChoices: '@=service("prestashop.module.link_block.choice_provider.product_page").getChoices()'
$staticPageChoices: '@=service("prestashop.module.link_block.choice_provider.static_page").getChoices()'
tags:
- { name: form.type }
prestashop.module.link_block.custom_url_type:
class: PrestaShop\Module\LinkList\Form\Type\CustomUrlType
parent: 'form.type.translatable.aware'
public: true
tags:
- { name: form.type }
# Link block form handler
prestashop.module.link_block.form_handler:
class: 'PrestaShop\PrestaShop\Core\Form\FormHandler'
arguments:
$formBuilder: '@=service("form.factory").createBuilder()'
$hookDispatcher: '@prestashop.core.hook.dispatcher'
$formDataProvider: '@prestashop.module.link_block.form_provider'
$formTypes:
'link_block': 'PrestaShop\Module\LinkList\Form\Type\LinkBlockType'
$hookName: 'AdminLinkWidget'

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>ps_linklist</name>
<displayName><![CDATA[Liste de liens]]></displayName>
<version><![CDATA[3.2.0]]></version>
<description><![CDATA[Ajoute un bloc avec plusieurs liens.]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[front_office_features]]></tab>
<is_configurable>1</is_configurable>
<need_instance>0</need_instance>
<limited_countries></limited_countries>
</module>

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
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;

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

View File

@@ -0,0 +1,281 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
if (!defined('_CAN_LOAD_FILES_')) {
exit;
}
if (file_exists(__DIR__ . '/vendor/autoload.php')) {
require_once __DIR__ . '/vendor/autoload.php';
}
use PrestaShop\PrestaShop\Core\Module\WidgetInterface;
use PrestaShop\Module\LinkList\LegacyLinkBlockRepository;
use PrestaShop\Module\LinkList\Presenter\LinkBlockPresenter;
use PrestaShop\Module\LinkList\Model\LinkBlockLang;
use PrestaShop\Module\LinkList\Repository\LinkBlockRepository;
use PrestaShop\PrestaShop\Adapter\SymfonyContainer;
use PrestaShop\PrestaShop\Adapter\LegacyContext;
use PrestaShop\PrestaShop\Adapter\Shop\Context;
/**
* Class Ps_Linklist.
*/
class Ps_Linklist extends Module implements WidgetInterface
{
const MODULE_NAME = 'ps_linklist';
protected $_html;
protected $_display;
/**
* @var LinkBlockPresenter
*/
private $linkBlockPresenter;
/**
* @var LegacyLinkBlockRepository
*/
private $legacyBlockRepository;
/**
* @var LinkBlockRepository
*/
private $repository;
public $templateFile;
public function __construct()
{
$this->name = 'ps_linklist';
$this->author = 'PrestaShop';
$this->version = '3.2.0';
$this->need_instance = 0;
$this->tab = 'front_office_features';
$this->tabs = [
[
'class_name' => 'AdminLinkWidget',
'visible' => true,
'name' => 'Link Widget',
'parent_class_name' => 'AdminParentThemes',
],
];
$this->bootstrap = true;
parent::__construct();
$this->displayName = $this->trans('Link List', array(), 'Modules.Linklist.Admin');
$this->description = $this->trans('Adds a block with several links.', array(), 'Modules.Linklist.Admin');
$this->secure_key = Tools::encrypt($this->name);
$this->ps_versions_compliancy = array('min' => '1.7.5.0', 'max' => _PS_VERSION_);
$this->templateFile = 'module:ps_linklist/views/templates/hook/linkblock.tpl';
$this->linkBlockPresenter = new LinkBlockPresenter(new Link(), $this->context->language);
$this->legacyBlockRepository = new LegacyLinkBlockRepository(Db::getInstance(), $this->context->shop, $this->context->getTranslator());
}
public function install()
{
if (!parent::install()) {
return false;
}
$installed = $this->installFixtures();
if ($installed
&& $this->registerHook('displayFooter')
&& $this->registerHook('actionUpdateLangAfter')
&& $this->installTab()) {
return true;
}
$this->uninstall();
return false;
}
public function enable($force_all = false)
{
if (!$this->installTab()) {
return false;
}
return parent::enable($force_all);
}
/**
* @return bool
*
* @throws \Doctrine\DBAL\DBALException
*/
private function installFixtures()
{
$installed = true;
$result = $this->getRepository()->createTables();
if (false === $result || (is_array($result) && !empty($result))) {
if (is_array($result)) {
$this->addModuleErrors($result);
}
$installed = false;
}
$result = $this->getRepository()->installFixtures();
if (false === $result || (is_array($result) && !empty($result))) {
if (is_array($result)) {
$this->addModuleErrors($result);
}
$installed = false;
}
return $installed;
}
public function uninstall()
{
$uninstalled = true;
$result = $this->getRepository()->dropTables();
if (false === $result || (is_array($result) && !empty($result))) {
if (is_array($result)) {
$this->addModuleErrors($result);
}
$uninstalled = false;
}
return $uninstalled && parent::uninstall();
}
/**
* The Core is supposed to register the tabs automatically thanks to the getTabs() return.
* However in 1.7.5 it only works when the module contains a AdminLinkWidgetController file,
* this works fine when module has been upgraded and the former file is still present however
* for a fresh install we need to install it manually until the core is able to manage new modules.
*
* @return bool
*/
public function installTab()
{
if (Tab::getIdFromClassName('AdminLinkWidget')) {
return true;
}
$tab = new Tab();
$tab->active = 1;
$tab->class_name = 'AdminLinkWidget';
$tab->name = array();
foreach (Language::getLanguages(true) as $lang) {
$tab->name[$lang['id_lang']] = 'Link Widget';
}
$tab->id_parent = (int) Tab::getIdFromClassName('AdminParentThemes');
$tab->module = $this->name;
return $tab->add();
}
public function hookActionUpdateLangAfter($params)
{
if (!empty($params['lang']) && $params['lang'] instanceof Language) {
Language::updateMultilangFromClass(_DB_PREFIX_ . 'link_block_lang', LinkBlockLang::class, $params['lang']);
}
}
public function _clearCache($template, $cache_id = null, $compile_id = null)
{
parent::_clearCache($this->templateFile);
}
public function getContent()
{
Tools::redirectAdmin(
$this->context->link->getAdminLink('AdminLinkWidget')
);
}
public function renderWidget($hookName, array $configuration)
{
$key = 'ps_linklist|' . $hookName;
if (!$this->isCached($this->templateFile, $this->getCacheId($key))) {
$this->smarty->assign($this->getWidgetVariables($hookName, $configuration));
}
return $this->fetch($this->templateFile, $this->getCacheId($key));
}
public function getWidgetVariables($hookName, array $configuration)
{
$id_hook = Hook::getIdByName($hookName);
$linkBlocks = $this->legacyBlockRepository->getByIdHook($id_hook);
$blocks = array();
foreach ($linkBlocks as $block) {
$blocks[] = $this->linkBlockPresenter->present($block);
}
return array(
'linkBlocks' => $blocks,
'hookName' => $hookName,
);
}
/**
* @param array $errors
*/
private function addModuleErrors(array $errors)
{
foreach ($errors as $error) {
$this->_errors[] = $this->trans($error['key'], $error['parameters'], $error['domain']);
}
}
/**
* @return LinkBlockRepository|LegacyLinkBlockRepository|null
*/
private function getRepository()
{
if (null === $this->repository) {
try {
$this->repository = $this->get('prestashop.module.link_block.repository');
} catch (Throwable $e) {
try {
$container = SymfonyContainer::getInstance();
if (null !== $container) {
//Module is not installed so its services are not loaded
/** @var LegacyContext $context */
$legacyContext = $container->get('prestashop.adapter.legacy.context');
/** @var Context $shopContext */
$shopContext = $container->get('prestashop.adapter.shop.context');
$this->repository = new LinkBlockRepository(
$container->get('doctrine.dbal.default_connection'),
$container->getParameter('database_prefix'),
$legacyContext->getLanguages(true, $shopContext->getContextShopID()),
$container->get('translator')
);
}
} catch (Throwable $e) {
}
}
}
// Container is not available so we use legacy repository as fallback
if (!$this->repository) {
$this->repository = $this->legacyBlockRepository;
}
return $this->repository;
}
}

View File

@@ -0,0 +1,55 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
namespace PrestaShop\Module\LinkList\Cache;
use PrestaShop\PrestaShop\Core\Addon\Module\ModuleRepository;
use Ps_Linklist;
/**
* Class LegacyBlockCache.
*/
final class LegacyLinkBlockCache implements LinkBlockCacheInterface
{
/**
* @var ModuleRepository
*/
private $moduleRepository;
/**
* LegacyLinkBlockCache constructor.
*
* @param ModuleRepository $moduleRepository
*/
public function __construct(ModuleRepository $moduleRepository)
{
$this->moduleRepository = $moduleRepository;
}
/**
* {@inheritdoc}
*/
public function clearModuleCache()
{
/** @var Ps_Linklist $module */
$module = $this->moduleRepository->getInstanceByName(Ps_Linklist::MODULE_NAME);
$module->_clearCache($module->templateFile);
}
}

View File

@@ -0,0 +1,32 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
namespace PrestaShop\Module\LinkList\Cache;
/**
* Interface LinkBlockCacheInterface.
*/
interface LinkBlockCacheInterface
{
/**
* Clear module cache.
*/
public function clearModuleCache();
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
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;

View File

@@ -0,0 +1,309 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
namespace PrestaShop\Module\LinkList\Controller\Admin\Improve\Design;
use PrestaShop\Module\LinkList\Core\Grid\LinkBlockGridFactory;
use PrestaShop\Module\LinkList\Core\Search\Filters\LinkBlockFilters;
use PrestaShop\Module\LinkList\Form\LinkBlockFormDataProvider;
use PrestaShop\Module\LinkList\Repository\LinkBlockRepository;
use PrestaShop\PrestaShop\Core\Exception\DatabaseException;
use PrestaShop\PrestaShop\Core\Form\FormHandlerInterface;
use PrestaShop\PrestaShop\Core\Grid\Position\Exception\PositionDataException;
use PrestaShop\PrestaShop\Core\Grid\Position\Exception\PositionUpdateException;
use PrestaShop\PrestaShop\Core\Grid\Position\GridPositionUpdaterInterface;
use PrestaShop\PrestaShop\Core\Grid\Position\PositionUpdateFactory;
use PrestaShop\PrestaShop\Core\Grid\Position\PositionDefinition;
use PrestaShop\PrestaShop\Core\Grid\Position\PositionUpdate;
use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController;
use PrestaShopBundle\Security\Annotation\AdminSecurity;
use PrestaShopBundle\Security\Annotation\ModuleActivated;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
/**
* Class LinkBlockController.
*
* @ModuleActivated(moduleName="ps_linklist", redirectRoute="admin_module_manage")
*/
class LinkBlockController extends FrameworkBundleAdminController
{
/**
* @AdminSecurity("is_granted('read', request.get('_legacy_controller'))", message="Access denied.")
*
* @param Request $request
*
* @return Response
*/
public function listAction(Request $request)
{
//Get hook list, then loop through hooks setting it in in the filter
/** @var LinkBlockRepository $repository */
$repository = $this->get('prestashop.module.link_block.repository');
$hooks = $repository->getHooksWithLinks();
$filtersParams = $this->buildFiltersParamsByRequest($request);
/** @var LinkBlockGridFactory $linkBlockGridFactory */
$linkBlockGridFactory = $this->get('prestashop.module.link_block.grid.factory');
$grids = $linkBlockGridFactory->getGrids($hooks, $filtersParams);
$presentedGrids = [];
foreach ($grids as $grid) {
$presentedGrids[] = $this->presentGrid($grid);
}
return $this->render('@Modules/ps_linklist/views/templates/admin/link_block/list.html.twig', [
'grids' => $presentedGrids,
'enableSidebar' => true,
'layoutHeaderToolbarBtn' => $this->getToolbarButtons(),
'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')),
]);
}
/**
* @AdminSecurity("is_granted('create', request.get('_legacy_controller'))", message="Access denied.")
*
* @param Request $request
*
* @return Response
*
* @throws \Exception
*/
public function createAction(Request $request)
{
$this->get('prestashop.module.link_block.form_provider')->setIdLinkBlock(null);
$form = $this->get('prestashop.module.link_block.form_handler')->getForm();
return $this->render('@Modules/ps_linklist/views/templates/admin/link_block/form.html.twig', [
'linkBlockForm' => $form->createView(),
'enableSidebar' => true,
'layoutHeaderToolbarBtn' => $this->getToolbarButtons(),
'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')),
]);
}
/**
* @AdminSecurity("is_granted('update', request.get('_legacy_controller'))", message="Access denied.")
*
* @param Request $request
* @param int $linkBlockId
*
* @return Response
*
* @throws \Exception
*/
public function editAction(Request $request, $linkBlockId)
{
$this->get('prestashop.module.link_block.form_provider')->setIdLinkBlock($linkBlockId);
$form = $this->get('prestashop.module.link_block.form_handler')->getForm();
return $this->render('@Modules/ps_linklist/views/templates/admin/link_block/form.html.twig', [
'linkBlockForm' => $form->createView(),
'enableSidebar' => true,
'layoutHeaderToolbarBtn' => $this->getToolbarButtons(),
'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')),
]);
}
/**
* @AdminSecurity("is_granted('create', request.get('_legacy_controller'))", message="Access denied.")
*
* @param Request $request
*
* @return RedirectResponse|Response
*
* @throws \Exception
*/
public function createProcessAction(Request $request)
{
return $this->processForm($request, 'Successful creation.');
}
/**
* @AdminSecurity("is_granted('update', request.get('_legacy_controller'))", message="Access denied.")
*
* @param Request $request
* @param int $linkBlockId
*
* @return RedirectResponse|Response
*
* @throws \Exception
*/
public function editProcessAction(Request $request, $linkBlockId)
{
return $this->processForm($request, 'Successful update.', $linkBlockId);
}
/**
* @AdminSecurity("is_granted('delete', request.get('_legacy_controller'))", message="Access denied.")
*
* @param int $linkBlockId
*
* @return RedirectResponse
*/
public function deleteAction($linkBlockId)
{
$repository = $this->get('prestashop.module.link_block.repository');
$errors = [];
try {
$repository->delete($linkBlockId);
} catch (DatabaseException $e) {
$errors[] = [
'key' => 'Could not delete #%i',
'domain' => 'Admin.Catalog.Notification',
'parameters' => [$linkBlockId],
];
}
if (0 === count($errors)) {
$this->clearModuleCache();
$this->addFlash('success', $this->trans('Successful deletion.', 'Admin.Notifications.Success'));
} else {
$this->flashErrors($errors);
}
return $this->redirectToRoute('admin_link_block_list');
}
/**
* @AdminSecurity("is_granted('update', request.get('_legacy_controller'))", message="Access denied.")
*
* @param Request $request
* @param int $hookId
*
* @throws \Exception
*
* @return RedirectResponse
*/
public function updatePositionsAction(Request $request, $hookId)
{
$positionsData = [
'positions' => $request->request->get('positions', null),
'parentId' => $hookId,
];
/** @var PositionDefinition $positionDefinition */
$positionDefinition = $this->get('prestashop.module.link_block.grid.position_definition');
/** @var PositionUpdateFactory $positionUpdateFactory */
$positionUpdateFactory = $this->get('prestashop.core.grid.position.position_update_factory');
try {
/** @var PositionUpdate $positionUpdate */
$positionUpdate = $positionUpdateFactory->buildPositionUpdate($positionsData, $positionDefinition);
} catch (PositionDataException $e) {
$errors = [$e->toArray()];
$this->flashErrors($errors);
return $this->redirectToRoute('admin_link_block_list');
}
/** @var GridPositionUpdaterInterface $updater */
$updater = $this->get('prestashop.core.grid.position.doctrine_grid_position_updater');
try {
$updater->update($positionUpdate);
$this->clearModuleCache();
$this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success'));
} catch (PositionUpdateException $e) {
$errors = [$e->toArray()];
$this->flashErrors($errors);
}
return $this->redirectToRoute('admin_link_block_list');
}
/**
* @param Request $request
* @param string $successMessage
* @param int|null $linkBlockId
*
* @return Response|RedirectResponse
*
* @throws \Exception
*/
private function processForm(Request $request, $successMessage, $linkBlockId = null)
{
/** @var LinkBlockFormDataProvider $formProvider */
$formProvider = $this->get('prestashop.module.link_block.form_provider');
$formProvider->setIdLinkBlock($linkBlockId);
/** @var FormHandlerInterface $formHandler */
$formHandler = $this->get('prestashop.module.link_block.form_handler');
$form = $formHandler->getForm();
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$data = $form->getData();
$saveErrors = $formHandler->save($data);
if (0 === count($saveErrors)) {
$this->addFlash('success', $this->trans($successMessage, 'Admin.Notifications.Success'));
return $this->redirectToRoute('admin_link_block_list');
}
$this->flashErrors($saveErrors);
}
return $this->render('@Modules/ps_linklist/views/templates/admin/link_block/form.html.twig', [
'linkBlockForm' => $form->createView(),
'enableSidebar' => true,
'layoutHeaderToolbarBtn' => $this->getToolbarButtons(),
'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')),
]);
}
/**
* @param Request $request
*
* @return array
*/
private function buildFiltersParamsByRequest(Request $request)
{
$filtersParams = array_merge(LinkBlockFilters::getDefaults(), $request->query->all());
$filtersParams['filters']['id_lang'] = $this->getContext()->language->id;
return $filtersParams;
}
/**
* Gets the header toolbar buttons.
*
* @return array
*/
private function getToolbarButtons()
{
return [
'add' => [
'href' => $this->generateUrl('admin_link_block_create'),
'desc' => $this->trans('New block', 'Modules.Linklist.Admin'),
'icon' => 'add_circle_outline',
],
];
}
/**
* Clear module cache.
*/
private function clearModuleCache()
{
$this->get('prestashop.module.link_block.cache')->clearModuleCache();
}
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
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;

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
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;

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
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;

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
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;

View File

@@ -0,0 +1,130 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
namespace PrestaShop\Module\LinkList\Core\Grid\Definition\Factory;
use PrestaShop\PrestaShop\Core\Grid\Action\Row\RowActionCollection;
use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\LinkRowAction;
use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\SubmitRowAction;
use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollection;
use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\PositionColumn;
use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ActionColumn;
use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn;
use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\AbstractGridDefinitionFactory;
/**
* Class LinkBlockDefinitionFactory.
*/
final class LinkBlockDefinitionFactory extends AbstractGridDefinitionFactory
{
const FACTORY_ID = 'link_widget_grid_';
/**
* @var array
*/
private $hook;
/**
* LinkBlockDefinitionFactory constructor.
*
* @param array $hook
*/
public function __construct(array $hook)
{
$this->hook = $hook;
}
/**
* {@inheritdoc}
*/
protected function getId()
{
return self::FACTORY_ID . $this->hook['id_hook'];
}
/**
* {@inheritdoc}
*/
protected function getName()
{
return $this->hook['name'] . ' ' . $this->hook['title'];
}
/**
* {@inheritdoc}
*/
protected function getColumns()
{
return (new ColumnCollection())
->add((new DataColumn('id_link_block'))
->setName($this->trans('ID', [], 'Modules.Linklist.Admin'))
->setOptions([
'field' => 'id_link_block',
])
)
->add((new DataColumn('block_name'))
->setName($this->trans('Name of the block', [], 'Modules.Linklist.Admin'))
->setOptions([
'field' => 'block_name',
])
)
->add((new PositionColumn('position'))
->setName($this->trans('Position', [], 'Admin.Global'))
->setOptions([
'id_field' => 'id_link_block',
'position_field' => 'position',
'update_route' => 'admin_link_block_update_positions',
'update_method' => 'POST',
'record_route_params' => [
'id_hook' => 'hookId',
],
])
)
->add((new ActionColumn('actions'))
->setOptions([
'actions' => (new RowActionCollection())
->add((new LinkRowAction('edit'))
->setIcon('edit')
->setOptions([
'route' => 'admin_link_block_edit',
'route_param_name' => 'linkBlockId',
'route_param_field' => 'id_link_block',
])
)
->add((new SubmitRowAction('delete'))
->setName($this->trans('Delete', [], 'Admin.Actions'))
->setIcon('delete')
->setOptions([
'method' => 'POST',
'route' => 'admin_link_block_delete',
'route_param_name' => 'linkBlockId',
'route_param_field' => 'id_link_block',
'confirm_message' => $this->trans(
'Delete selected item?',
[],
'Admin.Notifications.Warning'
),
])
),
])
)
;
}
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
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;

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
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;

View File

@@ -0,0 +1,119 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
namespace PrestaShop\Module\LinkList\Core\Grid;
use PrestaShop\Module\LinkList\Core\Grid\Definition\Factory\LinkBlockDefinitionFactory;
use PrestaShop\Module\LinkList\Core\Search\Filters\LinkBlockFilters;
use PrestaShop\PrestaShop\Core\Grid\Data\Factory\GridDataFactoryInterface;
use PrestaShop\PrestaShop\Core\Grid\Filter\GridFilterFormFactoryInterface;
use PrestaShop\PrestaShop\Core\Grid\Grid;
use PrestaShop\PrestaShop\Core\Grid\GridFactory;
use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface;
use Symfony\Component\Translation\TranslatorInterface;
/**
* Class LinkBlockGridFactory.
*/
final class LinkBlockGridFactory
{
/**
* @var TranslatorInterface
*/
private $translator;
/**
* @var HookDispatcherInterface
*/
private $hookDispatcher;
/**
* @var GridDataFactoryInterface
*/
private $dataFactory;
/**
* @var GridFilterFormFactoryInterface
*/
private $filterFormFactory;
/**
* HookGridFactory constructor.
*
* @param TranslatorInterface $translator
* @param HookDispatcherInterface $hookDispatcher
* @param GridDataFactoryInterface $dataFactory
* @param GridFilterFormFactoryInterface $filterFormFactory
*/
public function __construct(
TranslatorInterface $translator,
GridDataFactoryInterface $dataFactory,
HookDispatcherInterface $hookDispatcher,
GridFilterFormFactoryInterface $filterFormFactory
) {
$this->translator = $translator;
$this->hookDispatcher = $hookDispatcher;
$this->dataFactory = $dataFactory;
$this->filterFormFactory = $filterFormFactory;
}
/**
* @param array $hooks
* @param array $filtersParams
*
* @return Grid[]
*/
public function getGrids(array $hooks, array $filtersParams)
{
$grids = [];
foreach ($hooks as $hook) {
$hookParams = $filtersParams;
$hookParams['filters']['id_hook'] = $hook['id_hook'];
$filters = new LinkBlockFilters($hookParams);
$gridFactory = $this->buildGridFactoryByHook($hook);
$grids[] = $gridFactory->getGrid($filters);
}
return $grids;
}
/**
* Each definition depends on the hook, therefore each factory also
* depends on the hook.
*
* @param array $hook
*
* @return GridFactory
*/
private function buildGridFactoryByHook(array $hook)
{
$definitionFactory = new LinkBlockDefinitionFactory($hook);
$definitionFactory->setTranslator($this->translator);
$definitionFactory->setHookDispatcher($this->hookDispatcher);
return new GridFactory(
$definitionFactory,
$this->dataFactory,
$this->filterFormFactory
);
}
}

View File

@@ -0,0 +1,120 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
namespace PrestaShop\Module\LinkList\Core\Grid\Query;
use Doctrine\DBAL\Query\QueryBuilder;
use PrestaShop\PrestaShop\Core\Grid\Query\AbstractDoctrineQueryBuilder;
use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface;
/**
* Class LinkBlockQueryBuilder.
*/
final class LinkBlockQueryBuilder extends AbstractDoctrineQueryBuilder
{
/**
* @param null|SearchCriteriaInterface $searchCriteria
*
* @return QueryBuilder
*/
public function getSearchQueryBuilder(SearchCriteriaInterface $searchCriteria = null)
{
$qb = $this->getQueryBuilder($searchCriteria->getFilters());
$qb->select('
lb.id_link_block,
lbl.name AS block_name,
lb.id_hook,
h.name as hook_name,
h.title as hook_title,
h.description as hook_description,
lb.position
')
->orderBy(
$searchCriteria->getOrderBy(),
$searchCriteria->getOrderWay()
)
;
if ($searchCriteria->getLimit() > 0) {
$qb
->setFirstResult($searchCriteria->getOffset())
->setMaxResults($searchCriteria->getLimit())
;
}
return $qb;
}
/**
* @param null|SearchCriteriaInterface $searchCriteria
*
* @return QueryBuilder
*/
public function getCountQueryBuilder(SearchCriteriaInterface $searchCriteria = null)
{
$qb = $this->getQueryBuilder($searchCriteria->getFilters());
$qb->select('COUNT(lb.id_link_block)');
return $qb;
}
/**
* Get generic query builder.
*
* @param array $filters
*
* @return QueryBuilder
*/
private function getQueryBuilder(array $filters)
{
$qb = $this->connection
->createQueryBuilder()
->from($this->dbPrefix . 'link_block', 'lb')
->innerJoin('lb', $this->dbPrefix . 'link_block_lang', 'lbl', 'lb.id_link_block = lbl.id_link_block')
->leftJoin('lb', $this->dbPrefix . 'hook', 'h', 'lb.id_hook = h.id_hook');
foreach ($filters as $name => $value) {
if ('id_lang' === $name) {
$qb
->andWhere("lbl.id_lang = :$name")
->setParameter($name, $value)
;
continue;
}
if ('id_hook' === $name) {
$qb
->andWhere("h.id_hook = :$name")
->setParameter($name, $value)
;
continue;
}
$qb
->andWhere(sprintf('lbl.%s LIKE :%s', $name, $name))
->setParameter($name, '%' . $value . '%')
;
}
return $qb;
}
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
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;

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
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;

View File

@@ -0,0 +1,43 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
namespace PrestaShop\Module\LinkList\Core\Search\Filters;
use PrestaShop\PrestaShop\Core\Search\Filters;
/**
* Class LinkBlockFilters.
*/
final class LinkBlockFilters extends Filters
{
/**
* {@inheritdoc}
*/
public static function getDefaults()
{
return [
'limit' => 0,
'offset' => 0,
'orderBy' => 'position',
'sortOrder' => 'asc',
'filters' => [],
];
}
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
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;

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
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;

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
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;

View File

@@ -0,0 +1,71 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
namespace PrestaShop\Module\LinkList\Form\ChoiceProvider;
use Doctrine\DBAL\Connection;
use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface;
/**
* Class AbstractDatabaseChoiceProvider.
*/
abstract class AbstractDatabaseChoiceProvider implements FormChoiceProviderInterface
{
/**
* @var Connection
*/
protected $connection;
/**
* @var string
*/
protected $dbPrefix;
/**
* @var int
*/
protected $idLang;
/**
* @var array
*/
protected $shopIds;
/**
* AbstractDatabaseChoiceProvider constructor.
*
* @param Connection $connection
* @param string $dbPrefix
* @param int|null $idLang
* @param array|null $shopIds
*/
public function __construct(Connection $connection, $dbPrefix, $idLang = null, array $shopIds = null)
{
$this->connection = $connection;
$this->dbPrefix = $dbPrefix;
$this->idLang = $idLang;
$this->shopIds = $shopIds;
}
/**
* {@inheritdoc}
*/
abstract public function getChoices();
}

View File

@@ -0,0 +1,55 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
namespace PrestaShop\Module\LinkList\Form\ChoiceProvider;
/**
* Class CMSCategoryChoiceProvider.
*/
final class CMSCategoryChoiceProvider extends AbstractDatabaseChoiceProvider
{
/**
* @return array
*/
public function getChoices()
{
$qb = $this->connection->createQueryBuilder();
$qb
->select('cc.id_cms_category, ccl.name')
->from($this->dbPrefix . 'cms_category', 'cc')
->innerJoin('cc', $this->dbPrefix . 'cms_category_lang', 'ccl', 'cc.id_cms_category = ccl.id_cms_category')
->innerJoin('cc', $this->dbPrefix . 'cms_category_shop', 'ccs', 'cc.id_cms_category = ccs.id_cms_category')
->andWhere('cc.active = 1')
->andWhere('ccl.id_lang = :idLang')
->andWhere('ccs.id_shop IN (:shopIds)')
->setParameter('idLang', $this->idLang)
->setParameter('shopIds', implode(',', $this->shopIds))
->orderBy('ccl.name')
;
$categories = $qb->execute()->fetchAll();
$choices = [];
foreach ($categories as $category) {
$choices[$category['name']] = $category['id_cms_category'];
}
return $choices;
}
}

View File

@@ -0,0 +1,86 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
namespace PrestaShop\Module\LinkList\Form\ChoiceProvider;
use Doctrine\DBAL\Connection;
/**
* Class CMSPageChoiceProvider.
*/
final class CMSPageChoiceProvider extends AbstractDatabaseChoiceProvider
{
/**
* @var array
*/
private $categories;
/**
* CMSPageChoiceProvider constructor.
*
* @param Connection $connection
* @param string $dbPrefix
* @param array $categories
* @param int $idLang
* @param array $shopIds
*/
public function __construct(
Connection $connection,
$dbPrefix,
array $categories,
$idLang,
$shopIds
) {
parent::__construct($connection, $dbPrefix, $idLang, $shopIds);
$this->categories = $categories;
}
/**
* @return array
*/
public function getChoices()
{
$choices = [];
foreach ($this->categories as $categoryName => $categoryId) {
$qb = $this->connection->createQueryBuilder();
$qb
->select('c.id_cms, cl.meta_title')
->from($this->dbPrefix . 'cms', 'c')
->innerJoin('c', $this->dbPrefix . 'cms_lang', 'cl', 'c.id_cms = cl.id_cms')
->innerJoin('c', $this->dbPrefix . 'cms_shop', 'cs', 'c.id_cms = cs.id_cms')
->andWhere('c.active = 1')
->andWhere('cl.id_lang = :idLang')
->andWhere('cs.id_shop IN (:shopIds)')
->andWhere('c.id_cms_category = :idCmsCategory')
->setParameter('idCmsCategory', $categoryId)
->setParameter('idLang', $this->idLang)
->setParameter('shopIds', implode(',', $this->shopIds))
->orderBy('c.position')
;
$pages = $qb->execute()->fetchAll();
foreach ($pages as $page) {
$choices[$categoryName][$page['id_cms'] . ' ' . $page['meta_title']] = $page['id_cms'];
}
}
return $choices;
}
}

View File

@@ -0,0 +1,50 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
namespace PrestaShop\Module\LinkList\Form\ChoiceProvider;
/**
* Class HookChoiceProvider.
*/
final class HookChoiceProvider extends AbstractDatabaseChoiceProvider
{
/**
* @return mixed
*/
public function getChoices()
{
$qb = $this->connection->createQueryBuilder();
$qb
->select('h.id_hook, h.name')
->from($this->dbPrefix . 'hook', 'h')
->andWhere('h.name LIKE :displayHook')
->setParameter('displayHook', 'display%')
->orderBy('h.name')
;
$hooks = $qb->execute()->fetchAll();
$choices = [];
foreach ($hooks as $hook) {
$choices[$hook['name']] = $hook['id_hook'];
}
return $choices;
}
}

View File

@@ -0,0 +1,87 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
namespace PrestaShop\Module\LinkList\Form\ChoiceProvider;
use Doctrine\DBAL\Connection;
use PrestaShop\PrestaShop\Core\Foundation\Database\EntityNotFoundException;
use Tools;
/**
* Class PageChoiceProvider.
*/
final class PageChoiceProvider extends AbstractDatabaseChoiceProvider
{
/**
* @var array
*/
private $pageNames;
/**
* PageChoiceProvider constructor.
*
* @param Connection $connection
* @param string $dbPrefix
* @param int $idLang
* @param array $shopIds
* @param array $pageNames
*/
public function __construct(
Connection $connection,
$dbPrefix,
$idLang,
array $shopIds,
array $pageNames
) {
parent::__construct($connection, $dbPrefix, $idLang, $shopIds);
$this->pageNames = $pageNames;
}
/**
* @return array
*
* @throws EntityNotFoundException
*/
public function getChoices()
{
$choices = [];
foreach ($this->pageNames as $pageName) {
$qb = $this->connection->createQueryBuilder();
$qb
->select('m.id_meta, ml.title')
->from($this->dbPrefix . 'meta', 'm')
->leftJoin('m', $this->dbPrefix . 'meta_lang', 'ml', 'm.id_meta = ml.id_meta')
->andWhere($qb->expr()->orX('m.page = :page', 'm.page = :pageSlug'))
->andWhere('ml.id_lang = :idLang')
->andWhere('ml.id_shop IN (:shopIds)')
->setParameter('idLang', $this->idLang)
->setParameter('shopIds', implode(',', $this->shopIds))
->setParameter('page', $pageName)
->setParameter('pageSlug', str_replace('-', '', Tools::strtolower($pageName)))
;
$meta = $qb->execute()->fetchAll();
if (!empty($meta)) {
$choices[$meta[0]['title']] = $pageName;
}
}
return $choices;
}
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
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;

View File

@@ -0,0 +1,293 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
namespace PrestaShop\Module\LinkList\Form;
use PrestaShop\Module\LinkList\Cache\LinkBlockCacheInterface;
use PrestaShop\Module\LinkList\Model\LinkBlock;
use PrestaShop\Module\LinkList\Repository\LinkBlockRepository;
use PrestaShop\PrestaShop\Core\Addon\Module\ModuleRepository;
use PrestaShop\PrestaShop\Core\Form\FormDataProviderInterface;
use Hook;
use Ps_Linklist;
/**
* Class LinkBlockFormDataProvider.
*/
class LinkBlockFormDataProvider implements FormDataProviderInterface
{
/**
* @var int|null
*/
private $idLinkBlock;
/**
* @var LinkBlockRepository
*/
private $repository;
/**
* @var LinkBlockCacheInterface
*/
private $cache;
/**
* @var ModuleRepository
*/
private $moduleRepository;
/**
* @var array
*/
private $languages;
/**
* @var int
*/
private $shopId;
/**
* LinkBlockFormDataProvider constructor.
*
* @param LinkBlockRepository $repository
* @param LinkBlockCacheInterface $cache
* @param ModuleRepository $moduleRepository
* @param array $languages
* @param int $shopId
*/
public function __construct(
LinkBlockRepository $repository,
LinkBlockCacheInterface $cache,
ModuleRepository $moduleRepository,
array $languages,
$shopId
) {
$this->repository = $repository;
$this->cache = $cache;
$this->moduleRepository = $moduleRepository;
$this->languages = $languages;
$this->shopId = $shopId;
}
/**
* @return array
*
* @throws \PrestaShopDatabaseException
* @throws \PrestaShopException
*/
public function getData()
{
if (null === $this->idLinkBlock) {
return [];
}
$linkBlock = new LinkBlock($this->idLinkBlock);
$arrayLinkBlock = $linkBlock->toArray();
//The form and the database model don't have the same data hierarchy
//Transform array $custom[en][1][name] to $custom[1][en][name]
$arrayCustom = [];
foreach ($arrayLinkBlock['custom_content'] as $idLang => $customs) {
if (!is_array($customs)) {
continue;
}
foreach ($customs as $i => $custom) {
$arrayCustom[$i][$idLang] = $custom;
}
}
return ['link_block' => [
'id_link_block' => $arrayLinkBlock['id_link_block'],
'block_name' => $arrayLinkBlock['name'],
'id_hook' => $arrayLinkBlock['id_hook'],
'cms' => $arrayLinkBlock['content']['cms'],
'product' => $arrayLinkBlock['content']['product'],
'static' => $arrayLinkBlock['content']['static'],
'custom' => $arrayCustom,
]];
}
/**
* @param array $data
*
* @return array
*
* @throws \PrestaShop\PrestaShop\Adapter\Entity\PrestaShopDatabaseException
*/
public function setData(array $data)
{
$linkBlock = $data['link_block'];
$errors = $this->validateLinkBlock($linkBlock);
if (!empty($errors)) {
return $errors;
}
$customContent = [];
if (!empty($linkBlock['custom'])) {
foreach ($linkBlock['custom'] as $customLanguages) {
if ($this->isEmptyCustom($customLanguages)) {
continue;
}
foreach ($customLanguages as $idLang => $custom) {
$customContent[$idLang][] = $custom;
}
}
}
$linkBlock['custom_content'] = $customContent;
if (empty($linkBlock['id_link_block'])) {
$linkBlockId = $this->repository->create($linkBlock);
$this->setIdLinkBlock($linkBlockId);
} else {
$linkBlockId = $linkBlock['id_link_block'];
$this->repository->update($linkBlockId, $linkBlock);
}
$this->updateHook($linkBlock['id_hook']);
$this->cache->clearModuleCache();
return [];
}
/**
* @return int
*/
public function getIdLinkBlock()
{
return $this->idLinkBlock;
}
/**
* @param int $idLinkBlock
*
* @return LinkBlockFormDataProvider
*/
public function setIdLinkBlock($idLinkBlock)
{
$this->idLinkBlock = $idLinkBlock;
return $this;
}
/**
* @param array $data
*
* @return array
*/
private function validateLinkBlock(array $data)
{
$errors = [];
if (!isset($data['id_hook'])) {
$errors[] = [
'key' => 'Missing id_hook',
'domain' => 'Admin.Catalog.Notification',
'parameters' => [],
];
}
if (!isset($data['block_name'])) {
$errors[] = [
'key' => 'Missing block_name',
'domain' => 'Admin.Catalog.Notification',
'parameters' => [],
];
} else {
foreach ($this->languages as $language) {
if (empty($data['block_name'][$language['id_lang']])) {
$errors[] = [
'key' => 'Missing block_name value for language %s',
'domain' => 'Admin.Catalog.Notification',
'parameters' => [$language['iso_code']],
];
}
}
}
if (!isset($data['custom'])) {
return $errors;
}
foreach ($data['custom'] as $customIndex => $custom) {
if ($this->isEmptyCustom($custom)) {
continue;
}
foreach ($this->languages as $language) {
if (!isset($custom[$language['id_lang']])) {
$errors[] = [
'key' => 'Missing block_name value for language %s',
'domain' => 'Admin.Catalog.Notification',
'parameters' => [$language['iso_code']],
];
} else {
$langCustom = $custom[$language['id_lang']];
$fields = ['title', 'url'];
foreach ($fields as $field) {
if (empty($langCustom[$field])) {
$errors[] = [
'key' => 'Missing %s value in custom[%s] for language %s',
'domain' => 'Admin.Catalog.Notification',
'parameters' => [$field, $customIndex, $language['iso_code']],
];
}
}
}
}
}
return $errors;
}
/**
* @param array $custom
*
* @return bool
*/
private function isEmptyCustom(array $custom)
{
$fields = ['title', 'url'];
foreach ($custom as $langCustom) {
foreach ($fields as $field) {
if (!empty($langCustom[$field])) {
return false;
}
}
}
return true;
}
/**
* Register the selected hook to this module if it was not registered yet.
*
* @param int $hookId
*
* @throws \PrestaShopException
*/
private function updateHook($hookId)
{
$hookName = Hook::getNameById($hookId);
$module = $this->moduleRepository->getInstanceByName(Ps_Linklist::MODULE_NAME);
if (!Hook::isModuleRegisteredOnHook($module, $hookName, $this->shopId)) {
Hook::registerHook($module, $hookName);
}
}
}

View File

@@ -0,0 +1,47 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
namespace PrestaShop\Module\LinkList\Form\Type;
use PrestaShopBundle\Form\Admin\Type\TranslatorAwareType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints as Assert;
class CustomUrlType extends TranslatorAwareType
{
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('title', TextType::class, [
'label' => $this->trans('Title', 'Modules.Linklist.Admin'),
'required' => true,
])
->add('url', TextType::class, [
'label' => $this->trans('URL', 'Modules.Linklist.Admin'),
'required' => true,
'constraints' => [new Assert\Url()],
])
;
}
}

View File

@@ -0,0 +1,151 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
namespace PrestaShop\Module\LinkList\Form\Type;
use PrestaShopBundle\Form\Admin\Type\TranslateTextType;
use PrestaShopBundle\Form\Admin\Type\TranslatorAwareType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Translation\TranslatorInterface;
class LinkBlockType extends TranslatorAwareType
{
/**
* @var array
*/
private $hookChoices;
/**
* @var array
*/
private $cmsPageChoices;
/**
* @var array
*/
private $productPageChoices;
/**
* @var array
*/
private $staticPageChoices;
/**
* LinkBlockType constructor.
*
* @param TranslatorInterface $translator
* @param array $locales
* @param array $hookChoices
* @param array $cmsPageChoices
* @param array $productPageChoices
* @param array $staticPageChoices
*/
public function __construct(
TranslatorInterface $translator,
array $locales,
array $hookChoices,
array $cmsPageChoices,
array $productPageChoices,
array $staticPageChoices
) {
parent::__construct($translator, $locales);
$this->hookChoices = $hookChoices;
$this->cmsPageChoices = $cmsPageChoices;
$this->productPageChoices = $productPageChoices;
$this->staticPageChoices = $staticPageChoices;
}
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('id_link_block', HiddenType::class)
->add('block_name', TranslateTextType::class, [
'locales' => $this->locales,
'required' => true,
'label' => $this->trans('Name of the block', 'Modules.Linklist.Admin'),
])
->add('id_hook', ChoiceType::class, [
'choices' => $this->hookChoices,
'attr' => [
'data-toggle' => 'select2',
'data-minimumResultsForSearch' => '7',
],
'label' => $this->trans('Hook', 'Admin.Global'),
])
->add('cms', ChoiceType::class, [
'choices' => $this->cmsPageChoices,
'label' => $this->trans('Content pages', 'Modules.Linklist.Admin'),
'multiple' => true,
'expanded' => true,
])
->add('product', ChoiceType::class, [
'choices' => $this->productPageChoices,
'label' => $this->trans('Product pages', 'Modules.Linklist.Admin'),
'multiple' => true,
'expanded' => true,
])
->add('static', ChoiceType::class, [
'choices' => $this->staticPageChoices,
'label' => $this->trans('Static content', 'Modules.Linklist.Admin'),
'multiple' => true,
'expanded' => true,
])
->add('custom', CollectionType::class, [
'entry_type' => TranslateCustomUrlType::class,
'entry_options' => [
'locales' => $this->locales,
'label' => false,
],
'attr' => [
'class' => 'custom_collection',
'data-delete-button-label' => $this->trans('Delete', 'Admin.Global'),
],
'allow_add' => true,
'allow_delete' => true,
'label' => $this->trans('Custom content', 'Modules.Linklist.Admin'),
])
;
}
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'label' => false,
]);
}
/**
* {@inheritdoc}
*/
public function getBlockPrefix()
{
return 'module_link_block';
}
}

View File

@@ -0,0 +1,47 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
namespace PrestaShop\Module\LinkList\Form\Type;
use PrestaShopBundle\Form\Admin\Type\TranslateTextType;
use Symfony\Component\Form\FormBuilderInterface;
/**
* Class TranslatableUrlType.
*/
class TranslateCustomUrlType extends TranslateTextType
{
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
foreach ($options['locales'] as $locale) {
$localeOptions = $options['options'];
$localeOptions['label'] = $locale['iso_code'];
if (!isset($localeOptions['required'])) {
$localeOptions['required'] = false;
}
$builder->add($locale['id_lang'], CustomUrlType::class, $localeOptions);
}
}
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
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;

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
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;

View File

@@ -0,0 +1,151 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
namespace PrestaShop\Module\LinkList;
use PrestaShop\Module\LinkList\Model\LinkBlock;
use Symfony\Component\Translation\TranslatorInterface as Translator;
use Shop;
use Hook;
use DB;
use Language;
use Context;
/**
* Class LegacyLinkBlockRepository.
*/
class LegacyLinkBlockRepository
{
private $db;
private $shop;
private $db_prefix;
private $translator;
/**
* @param DB $db
* @param Shop $shop
* @param Translator $translator
*/
public function __construct(Db $db, Shop $shop, Translator $translator)
{
$this->db = $db;
$this->shop = $shop;
$this->db_prefix = $db->getPrefix();
$this->translator = $translator;
}
/**
* @param int $id_hook
*
* @return array
*
* @throws \PrestaShopDatabaseException
* @throws \PrestaShopException
*/
public function getByIdHook($id_hook)
{
$id_hook = (int) $id_hook;
$sql = "SELECT cb.`id_link_block`
FROM {$this->db_prefix}link_block cb
WHERE `id_hook` = $id_hook
ORDER by cb.`position`
";
$ids = $this->db->executeS($sql);
$cmsBlock = array();
foreach ($ids as $id) {
$cmsBlock[] = new LinkBlock((int) $id['id_link_block']);
}
return $cmsBlock;
}
/**
* @return bool
*/
public function createTables()
{
$engine = _MYSQL_ENGINE_;
$success = true;
$this->dropTables();
$queries = [
"CREATE TABLE IF NOT EXISTS `{$this->db_prefix}link_block`(
`id_link_block` int(10) unsigned NOT NULL auto_increment,
`id_hook` int(1) unsigned DEFAULT NULL,
`position` int(10) unsigned NOT NULL default '0',
`content` text default NULL,
PRIMARY KEY (`id_link_block`)
) ENGINE=$engine DEFAULT CHARSET=utf8",
"CREATE TABLE IF NOT EXISTS `{$this->db_prefix}link_block_lang`(
`id_link_block` int(10) unsigned NOT NULL,
`id_lang` int(10) unsigned NOT NULL,
`name` varchar(40) NOT NULL default '',
`custom_content` text default NULL,
PRIMARY KEY (`id_link_block`, `id_lang`)
) ENGINE=$engine DEFAULT CHARSET=utf8",
"CREATE TABLE IF NOT EXISTS `{$this->db_prefix}link_block_shop` (
`id_link_block` int(10) unsigned NOT NULL auto_increment,
`id_shop` int(10) unsigned NOT NULL,
PRIMARY KEY (`id_link_block`, `id_shop`)
) ENGINE=$engine DEFAULT CHARSET=utf8",
];
foreach ($queries as $query) {
$success &= $this->db->execute($query);
}
return $success;
}
public function dropTables()
{
$sql = "DROP TABLE IF EXISTS
`{$this->db_prefix}link_block`,
`{$this->db_prefix}link_block_lang`,
`{$this->db_prefix}link_block_shop`";
return $this->db->execute($sql);
}
/**
* @return bool
*/
public function installFixtures()
{
$success = true;
$id_hook = (int) Hook::getIdByName('displayFooter');
$queries = [
'INSERT INTO `' . $this->db_prefix . 'link_block` (`id_link_block`, `id_hook`, `position`, `content`) VALUES
(1, ' . $id_hook . ', 0, \'{"cms":[false],"product":["prices-drop","new-products","best-sales"],"static":[false]}\'),
(2, ' . $id_hook . ', 1, \'{"cms":["1","2","3","4","5"],"product":[false],"static":["contact","sitemap","stores"]}\');',
];
foreach (Language::getLanguages(true, Context::getContext()->shop->id) as $lang) {
$queries[] = 'INSERT INTO `' . $this->db_prefix . 'link_block_lang` (`id_link_block`, `id_lang`, `name`) VALUES
(1, ' . (int) $lang['id_lang'] . ', "' . pSQL($this->translator->trans('Products', array(), 'Modules.Linklist.Shop', $lang['locale'])) . '"),
(2, ' . (int) $lang['id_lang'] . ', "' . pSQL($this->translator->trans('Our company', array(), 'Modules.Linklist.Shop', $lang['locale'])) . '")'
;
}
foreach ($queries as $query) {
$success &= $this->db->execute($query);
}
return $success;
}
}

View File

@@ -0,0 +1,139 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
namespace PrestaShop\Module\LinkList\Model;
/**
* Class LinkBlock.
*/
class LinkBlock extends \ObjectModel
{
/**
* @var int
*/
public $id_link_block;
/**
* @var string
*/
public $name;
/**
* @var int
*/
public $id_hook;
/**
* @var int
*/
public $position;
/**
* @var array
*/
public $content;
/**
* @var array
*/
public $custom_content;
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
'table' => 'link_block',
'primary' => 'id_link_block',
'multilang' => true,
'fields' => array(
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'required' => true, 'size' => 128),
'id_hook' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true),
'position' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true),
'content' => array('type' => self::TYPE_STRING, 'validate' => 'isJson'),
'custom_content' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isJson'),
),
);
public function __construct($id = null, $id_lang = null, $id_shop = null)
{
parent::__construct($id, $id_lang, $id_shop);
if ($this->id) {
$this->content = json_decode($this->content, true);
if ($this->custom_content) {
$this->custom_content = array_map(
function ($el) {
return json_decode($el, true);
},
$this->custom_content
);
}
}
if (is_null($this->content)) {
$this->content = array(
'cms' => array(),
'product' => array(),
'static' => array(),
);
}
}
public function add($auto_date = true, $null_values = false)
{
if (is_array($this->content)) {
$this->content = json_encode($this->content);
}
if (!$this->position) {
$this->position = 1;
}
$return = parent::add($auto_date, $null_values);
$this->content = json_decode($this->content, true);
return $return;
}
public function update($auto_date = true, $null_values = false)
{
if (is_array($this->content)) {
$this->content = json_encode($this->content);
}
$return = parent::update($auto_date, $null_values);
$this->content = json_decode($this->content, true);
return $return;
}
public function toArray()
{
return [
'id' => $this->id,
'id_link_block' => $this->id_link_block,
'name' => $this->name,
'id_hook' => $this->id_hook,
'position' => $this->position,
'content' => $this->content,
'custom_content' => $this->custom_content,
];
}
}

View File

@@ -0,0 +1,46 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
namespace PrestaShop\Module\LinkList\Model;
use DataLangCore;
/**
* Class LinkBlockLang.
*/
class LinkBlockLang extends DataLangCore
{
// Don't replace domain in init() with $this->domain for translation parsing
protected $domain = 'Modules.Linklist.Shop';
protected $keys = array('id_link_block');
protected $fieldsToUpdate = array('name');
protected function init()
{
$this->fieldNames = array(
'name' => array(
md5('Products') => $this->translator->trans('Products', array(), 'Modules.Linklist.Shop', $this->locale),
md5('Our company') => $this->translator->trans('Our company', array(), 'Modules.Linklist.Shop', $this->locale),
),
);
}
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
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;

View File

@@ -0,0 +1,218 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
namespace PrestaShop\Module\LinkList\Presenter;
use PrestaShop\Module\LinkList\Model\LinkBlock;
use Tools;
/**
* Class LinkBlockPresenter.
*/
class LinkBlockPresenter
{
private $link;
private $language;
/**
* LinkBlockPresenter constructor.
*
* @param \Link $link
* @param \Language $language
*/
public function __construct(\Link $link, \Language $language)
{
$this->link = $link;
$this->language = $language;
}
/**
* @param LinkBlock $cmsBlock
*
* @return array
*
* @throws \PrestaShopDatabaseException
* @throws \PrestaShopException
*/
public function present(LinkBlock $cmsBlock)
{
return array(
'id' => (int) $cmsBlock->id,
'title' => $cmsBlock->name[(int) $this->language->id],
'hook' => (new \Hook((int) $cmsBlock->id_hook))->name,
'position' => $cmsBlock->position,
'links' => $this->makeLinks($cmsBlock->content, $cmsBlock->custom_content),
);
}
/**
* Check the url if is an external link.
*
* @param $url
*
* @return bool
*/
public function isExternalLink($url)
{
$baseLink = preg_replace('#^(http)s?://#', '', $this->link->getBaseLink());
$url = Tools::strtolower($url);
if (preg_match('#^(http)s?://#', $url) && !preg_match('#^(http)s?://' . preg_quote(rtrim($baseLink, '/'), '/') . '#', $url)) {
return true;
}
return false;
}
/**
* @param array $content
* @param array $custom_content
*
* @return array
*/
private function makeLinks($content, $custom_content)
{
$cmsLinks = $productLinks = $staticsLinks = $customLinks = array();
if (isset($content['cms'])) {
$cmsLinks = $this->makeCmsLinks($content['cms']);
}
if (isset($content['product'])) {
$productLinks = $this->makeProductLinks($content['product']);
}
if (isset($content['static'])) {
$staticsLinks = $this->makeStaticLinks($content['static']);
}
$customLinks = $this->makeCustomLinks($custom_content);
return array_merge(
$cmsLinks,
$productLinks,
$staticsLinks,
$customLinks
);
}
/**
* @param array $cmsIds
*
* @return array
*
* @throws \PrestaShopDatabaseException
* @throws \PrestaShopException
*/
private function makeCmsLinks($cmsIds)
{
$cmsLinks = array();
foreach ($cmsIds as $cmsId) {
$cms = new \CMS((int) $cmsId);
if (null !== $cms->id && $cms->active) {
$cmsLinks[] = array(
'id' => 'link-cms-page-' . $cms->id,
'class' => 'cms-page-link',
'title' => $cms->meta_title[(int) $this->language->id],
'description' => $cms->meta_description[(int) $this->language->id],
'url' => $this->link->getCMSLink($cms),
);
}
}
return $cmsLinks;
}
/**
* @param array $productIds
*
* @return array
*/
private function makeProductLinks($productIds)
{
$productLinks = array();
foreach ($productIds as $productId) {
if (false !== $productId) {
$meta = \Meta::getMetaByPage($productId, (int) $this->language->id);
$productLinks[] = array(
'id' => 'link-product-page-' . $productId,
'class' => 'cms-page-link',
'title' => $meta['title'],
'description' => $meta['description'],
'url' => $this->link->getPageLink($productId, true),
);
}
}
return $productLinks;
}
/**
* @param array $staticIds
*
* @return array
*/
private function makeStaticLinks($staticIds)
{
$staticLinks = array();
foreach ($staticIds as $staticId) {
if (false !== $staticId) {
$meta = \Meta::getMetaByPage($staticId, (int) $this->language->id);
$staticLinks[] = array(
'id' => 'link-static-page-' . $staticId,
'class' => 'cms-page-link',
'title' => $meta['title'],
'description' => $meta['description'],
'url' => $this->link->getPageLink($staticId, true),
);
}
}
return $staticLinks;
}
/**
* @param array $customContent
*
* @return array
*/
private function makeCustomLinks($customContent)
{
$customLinks = array();
if (isset($customContent[$this->language->id])) {
$customLinks = $customContent[$this->language->id];
$self = $this;
$customLinks = array_map(function ($el) use ($self) {
return array(
'id' => 'link-custom-page-' . Tools::link_rewrite($el['title']),
'class' => 'custom-page-link',
'title' => $el['title'],
'description' => '',
'url' => $el['url'],
'target' => $self->isExternalLink($el['url']) ? '_blank' : '',
);
}, array_filter($customLinks));
}
return $customLinks;
}
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
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;

View File

@@ -0,0 +1,385 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
namespace PrestaShop\Module\LinkList\Repository;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\Query\QueryBuilder;
use PrestaShop\PrestaShop\Core\Exception\DatabaseException;
use Symfony\Component\Translation\TranslatorInterface;
use Hook;
/**
* Class LinkBlockRepository.
*/
class LinkBlockRepository
{
/**
* @var Connection
*/
private $connection;
/**
* @var string
*/
private $dbPrefix;
/**
* @var array
*/
private $languages;
/**
* @var TranslatorInterface
*/
private $translator;
/**
* LinkBlockRepository constructor.
*
* @param Connection $connection
* @param string $dbPrefix
* @param array $languages
* @param TranslatorInterface $translator
*/
public function __construct(
Connection $connection,
$dbPrefix,
array $languages,
TranslatorInterface $translator
) {
$this->connection = $connection;
$this->dbPrefix = $dbPrefix;
$this->languages = $languages;
$this->translator = $translator;
}
/**
* Returns the list of hook with associated Link blocks.
*
* @return array
*/
public function getHooksWithLinks()
{
$qb = $this->connection->createQueryBuilder();
$qb
->select('h.id_hook, h.name, h.title')
->from($this->dbPrefix . 'link_block', 'lb')
->leftJoin('lb', $this->dbPrefix . 'hook', 'h', 'lb.id_hook = h.id_hook')
->groupBy('h.id_hook')
->orderBy('h.name')
;
return $qb->execute()->fetchAll();
}
/**
* @param array $data
*
* @return string
*
* @throws DatabaseException
*/
public function create(array $data)
{
$idHook = $data['id_hook'];
$maxPosition = $this->getHookMaxPosition($idHook);
$qb = $this->connection->createQueryBuilder();
$qb
->insert($this->dbPrefix . 'link_block')
->values([
'id_hook' => ':idHook',
'position' => ':position',
'content' => ':content',
])
->setParameters([
'idHook' => $idHook,
'position' => null !== $maxPosition ? $maxPosition + 1 : 0,
'content' => json_encode([
'cms' => empty($data['cms']) ? [false] : $data['cms'],
'static' => empty($data['static']) ? [false] : $data['static'],
'product' => empty($data['product']) ? [false] : $data['product'],
]),
]);
$this->executeQueryBuilder($qb, 'Link block error');
$linkBlockId = $this->connection->lastInsertId();
$this->updateLanguages($linkBlockId, $data['block_name'], $data['custom_content']);
return $linkBlockId;
}
/**
* @param int $linkBlockId
* @param array $data
*
* @throws DatabaseException
*/
public function update($linkBlockId, array $data)
{
$qb = $this->connection->createQueryBuilder();
$qb
->update($this->dbPrefix . 'link_block', 'lb')
->andWhere('lb.id_link_block = :linkBlockId')
->set('id_hook', ':idHook')
->set('content', ':content')
->setParameters([
'linkBlockId' => $linkBlockId,
'idHook' => $data['id_hook'],
'content' => json_encode([
'cms' => empty($data['cms']) ? [false] : $data['cms'],
'static' => empty($data['static']) ? [false] : $data['static'],
'product' => empty($data['product']) ? [false] : $data['product'],
]),
])
;
$this->executeQueryBuilder($qb, 'Link block error');
$this->updateLanguages($linkBlockId, $data['block_name'], $data['custom_content']);
}
/**
* @param int $idLinkBlock
*
* @throws DatabaseException
*/
public function delete($idLinkBlock)
{
$tableNames = [
'link_block_shop',
'link_block_lang',
'link_block',
];
foreach ($tableNames as $tableName) {
$qb = $this->connection->createQueryBuilder();
$qb
->delete($this->dbPrefix . $tableName)
->andWhere('id_link_block = :idLinkBlock')
->setParameter('idLinkBlock', $idLinkBlock)
;
$this->executeQueryBuilder($qb, 'Delete error');
}
}
/**
* @return array
*
* @throws \Doctrine\DBAL\DBALException
*/
public function createTables()
{
$errors = [];
$engine = _MYSQL_ENGINE_;
$this->dropTables();
$queries = [
"CREATE TABLE IF NOT EXISTS `{$this->dbPrefix}link_block`(
`id_link_block` int(10) unsigned NOT NULL auto_increment,
`id_hook` int(1) unsigned DEFAULT NULL,
`position` int(10) unsigned NOT NULL default '0',
`content` text default NULL,
PRIMARY KEY (`id_link_block`)
) ENGINE=$engine DEFAULT CHARSET=utf8",
"CREATE TABLE IF NOT EXISTS `{$this->dbPrefix}link_block_lang`(
`id_link_block` int(10) unsigned NOT NULL,
`id_lang` int(10) unsigned NOT NULL,
`name` varchar(40) NOT NULL default '',
`custom_content` text default NULL,
PRIMARY KEY (`id_link_block`, `id_lang`)
) ENGINE=$engine DEFAULT CHARSET=utf8",
"CREATE TABLE IF NOT EXISTS `{$this->dbPrefix}link_block_shop` (
`id_link_block` int(10) unsigned NOT NULL auto_increment,
`id_shop` int(10) unsigned NOT NULL,
PRIMARY KEY (`id_link_block`, `id_shop`)
) ENGINE=$engine DEFAULT CHARSET=utf8",
];
foreach ($queries as $query) {
$statement = $this->connection->executeQuery($query);
if (0 != (int) $statement->errorCode()) {
$errors[] = [
'key' => json_encode($statement->errorInfo()),
'parameters' => [],
'domain' => 'Admin.Modules.Notification',
];
}
}
return $errors;
}
/**
* @return array
*
* @throws \Doctrine\DBAL\DBALException
*/
public function installFixtures()
{
$errors = [];
$id_hook = (int) Hook::getIdByName('displayFooter');
$queries = [
'INSERT INTO `' . $this->dbPrefix . 'link_block` (`id_link_block`, `id_hook`, `position`, `content`) VALUES
(1, ' . $id_hook . ', 0, \'{"cms":[false],"product":["prices-drop","new-products","best-sales"],"static":[false]}\'),
(2, ' . $id_hook . ', 1, \'{"cms":["1","2","3","4","5"],"product":[false],"static":["contact","sitemap","stores"]}\');',
];
foreach ($this->languages as $lang) {
$queries[] = 'INSERT INTO `' . $this->dbPrefix . 'link_block_lang` (`id_link_block`, `id_lang`, `name`) VALUES
(1, ' . (int) $lang['id_lang'] . ', "' . pSQL($this->translator->trans('Products', array(), 'Modules.Linklist.Shop', $lang['locale'])) . '"),
(2, ' . (int) $lang['id_lang'] . ', "' . pSQL($this->translator->trans('Our company', array(), 'Modules.Linklist.Shop', $lang['locale'])) . '")'
;
}
foreach ($queries as $query) {
$statement = $this->connection->executeQuery($query);
if (0 != (int) $statement->errorCode()) {
$errors[] = [
'key' => json_encode($statement->errorInfo()),
'parameters' => [],
'domain' => 'Admin.Modules.Notification',
];
}
}
return $errors;
}
/**
* @return array
*
* @throws \Doctrine\DBAL\DBALException
*/
public function dropTables()
{
$errors = [];
$tableNames = [
'link_block_shop',
'link_block_lang',
'link_block',
];
foreach ($tableNames as $tableName) {
$sql = 'DROP TABLE IF EXISTS ' . $this->dbPrefix . $tableName;
$statement = $this->connection->executeQuery($sql);
if ($statement instanceof Statement && 0 != (int) $statement->errorCode()) {
$errors[] = [
'key' => json_encode($statement->errorInfo()),
'parameters' => [],
'domain' => 'Admin.Modules.Notification',
];
}
}
return $errors;
}
/**
* @param int $linkBlockId
* @param array $blockName
* @param array $custom
*
* @throws DatabaseException
*/
private function updateLanguages($linkBlockId, array $blockName, array $custom)
{
foreach ($this->languages as $language) {
$qb = $this->connection->createQueryBuilder();
$qb
->select('lbl.id_link_block')
->from($this->dbPrefix . 'link_block_lang', 'lbl')
->andWhere('lbl.id_link_block = :linkBlockId')
->andWhere('lbl.id_lang = :langId')
->setParameter('linkBlockId', $linkBlockId)
->setParameter('langId', $language['id_lang'])
;
$foundRows = $qb->execute()->rowCount();
$qb = $this->connection->createQueryBuilder();
if (!$foundRows) {
$qb
->insert($this->dbPrefix . 'link_block_lang')
->values([
'id_link_block' => ':linkBlockId',
'id_lang' => ':langId',
'name' => ':name',
'custom_content' => ':customContent',
])
;
} else {
$qb
->update($this->dbPrefix . 'link_block_lang', 'lbl')
->set('name', ':name')
->set('custom_content', ':customContent')
->andWhere('lbl.id_link_block = :linkBlockId')
->andWhere('lbl.id_lang = :langId')
;
}
$qb
->setParameters([
'linkBlockId' => $linkBlockId,
'langId' => $language['id_lang'],
'name' => $blockName[$language['id_lang']],
'customContent' => empty($custom) ? null : json_encode($custom[$language['id_lang']]),
]);
$this->executeQueryBuilder($qb, 'Link block language error');
}
}
/**
* @param QueryBuilder $qb
* @param string $errorPrefix
*
* @return Statement|int
*
* @throws DatabaseException
*/
private function executeQueryBuilder(QueryBuilder $qb, $errorPrefix = 'SQL error')
{
$statement = $qb->execute();
if ($statement instanceof Statement && !empty($statement->errorInfo())) {
throw new DatabaseException($errorPrefix . ': ' . var_export($statement->errorInfo(), true));
}
return $statement;
}
/**
* @param int $idHook
*
* @return bool|string
*/
private function getHookMaxPosition($idHook)
{
$qb = $this->connection->createQueryBuilder();
$qb->select('MAX(lb.position)')
->from($this->dbPrefix . 'link_block', 'lb')
->andWhere('lb.id_hook = :idHook')
->setParameter('idHook', $idHook)
;
return $qb->execute()->fetchColumn(0);
}
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
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;

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
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;

View File

@@ -0,0 +1,29 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
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;

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
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;

View File

@@ -0,0 +1,27 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
if (!defined('_PS_VERSION_')) {
exit;
}
function upgrade_module_1_3($object)
{
return $object->registerHook('actionObjectCmsUpdateAfter') && $object->registerHook('actionObjectCmsDeleteAfter');
}

View File

@@ -0,0 +1,27 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
if (!defined('_PS_VERSION_')) {
exit;
}
function upgrade_module_1_4($object)
{
return $object->registerHook('actionAdminStoresControllerUpdate_optionsAfter');
}

View File

@@ -0,0 +1,38 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
if (!defined('_PS_VERSION_')) {
exit;
}
function upgrade_module_3_0($object)
{
Configuration::deleteByName('FOOTER_CMS');
Configuration::deleteByName('FOOTER_BLOCK_ACTIVATION');
Configuration::deleteByName('FOOTER_POWEREDBY');
Configuration::deleteByName('FOOTER_PRICE-DROP');
Configuration::deleteByName('FOOTER_NEW-PRODUCTS');
Configuration::deleteByName('FOOTER_BEST-SALES');
Configuration::deleteByName('FOOTER_CONTACT');
Configuration::deleteByName('FOOTER_SITEMAP');
Db::getInstance()->execute('DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'cms_block_page`');
return true;
}

10
modules/ps_linklist/vendor/.htaccess vendored Normal file
View File

@@ -0,0 +1,10 @@
# Apache 2.2
<IfModule !mod_authz_core.c>
Order deny,allow
Deny from all
</IfModule>
# Apache 2.4
<IfModule mod_authz_core.c>
Require all denied
</IfModule>

View File

@@ -0,0 +1,7 @@
<?php
// autoload.php @generated by Composer
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit12ca517bc1a1e1e064f0657d01aade67::getLoader();

View File

@@ -0,0 +1,445 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Autoload;
/**
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
*
* $loader = new \Composer\Autoload\ClassLoader();
*
* // register classes with namespaces
* $loader->add('Symfony\Component', __DIR__.'/component');
* $loader->add('Symfony', __DIR__.'/framework');
*
* // activate the autoloader
* $loader->register();
*
* // to enable searching the include path (eg. for PEAR packages)
* $loader->setUseIncludePath(true);
*
* In this example, if you try to use a class in the Symfony\Component
* namespace or one of its children (Symfony\Component\Console for instance),
* the autoloader will first look for the class under the component/
* directory, and it will then fallback to the framework/ directory if not
* found before giving up.
*
* This class is loosely based on the Symfony UniversalClassLoader.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
* @see http://www.php-fig.org/psr/psr-0/
* @see http://www.php-fig.org/psr/psr-4/
*/
class ClassLoader
{
// PSR-4
private $prefixLengthsPsr4 = array();
private $prefixDirsPsr4 = array();
private $fallbackDirsPsr4 = array();
// PSR-0
private $prefixesPsr0 = array();
private $fallbackDirsPsr0 = array();
private $useIncludePath = false;
private $classMap = array();
private $classMapAuthoritative = false;
private $missingClasses = array();
private $apcuPrefix;
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
return call_user_func_array('array_merge', $this->prefixesPsr0);
}
return array();
}
public function getPrefixesPsr4()
{
return $this->prefixDirsPsr4;
}
public function getFallbackDirs()
{
return $this->fallbackDirsPsr0;
}
public function getFallbackDirsPsr4()
{
return $this->fallbackDirsPsr4;
}
public function getClassMap()
{
return $this->classMap;
}
/**
* @param array $classMap Class to filename map
*/
public function addClassMap(array $classMap)
{
if ($this->classMap) {
$this->classMap = array_merge($this->classMap, $classMap);
} else {
$this->classMap = $classMap;
}
}
/**
* Registers a set of PSR-0 directories for a given prefix, either
* appending or prepending to the ones previously set for this prefix.
*
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 root directories
* @param bool $prepend Whether to prepend the directories
*/
public function add($prefix, $paths, $prepend = false)
{
if (!$prefix) {
if ($prepend) {
$this->fallbackDirsPsr0 = array_merge(
(array) $paths,
$this->fallbackDirsPsr0
);
} else {
$this->fallbackDirsPsr0 = array_merge(
$this->fallbackDirsPsr0,
(array) $paths
);
}
return;
}
$first = $prefix[0];
if (!isset($this->prefixesPsr0[$first][$prefix])) {
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
return;
}
if ($prepend) {
$this->prefixesPsr0[$first][$prefix] = array_merge(
(array) $paths,
$this->prefixesPsr0[$first][$prefix]
);
} else {
$this->prefixesPsr0[$first][$prefix] = array_merge(
$this->prefixesPsr0[$first][$prefix],
(array) $paths
);
}
}
/**
* Registers a set of PSR-4 directories for a given namespace, either
* appending or prepending to the ones previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-4 base directories
* @param bool $prepend Whether to prepend the directories
*
* @throws \InvalidArgumentException
*/
public function addPsr4($prefix, $paths, $prepend = false)
{
if (!$prefix) {
// Register directories for the root namespace.
if ($prepend) {
$this->fallbackDirsPsr4 = array_merge(
(array) $paths,
$this->fallbackDirsPsr4
);
} else {
$this->fallbackDirsPsr4 = array_merge(
$this->fallbackDirsPsr4,
(array) $paths
);
}
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
// Register directories for a new namespace.
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
} elseif ($prepend) {
// Prepend directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
(array) $paths,
$this->prefixDirsPsr4[$prefix]
);
} else {
// Append directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
$this->prefixDirsPsr4[$prefix],
(array) $paths
);
}
}
/**
* Registers a set of PSR-0 directories for a given prefix,
* replacing any others previously set for this prefix.
*
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 base directories
*/
public function set($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr0 = (array) $paths;
} else {
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
}
}
/**
* Registers a set of PSR-4 directories for a given namespace,
* replacing any others previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-4 base directories
*
* @throws \InvalidArgumentException
*/
public function setPsr4($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr4 = (array) $paths;
} else {
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
}
}
/**
* Turns on searching the include path for class files.
*
* @param bool $useIncludePath
*/
public function setUseIncludePath($useIncludePath)
{
$this->useIncludePath = $useIncludePath;
}
/**
* Can be used to check if the autoloader uses the include path to check
* for classes.
*
* @return bool
*/
public function getUseIncludePath()
{
return $this->useIncludePath;
}
/**
* Turns off searching the prefix and fallback directories for classes
* that have not been registered with the class map.
*
* @param bool $classMapAuthoritative
*/
public function setClassMapAuthoritative($classMapAuthoritative)
{
$this->classMapAuthoritative = $classMapAuthoritative;
}
/**
* Should class lookup fail if not found in the current class map?
*
* @return bool
*/
public function isClassMapAuthoritative()
{
return $this->classMapAuthoritative;
}
/**
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
*
* @param string|null $apcuPrefix
*/
public function setApcuPrefix($apcuPrefix)
{
$this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null;
}
/**
* The APCu prefix in use, or null if APCu caching is not enabled.
*
* @return string|null
*/
public function getApcuPrefix()
{
return $this->apcuPrefix;
}
/**
* Registers this instance as an autoloader.
*
* @param bool $prepend Whether to prepend the autoloader or not
*/
public function register($prepend = false)
{
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
}
/**
* Unregisters this instance as an autoloader.
*/
public function unregister()
{
spl_autoload_unregister(array($this, 'loadClass'));
}
/**
* Loads the given class or interface.
*
* @param string $class The name of the class
* @return bool|null True if loaded, null otherwise
*/
public function loadClass($class)
{
if ($file = $this->findFile($class)) {
includeFile($file);
return true;
}
}
/**
* Finds the path to the file where the class is defined.
*
* @param string $class The name of the class
*
* @return string|false The path if found, false otherwise
*/
public function findFile($class)
{
// class map lookup
if (isset($this->classMap[$class])) {
return $this->classMap[$class];
}
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
return false;
}
if (null !== $this->apcuPrefix) {
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
if ($hit) {
return $file;
}
}
$file = $this->findFileWithExtension($class, '.php');
// Search for Hack files if we are running on HHVM
if (false === $file && defined('HHVM_VERSION')) {
$file = $this->findFileWithExtension($class, '.hh');
}
if (null !== $this->apcuPrefix) {
apcu_add($this->apcuPrefix.$class, $file);
}
if (false === $file) {
// Remember that this class does not exist.
$this->missingClasses[$class] = true;
}
return $file;
}
private function findFileWithExtension($class, $ext)
{
// PSR-4 lookup
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
$first = $class[0];
if (isset($this->prefixLengthsPsr4[$first])) {
$subPath = $class;
while (false !== $lastPos = strrpos($subPath, '\\')) {
$subPath = substr($subPath, 0, $lastPos);
$search = $subPath.'\\';
if (isset($this->prefixDirsPsr4[$search])) {
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
foreach ($this->prefixDirsPsr4[$search] as $dir) {
if (file_exists($file = $dir . $pathEnd)) {
return $file;
}
}
}
}
}
// PSR-4 fallback dirs
foreach ($this->fallbackDirsPsr4 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
return $file;
}
}
// PSR-0 lookup
if (false !== $pos = strrpos($class, '\\')) {
// namespaced class name
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
} else {
// PEAR-like class name
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
}
if (isset($this->prefixesPsr0[$first])) {
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
if (0 === strpos($class, $prefix)) {
foreach ($dirs as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
}
}
}
// PSR-0 fallback dirs
foreach ($this->fallbackDirsPsr0 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
// PSR-0 include paths.
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
return $file;
}
return false;
}
}
/**
* Scope isolated include.
*
* Prevents access to $this/self from included files.
*/
function includeFile($file)
{
include $file;
}

View File

@@ -0,0 +1,21 @@
Copyright (c) Nils Adermann, Jordi Boggiano
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,31 @@
<?php
// autoload_classmap.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'PrestaShop\\Module\\LinkList\\Cache\\LegacyLinkBlockCache' => $baseDir . '/src/Cache/LegacyLinkBlockCache.php',
'PrestaShop\\Module\\LinkList\\Cache\\LinkBlockCacheInterface' => $baseDir . '/src/Cache/LinkBlockCacheInterface.php',
'PrestaShop\\Module\\LinkList\\Controller\\Admin\\Improve\\Design\\LinkBlockController' => $baseDir . '/src/Controller/Admin/Improve/Design/LinkBlockController.php',
'PrestaShop\\Module\\LinkList\\Core\\Grid\\Definition\\Factory\\LinkBlockDefinitionFactory' => $baseDir . '/src/Core/Grid/Definition/Factory/LinkBlockDefinitionFactory.php',
'PrestaShop\\Module\\LinkList\\Core\\Grid\\LinkBlockGridFactory' => $baseDir . '/src/Core/Grid/LinkBlockGridFactory.php',
'PrestaShop\\Module\\LinkList\\Core\\Grid\\Query\\LinkBlockQueryBuilder' => $baseDir . '/src/Core/Grid/Query/LinkBlockQueryBuilder.php',
'PrestaShop\\Module\\LinkList\\Core\\Search\\Filters\\LinkBlockFilters' => $baseDir . '/src/Core/Search/Filters/LinkBlockFilters.php',
'PrestaShop\\Module\\LinkList\\Form\\ChoiceProvider\\AbstractDatabaseChoiceProvider' => $baseDir . '/src/Form/ChoiceProvider/AbstractDatabaseChoiceProvider.php',
'PrestaShop\\Module\\LinkList\\Form\\ChoiceProvider\\CMSCategoryChoiceProvider' => $baseDir . '/src/Form/ChoiceProvider/CMSCategoryChoiceProvider.php',
'PrestaShop\\Module\\LinkList\\Form\\ChoiceProvider\\CMSPageChoiceProvider' => $baseDir . '/src/Form/ChoiceProvider/CMSPageChoiceProvider.php',
'PrestaShop\\Module\\LinkList\\Form\\ChoiceProvider\\HookChoiceProvider' => $baseDir . '/src/Form/ChoiceProvider/HookChoiceProvider.php',
'PrestaShop\\Module\\LinkList\\Form\\ChoiceProvider\\PageChoiceProvider' => $baseDir . '/src/Form/ChoiceProvider/PageChoiceProvider.php',
'PrestaShop\\Module\\LinkList\\Form\\LinkBlockFormDataProvider' => $baseDir . '/src/Form/LinkBlockFormDataProvider.php',
'PrestaShop\\Module\\LinkList\\Form\\Type\\CustomUrlType' => $baseDir . '/src/Form/Type/CustomUrlType.php',
'PrestaShop\\Module\\LinkList\\Form\\Type\\LinkBlockType' => $baseDir . '/src/Form/Type/LinkBlockType.php',
'PrestaShop\\Module\\LinkList\\Form\\Type\\TranslateCustomUrlType' => $baseDir . '/src/Form/Type/TranslateCustomUrlType.php',
'PrestaShop\\Module\\LinkList\\LegacyLinkBlockRepository' => $baseDir . '/src/LegacyLinkBlockRepository.php',
'PrestaShop\\Module\\LinkList\\Model\\LinkBlock' => $baseDir . '/src/Model/LinkBlock.php',
'PrestaShop\\Module\\LinkList\\Model\\LinkBlockLang' => $baseDir . '/src/Model/LinkBlockLang.php',
'PrestaShop\\Module\\LinkList\\Presenter\\LinkBlockPresenter' => $baseDir . '/src/Presenter/LinkBlockPresenter.php',
'PrestaShop\\Module\\LinkList\\Repository\\LinkBlockRepository' => $baseDir . '/src/Repository/LinkBlockRepository.php',
'Ps_Linklist' => $baseDir . '/ps_linklist.php',
);

View File

@@ -0,0 +1,9 @@
<?php
// autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
);

View File

@@ -0,0 +1,10 @@
<?php
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'PrestaShop\\Module\\LinkList\\' => array($baseDir . '/src'),
);

View File

@@ -0,0 +1,43 @@
<?php
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit12ca517bc1a1e1e064f0657d01aade67
{
private static $loader;
public static function loadClassLoader($class)
{
if ('Composer\Autoload\ClassLoader' === $class) {
require __DIR__ . '/ClassLoader.php';
}
}
public static function getLoader()
{
if (null !== self::$loader) {
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit12ca517bc1a1e1e064f0657d01aade67', 'loadClassLoader'), true, false);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInit12ca517bc1a1e1e064f0657d01aade67', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit12ca517bc1a1e1e064f0657d01aade67::getInitializer($loader));
} else {
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
}
}
$loader->setClassMapAuthoritative(true);
$loader->register(false);
return $loader;
}
}

View File

@@ -0,0 +1,57 @@
<?php
// autoload_static.php @generated by Composer
namespace Composer\Autoload;
class ComposerStaticInit12ca517bc1a1e1e064f0657d01aade67
{
public static $prefixLengthsPsr4 = array (
'P' =>
array (
'PrestaShop\\Module\\LinkList\\' => 27,
),
);
public static $prefixDirsPsr4 = array (
'PrestaShop\\Module\\LinkList\\' =>
array (
0 => __DIR__ . '/../..' . '/src',
),
);
public static $classMap = array (
'PrestaShop\\Module\\LinkList\\Cache\\LegacyLinkBlockCache' => __DIR__ . '/../..' . '/src/Cache/LegacyLinkBlockCache.php',
'PrestaShop\\Module\\LinkList\\Cache\\LinkBlockCacheInterface' => __DIR__ . '/../..' . '/src/Cache/LinkBlockCacheInterface.php',
'PrestaShop\\Module\\LinkList\\Controller\\Admin\\Improve\\Design\\LinkBlockController' => __DIR__ . '/../..' . '/src/Controller/Admin/Improve/Design/LinkBlockController.php',
'PrestaShop\\Module\\LinkList\\Core\\Grid\\Definition\\Factory\\LinkBlockDefinitionFactory' => __DIR__ . '/../..' . '/src/Core/Grid/Definition/Factory/LinkBlockDefinitionFactory.php',
'PrestaShop\\Module\\LinkList\\Core\\Grid\\LinkBlockGridFactory' => __DIR__ . '/../..' . '/src/Core/Grid/LinkBlockGridFactory.php',
'PrestaShop\\Module\\LinkList\\Core\\Grid\\Query\\LinkBlockQueryBuilder' => __DIR__ . '/../..' . '/src/Core/Grid/Query/LinkBlockQueryBuilder.php',
'PrestaShop\\Module\\LinkList\\Core\\Search\\Filters\\LinkBlockFilters' => __DIR__ . '/../..' . '/src/Core/Search/Filters/LinkBlockFilters.php',
'PrestaShop\\Module\\LinkList\\Form\\ChoiceProvider\\AbstractDatabaseChoiceProvider' => __DIR__ . '/../..' . '/src/Form/ChoiceProvider/AbstractDatabaseChoiceProvider.php',
'PrestaShop\\Module\\LinkList\\Form\\ChoiceProvider\\CMSCategoryChoiceProvider' => __DIR__ . '/../..' . '/src/Form/ChoiceProvider/CMSCategoryChoiceProvider.php',
'PrestaShop\\Module\\LinkList\\Form\\ChoiceProvider\\CMSPageChoiceProvider' => __DIR__ . '/../..' . '/src/Form/ChoiceProvider/CMSPageChoiceProvider.php',
'PrestaShop\\Module\\LinkList\\Form\\ChoiceProvider\\HookChoiceProvider' => __DIR__ . '/../..' . '/src/Form/ChoiceProvider/HookChoiceProvider.php',
'PrestaShop\\Module\\LinkList\\Form\\ChoiceProvider\\PageChoiceProvider' => __DIR__ . '/../..' . '/src/Form/ChoiceProvider/PageChoiceProvider.php',
'PrestaShop\\Module\\LinkList\\Form\\LinkBlockFormDataProvider' => __DIR__ . '/../..' . '/src/Form/LinkBlockFormDataProvider.php',
'PrestaShop\\Module\\LinkList\\Form\\Type\\CustomUrlType' => __DIR__ . '/../..' . '/src/Form/Type/CustomUrlType.php',
'PrestaShop\\Module\\LinkList\\Form\\Type\\LinkBlockType' => __DIR__ . '/../..' . '/src/Form/Type/LinkBlockType.php',
'PrestaShop\\Module\\LinkList\\Form\\Type\\TranslateCustomUrlType' => __DIR__ . '/../..' . '/src/Form/Type/TranslateCustomUrlType.php',
'PrestaShop\\Module\\LinkList\\LegacyLinkBlockRepository' => __DIR__ . '/../..' . '/src/LegacyLinkBlockRepository.php',
'PrestaShop\\Module\\LinkList\\Model\\LinkBlock' => __DIR__ . '/../..' . '/src/Model/LinkBlock.php',
'PrestaShop\\Module\\LinkList\\Model\\LinkBlockLang' => __DIR__ . '/../..' . '/src/Model/LinkBlockLang.php',
'PrestaShop\\Module\\LinkList\\Presenter\\LinkBlockPresenter' => __DIR__ . '/../..' . '/src/Presenter/LinkBlockPresenter.php',
'PrestaShop\\Module\\LinkList\\Repository\\LinkBlockRepository' => __DIR__ . '/../..' . '/src/Repository/LinkBlockRepository.php',
'Ps_Linklist' => __DIR__ . '/../..' . '/ps_linklist.php',
);
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit12ca517bc1a1e1e064f0657d01aade67::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit12ca517bc1a1e1e064f0657d01aade67::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit12ca517bc1a1e1e064f0657d01aade67::$classMap;
}, null, ClassLoader::class);
}
}

View File

@@ -0,0 +1 @@
[]

View File

@@ -0,0 +1,44 @@
{#**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*#}
<div class="card js-grid-panel" id="{{ grid.id }}_grid_panel" data-hook-name="{{ grid.name|split(' ')|first }}">
{% block grid_panel_header %}
<div class="card-header js-grid-header">
<h3 class="d-inline-block card-header-title">
{{ grid.name }} ({{ grid.data.records_total }})
</h3>
{% block grid_actions_block %}
<div class="d-inline-block float-right">
{{ include('@PrestaShop/Admin/Common/Grid/Blocks/grid_actions.html.twig', {'grid': grid}) }}
</div>
{% endblock %}
</div>
{% endblock %}
{% block grid_panel_body %}
<div class="card-body">
{% block grid_view_block %}
{{ include('@PrestaShop/Admin/Common/Grid/grid.html.twig', {'grid': grid }) }}
{% endblock %}
</div>
{% endblock %}
{% block grid_panel_footer %}{% endblock %}
</div>
{% block grid_panel_extra_content %}{% endblock %}

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
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;

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
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;

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
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;

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
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;

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
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;

View File

@@ -0,0 +1,84 @@
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
import TranslatableInput from '@components/translatable-input';
const $ = window.$;
$(() => {
new TranslatableInput({localeInputSelector: '.js-locale-input'});
const idHookSelect = $('#form_link_block_id_hook');
if (idHookSelect.hasClass('select2-hidden-accessible')) {
const targetNode = document.getElementsByTagName('body')[0];
const observer = new MutationObserver(function(mutationsList, observer) {
for(let mutation of mutationsList) {
if (mutation.type === 'childList' && mutation.addedNodes.length == 1) {
let node = mutation.addedNodes[0];
if ($(node).hasClass('select2-container--open')) {
$('#select2-form_link_block_id_hook-results li').each(function () {
$(this).attr('data-hook-name', $(this).html());
});
}
}
}
});
observer.observe(targetNode, { childList: true });
}
const addCustomButton = $('.add-collection-btn');
addCustomButton.on('click', appendPrototype);
const collectionId = addCustomButton.data().collectionId;
const collection = document.getElementById(collectionId);
const collectionPrototype = collection.dataset.prototype;
if (collection.children.length) {
$('.custom_collection .col-sm-12').each((index, customBlock) => {
appendDeleteButton($(customBlock));
});
} else {
appendPrototype();
}
function appendPrototype(event) {
if (event) {
event.preventDefault();
}
const newChild = collectionPrototype.replace(/__name__/g, (collection.children.length + 1));
const $newChild = $(newChild);
$('#'+collectionId).append($newChild);
appendDeleteButton($newChild);
}
function appendDeleteButton(customBlock) {
const collection = customBlock.closest('.custom_collection');
const $button = $('<button class="remove_custom_url btn btn-primary mt-1">'+collection.data('deleteButtonLabel')+'</button>');
$button.on('click', (event) => {
event.preventDefault();
const $button = $(event.target);
const $row = $button.closest('.row');
$row.remove();
return false;
});
customBlock.find('.locale-input-group').first().closest('.col-sm-12').append($button);
}
});

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
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;

View File

@@ -0,0 +1,38 @@
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
import Grid from '@components/grid/grid';
import LinkRowActionExtension from '@components/grid/extension/link-row-action-extension';
import SubmitRowActionExtension from '@components/grid/extension/action/row/submit-row-action-extension';
import SortingExtension from "@components/grid/extension/sorting-extension";
import PositionExtension from "@components/grid/extension/position-extension";
const $ = window.$;
$(() => {
let gridDivs = document.querySelectorAll('.js-grid');
gridDivs.forEach((gridDiv) => {
const linkBlockGrid = new Grid(gridDiv.dataset.gridId);
linkBlockGrid.addExtension(new SortingExtension());
linkBlockGrid.addExtension(new LinkRowActionExtension());
linkBlockGrid.addExtension(new SubmitRowActionExtension());
linkBlockGrid.addExtension(new PositionExtension());
});
});

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
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;

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
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;

4280
modules/ps_linklist/views/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,21 @@
{
"name": "ps_linklist",
"version": "3.0.4",
"description": "",
"scripts": {
"build": "NODE_ENV=production webpack --progress --colors --debug --display-chunks",
"watch": "webpack --progress --colors --debug --display-chunks --watch"
},
"author": "PrestaShop",
"license": "OSL-3.0",
"devDependencies": {
"babel-core": "^6.25.0",
"babel-loader": "^6.2.1",
"babel-preset-env": "^1.6.0",
"babel-preset-es2015": "^6.3.13",
"babel-preset-stage-2": "^6.22.0",
"path": "^0.12.7",
"uglify-save-license": "^0.4.1",
"webpack": "^2.7.0"
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
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;

View File

@@ -0,0 +1,97 @@
{#**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*#}
{%- block choice_widget_expanded -%}
<div {{ block('widget_container_attributes') }}>
{% for name, choices in form.vars.choices %}
{% if choices is iterable %}
<label class="choice_category">
<strong>
{{ choice_translation_domain is same as(false) ? name : name|trans({}, choice_translation_domain) }}
</strong>
</label>
<div>
{% for key,choice in choices %}
{{ form_widget(form[key]) }}
{{ form_label(form[key]) }}
{% endfor %}
</div>
{% else %}
{{- form_widget(form[name]) -}}
{{- form_label(form[name], null, {translation_domain: choice_translation_domain}) -}}
{% endif %}
{% endfor %}
</div>
{%- endblock choice_widget_expanded -%}
{% block checkbox_widget -%}
{% set parent_label_class = parent_label_class|default('') -%}
{% set switch = switch|default('') -%}
{% set checkbox_input %}
<input type="checkbox" class="js-bulk-action-checkbox"
{% if switch %}data-toggle="switch"{% endif %} {% if switch %}class="{{ switch }}"{% endif %} {{ block('widget_attributes') }}{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %} />
<i class="md-checkbox-control"></i>
{% endset %}
{% if 'checkbox-inline' in parent_label_class %}
<div class="md-checkbox md-checkbox-inline">
{{- form_label(form, null, { widget: checkbox_input }) -}}
</div>
{% else -%}
<div class="md-checkbox my-1">
{{- form_label(form, null, { widget: checkbox_input }) -}}
</div>
{%- endif %}
{%- endblock checkbox_widget %}
{% block form_row -%}
{% spaceless %}
<div class="{{ block('form_row_class') }} {% if (not compound or force_error|default(false)) and not valid %} has-error{% endif %}">
{% if form.vars.label is not same as(false) %}
{{ form_label(form) }}
{% set formGroupClasses = block('form_group_class') %}
{% else %}
{% set formGroupClasses = block('unlabeled_form_group_class') %}
{% endif %}
<div class="{{ formGroupClasses }}">
{{ form_widget(form) }}
{{ form_errors(form) }}
</div>
</div>
{% endspaceless %}
{%- endblock form_row %}
{% block form_row_class -%}
form-group row
{%- endblock form_row_class %}
{% block unlabeled_form_group_class -%}
col-sm-12
{%- endblock unlabeled_form_group_class %}
{%- block custom_url_widget -%}
<div class="form-control {{ attr.class }}">
{{ form_row(form.title) }}
{{ form_row(form.url) }}
</div>
{%- endblock custom_url_widget -%}

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
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;

View File

@@ -0,0 +1,77 @@
{#**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*#}
{% extends '@PrestaShop/Admin/layout.html.twig' %}
{% trans_default_domain "Admin.Design.Feature" %}
{% form_theme linkBlockForm '@Modules/ps_linklist/views/templates/admin/fields.html.twig' %}
{% block content %}
{% if linkBlockForm.vars.data.link_block.id_link_block is defined and linkBlockForm.vars.data.link_block.id_link_block is not null %}
{% set formAction = url('admin_link_block_edit_process', {'linkBlockId': linkBlockForm.vars.data.link_block.id_link_block}) %}
{% else %}
{% set formAction = url('admin_link_block_create_process') %}
{% endif %}
{{ form_start(linkBlockForm, {'action': formAction, 'attr': {'class': 'form', 'id': 'link_block_form'}}) }}
<div class="row justify-content-center">
{% block link_block_form %}
<div class="col-xl-10">
<div class="card">
<h3 class="card-header">
<i class="material-icons">mode_edit</i>
{% if linkBlockForm.vars.data.link_block.id_link_block is defined %}
{{ 'Edit the link block.'|trans({}, 'Modules.Linklist.Admin') }}
{% else %}
{{ 'New link block'|trans({}, 'Modules.Linklist.Admin') }}
{% endif %}
</h3>
<div class="card-block row">
<div class="card-text">
{{ form_row(linkBlockForm.link_block.block_name) }}
{{ form_row(linkBlockForm.link_block.id_hook) }}
{{ form_row(linkBlockForm.link_block.cms) }}
{{ form_row(linkBlockForm.link_block.product) }}
{{ form_row(linkBlockForm.link_block.static) }}
<div class="form-group">
{{ form_row(linkBlockForm.link_block.custom) }}
<div class="d-flex justify-content-end">
<button data-collection-id="{{ linkBlockForm.link_block.custom.vars.id }}" class="btn btn-primary add-collection-btn">{{ 'Add'|trans({}, 'Admin.Actions') }}</button>
</div>
</div>
{{ form_rest(linkBlockForm.link_block) }}
{% do linkBlockForm.link_block.setRendered %}
{{ form_rest(linkBlockForm) }}
</div>
</div>
<div class="card-footer">
<div class="d-flex justify-content-between">
<a href="{{ url('admin_link_block_list') }}" class="btn btn-secondary">{{ 'Cancel'|trans({}, 'Admin.Actions') }}</a>
<button class="btn btn-primary">{{ 'Save'|trans({}, 'Admin.Actions') }}</button>
</div>
</div>
</div>
</div>
{% endblock %}
</div>
{{ form_end(linkBlockForm) }}
{% endblock %}
{% block javascripts %}
{{ parent() }}
<script src="{{ asset('../modules/ps_linklist/views/public/form.bundle.js') }}"></script>
{% endblock %}

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
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;

View File

@@ -0,0 +1,36 @@
{#**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*#}
{% extends '@PrestaShop/Admin/layout.html.twig' %}
{% trans_default_domain "Admin.Design.Feature" %}
{% block content %}
<div class="row">
{% for grid in grids %}
<div class="col-sm-6">
{{ include('@PrestaShop/Admin/Common/Grid/grid_panel.html.twig', {'grid': grid }) }}
</div>
{% endfor %}
</div>
{% endblock %}
{% block javascripts %}
{{ parent() }}
<script src="{{ asset('../modules/ps_linklist/views/public/grid.bundle.js') }}"></script>
{% endblock %}

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
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;

View File

@@ -0,0 +1,37 @@
{**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*}
{foreach $linkBlocks as $linkBlock}
<h3>{$linkBlock.title|escape:'html':'UTF-8'}</h3>
<ul>
{foreach $linkBlock.links as $link}
<li>
<a
id="{$link.id}-{$linkBlock.id}"
class="{$link.class}"
href="{$link.url|escape:'html':'UTF-8'}"
title="{$link.description|escape:'html':'UTF-8'}"
{if !empty($link.target)} target="{$link.target|escape:'html':'UTF-8'}" {/if}
>
{$link.title|escape:'html':'UTF-8'}
</a>
</li>
{/foreach}
</ul>
{/foreach}

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
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;

View File

@@ -0,0 +1,102 @@
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* 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
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @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
*/
const path = require('path');
const webpack = require('webpack');
const keepLicense = require('uglify-save-license');
const psRootDir = path.resolve(process.env.PWD, '../../../');
const psJsDir = path.resolve(psRootDir, 'admin-dev/themes/new-theme/js');
const psAppDir = path.resolve(psJsDir, 'app');
const psComponentsDir = path.resolve(psJsDir, 'components');
const config = {
entry: {
grid: [
'./js/grid',
],
form: [
'./js/form',
]
},
output: {
path: path.resolve(__dirname, 'public'),
filename: '[name].bundle.js'
},
//devtool: 'source-map', // uncomment me to build source maps (really slow)
resolve: {
extensions: ['.js'],
alias: {
'@app': psAppDir,
'@components': psComponentsDir,
},
},
module: {
rules: [
{
test: /\.js$/,
include: path.resolve(__dirname, 'js'),
use: [{
loader: 'babel-loader',
options: {
presets: [
['es2015', { modules: false }]
]
}
}]
},
{
test: /\.js$/,
include: path.resolve(__dirname, '../../../admin-dev/themes/new-theme/js'),
use: [{
loader: 'babel-loader',
options: {
presets: [
['es2015', { modules: false }]
]
}
}]
}
]
},
plugins: []
};
if (process.env.NODE_ENV === 'production') {
config.plugins.push(
new webpack.optimize.UglifyJsPlugin({
sourceMap: false,
compress: {
sequences: true,
conditionals: true,
booleans: true,
if_return: true,
join_vars: true,
drop_console: true
},
output: {
comments: keepLicense
}
})
);
} else {
config.plugins.push(new webpack.HotModuleReplacementPlugin());
}
module.exports = config;