feat: VivesPOS landing on Winter CMS 1.2 — theme + plugin + Dockerfile
Some checks are pending
Module sub-split / Sub-split (push) Waiting to run
Some checks are pending
Module sub-split / Sub-split (push) Waiting to run
- Base: wintercms/winter branch 1.2 (full framework) - Theme vivespos: Canvas 7 + Bootstrap 5 CDN, custom CSS - Layout: deferred GTM/GA4 tracking, JSON-LD SoftwareApplication - Partials: hero (offline-first), features, modes (offline/nube toggle), screenshots, pricing (3 planes), comparison, FAQ, CTA - Plugin VivesPOS.Site with ContactForm - Dockerfile: PHP 8.2 Apache, port 80, healthcheck - Added winter/wn-pages, blog, sitemap, seo plugins - Active theme set to vivespos
This commit is contained in:
174
modules/backend/widgets/Search.php
Normal file
174
modules/backend/widgets/Search.php
Normal file
@@ -0,0 +1,174 @@
|
||||
<?php namespace Backend\Widgets;
|
||||
|
||||
use Lang;
|
||||
use Backend\Classes\WidgetBase;
|
||||
|
||||
/**
|
||||
* Search Widget
|
||||
* Used for building a toolbar, Renders a search container.
|
||||
*
|
||||
* @package winter\wn-backend-module
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*/
|
||||
class Search extends WidgetBase
|
||||
{
|
||||
//
|
||||
// Configurable properties
|
||||
//
|
||||
|
||||
/**
|
||||
* @var string Search placeholder text.
|
||||
*/
|
||||
public $prompt;
|
||||
|
||||
/**
|
||||
* @var bool Field show grow when selected.
|
||||
*/
|
||||
public $growable = true;
|
||||
|
||||
/**
|
||||
* @var string Custom partial file definition, in context of the controller.
|
||||
*/
|
||||
public $partial;
|
||||
|
||||
/**
|
||||
* @var string Defines the search mode. Commonly passed to the searchWhere() query.
|
||||
*/
|
||||
public $mode;
|
||||
|
||||
/**
|
||||
* @var string Custom scope method name. Commonly passed to the query.
|
||||
*/
|
||||
public $scope;
|
||||
|
||||
/**
|
||||
* @var bool Search on enter key instead of every key stroke.
|
||||
*/
|
||||
public $searchOnEnter = false;
|
||||
|
||||
//
|
||||
// Object properties
|
||||
//
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected $defaultAlias = 'search';
|
||||
|
||||
/**
|
||||
* @var string Active search term pulled from session data.
|
||||
*/
|
||||
protected $activeTerm;
|
||||
|
||||
/**
|
||||
* @var array List of CSS classes to apply to the list container element.
|
||||
*/
|
||||
public $cssClasses = [];
|
||||
|
||||
/**
|
||||
* Initialize the widget, called by the constructor and free from its parameters.
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$this->fillFromConfig([
|
||||
'prompt',
|
||||
'partial',
|
||||
'growable',
|
||||
'scope',
|
||||
'mode',
|
||||
'searchOnEnter',
|
||||
]);
|
||||
|
||||
/*
|
||||
* Add CSS class styles
|
||||
*/
|
||||
$this->cssClasses[] = 'icon search';
|
||||
|
||||
if ($this->growable) {
|
||||
$this->cssClasses[] = 'growable';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the widget.
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$this->prepareVars();
|
||||
|
||||
if ($this->partial) {
|
||||
return $this->controller->makePartial($this->partial);
|
||||
}
|
||||
|
||||
return $this->makePartial('search');
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares the view data
|
||||
*/
|
||||
public function prepareVars()
|
||||
{
|
||||
$this->vars['cssClasses'] = implode(' ', $this->cssClasses);
|
||||
$this->vars['placeholder'] = Lang::get($this->prompt);
|
||||
$this->vars['value'] = $this->getActiveTerm();
|
||||
$this->vars['searchOnEnter'] = $this->searchOnEnter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search field has been submitted.
|
||||
*/
|
||||
public function onSubmit()
|
||||
{
|
||||
/*
|
||||
* Save or reset search term in session
|
||||
*/
|
||||
$this->setActiveTerm(post($this->getName()));
|
||||
|
||||
/*
|
||||
* Trigger class event, merge results as viewable array
|
||||
*/
|
||||
$params = func_get_args();
|
||||
try {
|
||||
$result = $this->fireEvent('search.submit', [$params]);
|
||||
} catch (\Throwable $e) {
|
||||
// Remove the search term from the session if the search has failed.
|
||||
$this->setActiveTerm('');
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if ($result && is_array($result)) {
|
||||
return call_user_func_array('array_merge', $result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an active search term for this widget instance.
|
||||
*/
|
||||
public function getActiveTerm()
|
||||
{
|
||||
return $this->activeTerm = $this->getSession('term', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an active search term for this widget instance.
|
||||
*/
|
||||
public function setActiveTerm($term)
|
||||
{
|
||||
if (strlen($term)) {
|
||||
$this->putSession('term', $term);
|
||||
} else {
|
||||
$this->resetSession();
|
||||
}
|
||||
|
||||
$this->activeTerm = $term;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value suitable for the field name property.
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->alias . '[term]';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user