N°2847 - Add method to add several blocks at once to a content area (tUIContentAreas)

This commit is contained in:
Molkobain
2021-03-04 15:13:46 +01:00
parent cf956099ac
commit 9bdccb0fb3
3 changed files with 96 additions and 7 deletions

View File

@@ -230,12 +230,28 @@ class Panel extends UIContentBlock
*
* @return $this
*/
public function AddMainBlock(iUIBlock $oBlock) {
public function AddMainBlock(iUIBlock $oBlock)
{
$this->AddBlockToContentArea(static::ENUM_CONTENT_AREA_MAIN, $oBlock);
return $this;
}
/**
* Add all $aBlocks to the main blocks
*
* @param \Combodo\iTop\Application\UI\Base\iUIBlock[] $aBlocks
*
* @return $this
* @uses static::AddBlocksToContentArea()
*/
public function AddMainBlocks(array $aBlocks)
{
$this->AddBlocksToContentArea(static::ENUM_CONTENT_AREA_MAIN, $aBlocks);
return $this;
}
/**
* Remove the main block identified by $sBlockId.
* Note that if no block with that ID exists, it will proceed silently.
@@ -244,7 +260,8 @@ class Panel extends UIContentBlock
*
* @return $this
*/
public function RemoveMainBlock(string $sBlockId) {
public function RemoveMainBlock(string $sBlockId)
{
$this->RemoveBlockFromContentArea(static::ENUM_CONTENT_AREA_MAIN, $sBlockId);
return $this;
@@ -281,12 +298,28 @@ class Panel extends UIContentBlock
*
* @return $this
*/
public function AddToolbarBlock(iUIBlock $oBlock) {
public function AddToolbarBlock(iUIBlock $oBlock)
{
$this->AddBlockToContentArea(static::ENUM_CONTENT_AREA_TOOLBAR, $oBlock);
return $this;
}
/**
* Add all $aBlocks to the toolbar blocks
*
* @param \Combodo\iTop\Application\UI\Base\iUIBlock[] $aBlocks
*
* @return $this
* @uses static::AddBlocksToContentArea()
*/
public function AddToolbarBlocks(array $aBlocks)
{
$this->AddBlocksToContentArea(static::ENUM_CONTENT_AREA_TOOLBAR, $aBlocks);
return $this;
}
/**
* Remove the toolbar block identified by $sBlockId.
* Note that if no block with that ID exists, it will proceed silently.
@@ -295,7 +328,8 @@ class Panel extends UIContentBlock
*
* @return $this
*/
public function RemoveToolbarBlock(string $sBlockId) {
public function RemoveToolbarBlock(string $sBlockId)
{
$this->RemoveBlockFromContentArea(static::ENUM_CONTENT_AREA_TOOLBAR, $sBlockId);
return $this;

View File

@@ -93,12 +93,28 @@ class PageContent extends UIBlock implements iUIContentBlock {
*
* @return $this
*/
public function AddMainBlock(iUIBlock $oBlock) {
public function AddMainBlock(iUIBlock $oBlock)
{
$this->AddBlockToContentArea(static::ENUM_CONTENT_AREA_MAIN, $oBlock);
return $this;
}
/**
* Add all $aBlocks to the main content area
*
* @param \Combodo\iTop\Application\UI\Base\iUIBlock[] $aBlocks
*
* @return $this
* @uses static::AddBlocksToContentArea()
*/
public function AddMainBlocks(array $aBlocks)
{
$this->AddBlocksToContentArea(static::ENUM_CONTENT_AREA_MAIN, $aBlocks);
return $this;
}
/**
* Remove the main block identified by $sBlockId.
* Note that if no block with that ID exists, it will proceed silently.
@@ -107,7 +123,8 @@ class PageContent extends UIBlock implements iUIContentBlock {
*
* @return $this
*/
public function RemoveMainBlock(string $sBlockId) {
public function RemoveMainBlock(string $sBlockId)
{
$this->RemoveBlockFromContentArea(static::ENUM_CONTENT_AREA_MAIN, $sBlockId);
return $this;

View File

@@ -131,7 +131,26 @@ trait tUIContentAreas {
}
/**
* Add $oBlock to the $sAreaId content area.
* Add all $aBlocks to the $sAreaId content area
*
* @param string $sAreaId
* @param \Combodo\iTop\Application\UI\Base\iUIBlock[] $aBlocks
*
* @return $this
* @uses static::AddBlockToContentArea()
*
*/
protected function AddBlocksToContentArea(string $sAreaId, array $aBlocks)
{
foreach ($aBlocks as $oBlock) {
$this->AddBlockToContentArea($sAreaId, $oBlock);
}
return $this;
}
/**
* Add $oBlock as deferred to the $sAreaId content area.
* Note that if the area doesn't exist yet, it is created. Also if a block with the same ID already exists, it will be replaced.
*
* @param string $sAreaId
@@ -150,6 +169,25 @@ trait tUIContentAreas {
return $this;
}
/**
* Add all $aBlocks as deferred to the $sAreaId content area
*
* @param string $sAreaId
* @param \Combodo\iTop\Application\UI\Base\iUIBlock[] $aBlocks
*
* @return $this
* @uses static::AddDeferredBlockToContentArea()
*
*/
protected function AddDeferredBlocksToContentArea(string $sAreaId, array $aBlocks)
{
foreach ($aBlocks as $oBlock) {
$this->AddDeferredBlockToContentArea($sAreaId, $oBlock);
}
return $this;
}
/**
* Remove the $sBlockId from the $sAreaId content area.
* Note that if the $sBlockId or the $sAreaId do not exist, it proceeds silently.