Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #148 from PrestaShop/dev
Release 3.4.0
- Loading branch information
Showing
24 changed files
with
732 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
/** | ||
* 2007-2019 PrestaShop. | ||
* | ||
* 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. | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer | ||
* versions in the future. If you wish to customize PrestaShop for your | ||
* needs please refer to http://www.prestashop.com for more information. | ||
* | ||
* @author PrestaShop SA <contact@prestashop.com> | ||
* @copyright 2007-2019 PrestaShop SA | ||
* @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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
services: | ||
_defaults: | ||
public: true | ||
|
||
prestashop.module.ps_facetedsearch.constraint.url_segment_validator: | ||
class: PrestaShop\Module\FacetedSearch\Constraint\UrlSegmentValidator | ||
arguments: | ||
- '@prestashop.adapter.tools' | ||
tags: | ||
- { name: validator.constraint_validator } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
/** | ||
* 2007-2019 PrestaShop and Contributors | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Open Software License (OSL 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/OSL-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. | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer | ||
* versions in the future. If you wish to customize PrestaShop for your | ||
* needs please refer to https://www.prestashop.com for more information. | ||
* | ||
* @author PrestaShop SA <contact@prestashop.com> | ||
* @copyright 2007-2019 PrestaShop SA and Contributors | ||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) | ||
* International Registered Trademark & Property of PrestaShop SA | ||
*/ | ||
|
||
namespace PrestaShop\Module\FacetedSearch\Constraint; | ||
|
||
use Symfony\Component\Validator\Constraint; | ||
|
||
class UrlSegment extends Constraint | ||
{ | ||
public $message = '%s is invalid.'; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function validatedBy() | ||
{ | ||
return UrlSegmentValidator::class; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
/** | ||
* 2007-2019 PrestaShop and Contributors | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Open Software License (OSL 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/OSL-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. | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer | ||
* versions in the future. If you wish to customize PrestaShop for your | ||
* needs please refer to https://www.prestashop.com for more information. | ||
* | ||
* @author PrestaShop SA <contact@prestashop.com> | ||
* @copyright 2007-2019 PrestaShop SA and Contributors | ||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) | ||
* International Registered Trademark & Property of PrestaShop SA | ||
*/ | ||
|
||
namespace PrestaShop\Module\FacetedSearch\Constraint; | ||
|
||
use PrestaShop\PrestaShop\Adapter\Tools; | ||
use Symfony\Component\Validator\Constraint; | ||
use Symfony\Component\Validator\ConstraintValidator; | ||
use Symfony\Component\Validator\Exception\UnexpectedTypeException; | ||
|
||
/** | ||
* Class UrlSegmentValidator responsible for validating an URL segment. | ||
*/ | ||
class UrlSegmentValidator extends ConstraintValidator | ||
{ | ||
/** | ||
* @var Tools | ||
*/ | ||
private $tools; | ||
|
||
/** | ||
* @param Tools $tools | ||
*/ | ||
public function __construct(Tools $tools) | ||
{ | ||
$this->tools = $tools; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function validate($value, Constraint $constraint) | ||
{ | ||
if (!$constraint instanceof UrlSegment) { | ||
throw new UnexpectedTypeException($constraint, UrlSegment::class); | ||
} | ||
|
||
if (null === $value || '' === $value) { | ||
return; | ||
} | ||
|
||
if (strtolower($value) !== $this->tools->linkRewrite($value)) { | ||
$this->context->buildViolation($constraint->message) | ||
->setTranslationDomain('Admin.Notifications.Error') | ||
->setParameter('%s', $this->formatValue($value)) | ||
->addViolation() | ||
; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<?php | ||
/** | ||
* 2007-2019 PrestaShop and Contributors | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Open Software License (OSL 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/OSL-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. | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer | ||
* versions in the future. If you wish to customize PrestaShop for your | ||
* needs please refer to https://www.prestashop.com for more information. | ||
* | ||
* @author PrestaShop SA <contact@prestashop.com> | ||
* @copyright 2007-2019 PrestaShop SA and Contributors | ||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) | ||
* International Registered Trademark & Property of PrestaShop SA | ||
*/ | ||
|
||
namespace PrestaShop\Module\FacetedSearch\Form\Feature; | ||
|
||
use Db; | ||
use PrestaShopDatabaseException; | ||
|
||
/** | ||
* Provides form data | ||
*/ | ||
class FormDataProvider | ||
{ | ||
/** | ||
* @var Db | ||
*/ | ||
private $database; | ||
|
||
public function __construct(Db $database) | ||
{ | ||
$this->database = $database; | ||
} | ||
|
||
/** | ||
* Fills form data | ||
* | ||
* @param array $params | ||
* | ||
* @return array | ||
* | ||
* @throws PrestaShopDatabaseException | ||
*/ | ||
public function getData(array $params) | ||
{ | ||
$defaultUrl = []; | ||
$defaultMetaTitle = []; | ||
$isIndexable = true; | ||
|
||
// if params contains id, gets data for edit form | ||
if (!empty($params['id'])) { | ||
$featureId = (int) $params['id']; | ||
|
||
// returns false if request failed. | ||
$queryIndexable = $this->database->getValue( | ||
'SELECT `indexable` ' . | ||
'FROM ' . _DB_PREFIX_ . 'layered_indexable_feature ' . | ||
'WHERE `id_feature` = ' . $featureId | ||
); | ||
|
||
$isIndexable = (bool) $queryIndexable; | ||
$result = $this->database->executeS( | ||
'SELECT `url_name`, `meta_title`, `id_lang` ' . | ||
'FROM ' . _DB_PREFIX_ . 'layered_indexable_feature_lang_value ' . | ||
'WHERE `id_feature` = ' . $featureId | ||
); | ||
|
||
if (!empty($result) && is_array($result)) { | ||
foreach ($result as $data) { | ||
$defaultUrl[$data['id_lang']] = $data['url_name']; | ||
$defaultMetaTitle[$data['id_lang']] = $data['meta_title']; | ||
} | ||
} | ||
} | ||
|
||
return [ | ||
'url' => $defaultUrl, | ||
'meta_title' => $defaultMetaTitle, | ||
'is_indexable' => $isIndexable, | ||
]; | ||
} | ||
} |
Oops, something went wrong.