<?php
/**
* Copyright (C) 2021 Rhyme Digital, LLC
*
* @author Blair Winans <blair@rhyme.digital>
* @author Adam Fisher <adam@rhyme.digital>
* @link https://rhyme.digital
* @license http://www.gnu.org/licenses/lgpl-3.0.html LGPL
*/
namespace Rhyme\WMassArtsHub\ProfileFilter;
use Contao\Input;
use Contao\Template;
use Contao\Module;
/**
* Class Keywords
* Keywords filter
*/
class Keywords extends ProfileFilter
{
/**
* Filter key
* @var string
*/
protected static $strKey = 'keywords';
/**
* Add this filter to the module's template or get the URL params
* @param Template $objTemplate
* @param Module $objModule
* @param bool $blnGenURL
* @return bool|mixed|string
*/
public static function generateFilter(Template &$objTemplate, Module $objModule, bool $blnGenURL=false)
{
if($blnGenURL)
{
// Return the URL fragment needed for this filter to pass to the lister
if ((Input::post(static::$strKey)) && \trim(Input::post(static::$strKey)) != $GLOBALS['TL_LANG']['MSC']['defaultSearchText'])
{
return static::$strKey . '/' . \urlencode(ProfileFilter::cleanChars(Input::post(static::$strKey)));
}
return false;
}
$objTemplate->hasSearch = true;
$objTemplate->hasAutocomplete = \strlen($objModule->artshub_searchAutocomplete) ? true : false;
$objTemplate->keywords = htmlentities(ProfileFilter::uncleanChars(Input::get(static::$strKey)));
$objTemplate->pkeywordsLabel = $GLOBALS['TL_LANG']['MSC'][static::$strKey.'FilterLabel'];
$objTemplate->defaultSearchText = $GLOBALS['TL_LANG']['MSC']['defaultSearchText'];
}
}