first commit
This commit is contained in:
1835
modules/ps_searchbar/composer.lock
generated
Normal file
1835
modules/ps_searchbar/composer.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
11
modules/ps_searchbar/config.xml
Normal file
11
modules/ps_searchbar/config.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<module>
|
||||
<name>ps_searchbar</name>
|
||||
<displayName><![CDATA[Search bar]]></displayName>
|
||||
<version><![CDATA[2.0.2]]></version>
|
||||
<description><![CDATA[Adds a quick search bar to your website.]]></description>
|
||||
<author><![CDATA[PrestaShop]]></author>
|
||||
<is_configurable>0</is_configurable>
|
||||
<need_instance>0</need_instance>
|
||||
<limited_countries></limited_countries>
|
||||
</module>
|
||||
12
modules/ps_searchbar/config_pl.xml
Normal file
12
modules/ps_searchbar/config_pl.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<module>
|
||||
<name>ps_searchbar</name>
|
||||
<displayName><![CDATA[Pasek Szukania]]></displayName>
|
||||
<version><![CDATA[2.0.2]]></version>
|
||||
<description><![CDATA[Help your visitors find what they are looking for, add a quick search field to your store.]]></description>
|
||||
<author><![CDATA[PrestaShop]]></author>
|
||||
<tab><![CDATA[]]></tab>
|
||||
<is_configurable>0</is_configurable>
|
||||
<need_instance>0</need_instance>
|
||||
<limited_countries></limited_countries>
|
||||
</module>
|
||||
34
modules/ps_searchbar/index.php
Normal file
34
modules/ps_searchbar/index.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2020 PrestaShop SA 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.
|
||||
*
|
||||
* 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-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;
|
||||
BIN
modules/ps_searchbar/logo.png
Normal file
BIN
modules/ps_searchbar/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.5 KiB |
35
modules/ps_searchbar/ps_searchbar.js
Normal file
35
modules/ps_searchbar/ps_searchbar.js
Normal file
@@ -0,0 +1,35 @@
|
||||
/* global $ */
|
||||
$(document).ready(function () {
|
||||
var $searchWidget = $('#search_widget');
|
||||
var $searchBox = $searchWidget.find('input[type=text]');
|
||||
var searchURL = $searchWidget.attr('data-search-controller-url');
|
||||
|
||||
$.widget('prestashop.psBlockSearchAutocomplete', $.ui.autocomplete, {
|
||||
_renderItem: function (ul, product) {
|
||||
return $("<li>")
|
||||
.append($("<a>")
|
||||
.append($("<span>").html(product.category_name).addClass("category"))
|
||||
.append($("<span>").html(' > ').addClass("separator"))
|
||||
.append($("<span>").html(product.name).addClass("product"))
|
||||
).appendTo(ul)
|
||||
;
|
||||
}
|
||||
});
|
||||
|
||||
$searchBox.psBlockSearchAutocomplete({
|
||||
source: function (query, response) {
|
||||
$.post(searchURL, {
|
||||
s: query.term,
|
||||
resultsPerPage: 10
|
||||
}, null, 'json')
|
||||
.then(function (resp) {
|
||||
response(resp.products);
|
||||
})
|
||||
.fail(response);
|
||||
},
|
||||
select: function (event, ui) {
|
||||
var url = ui.item.url;
|
||||
window.location.href = url;
|
||||
},
|
||||
});
|
||||
});
|
||||
107
modules/ps_searchbar/ps_searchbar.php
Normal file
107
modules/ps_searchbar/ps_searchbar.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2020 PrestaShop SA 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.
|
||||
*
|
||||
* 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-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;
|
||||
}
|
||||
|
||||
$autoloadPath = __DIR__ . '/vendor/autoload.php';
|
||||
if (file_exists($autoloadPath)) {
|
||||
require_once $autoloadPath;
|
||||
}
|
||||
|
||||
use PrestaShop\PrestaShop\Core\Module\WidgetInterface;
|
||||
|
||||
class Ps_Searchbar extends Module implements WidgetInterface
|
||||
{
|
||||
/**
|
||||
* @var string Name of the module running on PS 1.6.x. Used for data migration.
|
||||
*/
|
||||
const PS_16_EQUIVALENT_MODULE = 'blocksearch';
|
||||
|
||||
private $templateFile;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->name = 'ps_searchbar';
|
||||
$this->author = 'PrestaShop';
|
||||
$this->version = '2.0.2';
|
||||
$this->need_instance = 0;
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->displayName = $this->trans('Search bar', [], 'Modules.Searchbar.Admin');
|
||||
$this->description = $this->trans('Help your visitors find what they are looking for, add a quick search field to your store.', [], 'Modules.Searchbar.Admin');
|
||||
|
||||
$this->ps_versions_compliancy = ['min' => '1.7.1.0', 'max' => _PS_VERSION_];
|
||||
|
||||
$this->templateFile = 'module:ps_searchbar/ps_searchbar.tpl';
|
||||
}
|
||||
|
||||
public function install()
|
||||
{
|
||||
// Migrate data from 1.6 equivalent module (if applicable), then uninstall
|
||||
if (Module::isInstalled(self::PS_16_EQUIVALENT_MODULE)) {
|
||||
$oldModule = Module::getInstanceByName(self::PS_16_EQUIVALENT_MODULE);
|
||||
if ($oldModule) {
|
||||
$oldModule->uninstall();
|
||||
}
|
||||
}
|
||||
|
||||
return parent::install()
|
||||
&& $this->registerHook('top')
|
||||
&& $this->registerHook('displaySearch')
|
||||
&& $this->registerHook('header')
|
||||
;
|
||||
}
|
||||
|
||||
public function hookHeader()
|
||||
{
|
||||
$this->context->controller->addJqueryUI('ui.autocomplete');
|
||||
$this->context->controller->registerJavascript('modules-searchbar', 'modules/' . $this->name . '/ps_searchbar.js', ['position' => 'bottom', 'priority' => 150]);
|
||||
}
|
||||
|
||||
public function getWidgetVariables($hookName, array $configuration = [])
|
||||
{
|
||||
$widgetVariables = [
|
||||
'search_controller_url' => $this->context->link->getPageLink('search', null, null, null, false, null, true),
|
||||
];
|
||||
|
||||
/** @var array $templateVars */
|
||||
$templateVars = $this->context->smarty->getTemplateVars();
|
||||
if (is_array($templateVars) && !array_key_exists('search_string', $templateVars)) {
|
||||
$widgetVariables['search_string'] = '';
|
||||
}
|
||||
|
||||
return $widgetVariables;
|
||||
}
|
||||
|
||||
public function renderWidget($hookName, array $configuration = [])
|
||||
{
|
||||
$this->smarty->assign($this->getWidgetVariables($hookName, $configuration));
|
||||
|
||||
return $this->fetch($this->templateFile);
|
||||
}
|
||||
}
|
||||
34
modules/ps_searchbar/ps_searchbar.tpl
Normal file
34
modules/ps_searchbar/ps_searchbar.tpl
Normal file
@@ -0,0 +1,34 @@
|
||||
{**
|
||||
* 2007-2020 PrestaShop SA 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.
|
||||
*
|
||||
* 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-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 id="search_widget" data-search-controller-url="{$search_controller_url}">
|
||||
<form method="get" action="{$search_controller_url}">
|
||||
<input type="hidden" name="controller" value="search">
|
||||
<input type="text" name="s" value="{$search_string}">
|
||||
<button type="submit">
|
||||
{l s='Search' d='Modules.Searchbar.Shop'}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
34
modules/ps_searchbar/translations/index.php
Normal file
34
modules/ps_searchbar/translations/index.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2020 PrestaShop SA 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.
|
||||
*
|
||||
* 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-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;
|
||||
0
modules/ps_searchbar/translations/pl.php
Normal file
0
modules/ps_searchbar/translations/pl.php
Normal file
Reference in New Issue
Block a user