Skip to content

Commit

Permalink
Merge pull request #51 from PrestaShop/filter_catalog_page
Browse files Browse the repository at this point in the history
Filter catalog page
  • Loading branch information
PierreRambaud committed Oct 5, 2018
2 parents 9483cb1 + 39465d3 commit 836b1dc
Show file tree
Hide file tree
Showing 25 changed files with 1,715 additions and 1,589 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.php_cs.cache
106 changes: 42 additions & 64 deletions classes/Addons.php
Original file line number Diff line number Diff line change
@@ -1,39 +1,40 @@
<?php
/**
* 2007-2018 PrestaShop
*
* 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:
* http://opensource.org/licenses/osl-3.0.php
* 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-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
**/
* 2007-2018 PrestaShop
*
* 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:
* http://opensource.org/licenses/osl-3.0.php
* 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-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
**/

class Addons {

protected static $is_addons_up = true;
public static function addonsRequest($request, $params = array()) {
class Addons
{
protected static $is_addons_up = true;

public static function addonsRequest($request, $params = array())
{
if (!self::$is_addons_up) {
return false;
}

$post_query_data = array(
// 'version' => isset($params['version']) ? $params['version'] : _PS_VERSION_,
'version' => '1.7.3.0',
'iso_lang' => Tools::strtolower(isset($params['iso_lang']) ? $params['iso_lang'] : Context::getContext()->language->iso_code),
'iso_code' => Tools::strtolower(isset($params['iso_country']) ? $params['iso_country'] : Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'))),
Expand All @@ -52,40 +53,28 @@ public static function addonsRequest($request, $params = array()) {

switch ($request) {
case 'categories':
$protocols[] = 'http';
$post_data .= '&method=listing&action=categories';
break;
case 'native':
$protocols[] = 'http';
$post_data .= '&method=listing&action=native';
break;
case 'partner':
$protocols[] = 'http';
$post_data .= '&method=listing&action=partner';
break;
case 'service':
case 'must-have':
case 'must-have-themes':
$protocols[] = 'http';
$post_data .= '&method=listing&action=service';
$post_data .= sprintf(
'&method=listing&action=%s',
$request
);
break;
case 'native_all':
$protocols[] = 'http';
$post_data .= '&method=listing&action=native&iso_code=all';
break;
case 'must-have':
$protocols[] = 'http';
$post_data .= '&method=listing&action=must-have';
break;
case 'must-have-themes':
$protocols[] = 'http';
$post_data .= '&method=listing&action=must-have-themes';
break;
case 'customer':
$post_data .= '&method=listing&action=customer&username='.urlencode(trim(Context::getContext()->cookie->username_addons))
.'&password='.urlencode(trim(Context::getContext()->cookie->password_addons));
.'&password='.urlencode(trim(Context::getContext()->cookie->password_addons));
break;
case 'customer_themes':
$post_data .= '&method=listing&action=customer-themes&username='.urlencode(trim(Context::getContext()->cookie->username_addons))
.'&password='.urlencode(trim(Context::getContext()->cookie->password_addons));
.'&password='.urlencode(trim(Context::getContext()->cookie->password_addons));
break;
case 'check_customer':
$post_data .= '&method=check_customer&username='.urlencode($params['username_addons']).'&password='.urlencode($params['password_addons']);
Expand All @@ -103,9 +92,9 @@ public static function addonsRequest($request, $params = array()) {
break;
case 'hosted_module':
$post_data .= '&method=module&id_module='.urlencode((int)$params['id_module']).'&username='.urlencode($params['hosted_email'])
.'&password='.urlencode($params['password_addons'])
.'&shop_url='.urlencode(isset($params['shop_url']) ? $params['shop_url'] : Tools::getShopDomain())
.'&mail='.urlencode(isset($params['email']) ? $params['email'] : Configuration::get('PS_SHOP_EMAIL'));
.'&password='.urlencode($params['password_addons'])
.'&shop_url='.urlencode(isset($params['shop_url']) ? $params['shop_url'] : Tools::getShopDomain())
.'&mail='.urlencode(isset($params['email']) ? $params['email'] : Configuration::get('PS_SHOP_EMAIL'));
$protocols[] = 'https';
break;
case 'install-modules':
Expand All @@ -125,26 +114,15 @@ public static function addonsRequest($request, $params = array()) {
'timeout' => 5,
)
));

foreach ($protocols as $protocol) {
if ($content = Tools::file_get_contents($protocol.'://'.$end_point, false, $context)) {
return $content;
}
}


// $back_link = self::$currentIndex.'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name;
// $hook_link = 'index.php?tab=AdminModulesPositions&token='.Tools::getAdminTokenLite('AdminModulesPositions').'&show_modules='.(int)$module->id;
// $trad_link = 'index.php?tab=AdminTranslations&token='.Tools::getAdminTokenLite('AdminTranslations').'&type=modules&lang=';
// $rtl_link = 'index.php?tab=AdminModules&token='.Tools::getAdminTokenLite('AdminModules').'&configure='.$module->name.'&generate_rtl=1';
// $disable_link = $this->context->link->getAdminLink('AdminModules').'&module_name='.$module->name.'&enable=0&tab_module='.$module->tab;
// $uninstall_link = $this->context->link->getAdminLink('AdminModules').'&module_name='.$module->name.'&uninstall='.$module->name.'&tab_module='.$module->tab;
// $reset_link = $this->context->link->getAdminLink('AdminModules').'&module_name='.$module->name.'&reset&tab_module='.$module->tab;
// $update_link = $this->context->link->getAdminLink('AdminModules').'&checkAndUpdate=1&module_name='.$module->name;

self::$is_addons_up = false;

return false;
}


}
46 changes: 23 additions & 23 deletions classes/index.php
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
<?php
/**
* 2007-2017 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (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:
* http://opensource.org/licenses/afl-3.0.php
* 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-2017 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
* 2007-2018 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (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:
* http://opensource.org/licenses/afl-3.0.php
* 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-2018 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (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');
Expand Down
63 changes: 34 additions & 29 deletions controllers/admin/AdminPsMboModuleController.php
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
<?php
/**
* 2007-2018 PrestaShop
*
* 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:
* http://opensource.org/licenses/osl-3.0.php
* 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-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
**/
* 2007-2018 PrestaShop
*
* 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:
* http://opensource.org/licenses/osl-3.0.php
* 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-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
**/

use PrestaShop\PrestaShop\Adapter\SymfonyContainer;
use PrestaShop\PrestaShop\Core\Addon\AddonListFilter;
Expand Down Expand Up @@ -90,12 +90,17 @@ public function initContent()
'bo_img' => __PS_BASE_URI__ . $admin_webpath . '/themes/default/img/',
'install_url' => $install_url,
'module_controller_token' => $moduleControllerToken,
'notification_count_url' => $notification_count_url
'notification_count_url' => $notification_count_url,
'javascript_urls' => json_encode(
[
'configure' => $container->get('router')->generate(
'admin_module_configure_action',
['module_name' => '%module_name%']
)
]
),
));

$aJsDef = $aJs = array();


// @TODO, call vue.min.js
$aJs = array(
$this->module->js_path . 'vue.js',
Expand Down Expand Up @@ -123,7 +128,7 @@ public function initContent()
protected function addonsList($request)
{
$results = Addons::addonsRequest($request, array('format' => 'json'));
$results = json_decode($results, TRUE);
$results = json_decode($results, true);

if (!isset($results['modules'])) {
return json_encode(array());
Expand Down Expand Up @@ -248,7 +253,7 @@ public function ajaxProcessGetModuleQuickView()
public function ajaxProcessGetTabModulesList()
{
$result = $this->module->fetchModulesByController(true);

$this->context->smarty->assign(array(
'controller_name' => $result['controller_name'],
'currentIndex' => self::$currentIndex,
Expand Down
47 changes: 23 additions & 24 deletions controllers/admin/AdminPsMboThemeController.php
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
<?php
/**
* 2007-2018 PrestaShop
*
* 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:
* http://opensource.org/licenses/osl-3.0.php
* 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-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
**/
* 2007-2018 PrestaShop
*
* 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:
* http://opensource.org/licenses/osl-3.0.php
* 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-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
**/

require_once(dirname(__FILE__) . '../../../classes/Addons.php');

class AdminPsMboThemeController extends ModuleAdminController
{

public function __construct()
{
$this->controller_quick_name = 'theme';
Expand Down
26 changes: 13 additions & 13 deletions controllers/admin/index.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?php
/**
* 2007-2014 PrestaShop
*
* 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-2014 PrestaShop SA
* @license http://addons.prestashop.com/en/content/12-terms-and-conditions-of-use
* International Registered Trademark & Property of PrestaShop SA
*/
* 2007-2014 PrestaShop
*
* 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-2014 PrestaShop SA
* @license http://addons.prestashop.com/en/content/12-terms-and-conditions-of-use
* 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');
Expand Down

0 comments on commit 836b1dc

Please sign in to comment.