mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 02:28:44 +02:00
N°4622 - Advanced search: Fix dictionaries being retrieved by XHR calls
This commit is contained in:
@@ -745,7 +745,7 @@ $(function()
|
||||
{
|
||||
var sErrorMessage = Dict.Format('Error:XHR:Fail', '');
|
||||
|
||||
this._setACHint('=/');
|
||||
this._setACHint(sErrorMessage);
|
||||
this.handler.triggerHandler('itop.search.criteria.error_occured', sErrorMessage);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1566,29 +1566,31 @@ JS;
|
||||
*/
|
||||
protected function output_dict_entries($bReturnOutput = false)
|
||||
{
|
||||
/** @var \iBackofficeDictEntriesExtension $oExtensionInstance */
|
||||
foreach (MetaModel::EnumPlugins('iBackofficeDictEntriesExtension') as $oExtensionInstance) {
|
||||
foreach ($oExtensionInstance->GetDictEntries() as $sDictEntry) {
|
||||
$this->add_dict_entry($sDictEntry);
|
||||
}
|
||||
}
|
||||
/** @var \iBackofficeDictEntriesPrefixesExtension $oExtensionInstance */
|
||||
foreach (MetaModel::EnumPlugins('iBackofficeDictEntriesPrefixesExtension') as $oExtensionInstance) {
|
||||
foreach ($oExtensionInstance->GetDictEntriesPrefixes() as $sDictEntryPrefix) {
|
||||
$this->add_dict_entries($sDictEntryPrefix);
|
||||
}
|
||||
}
|
||||
if ((count($this->a_dict_entries) > 0) || (count($this->a_dict_entries_prefixes) > 0)) {
|
||||
if (class_exists('Dict')) {
|
||||
// The dictionary may not be available for example during the setup...
|
||||
// Create a specific dictionary file and load it as a JS script
|
||||
$sSignature = $this->get_dict_signature();
|
||||
$sJSFileName = utils::GetCachePath().$sSignature.'.js';
|
||||
if (!file_exists($sJSFileName) && is_writable(utils::GetCachePath())) {
|
||||
file_put_contents($sJSFileName, $this->get_dict_file_content());
|
||||
if ($this->sContentType != 'text/plain' && $this->sContentType != 'application/json') {
|
||||
/** @var \iBackofficeDictEntriesExtension $oExtensionInstance */
|
||||
foreach (MetaModel::EnumPlugins('iBackofficeDictEntriesExtension') as $oExtensionInstance) {
|
||||
foreach ($oExtensionInstance->GetDictEntries() as $sDictEntry) {
|
||||
$this->add_dict_entry($sDictEntry);
|
||||
}
|
||||
}
|
||||
/** @var \iBackofficeDictEntriesPrefixesExtension $oExtensionInstance */
|
||||
foreach (MetaModel::EnumPlugins('iBackofficeDictEntriesPrefixesExtension') as $oExtensionInstance) {
|
||||
foreach ($oExtensionInstance->GetDictEntriesPrefixes() as $sDictEntryPrefix) {
|
||||
$this->add_dict_entries($sDictEntryPrefix);
|
||||
}
|
||||
}
|
||||
if ((count($this->a_dict_entries) > 0) || (count($this->a_dict_entries_prefixes) > 0)) {
|
||||
if (class_exists('Dict')) {
|
||||
// The dictionary may not be available for example during the setup...
|
||||
// Create a specific dictionary file and load it as a JS script
|
||||
$sSignature = $this->get_dict_signature();
|
||||
$sJSFileName = utils::GetCachePath().$sSignature.'.js';
|
||||
if (!file_exists($sJSFileName) && is_writable(utils::GetCachePath())) {
|
||||
file_put_contents($sJSFileName, $this->get_dict_file_content());
|
||||
}
|
||||
// Load the dictionary as the first javascript file, so that other JS file benefit from the translations
|
||||
array_unshift($this->a_linked_scripts, utils::GetAbsoluteUrlAppRoot().'pages/ajax.document.php?operation=dict&s='.$sSignature);
|
||||
}
|
||||
// Load the dictionary as the first javascript file, so that other JS file benefit from the translations
|
||||
array_unshift($this->a_linked_scripts, utils::GetAbsoluteUrlAppRoot().'pages/ajax.document.php?operation=dict&s='.$sSignature);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -841,10 +841,6 @@ HTML;
|
||||
foreach (MetaModel::EnumPlugins('iBackofficeStyleExtension') as $oExtensionInstance) {
|
||||
$this->add_style($oExtensionInstance->GetStyle());
|
||||
}
|
||||
// - Generate necessary dict. files
|
||||
if ($this->bAddJSDict) {
|
||||
$this->output_dict_entries();
|
||||
}
|
||||
|
||||
// TODO 3.0.0 not displayed ?
|
||||
$this->GetContentLayout()->SetExtraHtmlContent(utils::FilterXSS($this->s_content));
|
||||
@@ -909,9 +905,13 @@ HTML;
|
||||
|
||||
// Components
|
||||
// Note: For now all components are either included in the layouts above or put in page through the AddUiBlock() API, so there is no need to do anything more.
|
||||
|
||||
$this->InitializeKeyboardShortcuts();
|
||||
|
||||
// - Generate necessary dict. files
|
||||
if ($this->bAddJSDict) {
|
||||
$this->output_dict_entries();
|
||||
}
|
||||
|
||||
// Variable content of the page
|
||||
$aData['aPage'] = array_merge(
|
||||
$aData['aPage'],
|
||||
|
||||
Reference in New Issue
Block a user