From b0e07f5d1796eb1bd2055e4d00647b796c250b79 Mon Sep 17 00:00:00 2001
From: Henning Leutz <leutz@pcsg.de>
Date: Wed, 11 Mar 2015 14:50:39 +0100
Subject: [PATCH] Bricks -> get areas fixes

---
 bin/Site/Category.js       | 18 +++++++++++++-----
 lib/QUI/Bricks/Brick.php   | 13 ++++++++++++-
 lib/QUI/Bricks/Manager.php |  6 +++---
 3 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/bin/Site/Category.js b/bin/Site/Category.js
index 315b9b1..a8f00fb 100644
--- a/bin/Site/Category.js
+++ b/bin/Site/Category.js
@@ -149,11 +149,19 @@ define('package/quiqqer/bricks/bin/Site/Category', [
             var Site    = this.getAttribute( 'Site' ),
                 Project = Site.getProject();
 
-            QUIAjax.get('package_quiqqer_bricks_ajax_project_getAreas', callback, {
-                'package' : 'quiqqer/bricks',
-                project   : Project.encode(),
-                layout    : Site.getAttribute( 'layout' )
-            });
+            Project.getConfig(function(layout)
+            {
+                if ( Site.getAttribute( 'layout' ) ) {
+                    layout = Site.getAttribute( 'layout' );
+                }
+
+                QUIAjax.get('package_quiqqer_bricks_ajax_project_getAreas', callback, {
+                    'package' : 'quiqqer/bricks',
+                    project   : Project.encode(),
+                    layout    : layout
+                });
+
+            }, 'layout');
         },
 
         /**
diff --git a/lib/QUI/Bricks/Brick.php b/lib/QUI/Bricks/Brick.php
index 6fec28c..c63457d 100644
--- a/lib/QUI/Bricks/Brick.php
+++ b/lib/QUI/Bricks/Brick.php
@@ -19,12 +19,14 @@ class Brick extends QUI\QDOM
 {
     /**
      * Brick settings
+     *
      * @var array
      */
     protected $_settings = array();
 
     /**
      * Constructor
+     *
      * @param array $params - brick params
      */
     public function __construct($params=array())
@@ -62,7 +64,7 @@ public function __construct($params=array())
         }
 
         // control default settings
-        if ( $Control )
+        if ( is_object( $Control ) )
         {
             $controlSettings = $Control->getAttributes();
 
@@ -104,6 +106,10 @@ public function __construct($params=array())
      */
     public function check()
     {
+        if ( $this->getAttribute( 'type' ) == 'content' ) {
+            return $this;
+        }
+
         $Control = $this->_getControl();
 
         if ( !$Control ) {
@@ -137,12 +143,17 @@ public function create()
 
     /**
      * Return the internal control
+     *
      * @return QUI\Control|Bool
      */
     protected function _getControl()
     {
         $Ctrl = $this->getAttribute( 'type' );
 
+        if ( $Ctrl === 'content' ) {
+            return true;
+        }
+
         if ( !is_callable( $Ctrl ) && !class_exists( $Ctrl ) ) {
             return false;
         }
diff --git a/lib/QUI/Bricks/Manager.php b/lib/QUI/Bricks/Manager.php
index a4beee2..0fdc4cf 100644
--- a/lib/QUI/Bricks/Manager.php
+++ b/lib/QUI/Bricks/Manager.php
@@ -96,9 +96,9 @@ public function getAreasByProject(Project $Project, $layoutType=false)
 
         $projectName = $Project->getName();
 
-        if ( !$layoutType ) {
-            $layoutType = $Project->getAttribute( 'layout' );
-        }
+//        if ( !$layoutType ) {
+//            $layoutType = $Project->getAttribute( 'layout' );
+//        }
 
         // get all vhosts, and the used templates of the project
         $vhosts = QUI::getRewrite()->getVHosts();
-- 
GitLab