mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 10:38:45 +02:00
N°2847 - Add Title component
* Add id to button factory * Rework of Configuration File Editor page
This commit is contained in:
@@ -1,17 +1,4 @@
|
||||
/*!
|
||||
* 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
|
||||
* copyright Copyright (C) 2010-2020 Combodo SARL
|
||||
* license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
@@ -1,19 +1,6 @@
|
||||
/*!
|
||||
* 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
|
||||
* copyright Copyright (C) 2010-2020 Combodo SARL
|
||||
* license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
@import "alert";
|
||||
@@ -28,4 +15,5 @@
|
||||
|
||||
@import "tabcontainer";
|
||||
@import "tab";
|
||||
@import "ajaxtab";
|
||||
@import "ajaxtab";
|
||||
@import "title";
|
||||
@@ -1,17 +1,4 @@
|
||||
/*!
|
||||
* 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
|
||||
* copyright Copyright (C) 2010-2020 Combodo SARL
|
||||
* license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
@@ -1,17 +1,4 @@
|
||||
/*!
|
||||
* 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
|
||||
* copyright Copyright (C) 2010-2020 Combodo SARL
|
||||
* license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
4
css/backoffice/components/_title.scss
Normal file
4
css/backoffice/components/_title.scss
Normal file
@@ -0,0 +1,4 @@
|
||||
/*!
|
||||
* copyright Copyright (C) 2010-2020 Combodo SARL
|
||||
* license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
@@ -24,6 +24,10 @@
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
use Combodo\iTop\Application\UI\Component\Alert\AlertFactory;
|
||||
use Combodo\iTop\Application\UI\Component\Button\ButtonFactory;
|
||||
use Combodo\iTop\Application\UI\Component\Html\Html;
|
||||
use Combodo\iTop\Application\UI\Component\Title\TitleFactory;
|
||||
use Combodo\iTop\Config\Validator\iTopConfigAstValidator;
|
||||
use Combodo\iTop\Config\Validator\iTopConfigSyntaxValidator;
|
||||
|
||||
@@ -59,8 +63,7 @@ function DBPasswordInNewConfigIsOk($sSafeContent)
|
||||
{
|
||||
$bIsWindows = (array_key_exists('WINDIR', $_SERVER) || array_key_exists('windir', $_SERVER));
|
||||
|
||||
if ($bIsWindows && (preg_match("@'db_pwd' => '[^%!\"]+',@U", $sSafeContent) === 0))
|
||||
{
|
||||
if ($bIsWindows && (preg_match("@'db_pwd' => '[^%!\"]+',@U", $sSafeContent) === 0)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -82,112 +85,108 @@ $oP->add_linked_script(utils::GetAbsoluteUrlAppRoot().'/js/ace/mode-php.js');
|
||||
$oP->add_linked_script(utils::GetAbsoluteUrlAppRoot().'/js/ace/theme-eclipse.js');
|
||||
$oP->add_linked_script(utils::GetAbsoluteUrlAppRoot().'/js/ace/ext-searchbox.js');
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$sOperation = utils::ReadParam('operation', '');
|
||||
$iEditorTopMargin = 0;
|
||||
$iEditorTopMargin = 2;
|
||||
|
||||
$oP->add("<h1>".Dict::S('config-edit-title')."</h1>");
|
||||
$oP->AddUiBlock(TitleFactory::MakeForPage(Dict::S('config-edit-title')));
|
||||
|
||||
if (MetaModel::GetConfig()->Get('demo_mode'))
|
||||
{
|
||||
$oP->add("<div class=\"header_message message_info\">Sorry, iTop is in <b>demonstration mode</b>: the configuration file cannot be edited.</div>");
|
||||
}
|
||||
else if (MetaModel::GetModuleSetting('itop-config', 'config_editor', '') == 'disabled')
|
||||
{
|
||||
$oP->add("<div class=\"header_message message_info\">iTop interactive edition of the configuration as been disabled. See <tt>'config_editor' => 'disabled'</tt> in the configuration file.</div>");
|
||||
}
|
||||
else
|
||||
{
|
||||
$sConfigFile = APPROOT.'conf/'.utils::GetCurrentEnvironment().'/config-itop.php';
|
||||
if (MetaModel::GetConfig()->Get('demo_mode')) {
|
||||
$oAlert = AlertFactory::MakeForInformation('', "Sorry, iTop is in <b>demonstration mode</b>: the configuration file cannot be edited.");
|
||||
$oP->AddUiBlock($oAlert);
|
||||
} else {
|
||||
if (MetaModel::GetModuleSetting('itop-config', 'config_editor', '') == 'disabled') {
|
||||
$oAlert = AlertFactory::MakeForWarning('', "iTop interactive edition of the configuration as been disabled. See <tt>'config_editor' => 'disabled'</tt> in the configuration file.");
|
||||
$oP->AddUiBlock($oAlert);
|
||||
} else {
|
||||
$sConfigFile = APPROOT.'conf/'.utils::GetCurrentEnvironment().'/config-itop.php';
|
||||
|
||||
$iEditorTopMargin += 9;
|
||||
$sConfig = str_replace("\r\n", "\n", file_get_contents($sConfigFile));
|
||||
$sOriginalConfig = $sConfig;
|
||||
$iEditorTopMargin += 9;
|
||||
$sConfig = str_replace("\r\n", "\n", file_get_contents($sConfigFile));
|
||||
$sOriginalConfig = $sConfig;
|
||||
|
||||
if (!empty($sOperation))
|
||||
{
|
||||
$iEditorTopMargin += 5;
|
||||
$sConfig = utils::ReadParam('new_config', '', false, 'raw_data');
|
||||
$sOriginalConfig = utils::ReadParam('prev_config', '', false, 'raw_data');
|
||||
}
|
||||
if (!empty($sOperation)) {
|
||||
$iEditorTopMargin += 5;
|
||||
$sConfig = utils::ReadParam('new_config', '', false, 'raw_data');
|
||||
$sOriginalConfig = utils::ReadParam('prev_config', '', false, 'raw_data');
|
||||
}
|
||||
|
||||
if ($sOperation == 'revert')
|
||||
{
|
||||
$oP->add('<div id="save_result" class="header_message message_info">'.Dict::S('config-reverted').'</div>');
|
||||
}
|
||||
if ($sOperation == 'save')
|
||||
{
|
||||
$sTransactionId = utils::ReadParam('transaction_id', '', false, 'transaction_id');
|
||||
if (!utils::IsTransactionValid($sTransactionId, true))
|
||||
{
|
||||
$oP->add("<div class=\"header_message message_info\">Error: invalid Transaction ID. The configuration was <b>NOT</b> modified.</div>");
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($sConfig == $sOriginalConfig)
|
||||
{
|
||||
$oP->add('<div id="save_result" class="header_message">'.Dict::S('config-no-change').'</div>');
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
TestConfig($sConfig, $oP); // throws exceptions
|
||||
if ($sOperation == 'revert') {
|
||||
$oAlert = AlertFactory::MakeForWarning('', Dict::S('config-reverted'));
|
||||
$oP->AddUiBlock($oAlert);
|
||||
}
|
||||
if ($sOperation == 'save') {
|
||||
$sTransactionId = utils::ReadParam('transaction_id', '', false, 'transaction_id');
|
||||
if (!utils::IsTransactionValid($sTransactionId, true)) {
|
||||
$oAlert = AlertFactory::MakeForFailure('', 'Error: invalid Transaction ID. The configuration was <b>NOT</b> modified.');
|
||||
$oP->AddUiBlock($oAlert);
|
||||
} else {
|
||||
if ($sConfig == $sOriginalConfig) {
|
||||
$oAlert = AlertFactory::MakeForInformation('', Dict::S('config-no-change'));
|
||||
$oP->AddUiBlock($oAlert);
|
||||
} else {
|
||||
try {
|
||||
TestConfig($sConfig, $oP); // throws exceptions
|
||||
|
||||
@chmod($sConfigFile, 0770); // Allow overwriting the file
|
||||
$sTmpFile = tempnam(SetupUtils::GetTmpDir(), 'itop-cfg-');
|
||||
// Don't write the file as-is since it would allow to inject any kind of PHP code.
|
||||
// Instead write the interpreted version of the file
|
||||
// Note:
|
||||
// The actual raw PHP code will anyhow be interpreted exactly twice: once in TestConfig() above
|
||||
// and a second time during the load of the Config object below.
|
||||
// If you are really concerned about an iTop administrator crafting some malicious
|
||||
// PHP code inside the config file, then turn off the interactive configuration
|
||||
// editor by adding the configuration parameter:
|
||||
// 'itop-config' => array(
|
||||
// 'config_editor' => 'disabled',
|
||||
// )
|
||||
file_put_contents($sTmpFile, $sConfig);
|
||||
$oTempConfig = new Config($sTmpFile, true);
|
||||
$oTempConfig->WriteToFile($sConfigFile);
|
||||
@unlink($sTmpFile);
|
||||
@chmod($sConfigFile, 0440); // Read-only
|
||||
@chmod($sConfigFile, 0770); // Allow overwriting the file
|
||||
$sTmpFile = tempnam(SetupUtils::GetTmpDir(), 'itop-cfg-');
|
||||
// Don't write the file as-is since it would allow to inject any kind of PHP code.
|
||||
// Instead write the interpreted version of the file
|
||||
// Note:
|
||||
// The actual raw PHP code will anyhow be interpreted exactly twice: once in TestConfig() above
|
||||
// and a second time during the load of the Config object below.
|
||||
// If you are really concerned about an iTop administrator crafting some malicious
|
||||
// PHP code inside the config file, then turn off the interactive configuration
|
||||
// editor by adding the configuration parameter:
|
||||
// 'itop-config' => array(
|
||||
// 'config_editor' => 'disabled',
|
||||
// )
|
||||
file_put_contents($sTmpFile, $sConfig);
|
||||
$oTempConfig = new Config($sTmpFile, true);
|
||||
$oTempConfig->WriteToFile($sConfigFile);
|
||||
@unlink($sTmpFile);
|
||||
@chmod($sConfigFile, 0440); // Read-only
|
||||
|
||||
if (DBPasswordInNewConfigIsOk($sConfig))
|
||||
{
|
||||
$oP->p('<div id="save_result" class="header_message message_ok">'.Dict::S('config-saved').'</div>');
|
||||
}
|
||||
else
|
||||
{
|
||||
$oP->p('<div id="save_result" class="header_message message_info">'.Dict::S('config-saved-warning-db-password').'</div>');
|
||||
}
|
||||
$sOriginalConfig = str_replace("\r\n", "\n", file_get_contents($sConfigFile));
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
$oP->p('<div id="save_result" class="header_message message_error">'.$e->getMessage().'</div>');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (DBPasswordInNewConfigIsOk($sConfig)) {
|
||||
$oAlert = AlertFactory::MakeForSuccess('', Dict::S('config-saved'));
|
||||
} else {
|
||||
$oAlert = AlertFactory::MakeForInformation('', Dict::S('config-saved-warning-db-password'));
|
||||
}
|
||||
$oP->AddUiBlock($oAlert);
|
||||
$sOriginalConfig = str_replace("\r\n", "\n", file_get_contents($sConfigFile));
|
||||
} catch (Exception $e) {
|
||||
$oAlert = AlertFactory::MakeForDanger('', $e->getMessage());
|
||||
$oP->AddUiBlock($oAlert);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$sConfigEscaped = htmlentities($sConfig, ENT_QUOTES, 'UTF-8');
|
||||
$sOriginalConfigEscaped = htmlentities($sOriginalConfig, ENT_QUOTES, 'UTF-8');
|
||||
$oP->p(Dict::S('config-edit-intro'));
|
||||
$oP->add("<form method=\"POST\">");
|
||||
$oP->add("<input id=\"operation\" type=\"hidden\" name=\"operation\" value=\"save\">");
|
||||
$oP->add("<input type=\"hidden\" name=\"transaction_id\" value=\"".utils::GetNewTransactionId()."\">");
|
||||
$oP->add("<input id=\"submit_button\" type=\"submit\" value=\"".Dict::S('config-apply')."\" title=\"".Dict::S('config-apply-title')."\"><button id=\"cancel_button\" disabled=\"disabled\" onclick=\"return ResetConfig();\">".Dict::S('config-cancel')."</button>");
|
||||
$oP->add("<input type=\"hidden\" id=\"prev_config\" name=\"prev_config\" value=\"$sOriginalConfigEscaped\">");
|
||||
$oP->add("<input type=\"hidden\" name=\"new_config\" value=\"$sConfigEscaped\">");
|
||||
$oP->add("<div id =\"new_config\" style=\"position: absolute; top: ".$iEditorTopMargin."em; bottom: 0; left: 5px; right: 5px;\"></div>");
|
||||
$oP->add("</form>");
|
||||
|
||||
$sConfirmCancel = addslashes(Dict::S('config-confirm-cancel'));
|
||||
$oP->add_script(
|
||||
<<<'JS'
|
||||
$sConfigEscaped = htmlentities($sConfig, ENT_QUOTES, 'UTF-8');
|
||||
$sOriginalConfigEscaped = htmlentities($sOriginalConfig, ENT_QUOTES, 'UTF-8');
|
||||
$oP->AddUiBlock(new Html('<p>'.Dict::S('config-edit-intro').'</p>'));
|
||||
|
||||
$oP->add("<form method=\"POST\">");
|
||||
$oP->add("<input id=\"operation\" type=\"hidden\" name=\"operation\" value=\"save\">");
|
||||
$oP->add("<input type=\"hidden\" name=\"transaction_id\" value=\"".utils::GetNewTransactionId()."\">");
|
||||
|
||||
// - Cancel button
|
||||
$oCancelButton = ButtonFactory::MakeForSecondaryAction(Dict::S('config-cancel'), 'cancel_button', null, true, 'cancel_button');
|
||||
$oCancelButton->SetOnClickJsCode("return ResetConfig();");
|
||||
$oP->AddUiBlock($oCancelButton);
|
||||
|
||||
// - Submit button
|
||||
$oSubmitButton = ButtonFactory::MakeForValidationAction(Dict::S('config-apply'), null, Dict::S('config-apply'), true, 'submit_button');
|
||||
$oP->AddUiBlock($oSubmitButton);
|
||||
|
||||
$oP->add("<input type=\"hidden\" id=\"prev_config\" name=\"prev_config\" value=\"$sOriginalConfigEscaped\">");
|
||||
$oP->add("<input type=\"hidden\" name=\"new_config\" value=\"$sConfigEscaped\">");
|
||||
$oP->add("<div id =\"new_config\" style=\"position: absolute; top: ".$iEditorTopMargin."em; bottom: 0; left: 5px; right: 5px;\"></div>");
|
||||
$oP->add("</form>");
|
||||
|
||||
$oP->add_script(
|
||||
<<<'JS'
|
||||
var EditorUtils = (function() {
|
||||
var STORAGE_RANGE_KEY = 'cfgEditorRange';
|
||||
var STORAGE_LINE_KEY = 'cfgEditorFirstline';
|
||||
@@ -301,30 +300,30 @@ $editorForm.submit(function() {
|
||||
EditorUtils.restoreEditorDisplay(editor);
|
||||
editor.focus();
|
||||
JS
|
||||
);
|
||||
);
|
||||
|
||||
$oP->add_script(
|
||||
<<<EOF
|
||||
$sConfirmCancel = addslashes(Dict::S('config-confirm-cancel'));
|
||||
$oP->add_script(<<<JS
|
||||
function ResetConfig()
|
||||
{
|
||||
var editor = ace.edit("new_config");
|
||||
$("#operation").attr('value', 'revert');
|
||||
if (editor.getValue() != $('#prev_config').val())
|
||||
var prevConfig = $('#prev_config');
|
||||
if (editor.getValue() != prevConfig.val())
|
||||
{
|
||||
if (confirm('$sConfirmCancel'))
|
||||
{
|
||||
$('input[name="new_config"]').val($('#prev_config').val());
|
||||
$('input[name="new_config"]').val(prevConfig.val());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
EOF
|
||||
);
|
||||
JS
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
} catch (Exception $e) {
|
||||
$oP->p('<b>'.$e->getMessage().'</b>');
|
||||
}
|
||||
|
||||
|
||||
@@ -173,6 +173,8 @@ return array(
|
||||
'Combodo\\iTop\\Application\\UI\\Component\\QuickCreate\\QuickCreate' => $baseDir . '/sources/application/UI/Component/QuickCreate/QuickCreate.php',
|
||||
'Combodo\\iTop\\Application\\UI\\Component\\QuickCreate\\QuickCreateFactory' => $baseDir . '/sources/application/UI/Component/QuickCreate/QuickCreateFactory.php',
|
||||
'Combodo\\iTop\\Application\\UI\\Component\\QuickCreate\\QuickCreateHelper' => $baseDir . '/sources/application/UI/Component/QuickCreate/QuickCreateHelper.php',
|
||||
'Combodo\\iTop\\Application\\UI\\Component\\Title\\Title' => $baseDir . '/sources/application/UI/Component/Title/Title.php',
|
||||
'Combodo\\iTop\\Application\\UI\\Component\\Title\\TitleFactory' => $baseDir . '/sources/application/UI/Component/Title/TitleFactory.php',
|
||||
'Combodo\\iTop\\Application\\UI\\Layout\\ActivityPanel\\ActivityEntry\\ActivityEntry' => $baseDir . '/sources/application/UI/Layout/ActivityPanel/ActivityEntry/ActivityEntry.php',
|
||||
'Combodo\\iTop\\Application\\UI\\Layout\\ActivityPanel\\ActivityEntry\\ActivityEntryFactory' => $baseDir . '/sources/application/UI/Layout/ActivityPanel/ActivityEntry/ActivityEntryFactory.php',
|
||||
'Combodo\\iTop\\Application\\UI\\Layout\\ActivityPanel\\ActivityEntry\\CMDBChangeOp\\CMDBChangeOpAttachmentAddedFactory' => $baseDir . '/sources/application/UI/Layout/ActivityPanel/ActivityEntry/CMDBChangeOp/CMDBChangeOpAttachmentAddedFactory.php',
|
||||
|
||||
@@ -403,6 +403,8 @@ class ComposerStaticInit0018331147de7601e7552f7da8e3bb8b
|
||||
'Combodo\\iTop\\Application\\UI\\Component\\QuickCreate\\QuickCreate' => __DIR__ . '/../..' . '/sources/application/UI/Component/QuickCreate/QuickCreate.php',
|
||||
'Combodo\\iTop\\Application\\UI\\Component\\QuickCreate\\QuickCreateFactory' => __DIR__ . '/../..' . '/sources/application/UI/Component/QuickCreate/QuickCreateFactory.php',
|
||||
'Combodo\\iTop\\Application\\UI\\Component\\QuickCreate\\QuickCreateHelper' => __DIR__ . '/../..' . '/sources/application/UI/Component/QuickCreate/QuickCreateHelper.php',
|
||||
'Combodo\\iTop\\Application\\UI\\Component\\Title\\Title' => __DIR__ . '/../..' . '/sources/application/UI/Component/Title/Title.php',
|
||||
'Combodo\\iTop\\Application\\UI\\Component\\Title\\TitleFactory' => __DIR__ . '/../..' . '/sources/application/UI/Component/Title/TitleFactory.php',
|
||||
'Combodo\\iTop\\Application\\UI\\Layout\\ActivityPanel\\ActivityEntry\\ActivityEntry' => __DIR__ . '/../..' . '/sources/application/UI/Layout/ActivityPanel/ActivityEntry/ActivityEntry.php',
|
||||
'Combodo\\iTop\\Application\\UI\\Layout\\ActivityPanel\\ActivityEntry\\ActivityEntryFactory' => __DIR__ . '/../..' . '/sources/application/UI/Layout/ActivityPanel/ActivityEntry/ActivityEntryFactory.php',
|
||||
'Combodo\\iTop\\Application\\UI\\Layout\\ActivityPanel\\ActivityEntry\\CMDBChangeOp\\CMDBChangeOpAttachmentAddedFactory' => __DIR__ . '/../..' . '/sources/application/UI/Layout/ActivityPanel/ActivityEntry/CMDBChangeOp/CMDBChangeOpAttachmentAddedFactory.php',
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
use Combodo\iTop\Application\UI\Component\Button\ButtonFactory;
|
||||
use Combodo\iTop\Application\UI\Component\Html\Html;
|
||||
use Combodo\iTop\Application\UI\Component\Panel\Panel;
|
||||
use Combodo\iTop\Application\UI\Component\Title\TitleFactory;
|
||||
use Combodo\iTop\Application\UI\Layout\PageContent\PageContentFactory;
|
||||
|
||||
require_once('../approot.inc.php');
|
||||
@@ -35,11 +36,9 @@ function DisplayPreferences($oP)
|
||||
$oContentLayout = PageContentFactory::MakeStandardEmpty();
|
||||
$oAppContext = new ApplicationContext();
|
||||
$sURL = utils::GetAbsoluteUrlAppRoot().'pages/UI.php?'.$oAppContext->GetForLink();
|
||||
|
||||
$sTitleHtml = '<h1 class="ibo-preferences--title title is-size-2">'.Dict::S('UI:Preferences:Title').'</h1>';
|
||||
$sTitleHtmlBlock = new Html($sTitleHtml);
|
||||
$oContentLayout->AddMainBlock($sTitleHtmlBlock);
|
||||
|
||||
|
||||
$oContentLayout->AddMainBlock(TitleFactory::MakeForPage(Dict::S('UI:Preferences:Title')));
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// User Language selection
|
||||
@@ -47,23 +46,20 @@ function DisplayPreferences($oP)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
$oUserLanguageBlock = new Panel(Dict::S('UI:FavoriteLanguage'), array(), 'grey', 'ibo-user-language-selection');
|
||||
$oUserLanguageStartForm = new Html('<form method="post">');
|
||||
|
||||
$aLanguages = Dict::GetLanguages();
|
||||
$aSortedlang = array();
|
||||
foreach($aLanguages as $sCode => $aLang)
|
||||
{
|
||||
if (MetaModel::GetConfig()->Get('demo_mode'))
|
||||
{
|
||||
if ($sCode != Dict::GetUserLanguage())
|
||||
{
|
||||
|
||||
$aLanguages = Dict::GetLanguages();
|
||||
$aSortedlang = array();
|
||||
foreach ($aLanguages as $sCode => $aLang) {
|
||||
if (MetaModel::GetConfig()->Get('demo_mode')) {
|
||||
if ($sCode != Dict::GetUserLanguage()) {
|
||||
// Demo mode: only the current user language is listed in the available choices
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$aSortedlang[$aLang['description']] = $sCode;
|
||||
}
|
||||
ksort($aSortedlang);
|
||||
$sUserLanguageBlockSelect = '';
|
||||
$aSortedlang[$aLang['description']] = $sCode;
|
||||
}
|
||||
ksort($aSortedlang);
|
||||
$sUserLanguageBlockSelect = '';
|
||||
$sUserLanguageBlockSelect .= '<p>'.Dict::S('UI:Favorites:SelectYourLanguage').' <select name="language">';
|
||||
foreach ($aSortedlang as $sCode)
|
||||
{
|
||||
|
||||
@@ -34,12 +34,13 @@ class ButtonFactory
|
||||
*
|
||||
* @param string $sLabel
|
||||
* @param string $sName See Button::$sName
|
||||
* @param string|null $sId
|
||||
*
|
||||
* @return \Combodo\iTop\Application\UI\Component\Button\Button
|
||||
*/
|
||||
public static function MakeNeutral(string $sLabel, string $sName)
|
||||
public static function MakeNeutral(string $sLabel, string $sName, ?string $sId = null)
|
||||
{
|
||||
$oButton = new Button($sLabel);
|
||||
$oButton = new Button($sLabel, $sId);
|
||||
$oButton->SetActionType(Button::ENUM_ACTION_TYPE_REGULAR)
|
||||
->SetColor(Button::ENUM_COLOR_NEUTRAL)
|
||||
->SetName($sName);
|
||||
@@ -54,12 +55,18 @@ class ButtonFactory
|
||||
* @param string|null $sName See Button::$sName
|
||||
* @param string|null $sValue See Button::$sValue
|
||||
* @param bool $bIsSubmit See Button::$sType
|
||||
* @param string|null $sId
|
||||
*
|
||||
* @return \Combodo\iTop\Application\UI\Component\Button\Button
|
||||
*/
|
||||
public static function MakeForPrimaryAction(string $sLabel, string $sName = null, string $sValue = null, bool $bIsSubmit = false
|
||||
public static function MakeForPrimaryAction(
|
||||
string $sLabel,
|
||||
string $sName = null,
|
||||
string $sValue = null,
|
||||
bool $bIsSubmit = false,
|
||||
?string $sId = null
|
||||
) {
|
||||
return static::MakeForAction($sLabel, Button::ENUM_COLOR_PRIMARY, Button::ENUM_ACTION_TYPE_REGULAR, $sValue, $sName, $bIsSubmit);
|
||||
return static::MakeForAction($sLabel, Button::ENUM_COLOR_PRIMARY, Button::ENUM_ACTION_TYPE_REGULAR, $sValue, $sName, $bIsSubmit, $sId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,12 +76,18 @@ class ButtonFactory
|
||||
* @param string|null $sName See Button::$sName
|
||||
* @param string|null $sValue See Button::$sValue
|
||||
* @param bool $bIsSubmit See Button::$sType
|
||||
* @param string|null $sId
|
||||
*
|
||||
* @return \Combodo\iTop\Application\UI\Component\Button\Button
|
||||
*/
|
||||
public static function MakeForSecondaryAction(string $sLabel, string $sName = null, string $sValue = null, bool $bIsSubmit = false
|
||||
public static function MakeForSecondaryAction(
|
||||
string $sLabel,
|
||||
string $sName = null,
|
||||
string $sValue = null,
|
||||
bool $bIsSubmit = false,
|
||||
?string $sId = null
|
||||
) {
|
||||
return static::MakeForAction($sLabel, Button::ENUM_COLOR_SECONDARY, Button::ENUM_ACTION_TYPE_REGULAR, $sValue, $sName, $bIsSubmit);
|
||||
return static::MakeForAction($sLabel, Button::ENUM_COLOR_SECONDARY, Button::ENUM_ACTION_TYPE_REGULAR, $sValue, $sName, $bIsSubmit, $sId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,12 +98,18 @@ class ButtonFactory
|
||||
* @param string|null $sName See Button::$sName
|
||||
* @param string|null $sValue See Button::$sValue
|
||||
* @param bool $bIsSubmit See Button::$sType
|
||||
* @param string|null $sId
|
||||
*
|
||||
* @return \Combodo\iTop\Application\UI\Component\Button\Button
|
||||
*/
|
||||
public static function MakeForValidationAction(string $sLabel, string $sName = null, string $sValue = null, bool $bIsSubmit = false
|
||||
public static function MakeForValidationAction(
|
||||
string $sLabel,
|
||||
string $sName = null,
|
||||
string $sValue = null,
|
||||
bool $bIsSubmit = false,
|
||||
?string $sId = null
|
||||
) {
|
||||
return static::MakeForAction($sLabel, Button::ENUM_COLOR_VALIDATION, Button::ENUM_ACTION_TYPE_REGULAR, $sValue, $sName, $bIsSubmit);
|
||||
return static::MakeForAction($sLabel, Button::ENUM_COLOR_VALIDATION, Button::ENUM_ACTION_TYPE_REGULAR, $sValue, $sName, $bIsSubmit, $sId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,13 +120,19 @@ class ButtonFactory
|
||||
* @param string|null $sName See Button::$sName
|
||||
* @param string|null $sValue See Button::$sValue
|
||||
* @param bool $bIsSubmit See Button::$sType
|
||||
* @param string|null $sId
|
||||
*
|
||||
* @return \Combodo\iTop\Application\UI\Component\Button\Button
|
||||
*/
|
||||
public static function MakeForDestructiveAction(string $sLabel, string $sName = null, string $sValue = null, bool $bIsSubmit = false
|
||||
public static function MakeForDestructiveAction(
|
||||
string $sLabel,
|
||||
string $sName = null,
|
||||
string $sValue = null,
|
||||
bool $bIsSubmit = false,
|
||||
?string $sId = null
|
||||
) {
|
||||
return static::MakeForAction($sLabel, Button::ENUM_COLOR_DESTRUCTIVE, Button::ENUM_ACTION_TYPE_REGULAR, $sValue, $sName,
|
||||
$bIsSubmit);
|
||||
$bIsSubmit, $sId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,12 +140,13 @@ class ButtonFactory
|
||||
*
|
||||
* @param string $sLabel
|
||||
* @param string $sName See Button::$sName
|
||||
* @param string|null $sId
|
||||
*
|
||||
* @return \Combodo\iTop\Application\UI\Component\Button\Button
|
||||
*/
|
||||
public static function MakeAlternativeNeutral(string $sLabel, string $sName)
|
||||
public static function MakeAlternativeNeutral(string $sLabel, string $sName, ?string $sId = null)
|
||||
{
|
||||
$oButton = new Button($sLabel);
|
||||
$oButton = new Button($sLabel, $sId);
|
||||
$oButton->SetActionType(Button::ENUM_ACTION_TYPE_ALTERNATIVE)
|
||||
->SetColor(Button::ENUM_COLOR_NEUTRAL)
|
||||
->SetName($sName);
|
||||
@@ -136,14 +162,19 @@ class ButtonFactory
|
||||
* @param string|null $sName See Button::$sName
|
||||
* @param string|null $sValue See Button::$sValue
|
||||
* @param bool $bIsSubmit See Button::$sType
|
||||
* @param string|null $sId
|
||||
*
|
||||
* @return \Combodo\iTop\Application\UI\Component\Button\Button
|
||||
*/
|
||||
public static function MakeForAlternativePrimaryAction(
|
||||
string $sLabel, string $sName = null, string $sValue = null, bool $bIsSubmit = false
|
||||
string $sLabel,
|
||||
string $sName = null,
|
||||
string $sValue = null,
|
||||
bool $bIsSubmit = false,
|
||||
?string $sId = null
|
||||
) {
|
||||
return static::MakeForAction($sLabel, Button::ENUM_COLOR_PRIMARY, Button::ENUM_ACTION_TYPE_ALTERNATIVE, $sValue, $sName,
|
||||
$bIsSubmit);
|
||||
$bIsSubmit, $sId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,14 +184,19 @@ class ButtonFactory
|
||||
* @param string|null $sName See Button::$sName
|
||||
* @param string|null $sValue See Button::$sValue
|
||||
* @param bool $bIsSubmit See Button::$sType
|
||||
* @param string|null $sId
|
||||
*
|
||||
* @return \Combodo\iTop\Application\UI\Component\Button\Button
|
||||
*/
|
||||
public static function MakeForAlternativeSecondaryAction(
|
||||
string $sLabel, string $sName = null, string $sValue = null, bool $bIsSubmit = false
|
||||
string $sLabel,
|
||||
string $sName = null,
|
||||
string $sValue = null,
|
||||
bool $bIsSubmit = false,
|
||||
?string $sId = null
|
||||
) {
|
||||
return static::MakeForAction($sLabel, Button::ENUM_COLOR_SECONDARY, Button::ENUM_ACTION_TYPE_ALTERNATIVE, $sValue, $sName,
|
||||
$bIsSubmit);
|
||||
$bIsSubmit, $sId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -170,14 +206,19 @@ class ButtonFactory
|
||||
* @param string|null $sName See Button::$sName
|
||||
* @param string|null $sValue See Button::$sValue
|
||||
* @param bool $bIsSubmit See Button::$sType
|
||||
* @param string|null $sId
|
||||
*
|
||||
* @return \Combodo\iTop\Application\UI\Component\Button\Button
|
||||
*/
|
||||
public static function MakeForAlternativeValidationAction(
|
||||
string $sLabel, string $sName = null, string $sValue = null, bool $bIsSubmit = false
|
||||
string $sLabel,
|
||||
string $sName = null,
|
||||
string $sValue = null,
|
||||
bool $bIsSubmit = false,
|
||||
?string $sId = null
|
||||
) {
|
||||
return static::MakeForAction($sLabel, Button::ENUM_COLOR_VALIDATION, Button::ENUM_ACTION_TYPE_ALTERNATIVE, $sValue, $sName,
|
||||
$bIsSubmit);
|
||||
$bIsSubmit, $sId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -187,14 +228,19 @@ class ButtonFactory
|
||||
* @param string|null $sName See Button::$sName
|
||||
* @param string|null $sValue See Button::$sValue
|
||||
* @param bool $bIsSubmit See Button::$sType
|
||||
* @param string|null $sId
|
||||
*
|
||||
* @return \Combodo\iTop\Application\UI\Component\Button\Button
|
||||
*/
|
||||
public static function MakeForAlternativeDestructiveAction(
|
||||
string $sLabel, string $sName = null, string $sValue = null, bool $bIsSubmit = false
|
||||
string $sLabel,
|
||||
string $sName = null,
|
||||
string $sValue = null,
|
||||
bool $bIsSubmit = false,
|
||||
?string $sId = null
|
||||
) {
|
||||
return static::MakeForAction($sLabel, Button::ENUM_COLOR_DESTRUCTIVE, Button::ENUM_ACTION_TYPE_ALTERNATIVE, $sValue, $sName,
|
||||
$bIsSubmit);
|
||||
$bIsSubmit, $sId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -206,30 +252,34 @@ class ButtonFactory
|
||||
* @param string|null $sValue See Button::$sValue
|
||||
* @param string|null $sName See Button::$sValue
|
||||
* @param bool $bIsSubmit
|
||||
* @param string|null $sId
|
||||
*
|
||||
* @return \Combodo\iTop\Application\UI\Component\Button\Button
|
||||
* @interal
|
||||
*/
|
||||
protected static function MakeForAction(
|
||||
string $sLabel, string $sColor, string $sActionType, string $sValue = null, string $sName = null, bool $bIsSubmit = false
|
||||
string $sLabel,
|
||||
string $sColor,
|
||||
string $sActionType,
|
||||
string $sValue = null,
|
||||
string $sName = null,
|
||||
bool $bIsSubmit = false,
|
||||
?string $sId = null
|
||||
) {
|
||||
$oButton = new Button($sLabel);
|
||||
$oButton = new Button($sLabel, $sId);
|
||||
$oButton->SetActionType($sActionType)
|
||||
->SetColor($sColor);
|
||||
|
||||
if (empty($sValue) === false)
|
||||
{
|
||||
if (empty($sValue) === false) {
|
||||
$oButton->SetValue($sValue);
|
||||
}
|
||||
|
||||
if (empty($sName) === false)
|
||||
{
|
||||
if (empty($sName) === false) {
|
||||
$oButton->SetName($sName);
|
||||
}
|
||||
|
||||
// Set as submit button if necessary
|
||||
if ($bIsSubmit === true)
|
||||
{
|
||||
if ($bIsSubmit === true) {
|
||||
$oButton->SetType(Button::ENUM_TYPE_SUBMIT);
|
||||
}
|
||||
|
||||
|
||||
51
sources/application/UI/Component/Title/Title.php
Normal file
51
sources/application/UI/Component/Title/Title.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (C) 2010-2020 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
namespace Combodo\iTop\Application\UI\Component\Title;
|
||||
|
||||
|
||||
use Combodo\iTop\Application\UI\UIBlock;
|
||||
|
||||
/**
|
||||
* Class Title
|
||||
*
|
||||
* @package Combodo\iTop\Application\UI\Component\Title
|
||||
*/
|
||||
class Title extends UIBlock
|
||||
{
|
||||
// Overloaded constants
|
||||
public const BLOCK_CODE = 'ibo-title';
|
||||
public const HTML_TEMPLATE_REL_PATH = 'components/title/layout';
|
||||
public const JS_TEMPLATE_REL_PATH = 'components/title/layout';
|
||||
|
||||
/** @var string */
|
||||
protected $sTitle;
|
||||
/** @var int */
|
||||
protected $iLevel;
|
||||
|
||||
public function __construct(string $sTitle = '', int $iLevel = 1, ?string $sId = null)
|
||||
{
|
||||
parent::__construct($sId);
|
||||
$this->sTitle = $sTitle;
|
||||
$this->iLevel = $iLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function GetTitle(): string
|
||||
{
|
||||
return $this->sTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function GetLevel(): int
|
||||
{
|
||||
return $this->iLevel;
|
||||
}
|
||||
}
|
||||
18
sources/application/UI/Component/Title/TitleFactory.php
Normal file
18
sources/application/UI/Component/Title/TitleFactory.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (C) 2010-2020 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
|
||||
namespace Combodo\iTop\Application\UI\Component\Title;
|
||||
|
||||
|
||||
class TitleFactory
|
||||
{
|
||||
|
||||
public static function MakeForPage(string $sTitle, ?string $sId = null)
|
||||
{
|
||||
return new Title($sTitle, 1, $sId);
|
||||
}
|
||||
}
|
||||
1
templates/components/title/layout.html.twig
Normal file
1
templates/components/title/layout.html.twig
Normal file
@@ -0,0 +1 @@
|
||||
<h{{ oUIBlock.GetLevel() }} class="ibo-preferences--title title is-size-{{ oUIBlock.GetLevel() + 2 }}">{{ oUIBlock.GetTitle() }}</h{{ oUIBlock.GetLevel() }}>
|
||||
Reference in New Issue
Block a user