Merge remote-tracking branch 'origin/develop' into feature/8772_form_dependencies_manager

This commit is contained in:
Eric Espie
2025-11-14 16:08:37 +01:00
2221 changed files with 56572 additions and 61991 deletions

View File

@@ -1,4 +1,5 @@
<?php
/*
* @copyright Copyright (C) 2010-2025 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0
@@ -6,20 +7,19 @@
namespace Combodo\iTop\Application\TwigBase\Controller;
abstract class AbstractProfilerExtension implements iProfilerExtension
{
public function Init()
{
}
public abstract function GetTemplatesPath(): null|string|array;
abstract public function GetTemplatesPath(): null|string|array;
public abstract function IsEnabled(): bool;
abstract public function IsEnabled(): bool;
public abstract function GetDebugTemplate(): string;
abstract public function GetDebugTemplate(): string;
public abstract function GetDebugParams(array $aParams): array;
abstract public function GetDebugParams(array $aParams): array;
public function GetLinkedScripts(): ?array
{
@@ -35,4 +35,4 @@ abstract class AbstractProfilerExtension implements iProfilerExtension
{
return null;
}
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Copyright (C) 2013-2024 Combodo SAS
*
@@ -156,7 +157,7 @@ abstract class Controller extends AbstractController
if (!in_array($path, $aAdditionalPaths)) {
$aAdditionalPaths[] = $path;
}
} else if (is_array($path)) {
} elseif (is_array($path)) {
foreach ($path as $sPath) {
if (!in_array($sPath, $aAdditionalPaths)) {
$aAdditionalPaths[] = $sPath;
@@ -169,8 +170,7 @@ abstract class Controller extends AbstractController
if ($sModuleName != 'core') {
try {
$this->aDefaultParams = ['sIndexURL' => utils::GetAbsoluteUrlModulePage($this->m_sModule, 'index.php')];
}
catch (Exception $e) {
} catch (Exception $e) {
IssueLog::Error($e->getMessage());
}
}
@@ -197,9 +197,8 @@ abstract class Controller extends AbstractController
$this->SetModuleName(basename($sModulePath));
$this->SetViewPath($sModulePath.'/view');
try {
$this->aDefaultParams = array('sIndexURL' => utils::GetAbsoluteUrlModulePage($this->m_sModule, 'index.php'));
}
catch (Exception $e) {
$this->aDefaultParams = ['sIndexURL' => utils::GetAbsoluteUrlModulePage($this->m_sModule, 'index.php')];
} catch (Exception $e) {
IssueLog::Error($e->getMessage());
}
}
@@ -302,7 +301,7 @@ abstract class Controller extends AbstractController
}
catch (Exception $e) {
http_response_code(500);
$aResponse = array('sError' => $e->getMessage());
$aResponse = ['sError' => $e->getMessage()];
echo json_encode($aResponse);
}
}
@@ -364,7 +363,9 @@ abstract class Controller extends AbstractController
$sDecodedPassedToken = urldecode($sPassedToken);
if ($sDecodedPassedToken !== $sConfiguredAccessTokenValue) {
$sMsg = "Invalid token passed under '$this->sAccessTokenConfigParamId' http param to reach '$sExecModule' page.";
IssueLog::Error($sMsg, null,
IssueLog::Error(
$sMsg,
null,
[
'sHtmlDecodedToken' => $sDecodedPassedToken,
'conf param ID' => $this->sAccessTokenConfigParamId,
@@ -464,7 +465,7 @@ abstract class Controller extends AbstractController
*
* @throws \Exception
*/
public function DisplayAjaxPage($aParams = array(), $sTemplateName = null): void
public function DisplayAjaxPage($aParams = [], $sTemplateName = null): void
{
$this->DisplayPage($aParams, $sTemplateName, 'ajax');
}
@@ -623,7 +624,7 @@ abstract class Controller extends AbstractController
file_put_contents($sHTMLReport, ob_get_contents());
ob_end_clean();
$this->ZipDownloadRemoveFile(array($sHTMLReport), $sZIPReportFile, true);
$this->ZipDownloadRemoveFile([$sHTMLReport], $sZIPReportFile, true);
}
/**
@@ -735,7 +736,7 @@ abstract class Controller extends AbstractController
if (is_null($sLabel)) {
$sLabel = Dict::S($sCode);
}
$this->aAjaxTabs[$sCode] = array('label' => $sLabel, 'url' => $sURL, 'cache' => $bCache);
$this->aAjaxTabs[$sCode] = ['label' => $sLabel, 'url' => $sURL, 'cache' => $bCache];
}
/**
@@ -838,8 +839,7 @@ abstract class Controller extends AbstractController
}
try {
return $this->oTwig->render($sTemplateFile, $aParams);
}
catch (SyntaxError $e) {
} catch (SyntaxError $e) {
IssueLog::Error($e->getMessage().' - file: '.$e->getFile().'('.$e->getLine().')');
$aErrors[self::TWIG_ERROR][] = $e->getMessage();

View File

@@ -1,4 +1,5 @@
<?php
/*
* @copyright Copyright (C) 2010-2025 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0
@@ -17,4 +18,4 @@ interface iProfilerExtension
public function GetLinkedScripts(): null|array;
public function GetLinkedStylesheets(): null|array;
public function GetSaas(): null|array;
}
}

View File

@@ -1,4 +1,5 @@
<?php
/*
* @copyright Copyright (C) 2010-2024 Combodo SAS
* @license http://opensource.org/licenses/AGPL-3.0
@@ -6,7 +7,6 @@
namespace Combodo\iTop\Application\TwigBase\Twig;
use ApplicationMenu;
use AttributeDate;
use AttributeDateTime;
@@ -76,8 +76,7 @@ class Extension
if (preg_match('@^\d\d\d\d-\d\d-\d\d$@', trim($sDate))) {
return AttributeDate::GetFormat()->Format($sDate);
}
}
catch (Exception $e) {
} catch (Exception $e) {
}
return $sDate;
@@ -202,7 +201,8 @@ class Extension
// Function to render a UI block (HTML, inline CSS, inline JS) and its sub blocks directly in the TWIG
// Usage in twig: {{ render_block(oBlock) }}
/** @since 3.0.0 */
$aFunctions[] = new TwigFunction('render_block',
$aFunctions[] = new TwigFunction(
'render_block',
function (iUIBlock $oBlock, $aContextParams = []) {
$oRenderer = new BlockRenderer($oBlock, $aContextParams);
@@ -211,28 +211,29 @@ class Extension
['is_safe' => ['html']]
);
/** @since 3.2.0 */
$aFunctions[] = new TwigFunction('source_abs', function (Environment $oEnv, $sUrlAbsName) {
// Extract the source path from the absolute url and replace it with approot
$sAppRootAbsName = str_replace(utils::GetAbsoluteUrlAppRoot(), APPROOT, $sUrlAbsName);
$oLoader = $oEnv->getLoader();
// Check if the file is in any of the twig paths
if($oLoader instanceof FilesystemLoader) {
$aPaths = $oLoader->getPaths();
foreach ($aPaths as $sPath) {
$sTwigPathRelativeName = substr($sAppRootAbsName, strlen($sPath) + 1);
// If we find our path in the absolute url and the file actually exist, return it
if (str_contains($sAppRootAbsName, $sPath) && $oLoader->exists($sTwigPathRelativeName)) {
return $oLoader->getSourceContext($sTwigPathRelativeName)->getCode();
$aFunctions[] = new TwigFunction(
'source_abs',
function (Environment $oEnv, $sUrlAbsName) {
// Extract the source path from the absolute url and replace it with approot
$sAppRootAbsName = str_replace(utils::GetAbsoluteUrlAppRoot(), APPROOT, $sUrlAbsName);
$oLoader = $oEnv->getLoader();
// Check if the file is in any of the twig paths
if ($oLoader instanceof FilesystemLoader) {
$aPaths = $oLoader->getPaths();
foreach ($aPaths as $sPath) {
$sTwigPathRelativeName = substr($sAppRootAbsName, strlen($sPath) + 1);
// If we find our path in the absolute url and the file actually exist, return it
if (str_contains($sAppRootAbsName, $sPath) && $oLoader->exists($sTwigPathRelativeName)) {
return $oLoader->getSourceContext($sTwigPathRelativeName)->getCode();
}
}
}
}
// Otherwise return empty content
$oEmptySource = new Source('', $sUrlAbsName, '');
return $oEmptySource->getCode();
},
['needs_environment' => true,
// Otherwise return empty content
$oEmptySource = new Source('', $sUrlAbsName, '');
return $oEmptySource->getCode();
},
['needs_environment' => true,
'is_safe' => ['all']]
);

View File

@@ -1,4 +1,5 @@
<?php
/*
* @copyright Copyright (C) 2010-2024 Combodo SAS
* @license http://opensource.org/licenses/AGPL-3.0
@@ -22,7 +23,6 @@ use Twig\Extension\DebugExtension;
use Twig\Loader\FilesystemLoader;
use utils;
/**
* Class TwigHelper
*
@@ -75,7 +75,7 @@ class TwigHelper
* @return Environment
* @throws \Twig\Error\LoaderError
*/
public static function GetTwigEnvironment($sViewPath, $aAdditionalPaths = array())
public static function GetTwigEnvironment($sViewPath, $aAdditionalPaths = [])
{
$oLoader = new FilesystemLoader($sViewPath);
foreach ($aAdditionalPaths as $sAdditionalPath) {
@@ -115,7 +115,7 @@ class TwigHelper
* @throws \Exception
* @api
*/
public static function RenderIntoPage(WebPage $oPage, $sViewPath, $sTemplateName, $aParams = array(), $sDefaultType = self::DEFAULT_FILE_TYPE)
public static function RenderIntoPage(WebPage $oPage, $sViewPath, $sTemplateName, $aParams = [], $sDefaultType = self::DEFAULT_FILE_TYPE)
{
$oTwig = self::GetTwigEnvironment($sViewPath);
$oTwig->addGlobal('UIBlockParent', [$oPage]);
@@ -139,7 +139,7 @@ class TwigHelper
* @throws \Twig\Error\LoaderError
* @since 3.0.0
*/
public static function RenderIntoBlock(WebPage $oPage, UIBlock $oBlock, $sViewPath, $sTemplateName, $aParams = array(), $sDefaultType = self::DEFAULT_FILE_TYPE)
public static function RenderIntoBlock(WebPage $oPage, UIBlock $oBlock, $sViewPath, $sTemplateName, $aParams = [], $sDefaultType = self::DEFAULT_FILE_TYPE)
{
$oTwig = self::GetTwigEnvironment($sViewPath);
$oTwig->addGlobal('UIBlockParent', [$oBlock]);
@@ -168,8 +168,7 @@ class TwigHelper
$oKPI->ComputeStats('Render TWIG', $sFileName);
return $sResult;
}
catch (Error $oTwigException) {
} catch (Error $oTwigException) {
$oTwigPreviousException = $oTwigException->getPrevious();
if (!is_null(($oTwigPreviousException)) && ($oTwigPreviousException instanceof CoreTemplateException)) {
// handles recursive calls : if we're here, an exception was already raised in a child template !

View File

@@ -1,13 +1,12 @@
<?php
/**
* @copyright Copyright (C) 2010-2024 Combodo SAS
* @license http://opensource.org/licenses/AGPL-3.0
*/
namespace Combodo\iTop\Application\TwigBase\UI;
use Combodo\iTop\Application\UI\Base\iUIBlockFactory;
use Combodo\iTop\Service\InterfaceDiscovery\InterfaceDiscovery;
use Twig\Extension\AbstractExtension;
@@ -36,4 +35,4 @@ class UIBlockExtension extends AbstractExtension
return $aParsers;
}
}
}

View File

@@ -1,13 +1,12 @@
<?php
/**
* @copyright Copyright (C) 2010-2024 Combodo SAS
* @license http://opensource.org/licenses/AGPL-3.0
*/
namespace Combodo\iTop\Application\TwigBase\UI;
use Exception;
use ReflectionClass;
use ReflectionException;
@@ -161,4 +160,4 @@ class UIBlockNode extends Node
}
$oCompiler->write("ob_start();\n");
}
}
}

View File

@@ -1,13 +1,12 @@
<?php
/**
* @copyright Copyright (C) 2010-2024 Combodo SAS
* @license http://opensource.org/licenses/AGPL-3.0
*/
namespace Combodo\iTop\Application\TwigBase\UI;
use Twig\Token;
use Twig\TokenParser\AbstractTokenParser;
@@ -30,7 +29,6 @@ class UIBlockParser extends AbstractTokenParser
/** @var string */
protected $sBlockClassName;
/**
* UIBlockParser constructor.
*
@@ -44,7 +42,6 @@ class UIBlockParser extends AbstractTokenParser
$this->bHasSubBlocks = is_subclass_of($this->sBlockClassName, "Combodo\\iTop\\Application\\UI\\Base\\Layout\\UIContentBlock") || $this->sBlockClassName == "Combodo\\iTop\\Application\\UI\\Base\\Layout\\UIContentBlock";
}
/**
* @inheritDoc
*/
@@ -81,4 +78,4 @@ class UIBlockParser extends AbstractTokenParser
{
return $sToken->test('End'.$this->sTag);
}
}
}