-
Notifications
You must be signed in to change notification settings - Fork 121
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 #979 from jolelievre/migrated-attribute-page-compa…
…tibility Migrated attribute page compatibility
- Loading branch information
Showing
24 changed files
with
825 additions
and
49 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,11 @@ | ||
<?php | ||
|
||
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,11 @@ | ||
<?php | ||
|
||
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,11 @@ | ||
<?php | ||
|
||
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,11 @@ | ||
<?php | ||
|
||
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,82 @@ | ||
<?php | ||
/** | ||
* Copyright since 2007 PrestaShop SA and Contributors | ||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA | ||
* | ||
* 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.md. | ||
* 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 [email protected] 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://devdocs.prestashop.com/ for more information. | ||
* | ||
* @author PrestaShop SA and Contributors <[email protected]> | ||
* @copyright Since 2007 PrestaShop SA and Contributors | ||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PrestaShop\Module\FacetedSearch\Form\Attribute; | ||
|
||
use Db; | ||
use PrestaShopDatabaseException; | ||
|
||
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 = []; | ||
|
||
// if params contains id, gets data for edit form | ||
if (!empty($params['id'])) { | ||
$attributeId = (int) $params['id']; | ||
$result = $this->database->executeS( | ||
'SELECT `url_name`, `meta_title`, `id_lang` ' . | ||
'FROM ' . _DB_PREFIX_ . 'layered_indexable_attribute_lang_value ' . | ||
'WHERE `id_attribute` = ' . $attributeId | ||
); | ||
|
||
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_name' => $defaultUrl, | ||
'meta_title' => $defaultMetaTitle, | ||
]; | ||
} | ||
} |
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,95 @@ | ||
<?php | ||
/** | ||
* Copyright since 2007 PrestaShop SA and Contributors | ||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA | ||
* | ||
* 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.md. | ||
* 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 [email protected] 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://devdocs.prestashop.com/ for more information. | ||
* | ||
* @author PrestaShop SA and Contributors <[email protected]> | ||
* @copyright Since 2007 PrestaShop SA and Contributors | ||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PrestaShop\Module\FacetedSearch\Form\Attribute; | ||
|
||
use PrestaShop\Module\FacetedSearch\Constraint\UrlSegment; | ||
use PrestaShopBundle\Form\Admin\Type\TranslatableType; | ||
use PrestaShopBundle\Translation\TranslatorComponent; | ||
use Symfony\Component\Form\FormBuilderInterface; | ||
|
||
class FormModifier | ||
{ | ||
/** | ||
* @var TranslatorComponent | ||
*/ | ||
private $translator; | ||
|
||
public function __construct(TranslatorComponent $translator) | ||
{ | ||
$this->translator = $translator; | ||
} | ||
|
||
public function modify(FormBuilderInterface $formBuilder) | ||
{ | ||
$invalidCharsHint = $this->translator->trans( | ||
'Invalid characters: <>;=#{}_', | ||
[], | ||
'Modules.Facetedsearch.Admin' | ||
); | ||
|
||
$urlTip = $this->translator->trans( | ||
'When the Faceted Search module is enabled, you can get more detailed URLs by choosing the word that best represent this attribute. By default, PrestaShop uses the attribute\'s name, but you can change that setting using this field.', | ||
[], | ||
'Modules.Facetedsearch.Admin' | ||
); | ||
$metaTitleTip = $this->translator->trans( | ||
'When the Faceted Search module is enabled, you can get more detailed page titles by choosing the word that best represent this attribute. By default, PrestaShop uses the attribute\'s name, but you can change that setting using this field.', | ||
[], | ||
'Modules.Facetedsearch.Admin' | ||
); | ||
|
||
$formBuilder | ||
->add( | ||
'url_name', | ||
TranslatableType::class, | ||
[ | ||
'required' => false, | ||
'label' => $this->translator->trans('URL', [], 'Modules.Facetedsearch.Admin'), | ||
'help' => $urlTip . ' ' . $invalidCharsHint, | ||
'options' => [ | ||
'constraints' => [ | ||
new UrlSegment([ | ||
'message' => $this->translator->trans('%s is invalid.', [], 'Admin.Notifications.Error'), | ||
]), | ||
], | ||
], | ||
] | ||
) | ||
->add( | ||
'meta_title', | ||
TranslatableType::class, | ||
[ | ||
'required' => false, | ||
'label' => $this->translator->trans('Meta title', [], 'Modules.Facetedsearch.Admin'), | ||
'help' => $metaTitleTip, | ||
] | ||
) | ||
; | ||
} | ||
} |
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,93 @@ | ||
<?php | ||
/** | ||
* Copyright since 2007 PrestaShop SA and Contributors | ||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA | ||
* | ||
* 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.md. | ||
* 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 [email protected] 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://devdocs.prestashop.com/ for more information. | ||
* | ||
* @author PrestaShop SA and Contributors <[email protected]> | ||
* @copyright Since 2007 PrestaShop SA and Contributors | ||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PrestaShop\Module\FacetedSearch\Form\AttributeGroup; | ||
|
||
use Db; | ||
use PrestaShopDatabaseException; | ||
|
||
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 = false; | ||
|
||
// if params contains id, gets data for edit form | ||
if (!empty($params['id'])) { | ||
$attributeGroupId = (int) $params['id']; | ||
|
||
// returns false if request failed. | ||
$queryIndexable = $this->database->getValue( | ||
'SELECT `indexable` ' . | ||
'FROM ' . _DB_PREFIX_ . 'layered_indexable_attribute_group ' . | ||
'WHERE `id_attribute_group` = ' . $attributeGroupId | ||
); | ||
|
||
$isIndexable = (bool) $queryIndexable; | ||
$result = $this->database->executeS( | ||
'SELECT `url_name`, `meta_title`, `id_lang` ' . | ||
'FROM ' . _DB_PREFIX_ . 'layered_indexable_attribute_group_lang_value ' . | ||
'WHERE `id_attribute_group` = ' . $attributeGroupId | ||
); | ||
|
||
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_name' => $defaultUrl, | ||
'meta_title' => $defaultMetaTitle, | ||
'is_indexable' => $isIndexable, | ||
]; | ||
} | ||
} |
Oops, something went wrong.