diff --git a/application/ajaxwebpage.class.inc.php b/application/ajaxwebpage.class.inc.php index 2717943a2..4561b0a36 100644 --- a/application/ajaxwebpage.class.inc.php +++ b/application/ajaxwebpage.class.inc.php @@ -214,7 +214,9 @@ PrepareWidgets(); EOF ); } - $s_captured_output = $this->ob_get_clean_safe(); + $this->outputCollapsibleSectionInit(); + + $s_captured_output = $this->ob_get_clean_safe(); if (($this->sContentType == 'text/html') && ($this->sContentDisposition == 'inline')) { // inline content != attachment && html => filter all scripts for malicious XSS scripts diff --git a/application/itopwebpage.class.inc.php b/application/itopwebpage.class.inc.php index 4d3add51f..ab2868c82 100644 --- a/application/itopwebpage.class.inc.php +++ b/application/itopwebpage.class.inc.php @@ -46,8 +46,6 @@ class iTopWebPage extends NiceWebPage implements iTabbedPage protected $sBreadCrumbEntryIcon; protected $oCtx; - protected $bHasCollapsibleSection = false; - public function __construct($sTitle, $bPrintable = false) { parent::__construct($sTitle, $bPrintable); @@ -1436,38 +1434,6 @@ EOF; ExecutionKPI::ReportStats(); } - /** - * Adds init scripts for the collapsible sections - */ - private function outputCollapsibleSectionInit() - { - if (!$this->bHasCollapsibleSection) - { - return; - } - - $this->add_script(<<<'EOD' -function initCollapsibleSection(iSectionId, bOpenedByDefault, sSectionStateStorageKey) -{ -var bStoredSectionState = JSON.parse(localStorage.getItem(sSectionStateStorageKey)); -var bIsSectionOpenedInitially = (bStoredSectionState == null) ? bOpenedByDefault : bStoredSectionState; - -if (bIsSectionOpenedInitially) { - $("#LnkCollapse_"+iSectionId).toggleClass("open"); - $("#Collapse_"+iSectionId).toggle(); -} - -$("#LnkCollapse_"+iSectionId).click(function(e) { - localStorage.setItem(sSectionStateStorageKey, !($("#Collapse_"+iSectionId).is(":visible"))); - $("#LnkCollapse_"+iSectionId).toggleClass("open"); - $("#Collapse_"+iSectionId).slideToggle("normal"); - e.preventDefault(); // we don't want to do anything more (see #1030 : a non wanted tab switching was triggered) -}); -} -EOD - ); - } - public function AddTabContainer($sTabContainer, $sPrefix = '') { $this->add($this->m_oTabs->AddTabContainer($sTabContainer, $sPrefix)); @@ -1538,43 +1504,6 @@ EOD $this->add_ready_script($this->m_oTabs->SelectTab($sTabContainer, $sTabLabel)); } - public function StartCollapsibleSection( - $sSectionLabel, $bOpenedByDefault = false, $sSectionStateStorageBusinessKey = '' - ) { - $this->add($this->GetStartCollapsibleSection($sSectionLabel, $bOpenedByDefault, - $sSectionStateStorageBusinessKey)); - } - - private function GetStartCollapsibleSection( - $sSectionLabel, $bOpenedByDefault = false, $sSectionStateStorageBusinessKey = '' - ) { - $this->bHasCollapsibleSection = true; - $sHtml = ''; - static $iSectionId = 0; - $sHtml .= ''.$sSectionLabel.'
'."\n"; - $sHtml .= '"; - } - public function add($sHtml) { if (($this->m_oTabs->GetCurrentTabContainer() != '') && ($this->m_oTabs->GetCurrentTab() != '')) diff --git a/application/webpage.class.inc.php b/application/webpage.class.inc.php index d06c5c06e..290823a14 100644 --- a/application/webpage.class.inc.php +++ b/application/webpage.class.inc.php @@ -80,6 +80,8 @@ class WebPage implements Page protected $s_sOutputFormat; protected $a_OutputOptions; protected $bPrintable; + protected $bHasCollapsibleSection; + public function __construct($s_title, $bPrintable = false) { @@ -102,6 +104,7 @@ class WebPage implements Page $this->bTrashUnexpectedOutput = false; $this->s_OutputFormat = utils::ReadParam('output_format', 'html'); $this->a_OutputOptions = array(); + $this->bHasCollapsibleSection = false; $this->bPrintable = $bPrintable; ob_start(); // Start capturing the output } @@ -887,6 +890,73 @@ class WebPage implements Page } } } + + + /** + * Adds init scripts for the collapsible sections + */ + protected function outputCollapsibleSectionInit() + { + if (!$this->bHasCollapsibleSection) + { + return; + } + + $this->add_script(<<<'EOD' +function initCollapsibleSection(iSectionId, bOpenedByDefault, sSectionStateStorageKey) +{ +var bStoredSectionState = JSON.parse(localStorage.getItem(sSectionStateStorageKey)); +var bIsSectionOpenedInitially = (bStoredSectionState == null) ? bOpenedByDefault : bStoredSectionState; + +if (bIsSectionOpenedInitially) { + $("#LnkCollapse_"+iSectionId).toggleClass("open"); + $("#Collapse_"+iSectionId).toggle(); +} + +$("#LnkCollapse_"+iSectionId).click(function(e) { + localStorage.setItem(sSectionStateStorageKey, !($("#Collapse_"+iSectionId).is(":visible"))); + $("#LnkCollapse_"+iSectionId).toggleClass("open"); + $("#Collapse_"+iSectionId).slideToggle("normal"); + e.preventDefault(); // we don't want to do anything more (see #1030 : a non wanted tab switching was triggered) +}); +} +EOD + ); + } + public function StartCollapsibleSection($sSectionLabel, $bOpenedByDefault = false, $sSectionStateStorageBusinessKey = '') + { + $this->add($this->GetStartCollapsibleSection($sSectionLabel, $bOpenedByDefault, $sSectionStateStorageBusinessKey)); + } + + private function GetStartCollapsibleSection($sSectionLabel, $bOpenedByDefault = false, $sSectionStateStorageBusinessKey = '') + { + $this->bHasCollapsibleSection = true; + $sHtml = ''; + static $iSectionId = 0; + $sHtml .= ''.$sSectionLabel.'
'."\n"; + $sHtml .= '"; + } + } diff --git a/pages/ajax.searchform.php b/pages/ajax.searchform.php index d4ab06b19..859d9edcf 100644 --- a/pages/ajax.searchform.php +++ b/pages/ajax.searchform.php @@ -64,12 +64,6 @@ try } $oFilter = CriterionParser::Parse($aParams['base_oql'], $aParams['criterion'], $sHiddenCriteria); - if (isset($aListParams['debug'])) - { - $sOQL = $oFilter->ToOQL(); - $oPage->add("
$sOQL
\n"); - } - //IssueLog::Info('Search OQL: "'.$oFilter->ToOQL().'"'); $oDisplayBlock = new DisplayBlock($oFilter, 'list_search', false); @@ -122,6 +116,13 @@ try } + if (isset($aListParams['debug']) || UserRights::IsAdministrator()) + { + $oPage->StartCollapsibleSection(Dict::S('UI:RunQuery:MoreInfo'), false, 'SearchQuery'); + $oPage->p(Dict::S('UI:RunQuery:DevelopedQuery').htmlentities($oFilter->ToOQL(), ENT_QUOTES, 'UTF-8')); + $oPage->EndCollapsibleSection(); + } + $oPage->output(); } catch (AjaxSearchException $e)