From b07080323de0019af24e8c091da4a2c873c29f86 Mon Sep 17 00:00:00 2001 From: Henning Leutz <leutz@pcsg.de> Date: Mon, 9 Mar 2015 21:04:15 +0100 Subject: [PATCH] layout trennung --- ajax/project/getAreas.php | 8 ++++---- bin/Site/Category.js | 2 +- lib/QUI/Bricks/Brick.php | 19 ++++++++++++++++++- lib/QUI/Bricks/Manager.php | 12 +++++++----- lib/QUI/Bricks/Utils.php | 10 +++++----- 5 files changed, 35 insertions(+), 16 deletions(-) diff --git a/ajax/project/getAreas.php b/ajax/project/getAreas.php index fa345cc..fa75c98 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 8b207b3..315b9b1 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 49cfb91..6fec28c 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 eab56a5..6ed62dc 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 0e7eb4e..a1c9f4d 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" ); } -- GitLab