* @package Combodo\iTop\Application\UI\Component\GlobalSearch * @internal * @since 2.8.0 */ class GlobalSearch extends UIBlock { const BLOCK_CODE = 'ibo-global-search'; const HTML_TEMPLATE_REL_PATH = 'components/global-search/layout'; const JS_TEMPLATE_REL_PATH = 'components/global-search/layout'; const JS_FILES_REL_PATH = [ 'js/components/global-search.js', ]; const DEFAULT_ENDPOINT_REL_URL = 'pages/UI.php?operation=full_text'; /** @var string $sEndpoint Absolute endpoint URL of the search form */ protected $sEndpoint; /** @var array $aLastQueries */ protected $aLastQueries; /** * GlobalSearch constructor. * * @param string $sId * @param array $aLastQueries * * @throws \Exception */ public function __construct($sId = null, $aLastQueries = []) { parent::__construct($sId); $this->SetEndpoint(static::DEFAULT_ENDPOINT_REL_URL); $this->SetLastQueries($aLastQueries); } /** * Set the search form endpoint URL. * If $bRelativeUrl is true, then $sEndpoint will be complete with the app_root_url * * @param string $sEndpoint URL to the endpoint * @param bool $bRelativeUrl Whether or not the $sEndpoint parameter is a relative URL * * @return $this * @throws \Exception */ public function SetEndpoint($sEndpoint, $bRelativeUrl = true) { $this->sEndpoint = (($bRelativeUrl) ? utils::GetAbsoluteUrlAppRoot() : '') . $sEndpoint; return $this; } /** * Return the absolute URL of the search form * * @return string * @throws \Exception */ public function GetEndpoint() { return $this->sEndpoint; } /** * Set all the last queries at once * * @param array $aLastQueries * * @return $this */ public function SetLastQueries($aLastQueries) { $this->aLastQueries = $aLastQueries; return $this; } /** * Return the last queries (query itself, label as HTML) * * @return array */ public function GetLastQueries() { return $this->aLastQueries; } }