first commit

This commit is contained in:
2024-11-05 12:22:50 +01:00
commit e5682a3912
19641 changed files with 2948548 additions and 0 deletions

1677
modules/ps_searchbar/composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

View 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.1.3]]></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>

View 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.1.3]]></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[front_office_features]]></tab>
<is_configurable>0</is_configurable>
<need_instance>0</need_instance>
<limited_countries></limited_countries>
</module>

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

@@ -0,0 +1,73 @@
#header, #header .header-top {
background-color: white;
}
#search_widget {
margin-bottom: .625rem;
overflow: auto;
}
#search_widget form {
position: relative;
}
#search_widget form i {
position: absolute;
padding: .5rem;
}
#search_widget form i.clear {
right: 15px;
display: none;
}
#search_widget form input {
width: 100%;
padding: 10px 20px 10px 40px;
outline: none;
background-color: #f1f1f1;
border: none;
border-radius: 5px;
}
.ui-autocomplete.searchbar-autocomplete {
width: 100%;
min-height: 100%;
border: none;
}
.ui-autocomplete.searchbar-autocomplete li a, .ui-autocomplete.searchbar-autocomplete li a.ui-state-focus {
padding: 8px 15px;
overflow: auto;
border: none;
background: none;
margin: auto;
border-radius: 0;
}
.ui-autocomplete.searchbar-autocomplete li a:hover {
background-color: #f1f1f1;
cursor: pointer;
}
.ui-autocomplete.searchbar-autocomplete li a .autocomplete-thumbnail {
float: left;
width: 50px;
height: auto;
margin-right: 8px;
}
@media only screen and (min-width: 768px) {
#search_widget {
float: right;
margin-bottom: 0;
}
.ui-autocomplete.searchbar-autocomplete {
width: 400px;
min-height: auto;
left: auto;
}
}
@media only screen and (min-width: 992px) {
#search_widget {
min-width: 16.5rem;
}
}

View File

@@ -0,0 +1,65 @@
/* global $ */
$(document).ready(function () {
var $searchWidget = $('#search_widget');
var $searchBox = $searchWidget.find('input[type=text]');
var searchURL = $searchWidget.attr('data-search-controller-url');
var $clearButton = $searchWidget.find('i.clear');
$.widget('prestashop.psBlockSearchAutocomplete', $.ui.autocomplete, {
_renderItem: function (ul, product) {
var image = (product.cover) ? product.cover : prestashop.urls.no_picture_image;
var $img = $('<img class="autocomplete-thumbnail" src="'+image.bySize.small_default.url+'">');
return $("<li>")
.append($("<a>")
.append($img)
.append($("<span>").html(product.name).addClass("product"))
).appendTo(ul)
;
}
});
var isMobile = function() {
return $(window).width() < 768;
};
var autocompletePosition = function() {
return {
my: 'right top',
at: 'right bottom',
of: isMobile() ? '.header-top' : '#search_widget',
};
};
$searchBox.psBlockSearchAutocomplete({
position: autocompletePosition(),
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;
},
}).psBlockSearchAutocomplete("widget").addClass('searchbar-autocomplete');
$(window).resize(function() {
$searchBox.psBlockSearchAutocomplete({
position: autocompletePosition(),
});
$searchBox.keyup();
});
$clearButton.click(function() {
$searchBox.val("");
$clearButton.hide();
});
$searchBox.keyup(function() {
$clearButton.toggle($searchBox.val() !== "" && isMobile());
});
});

View File

@@ -0,0 +1,109 @@
<?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->tab = 'front_office_features';
$this->author = 'PrestaShop';
$this->version = '2.1.3';
$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.8.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('displayTop')
&& $this->registerHook('displaySearch')
&& $this->registerHook('displayHeader')
;
}
public function hookDisplayHeader()
{
$this->context->controller->addJqueryUI('ui.autocomplete');
$this->context->controller->registerStylesheet('modules-searchbar', 'modules/' . $this->name . '/ps_searchbar.css');
$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);
}
}

View File

@@ -0,0 +1,33 @@
{**
* 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" class="search-widgets" data-search-controller-url="{$search_controller_url}">
<form method="get" action="{$search_controller_url}">
<input type="hidden" name="controller" value="search">
<i class="material-icons search" aria-hidden="true">search</i>
<input type="text" name="s" value="{$search_string}" placeholder="{l s='Search our catalog' d='Shop.Theme.Catalog'}" aria-label="{l s='Search' d='Shop.Theme.Catalog'}">
<i class="material-icons clear" aria-hidden="true">clear</i>
</form>
</div>

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

View File

View File

@@ -0,0 +1,53 @@
<?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 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://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
if (!defined('_PS_VERSION_')) {
exit;
}
// In the latest version PrestaShop 1.7.8 the override for this module in classic theme was removed
// because the module is now self-sufficient, so we disable it from the theme to make sure the correct
// internal template is used (we only clean the theme from core classic theme, and only if it was not
// updated). Since this version of the module is only compatible starting PS 1.7.8 this clean can always
// be performed regardless of the current PrestaShop version.
// We don't delete the file but rather rename it so that the merchant can perform a rollback in case important
// changes were present in the file
function upgrade_module_2_1_2($module)
{
$module->unregisterHook('top');
$module->registerHook('displayTop');
$module->unregisterHook('header');
$module->registerHook('displayHeader');
if (defined('_PS_ROOT_DIR_')) {
$coreThemeFile = realpath(_PS_ROOT_DIR_ . '/themes/classic/modules/ps_searchbar/ps_searchbar.tpl');
if (file_exists($coreThemeFile)) {
@rename($coreThemeFile, $coreThemeFile . '.bak');
}
}
return true;
}