diff --git a/ajax/project/getAreas.php b/ajax/project/getAreas.php index fa345cc74df404276cfc6d0ce15bfa11f490a0eb..fa75c98bf71804a7107135fa819be6fd044a9d60 100644 --- a/ajax/project/getAreas.php +++ b/ajax/project/getAreas.php @@ -8,19 +8,19 @@ * Returns the feed list * * @param string $project - json array, Project Data - * @param string $siteType - siteType + * @param string $layout - layout type * @return array */ -function package_quiqqer_bricks_ajax_project_getAreas($project, $siteType) +function package_quiqqer_bricks_ajax_project_getAreas($project, $layout) { $Project = QUI::getProjectManager()->decode( $project ); $BrickManager = new QUI\Bricks\Manager(); - return $BrickManager->getAreasByProject( $Project, $siteType ); + return $BrickManager->getAreasByProject( $Project, $layout ); } QUI::$Ajax->register( 'package_quiqqer_bricks_ajax_project_getAreas', - array( 'project', 'siteType' ), + array( 'project', 'layout' ), 'Permission::checkAdminUser' ); diff --git a/bin/Site/Category.js b/bin/Site/Category.js index 8b207b3372609d3769bb0842e35ef9e7c1105a9f..315b9b1332bcf05d604618f2d07a85d2f450cd85 100644 --- a/bin/Site/Category.js +++ b/bin/Site/Category.js @@ -152,7 +152,7 @@ define('package/quiqqer/bricks/bin/Site/Category', [ QUIAjax.get('package_quiqqer_bricks_ajax_project_getAreas', callback, { 'package' : 'quiqqer/bricks', project : Project.encode(), - siteType : Site.getAttribute( 'type' ) + layout : Site.getAttribute( 'layout' ) }); }, diff --git a/lib/QUI/Bricks/Brick.php b/lib/QUI/Bricks/Brick.php index 49cfb91aefbf92b63d62e53eaac449d9d87f35e4..6fec28cf93b58801e5f393bc483b721ec4bc98d4 100644 --- a/lib/QUI/Bricks/Brick.php +++ b/lib/QUI/Bricks/Brick.php @@ -96,6 +96,23 @@ public function __construct($params=array()) } } + /** + * Check, if control canbe created + * + * @throws QUI\Exception + * @return QUI\Bricks\Brick + */ + public function check() + { + $Control = $this->_getControl(); + + if ( !$Control ) { + throw new QUI\Exception( 'Control not found. Brick could not be created' ); + } + + return $Control; + } + /** * Return the HTML of the Brick * @@ -133,7 +150,7 @@ protected function _getControl() /* @var $Control \QUI\Control */ $Control = new $Ctrl( $this->getSettings() ); - if ( !($Control instanceof QUI\Control) ) { + if ( !($Control instanceof QUI\Control) || !$Control ) { return false; } diff --git a/lib/QUI/Bricks/Manager.php b/lib/QUI/Bricks/Manager.php index eab56a564dcf68a911280662eae0e1b4c0b1c7e7..6ed62dc652c74f8da56148d26c9d0efb010fdc27 100644 --- a/lib/QUI/Bricks/Manager.php +++ b/lib/QUI/Bricks/Manager.php @@ -86,10 +86,10 @@ public function deleteBrick($brickId) * Return the areas which are available in the project * * @param Project $Project - * @param string|bool $siteType - optional, returns only the areas for the specific site type (default = false) + * @param string|bool $layoutType - optional, returns only the areas for the specific layout type (default = false) * @return array */ - public function getAreasByProject(Project $Project, $siteType=false) + public function getAreasByProject(Project $Project, $layoutType=false) { $templates = array(); $bricks = array(); @@ -125,7 +125,7 @@ public function getAreasByProject(Project $Project, $siteType=false) $bricks = array_merge( $bricks, - Utils::getTemplateAreasFromXML( $brickXML, $siteType ) + Utils::getTemplateAreasFromXML( $brickXML, $layoutType ) ); } @@ -308,11 +308,13 @@ public function getBricksByArea($brickArea, Site $Site) try { - $result[] = $this->getBrickById( $brickId ); + $result[] = $this->getBrickById( $brickId )->check(); } catch ( QUI\Exception $Exception ) { - + QUI\System\Log::addWarning( + $Exception->getMessage() .' Brick-ID:'. $brickId + ); } } diff --git a/lib/QUI/Bricks/Utils.php b/lib/QUI/Bricks/Utils.php index 0e7eb4e124dc09ca9850ef62029f151af63b900d..a1c9f4d56f6fb81d955919f3eed45cfb632bb7a4 100644 --- a/lib/QUI/Bricks/Utils.php +++ b/lib/QUI/Bricks/Utils.php @@ -53,10 +53,10 @@ static function getBricksFromXML($file) * Return the template bricks from a xml file * * @param string $file - path to xm file - * @param string|bool $siteType - optional, return only the bricks for the specific site type + * @param string|bool $layoutType - optional, return only the bricks for the specific layout type * @return array */ - static function getTemplateAreasFromXML($file, $siteType=false) + static function getTemplateAreasFromXML($file, $layoutType=false) { if ( !file_exists( $file ) ) { return array(); @@ -67,15 +67,15 @@ static function getTemplateAreasFromXML($file, $siteType=false) $globalAreas = $Path->query( "//quiqqer/bricks/templateAreas/areas/area" ); - if ( $siteType ) + if ( $layoutType ) { $typeAreas = $Path->query( - "//quiqqer/bricks/templateAreas/types/type[@type='{$siteType}']/area" + "//quiqqer/bricks/templateAreas/layouts/layout[@layout='{$layoutType}']/area" ); } else { - $typeAreas = $Path->query( "//quiqqer/bricks/templateAreas/types/type/area" ); + $typeAreas = $Path->query( "//quiqqer/bricks/templateAreas/layouts/layout/area" ); }