mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-01 06:28:46 +02:00
N°2847 - Rework iTopWebPage layout (WIP Part VI)
- iTopWebPage: Restore "open search" feature - iTopWebPage: Change all resources URL to absolute in order to benefit from the "duplicate removal" benefits - iTopWebPage: Remove obsolete method IsMenuPaneVisible() - Config: Add new parameters quick_create.enabled / global_search.enabled / breadcrumb.enabled - utils: Add new GetAppRevisionNumber() method - Introduce iUIBlock interface for UI layouts, components, ... - Introduce BlockRenderer to properly render blocks - Add "render_block" function to TwigHelper to render blocks directly from TWIG - Refactor layouts and components into proper block classes to fit the new architecture
This commit is contained in:
115
sources/application/UI/Component/GlobalSearch/GlobalSearch.php
Normal file
115
sources/application/UI/Component/GlobalSearch/GlobalSearch.php
Normal file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2013-2020 Combodo SARL
|
||||
*
|
||||
* This file is part of iTop.
|
||||
*
|
||||
* iTop is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* iTop is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
*/
|
||||
|
||||
namespace Combodo\iTop\Application\UI\Component\GlobalSearch;
|
||||
|
||||
|
||||
use Combodo\iTop\Application\UI\UIBlock;
|
||||
use utils;
|
||||
|
||||
/**
|
||||
* Class GlobalSearch
|
||||
*
|
||||
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
|
||||
* @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 $aLastClasses
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __construct($sId = null, $aLastClasses = [])
|
||||
{
|
||||
parent::__construct($sId);
|
||||
$this->SetEndpoint(static::DEFAULT_ENDPOINT_REL_URL);
|
||||
$this->SetLastQueries($aLastClasses);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 $this
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user