N°4076 - Allow block parameters to change the behaviour of blocks on the page

This commit is contained in:
Eric
2021-07-26 17:20:22 +02:00
parent bfcfcdd4cc
commit 344cce9fdd
11 changed files with 126 additions and 77 deletions

View File

@@ -65,6 +65,7 @@ abstract class Controller
private $m_aLinkedStylesheets;
private $m_aSaas;
private $m_aAjaxTabs;
private $m_aBlockParams;
/** @var string */
private $m_sAccessTokenConfigParamId = null;
@@ -76,21 +77,19 @@ abstract class Controller
*/
public function __construct($sViewPath, $sModuleName = 'core')
{
$this->m_aLinkedScripts = array();
$this->m_aLinkedStylesheets = array();
$this->m_aSaas = array();
$this->m_aAjaxTabs = array();
$this->m_aDefaultParams = array();
$this->m_aLinkedScripts = [];
$this->m_aLinkedStylesheets = [];
$this->m_aSaas = [];
$this->m_aAjaxTabs = [];
$this->m_aDefaultParams = [];
$this->m_aBlockParams = [];
$this->SetViewPath($sViewPath);
$this->SetModuleName($sModuleName);
if ($sModuleName != 'core')
{
try
{
$this->m_aDefaultParams = array('sIndexURL' => utils::GetAbsoluteUrlModulePage($this->m_sModule, 'index.php'));
if ($sModuleName != 'core') {
try {
$this->m_aDefaultParams = ['sIndexURL' => utils::GetAbsoluteUrlModulePage($this->m_sModule, 'index.php')];
}
catch (Exception $e)
{
catch (Exception $e) {
IssueLog::Error($e->getMessage());
}
}
@@ -392,6 +391,9 @@ abstract class Controller
foreach ($this->m_aSaas as $sSaasRelPath) {
$this->AddSaasToPage($sSaasRelPath);
}
foreach ($this->m_aBlockParams as $sKey => $value) {
$this->SetBlockParamToPage($sKey, $value);
}
$this->OutputPage();
}
@@ -550,13 +552,20 @@ abstract class Controller
*/
public function AddAjaxTab($sCode, $sURL, $bCache = true, $sLabel = null)
{
if (is_null($sLabel))
{
if (is_null($sLabel)) {
$sLabel = Dict::S($sCode);
}
$this->m_aAjaxTabs[$sCode] = array('label' => $sLabel, 'url' => $sURL, 'cache' => $bCache);
}
/**
* @param array $aBlockParams
*/
public function AddBlockParams(array $aBlockParams)
{
$this->m_aBlockParams = $aBlockParams;
}
/**
* @param $aParams
* @param $sName
@@ -595,7 +604,7 @@ abstract class Controller
switch ($sPageType)
{
case self::ENUM_PAGE_TYPE_HTML:
$this->m_oPage = new iTopWebPage($this->GetOperationTitle());
$this->m_oPage = new iTopWebPage($this->GetOperationTitle(), false);
$this->m_oPage->add_xframe_options();
break;
@@ -679,6 +688,11 @@ abstract class Controller
$this->m_oPage->AddAjaxTab($sCode, $sURL, $bCache, $sTitle);
}
public function SetBlockParamToPage(string $sKey, $value)
{
$this->m_oPage->SetBlockParam($sKey, $value);
}
/**
* @throws \Exception
*/