diff --git a/application/itopwebpage.class.inc.php b/application/itopwebpage.class.inc.php index 2e68548b3..cd507e9ea 100644 --- a/application/itopwebpage.class.inc.php +++ b/application/itopwebpage.class.inc.php @@ -1581,6 +1581,47 @@ EOD } } + /** + * @param string $sTitle + * @param string[] $aIssues + * + * @see AddHeaderMessage + */ + public function AddHeaderMessageForErrors($sTitle, $aIssues) + { + $sContent = "$sTitle"; + + if (count($aIssues) == 1) + { + $sContent .= " {$aIssues[0]}"; + } + else + { + $sContent .= '\n'; + } + + $this->AddHeaderMessage($sContent, 'message_error'); + } + + /** + * Adds in the page a container with the header_message CSS class + * + * @param string $sContent + * @param string $sCssClasses CSS classes to add to the container + */ + public function AddHeaderMessage($sContent, $sCssClasses = 'message_info') + { + $this->add(<<$sContent +EOF + ); + } + /** * Adds a script to be executed when the DOM is ready (typical JQuery use), right before add_ready_script * diff --git a/dictionaries/cs.dictionary.itop.ui.php b/dictionaries/cs.dictionary.itop.ui.php index fbe5b228e..23603fcbb 100755 --- a/dictionaries/cs.dictionary.itop.ui.php +++ b/dictionaries/cs.dictionary.itop.ui.php @@ -393,6 +393,7 @@ Dict::Add('CS CZ', 'Czech', 'Čeština', array( 'UI:ClickToCreateNew' => 'Nový objekt (%1$s)', 'UI:SearchFor_Class' => 'Hledat objekty třídy %1$s', 'UI:NoObjectToDisplay' => 'Žádný objekt k zobrazení.', + 'UI:Error:SaveFailed' => 'The object cannot be saved :~~', 'UI:Error:MandatoryTemplateParameter_object_id' => 'Parametr object_id je povinný, pokud je uveden parametr link_attr. Zkontrolujte definici šablony zobrazení.', 'UI:Error:MandatoryTemplateParameter_target_attr' => 'Parametr target_attr je povinný, pokud je uveden parametr link_attr. Zkontrolujte definici šablony zobrazení.', 'UI:Error:MandatoryTemplateParameter_group_by' => 'Parametr group_by je povinný. Zkontrolujte definici šablony zobrazení.', diff --git a/dictionaries/da.dictionary.itop.ui.php b/dictionaries/da.dictionary.itop.ui.php index 1d5189195..413517250 100644 --- a/dictionaries/da.dictionary.itop.ui.php +++ b/dictionaries/da.dictionary.itop.ui.php @@ -270,6 +270,7 @@ Dict::Add('DA DA', 'Danish', 'Dansk', array( 'UI:ClickToCreateNew' => 'Opret nyt objekt af typen %1$s ', 'UI:SearchFor_Class' => 'Søg efter objekter af typen %1$s ', 'UI:NoObjectToDisplay' => 'Ingen objekter at vise.', + 'UI:Error:SaveFailed' => 'The object cannot be saved :~~', 'UI:Error:MandatoryTemplateParameter_object_id' => 'Parameter objekt_id er obligatorisk når link_attr er specificeret. Tjek definitionen af display skabelonen.', 'UI:Error:MandatoryTemplateParameter_target_attr' => 'Parameter objekt_id er obligatorisk når link_attr er specificeret. Tjek definitionen af display skabelonen.', 'UI:Error:MandatoryTemplateParameter_group_by' => 'Parameter group_by er obligatorisk. Tjek definitionen af display skabelonen.', diff --git a/dictionaries/de.dictionary.itop.ui.php b/dictionaries/de.dictionary.itop.ui.php index 37f502da5..a480d4d2c 100644 --- a/dictionaries/de.dictionary.itop.ui.php +++ b/dictionaries/de.dictionary.itop.ui.php @@ -276,6 +276,7 @@ Dict::Add('DE DE', 'German', 'Deutsch', array( 'UI:ClickToCreateNew' => 'Klicken Sie hier, um eine neues Objekt vom Typ %1$s zu erstellen', 'UI:SearchFor_Class' => 'Suche nach Objekten vom Typ "%1$s"', 'UI:NoObjectToDisplay' => 'Kein Objekt zur Anzeige vorhanden.', + 'UI:Error:SaveFailed' => 'The object cannot be saved :~~', 'UI:Error:MandatoryTemplateParameter_object_id' => 'Parameter object_id ist erforderlich, wenn link_attr verwendet wird. Überprüfen Sie die Defintion des Display-Templates.', 'UI:Error:MandatoryTemplateParameter_target_attr' => 'Parameter target_attr ist erforderlich, wenn link_attr verwendet wird. Überprüfen Sie die Defintion des Display-Templates.', 'UI:Error:MandatoryTemplateParameter_group_by' => 'Parameter group_by ist erforderlich. Überprüfen Sie die Defintion des Display-Templates.', diff --git a/dictionaries/en.dictionary.itop.ui.php b/dictionaries/en.dictionary.itop.ui.php index 48022abf3..a22b161bd 100644 --- a/dictionaries/en.dictionary.itop.ui.php +++ b/dictionaries/en.dictionary.itop.ui.php @@ -411,6 +411,7 @@ Dict::Add('EN US', 'English', 'English', array( 'UI:ClickToCreateNew' => 'Create a new %1$s', 'UI:SearchFor_Class' => 'Search for %1$s objects', 'UI:NoObjectToDisplay' => 'No object to display.', + 'UI:Error:SaveFailed' => 'The object cannot be saved :', 'UI:Error:MandatoryTemplateParameter_object_id' => 'Parameter object_id is mandatory when link_attr is specified. Check the definition of the display template.', 'UI:Error:MandatoryTemplateParameter_target_attr' => 'Parameter target_attr is mandatory when link_attr is specified. Check the definition of the display template.', 'UI:Error:MandatoryTemplateParameter_group_by' => 'Parameter group_by is mandatory. Check the definition of the display template.', diff --git a/dictionaries/es_cr.dictionary.itop.ui.php b/dictionaries/es_cr.dictionary.itop.ui.php index 93b61c94e..00c6cb65f 100644 --- a/dictionaries/es_cr.dictionary.itop.ui.php +++ b/dictionaries/es_cr.dictionary.itop.ui.php @@ -408,6 +408,7 @@ Dict::Add('ES CR', 'Spanish', 'Español, Castellano', array( 'UI:ClickToCreateNew' => 'Crear %1$s', 'UI:SearchFor_Class' => 'Buscar %1$s', 'UI:NoObjectToDisplay' => 'Ninguna Información por Visualizar.', + 'UI:Error:SaveFailed' => 'The object cannot be saved :~~', 'UI:Error:MandatoryTemplateParameter_object_id' => 'El parámetro object_id es obligatorio cuando link_attr es especificado. Verifique la definición de la plantilla de visualización.', 'UI:Error:MandatoryTemplateParameter_target_attr' => 'El parámetro target_attr es obligatorio cuando link_attr es especificado. Verifique la definición de la plantilla de visualización.', 'UI:Error:MandatoryTemplateParameter_group_by' => 'El parámetro group_by es obligatorio. Verifique la definición de la plantilla de visualización.', diff --git a/dictionaries/fr.dictionary.itop.ui.php b/dictionaries/fr.dictionary.itop.ui.php index ebbb52533..785626432 100644 --- a/dictionaries/fr.dictionary.itop.ui.php +++ b/dictionaries/fr.dictionary.itop.ui.php @@ -279,6 +279,7 @@ Dict::Add('FR FR', 'French', 'Français', array( 'UI:ClickToCreateNew' => 'Créer un nouvel objet de type %1$s', 'UI:SearchFor_Class' => 'Rechercher des objets de type %1$s', 'UI:NoObjectToDisplay' => 'Aucun objet à afficher.', + 'UI:Error:SaveFailed' => 'The object cannot be saved :~~', 'UI:Error:MandatoryTemplateParameter_object_id' => 'Le paramètre object_id est obligatoire quand link_attr est spécifié. Vérifiez la définition du modèle.', 'UI:Error:MandatoryTemplateParameter_target_attr' => 'Le paramètre taarget_attr est obligatoire quand link_attr est spécifié. Vérifiez la définition du modèle.', 'UI:Error:MandatoryTemplateParameter_group_by' => 'Le paramètre group_by est obligatoire. Vérifiez la définition du modèle.', diff --git a/dictionaries/hu.dictionary.itop.ui.php b/dictionaries/hu.dictionary.itop.ui.php index d799f8170..9e83a3f10 100755 --- a/dictionaries/hu.dictionary.itop.ui.php +++ b/dictionaries/hu.dictionary.itop.ui.php @@ -254,6 +254,7 @@ Dict::Add('HU HU', 'Hungarian', 'Magyar', array( 'UI:ClickToCreateNew' => 'Új %1$s létrehozása', 'UI:SearchFor_Class' => '%1$s objektumok keresése', 'UI:NoObjectToDisplay' => 'Nincs megjeleníthető objektum', + 'UI:Error:SaveFailed' => 'The object cannot be saved :~~', 'UI:Error:MandatoryTemplateParameter_object_id' => 'object_id pareméter kötelező a link_attr megadásánál. Ellenőrizze a sablon definíciót.', 'UI:Error:MandatoryTemplateParameter_target_attr' => 'target_attr pareméter kötelező a link_attr megadásánál. Ellenőrizze a sablon definíciót.', 'UI:Error:MandatoryTemplateParameter_group_by' => 'group_by paraméter kötelező. Ellenőrizze a sablon definíciót.', diff --git a/dictionaries/it.dictionary.itop.ui.php b/dictionaries/it.dictionary.itop.ui.php index ddbd0749e..6e223746d 100644 --- a/dictionaries/it.dictionary.itop.ui.php +++ b/dictionaries/it.dictionary.itop.ui.php @@ -383,6 +383,7 @@ Dict::Add('IT IT', 'Italian', 'Italiano', array( 'UI:ClickToCreateNew' => 'Crea un nuovo %1$s~~', 'UI:SearchFor_Class' => 'Cerca l\'oggetto %1$s', 'UI:NoObjectToDisplay' => 'Nessun oggetto da mostrare.', + 'UI:Error:SaveFailed' => 'The object cannot be saved :~~', 'UI:Error:MandatoryTemplateParameter_object_id' => 'Object_id parametro è obbligatorio quando link_attr è specificato. Verificare la definizione del modello di display.', 'UI:Error:MandatoryTemplateParameter_target_attr' => 'Target_attr parametro è obbligatorio quando link_attr è specificato. Verificare la definizione del modello di display.', 'UI:Error:MandatoryTemplateParameter_group_by' => 'Il parametro è group_by obbligatoria. Verificare la definizione del modello di display.', diff --git a/dictionaries/ja.dictionary.itop.ui.php b/dictionaries/ja.dictionary.itop.ui.php index 8a1deb723..f48f30e30 100644 --- a/dictionaries/ja.dictionary.itop.ui.php +++ b/dictionaries/ja.dictionary.itop.ui.php @@ -270,6 +270,7 @@ Dict::Add('JA JP', 'Japanese', '日本語', array( 'UI:ClickToCreateNew' => '新規 %1$s を作成', 'UI:SearchFor_Class' => '%1$s オブジェクトを検索', 'UI:NoObjectToDisplay' => '表示するオブジェクトはありません。', + 'UI:Error:SaveFailed' => 'The object cannot be saved :~~', 'UI:Error:MandatoryTemplateParameter_object_id' => 'link_attrが指定されている時は、object_idパラメータは必須です。表示テンプレートの定義を確認してください。', 'UI:Error:MandatoryTemplateParameter_target_attr' => 'link_attrを指定する場合は、target_attrパラメータは必須です。表示テンプレートの定義を確認してください。', 'UI:Error:MandatoryTemplateParameter_group_by' => 'group_byパラメータは必須です。表示テンプレートの定義を確認してください。', diff --git a/dictionaries/nl.dictionary.itop.ui.php b/dictionaries/nl.dictionary.itop.ui.php index 8acb7611d..b95c5007f 100644 --- a/dictionaries/nl.dictionary.itop.ui.php +++ b/dictionaries/nl.dictionary.itop.ui.php @@ -392,6 +392,7 @@ Dict::Add('NL NL', 'Dutch', 'Nederlands', array( 'UI:ClickToCreateNew' => 'Maak een %1$s aan', 'UI:SearchFor_Class' => 'Zoek naar %1$s objecten', 'UI:NoObjectToDisplay' => 'Geen object om weer te geven.', + 'UI:Error:SaveFailed' => 'The object cannot be saved :~~', 'UI:Error:MandatoryTemplateParameter_object_id' => 'Parameter object_id is verplicht als link_attr is gespecificeerd. Controleer de definitie van het display template.', 'UI:Error:MandatoryTemplateParameter_target_attr' => 'Parameter target_attr is verplicht als link_attr is gespecificeerd. Controleer de definitie van het display template.', 'UI:Error:MandatoryTemplateParameter_group_by' => 'Parameter group_by is verplicht. Controleer de definitie van het display template.', diff --git a/dictionaries/pt_br.dictionary.itop.ui.php b/dictionaries/pt_br.dictionary.itop.ui.php index 69f23703a..33ff61e09 100644 --- a/dictionaries/pt_br.dictionary.itop.ui.php +++ b/dictionaries/pt_br.dictionary.itop.ui.php @@ -385,6 +385,7 @@ Dict::Add('PT BR', 'Brazilian', 'Brazilian', array( 'UI:ClickToCreateNew' => 'Criar um(a) novo(a) %1$s', 'UI:SearchFor_Class' => 'Pesquisar por objeto(s) %1$s', 'UI:NoObjectToDisplay' => 'Nenhum objeto encontrado.', + 'UI:Error:SaveFailed' => 'The object cannot be saved :~~', 'UI:Error:MandatoryTemplateParameter_object_id' => 'Parâmetro Object_id é obrigatório quando link_attr é especificado. Verifique a definição do modelo de exibição.', 'UI:Error:MandatoryTemplateParameter_target_attr' => 'Parâmetro Target_attr é obrigatório quando link_attr é especificado. Verifique a definição do modelo de exibição.', 'UI:Error:MandatoryTemplateParameter_group_by' => 'Parâmetro Group_by é obrigatório. Verifique a definição do modelo de exibição.', diff --git a/dictionaries/ru.dictionary.itop.ui.php b/dictionaries/ru.dictionary.itop.ui.php index 0b5c273cb..db4baac3d 100644 --- a/dictionaries/ru.dictionary.itop.ui.php +++ b/dictionaries/ru.dictionary.itop.ui.php @@ -368,6 +368,7 @@ Dict::Add('RU RU', 'Russian', 'Русский', array( 'UI:ClickToCreateNew' => 'Создать: %1$s', 'UI:SearchFor_Class' => 'Поиск: %1$s', 'UI:NoObjectToDisplay' => 'Нет объектов для отображения.', + 'UI:Error:SaveFailed' => 'The object cannot be saved :~~', 'UI:Error:MandatoryTemplateParameter_object_id' => 'Параметр object_id является обязательным если указан link_attr. Проверьте определение отображения шаблона.', 'UI:Error:MandatoryTemplateParameter_target_attr' => 'Параметр object_id является обязательным если указан link_attr. Проверьте определение отображения шаблона', 'UI:Error:MandatoryTemplateParameter_group_by' => 'Параметр group_by является обязательным. Проверьте определение отображения шаблона.', diff --git a/dictionaries/tr.dictionary.itop.ui.php b/dictionaries/tr.dictionary.itop.ui.php index c389baf87..098842786 100644 --- a/dictionaries/tr.dictionary.itop.ui.php +++ b/dictionaries/tr.dictionary.itop.ui.php @@ -364,6 +364,7 @@ Dict::Add('TR TR', 'Turkish', 'Türkçe', array( 'UI:ClickToCreateNew' => 'Yeni %1$s yarat', 'UI:SearchFor_Class' => '%1$s Arama', 'UI:NoObjectToDisplay' => 'Görüntülenecek nesne bulunamadı.', + 'UI:Error:SaveFailed' => 'The object cannot be saved :~~', 'UI:Error:MandatoryTemplateParameter_object_id' => 'link_attr tanımlandığında object_id alanı zorunludur. Görüntülme (Display) şablonun tanımlamasını kontrol ediniz.', 'UI:Error:MandatoryTemplateParameter_target_attr' => 'link_attr tanımlandığında target_attr alanı zorunludur. Görüntülme (Display) şablonun tanımlamasını kontrol ediniz.', 'UI:Error:MandatoryTemplateParameter_group_by' => 'group_by alanı zorunludur. Görüntülme (Display) şablonun tanımlamasını kontrol ediniz.', diff --git a/dictionaries/zh.dictionary.itop.ui.php b/dictionaries/zh.dictionary.itop.ui.php index b9aa25263..db16ffdda 100644 --- a/dictionaries/zh.dictionary.itop.ui.php +++ b/dictionaries/zh.dictionary.itop.ui.php @@ -363,6 +363,7 @@ Dict::Add('ZH CN', 'Chinese', '简体中文', array( 'UI:ClickToCreateNew' => '创建一个新的 %1$s', 'UI:SearchFor_Class' => '搜索 %1$s 对象', 'UI:NoObjectToDisplay' => '没有对象可显示.', + 'UI:Error:SaveFailed' => 'The object cannot be saved :~~', 'UI:Error:MandatoryTemplateParameter_object_id' => '当link_attr被指定时,参数 object_id 是必须的. 检查显示模板的定义.', 'UI:Error:MandatoryTemplateParameter_target_attr' => '当 link_attr被指定时, 参数 target_attr 是必须的. 检查显示模板的定义.', 'UI:Error:MandatoryTemplateParameter_group_by' => '参数 group_by 是必须的. 检查显示模板的定义.', diff --git a/pages/UI.php b/pages/UI.php index 0d798da23..98f9499d5 100644 --- a/pages/UI.php +++ b/pages/UI.php @@ -920,7 +920,7 @@ EOF } else { - list($bRes, $aIssues) = $oObj->CheckToWrite(); + list($bRes, $aIssues) = $oObj->CheckToWrite(); // called also in DBUpdate() if ($bRes) { try @@ -951,9 +951,8 @@ EOF $bDisplayDetails = false; // Found issues, explain and give the user a second chance // + $oP->AddHeaderMessageForErrors(Dict::S('UI:Error:SaveFailed'), $aIssues); $oObj->DisplayModifyForm($oP, array('wizard_container' => true)); // wizard_container: display the wizard border and the title - $sIssueDesc = Dict::Format('UI:ObjectCouldNotBeWritten', implode(', ', $aIssues)); - $oP->add_ready_script("alert('".addslashes($sIssueDesc)."');"); } } } @@ -1102,7 +1101,7 @@ EOF $sClass = get_class($oObj); $sClassLabel = MetaModel::GetName($sClass); - list($bRes, $aIssues) = $oObj->CheckToWrite(); + list($bRes, $aIssues) = $oObj->CheckToWrite(); // called also in DBInsertNoReload() if ($bRes) { $oObj->DBInsertNoReload(); // No need to reload @@ -1133,10 +1132,9 @@ EOF $oP->set_title(Dict::Format('UI:CreationPageTitle_Class', $sClassLabel)); $oP->add("

".MetaModel::GetClassIcon($sClass)." ".Dict::Format('UI:CreationTitle_Class', $sClassLabel)."

\n"); $oP->add("
\n"); + $oP->AddHeaderMessageForErrors(Dict::S('UI:Error:SaveFailed'), $aIssues); cmdbAbstractObject::DisplayCreationForm($oP, $sClass, $oObj); $oP->add("
\n"); - $sIssueDesc = Dict::Format('UI:ObjectCouldNotBeWritten', implode(', ', $aIssues)); - $oP->add_ready_script("alert('".addslashes($sIssueDesc)."');"); } } break;