mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 10:38:45 +02:00
Merge remote-tracking branch 'origin/support/2.7' into support/3.0
N°5741 - remove use of get_config_parameter and get_module_setting in Twig # Conflicts: # application/twigextension.class.inc.php # datamodels/2.x/itop-portal-base/portal/src/Twig/AppExtension.php # sources/application/TwigBase/Twig/Extension.php
This commit is contained in:
@@ -14,7 +14,6 @@ use Combodo\iTop\Application\UI\Base\iUIBlock;
|
||||
use Combodo\iTop\Renderer\BlockRenderer;
|
||||
use Dict;
|
||||
use Exception;
|
||||
use MetaModel;
|
||||
use Twig_Environment;
|
||||
use Twig_SimpleFilter;
|
||||
use Twig_SimpleFunction;
|
||||
@@ -143,28 +142,6 @@ class Extension
|
||||
return utils::IsDevelopmentEnvironment();
|
||||
}));
|
||||
|
||||
// Function to get configuration parameter
|
||||
// Usage in twig: {{ get_config_parameter('foo') }}
|
||||
$oTwigEnv->addFunction(new Twig_SimpleFunction('get_config_parameter', function ($sParamName) {
|
||||
$oConfig = MetaModel::GetConfig();
|
||||
|
||||
return $oConfig->Get($sParamName);
|
||||
}));
|
||||
|
||||
/**
|
||||
* Function to get a module setting
|
||||
* Usage in twig: {{ get_module_setting(<MODULE_CODE>, <PROPERTY_CODE> [, <DEFAULT_VALUE>]) }}
|
||||
*
|
||||
* @uses Config::GetModuleSetting()
|
||||
* @since 3.0.0
|
||||
*/
|
||||
$oTwigEnv->addFunction(new Twig_SimpleFunction('get_module_setting',
|
||||
function (string $sModuleCode, string $sPropertyCode, $defaultValue = null) {
|
||||
$oConfig = MetaModel::GetConfig();
|
||||
|
||||
return $oConfig->GetModuleSetting($sModuleCode, $sPropertyCode, $defaultValue);
|
||||
}));
|
||||
|
||||
// Function to get iTop's app root absolute URL (eg. https://aaa.bbb.ccc/xxx/yyy/)
|
||||
// Usage in twig: {{ get_absolute_url_app_root() }}
|
||||
/** @since 3.0.0 */
|
||||
|
||||
@@ -24,6 +24,7 @@ use AttributeDateTime;
|
||||
use Combodo\iTop\Application\UI\Base\UIBlock;
|
||||
use Combodo\iTop\Core\CMDBChange\CMDBChangeOrigin;
|
||||
use DateTime;
|
||||
use MetaModel;
|
||||
use UserRights;
|
||||
use utils;
|
||||
|
||||
@@ -74,6 +75,8 @@ class ActivityEntry extends UIBlock
|
||||
*/
|
||||
protected $sOrigin;
|
||||
|
||||
protected $bShowAuthorNameBelowEntries;
|
||||
|
||||
/**
|
||||
* ActivityEntry constructor.
|
||||
*
|
||||
@@ -94,6 +97,7 @@ class ActivityEntry extends UIBlock
|
||||
$this->SetDateTime($oDateTime);
|
||||
$this->SetAuthor($sAuthorLogin);
|
||||
$this->SetOrigin(static::DEFAULT_ORIGIN);
|
||||
$this->SetShowAuthorNameBelowEntries(MetaModel::GetConfig()->Get('activity_panel.show_author_name_below_entries'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -306,6 +310,22 @@ class ActivityEntry extends UIBlock
|
||||
return $this->sOrigin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function ShowAuthorNameBelowEntries(): bool
|
||||
{
|
||||
return $this->bShowAuthorNameBelowEntries;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bShowAuthorNameBelowEntries
|
||||
*/
|
||||
public function SetShowAuthorNameBelowEntries($bShowAuthorNameBelowEntries): void
|
||||
{
|
||||
$this->bShowAuthorNameBelowEntries = $bShowAuthorNameBelowEntries;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null The CSS decoration classes for the origin of the entry
|
||||
* @see \CMDBChangeOrigin
|
||||
|
||||
@@ -90,6 +90,17 @@ class ActivityPanel extends UIBlock
|
||||
protected $oComposeMenu;
|
||||
/** @var bool Whether a confirmation dialog should be prompt when multiple entries are about to be submitted at once */
|
||||
protected $bShowMultipleEntriesSubmitConfirmation;
|
||||
/** @var int */
|
||||
protected $iDatetimesReformatLimit;
|
||||
/** @var int */
|
||||
protected $iLockWatcherPeriod;
|
||||
/** @var bool */
|
||||
protected $bPrefilterOnlyCurrentLog;
|
||||
/** @var bool */
|
||||
protected $bPrefilterStateChangesOnLogs;
|
||||
/** @var bool */
|
||||
protected $bPrefilterEditsOnLogs;
|
||||
|
||||
|
||||
/**
|
||||
* ActivityPanel constructor.
|
||||
@@ -105,12 +116,18 @@ class ActivityPanel extends UIBlock
|
||||
{
|
||||
parent::__construct($sId);
|
||||
|
||||
$oConfig = MetaModel::GetConfig();
|
||||
$this->InitializeCaseLogTabs();
|
||||
$this->InitializeCaseLogTabsEntryForms();
|
||||
$this->InitializeComposeMenu();
|
||||
$this->SetObjectMode(cmdbAbstractObject::DEFAULT_DISPLAY_MODE);
|
||||
$this->SetObject($oObject);
|
||||
$this->SetEntries($aEntries);
|
||||
$this->SetDatetimesReformatLimit($oConfig->Get('activity_panel.datetimes_reformat_limit'));
|
||||
$this->SetLockWatcherPeriod($oConfig->Get('activity_panel.lock_watcher_period'));
|
||||
$this->SetPrefilterOnlyCurrentLog($oConfig->Get('activity_panel.prefilter_only_current_log'));
|
||||
$this->SetPrefilterStateChangesOnLogs($oConfig->Get('activity_panel.prefilter_state_changes_on_logs'));
|
||||
$this->SetPrefilterEditsOnLogs($oConfig->Get('activity_panel.prefilter_edits_on_logs'));
|
||||
$this->bAreEntriesSorted = false;
|
||||
$this->bHasMoreEntriesToLoad = false;
|
||||
$this->aLastLoadedEntriesIds = [];
|
||||
@@ -846,6 +863,86 @@ class ActivityPanel extends UIBlock
|
||||
return utils::GetAbsoluteUrlAppRoot().'pages/ajax.render.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function GetDatetimesReformatLimit(): int
|
||||
{
|
||||
return $this->iDatetimesReformatLimit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $iDatetimesReformatLimit
|
||||
*/
|
||||
public function SetDatetimesReformatLimit(int $iDatetimesReformatLimit): void
|
||||
{
|
||||
$this->iDatetimesReformatLimit = $iDatetimesReformatLimit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function GetLockWatcherPeriod(): int
|
||||
{
|
||||
return $this->iLockWatcherPeriod;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $iLockWatcherPeriod
|
||||
*/
|
||||
public function SetLockWatcherPeriod(int $iLockWatcherPeriod): void
|
||||
{
|
||||
$this->iLockWatcherPeriod = $iLockWatcherPeriod;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function GetPrefilterOnlyCurrentLog(): bool
|
||||
{
|
||||
return $this->bPrefilterOnlyCurrentLog;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bPrefilterOnlyCurrentLog
|
||||
*/
|
||||
public function SetPrefilterOnlyCurrentLog(bool $bPrefilterOnlyCurrentLog): void
|
||||
{
|
||||
$this->bPrefilterOnlyCurrentLog = $bPrefilterOnlyCurrentLog;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function GetPrefilterStateChangesOnLogs(): bool
|
||||
{
|
||||
return $this->bPrefilterStateChangesOnLogs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bPrefilterStateChangesOnLogs
|
||||
*/
|
||||
public function SetPrefilterStateChangesOnLogs(bool $bPrefilterStateChangesOnLogs): void
|
||||
{
|
||||
$this->bPrefilterStateChangesOnLogs = $bPrefilterStateChangesOnLogs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function GetPrefilterEditsOnLogs(): bool
|
||||
{
|
||||
return $this->bPrefilterEditsOnLogs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bPrefilterEditsOnLogs
|
||||
*/
|
||||
public function SetPrefilterEditsOnLogs(bool $bPrefilterEditsOnLogs): void
|
||||
{
|
||||
$this->bPrefilterEditsOnLogs = $bPrefilterEditsOnLogs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
|
||||
@@ -86,6 +86,9 @@ class NavigationMenu extends UIBlock implements iKeyboardShortcut
|
||||
protected $bIsExpanded;
|
||||
/** @var bool Whether the hint on how the menu filter works shoudl be displayed or not */
|
||||
protected $bShowMenuFilterHint;
|
||||
/** @var bool */
|
||||
protected $bShowMenusCount;
|
||||
|
||||
|
||||
/**
|
||||
* NavigationMenu constructor.
|
||||
@@ -106,10 +109,13 @@ class NavigationMenu extends UIBlock implements iKeyboardShortcut
|
||||
) {
|
||||
parent::__construct($sId);
|
||||
|
||||
$oConfig = MetaModel::GetConfig();
|
||||
|
||||
$this->sAppRevisionNumber = utils::GetAppRevisionNumber();
|
||||
$this->sAppSquareIconUrl = Branding::GetCompactMainLogoAbsoluteUrl();
|
||||
$this->sAppFullIconUrl = Branding::GetFullMainLogoAbsoluteUrl();
|
||||
$this->sAppIconLink = MetaModel::GetConfig()->Get('app_icon_url');
|
||||
$this->sAppIconLink = $oConfig->Get('app_icon_url');
|
||||
$this->SetShowMenusCount($oConfig->Get('navigation_menu.show_menus_count'));
|
||||
$this->aSiloSelection = array();
|
||||
$this->aMenuGroups = ApplicationMenu::GetMenuGroups($oAppContext->GetAsHash());
|
||||
$this->oUserMenu = $oUserMenu;
|
||||
@@ -479,4 +485,21 @@ JS;
|
||||
{
|
||||
return "[data-role='".static::BLOCK_CODE."']";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function GetShowMenusCount(): bool
|
||||
{
|
||||
return $this->bShowMenusCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bShowMenusCount
|
||||
*/
|
||||
public function SetShowMenusCount(bool $bShowMenusCount): void
|
||||
{
|
||||
$this->bShowMenusCount = $bShowMenusCount;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user