first commit

This commit is contained in:
2024-12-17 13:43:22 +01:00
commit 8e6cd8b410
21292 changed files with 3514826 additions and 0 deletions

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[Lista link&oacute;w]]></displayName>
<version><![CDATA[3.2.0]]></version>
<description><![CDATA[Dodaje blok z kilkoma linkami.]]></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

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;
}

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

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;