diff --git a/sources/application/UI/Base/Component/Panel/Panel.php b/sources/application/UI/Base/Component/Panel/Panel.php index eb92c7f9a..1255e619d 100644 --- a/sources/application/UI/Base/Component/Panel/Panel.php +++ b/sources/application/UI/Base/Component/Panel/Panel.php @@ -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; diff --git a/sources/application/UI/Base/Layout/PageContent/PageContent.php b/sources/application/UI/Base/Layout/PageContent/PageContent.php index 3ef77141a..d48569fc9 100644 --- a/sources/application/UI/Base/Layout/PageContent/PageContent.php +++ b/sources/application/UI/Base/Layout/PageContent/PageContent.php @@ -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; diff --git a/sources/application/UI/Base/tUIContentAreas.php b/sources/application/UI/Base/tUIContentAreas.php index 8a1edfdc6..b8ad4141c 100644 --- a/sources/application/UI/Base/tUIContentAreas.php +++ b/sources/application/UI/Base/tUIContentAreas.php @@ -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.