From 421b75f82cfb828978c5a8048a620455fca93523 Mon Sep 17 00:00:00 2001
From: Henning Leutz <leutz@pcsg.de>
Date: Tue, 10 Apr 2018 16:55:07 +0200
Subject: [PATCH] feat: quiqqer/package-bricks#79 -> Page Search and Page Data
 Display

---
 ajax/getSitesFromBrick.php         |  36 ++++
 bin/BrickEdit.js                   |   3 +-
 bin/Controls/backend/BrickUsage.js |  40 ++++-
 locale.xml                         |   4 +
 src/QUI/Bricks/Manager.php         | 258 +++++++++++++++++------------
 src/QUI/Bricks/Utils.php           |  28 ++--
 6 files changed, 245 insertions(+), 124 deletions(-)
 create mode 100644 ajax/getSitesFromBrick.php

diff --git a/ajax/getSitesFromBrick.php b/ajax/getSitesFromBrick.php
new file mode 100644
index 0000000..cf62126
--- /dev/null
+++ b/ajax/getSitesFromBrick.php
@@ -0,0 +1,36 @@
+<?php
+
+/**
+ * Return a xml category
+ *
+ * @param array $file - list of xml files
+ * @param $category
+ * @return String
+ */
+QUI::$Ajax->registerFunction(
+    'package_quiqqer_bricks_ajax_getSitesFromBrick',
+    function ($brickId, $options) {
+        $options = json_decode($options, true);
+        $Bricks  = QUI\Bricks\Manager::init();
+        $Brick   = $Bricks->getBrickById($brickId);
+
+        $sites  = $Bricks->getSitesByBrick($Brick);
+        $result = array_map(function ($Site) {
+            /* @var $Site \QUI\Projects\Site */
+            return [
+                'project' => $Site->getProject()->getName(),
+                'lang'    => $Site->getProject()->getLang(),
+                'id'      => $Site->getId(),
+                'title'   => $Site->getAttribute('title'),
+                'name'    => $Site->getAttribute('name'),
+                'url'     => $Site->getUrlRewritten()
+            ];
+        }, $sites);
+
+        $Grid = new QUI\Utils\Grid();
+
+        return $Grid->parseResult($result, count($sites));
+    },
+    ['brickId', 'options'],
+    'Permission::checkAdminUser'
+);
diff --git a/bin/BrickEdit.js b/bin/BrickEdit.js
index 56c662b..63de5db 100644
--- a/bin/BrickEdit.js
+++ b/bin/BrickEdit.js
@@ -560,7 +560,8 @@ define('package/quiqqer/bricks/bin/BrickEdit', [
                 return new Promise(function (resolve) {
                     require(['package/quiqqer/bricks/bin/Controls/backend/BrickUsage'], function (Control) {
                         new Control({
-                            events: {
+                            brickId: self.getAttribute('id'),
+                            events : {
                                 onLoad: resolve
                             }
                         }).inject(self.$Container);
diff --git a/bin/Controls/backend/BrickUsage.js b/bin/Controls/backend/BrickUsage.js
index 32da813..e5b2ce6 100644
--- a/bin/Controls/backend/BrickUsage.js
+++ b/bin/Controls/backend/BrickUsage.js
@@ -7,10 +7,11 @@ define('package/quiqqer/bricks/bin/Controls/backend/BrickUsage', [
     'qui/QUI',
     'qui/controls/Control',
     'controls/grid/Grid',
+    'utils/Panels',
     'Locale',
     'Ajax'
 
-], function (QUI, QUIControl, Grid, QUILocale, QUIAjax) {
+], function (QUI, QUIControl, Grid, PanelUtils, QUILocale, QUIAjax) {
     "use strict";
 
     return new Class({
@@ -19,7 +20,8 @@ define('package/quiqqer/bricks/bin/Controls/backend/BrickUsage', [
         Type   : 'package/quiqqer/bricks/bin/Controls/backend/BrickUsage',
 
         Binds: [
-            '$onInject'
+            '$onInject',
+            '$dblClick'
         ],
 
         options: {
@@ -61,7 +63,7 @@ define('package/quiqqer/bricks/bin/Controls/backend/BrickUsage', [
             this.$Grid = new Grid(Container, {
                 columnModel: [{
                     header   : QUILocale.get('quiqqer/system', 'project'),
-                    dataIndex: 'id',
+                    dataIndex: 'project',
                     dataType : 'string',
                     width    : 100
                 }, {
@@ -79,10 +81,19 @@ define('package/quiqqer/bricks/bin/Controls/backend/BrickUsage', [
                     dataIndex: 'title',
                     dataType : 'string',
                     width    : 200
+                }, {
+                    header   : QUILocale.get('quiqqer/bricks', 'brick.panel.usage.grid.url'),
+                    dataIndex: 'url',
+                    dataType : 'string',
+                    width    : 300
                 }],
                 onrefresh  : this.refresh
             });
 
+            this.$Grid.addEvents({
+                onDblClick: this.$dblClick
+            });
+
             return this.$Elm;
         },
 
@@ -96,9 +107,11 @@ define('package/quiqqer/bricks/bin/Controls/backend/BrickUsage', [
                 QUIAjax.get('package_quiqqer_bricks_ajax_getSitesFromBrick', function (result) {
                     self.$Grid.setData(result);
                     resolve();
+                    console.log(result);
                 }, {
                     'package': 'quiqqer/bricks',
-                    brickId  : self.getAttribute('brickId')
+                    brickId  : self.getAttribute('brickId'),
+                    options  : JSON.encode({})
                 });
             });
         },
@@ -129,7 +142,24 @@ define('package/quiqqer/bricks/bin/Controls/backend/BrickUsage', [
         $onInject: function () {
             this.refresh().then(function () {
                 this.fireEvent('load', [this]);
-            });
+            }.bind(this));
+        },
+
+        /**
+         * grid dbl click
+         */
+        $dblClick: function () {
+            var selected = this.$Grid.getSelectedData();
+
+            if (!selected.length) {
+                return;
+            }
+
+            PanelUtils.openSitePanel(
+                selected[0].project,
+                selected[0].lang,
+                selected[0].id
+            );
         }
     });
 });
\ No newline at end of file
diff --git a/locale.xml b/locale.xml
index e2fb839..8f6dcc4 100644
--- a/locale.xml
+++ b/locale.xml
@@ -519,6 +519,10 @@
             <de><![CDATA[Verwendung]]></de>
             <en><![CDATA[Usage]]></en>
         </locale>
+        <locale name="brick.panel.usage.grid.url">
+            <de><![CDATA[Seiten URL]]></de>
+            <en><![CDATA[Site URL]]></en>
+        </locale>
     </groups>
 
     <groups name="quiqqer/bricks" datatype="php">
diff --git a/src/QUI/Bricks/Manager.php b/src/QUI/Bricks/Manager.php
index 5d0af28..3b250e0 100644
--- a/src/QUI/Bricks/Manager.php
+++ b/src/QUI/Bricks/Manager.php
@@ -38,14 +38,14 @@ class Manager
      *
      * @var array
      */
-    protected $bricks = array();
+    protected $bricks = [];
 
     /**
      * Brick UID temp collector
      *
      * @var array
      */
-    protected $brickUIDs = array();
+    protected $brickUIDs = [];
 
     /**
      * Initialized brick manager
@@ -115,13 +115,13 @@ public function createBrickForProject(Project $Project, Brick $Brick)
 
         QUI::getDataBase()->insert(
             $this->getTable(),
-            array(
+            [
                 'project'     => $Project->getName(),
                 'lang'        => $Project->getLang(),
                 'title'       => $Brick->getAttribute('title'),
                 'description' => $Brick->getAttribute('description'),
                 'type'        => $Brick->getAttribute('type')
-            )
+            ]
         );
 
         $lastId = QUI::getPDO()->lastInsertId();
@@ -138,7 +138,7 @@ public function createBrickForProject(Project $Project, Brick $Brick)
      *
      * @throws QUI\Exception
      */
-    public function createUniqueSiteBrick(Site $Site, $brickData = array())
+    public function createUniqueSiteBrick(Site $Site, $brickData = [])
     {
         if (!empty($brickData['uid'])) {
             $uid = $brickData['uid'];
@@ -150,7 +150,7 @@ public function createUniqueSiteBrick(Site $Site, $brickData = array())
             $uid = $this->createUniqueBrickId((int)$brickData['brickId'], $Site);
         }
 
-        $customFields = array();
+        $customFields = [];
 
         if (isset($brickData['customfields'])) {
             $customFields = $brickData['customfields'];
@@ -160,11 +160,11 @@ public function createUniqueSiteBrick(Site $Site, $brickData = array())
             $customFields = json_encode($customFields);
         }
 
-        QUI::getDataBase()->update($this->getUIDTable(), array(
+        QUI::getDataBase()->update($this->getUIDTable(), [
             'customfields' => $customFields
-        ), array(
+        ], [
             'uid' => $uid
-        ));
+        ]);
 
 
         return $uid;
@@ -185,14 +185,14 @@ protected function createUniqueBrickId($brickId, $Site)
         $uuid    = QUI\Utils\Uuid::get();
         $Brick   = $this->getBrickById($brickId);
 
-        QUI::getDataBase()->insert($this->getUIDTable(), array(
+        QUI::getDataBase()->insert($this->getUIDTable(), [
             'uid'        => $uuid,
             'brickId'    => $brickId,
             'project'    => $Project->getName(),
             'lang'       => $Project->getLang(),
             'siteId'     => $Site->getId(),
             'attributes' => json_encode($Brick->getAttributes())
-        ));
+        ]);
 
         return $uuid;
     }
@@ -205,13 +205,13 @@ protected function createUniqueBrickId($brickId, $Site)
      */
     public function existsUniqueBrickId($uid)
     {
-        $result = QUI::getDataBase()->fetch(array(
+        $result = QUI::getDataBase()->fetch([
             'from'  => $this->getUIDTable(),
-            'where' => array(
+            'where' => [
                 'uid' => $uid
-            ),
+            ],
             'limit' => 1
-        ));
+        ]);
 
         return isset($result[0]);
     }
@@ -237,25 +237,25 @@ public function deleteBrick($brickId)
         // check if brick exist
         $Brick = $this->getBrickById($brickId);
 
-        QUI::getDataBase()->delete($this->getTable(), array(
+        QUI::getDataBase()->delete($this->getTable(), [
             'id' => $brickId
-        ));
+        ]);
 
         if (isset($this->bricks[$brickId])) {
             unset($this->bricks[$brickId]);
         }
 
 
-        $uniqueBrickIds = QUI::getDataBase()->fetch(array(
+        $uniqueBrickIds = QUI::getDataBase()->fetch([
             'select' => 'siteId, project, lang',
             'from'   => QUI\Bricks\Manager::getUIDTable(),
-            'where'  => array(
+            'where'  => [
                 'brickId' => $brickId,
                 'project' => $Brick->getAttribute('project'),
                 'lang'    => $Brick->getAttribute('lang')
-            ),
+            ],
             'group'  => 'siteId, project, lang'
-        ));
+        ]);
 
         // delete bricks in sites
         foreach ($uniqueBrickIds as $uniqueBrickId) {
@@ -271,11 +271,11 @@ public function deleteBrick($brickId)
         }
 
         // delete unique ids
-        QUI::getDataBase()->delete(QUI\Bricks\Manager::getUIDTable(), array(
+        QUI::getDataBase()->delete(QUI\Bricks\Manager::getUIDTable(), [
             'brickId' => $brickId,
             'project' => $Brick->getAttribute('project'),
             'lang'    => $Brick->getAttribute('lang')
-        ));
+        ]);
     }
 
     /**
@@ -289,8 +289,8 @@ public function deleteBrick($brickId)
      */
     public function getAreasByProject(Project $Project, $layoutType = false)
     {
-        $templates = array();
-        $bricks    = array();
+        $templates = [];
+        $bricks    = [];
 
         $projectName = $Project->getName();
 
@@ -330,7 +330,7 @@ public function getAreasByProject(Project $Project, $layoutType = false)
         }
 
         // unique values
-        $cleaned = array();
+        $cleaned = [];
         foreach ($bricks as $val) {
             if (!isset($cleaned[$val['name']])) {
                 $cleaned[$val['name']] = $val;
@@ -362,11 +362,14 @@ public function getAreasByProject(Project $Project, $layoutType = false)
             return $transA > $transB ? 1 : -1;
         });
 
-
-        QUI::getEvents()->fireEvent(
-            'onBricksGetAreaByProject',
-            array($this, $Project, &$bricks)
-        );
+        try {
+            QUI::getEvents()->fireEvent(
+                'onBricksGetAreaByProject',
+                [$this, $Project, &$bricks]
+            );
+        } catch (QUI\Exception $Exception) {
+            QUI\System\Log::writeException($Exception);
+        }
 
         return $bricks;
     }
@@ -386,16 +389,16 @@ public function getAvailableBricks()
         }
 
         $xmlFiles = $this->getBricksXMLFiles();
-        $result   = array();
+        $result   = [];
 
-        $result[] = array(
-            'title'       => array('quiqqer/bricks', 'brick.content.title'),
-            'description' => array(
+        $result[] = [
+            'title'       => ['quiqqer/bricks', 'brick.content.title'],
+            'description' => [
                 'quiqqer/bricks',
                 'brick.content.description'
-            ),
+            ],
             'control'     => 'content'
-        );
+        ];
 
         foreach ($xmlFiles as $bricksXML) {
             $result = array_merge($result, Utils::getBricksFromXML($bricksXML));
@@ -406,13 +409,17 @@ public function getAvailableBricks()
         });
 
         // js workaround
-        $list = array();
+        $list = [];
 
         foreach ($result as $entry) {
             $list[] = $entry;
         }
 
-        QUI\Cache\Manager::set($cache, $list);
+        try {
+            QUI\Cache\Manager::set($cache, $list);
+        } catch (\Exception $Exception) {
+            QUI\System\Log::writeException($Exception);
+        }
 
         return $list;
     }
@@ -431,13 +438,13 @@ public function getBrickById($id)
             return $this->bricks[$id];
         }
 
-        $data = QUI::getDataBase()->fetch(array(
+        $data = QUI::getDataBase()->fetch([
             'from'  => $this->getTable(),
-            'where' => array(
+            'where' => [
                 'id' => (int)$id
-            ),
+            ],
             'limit' => 1
-        ));
+        ]);
 
         if (!isset($data[0])) {
             throw new QUI\Exception('Brick not found');
@@ -465,13 +472,13 @@ public function getBrickByUID($uid)
             return $this->brickUIDs[$uid];
         }
 
-        $data = QUI::getDataBase()->fetch(array(
+        $data = QUI::getDataBase()->fetch([
             'from'  => $this->getUIDTable(),
-            'where' => array(
+            'where' => [
                 'uid' => $uid
-            ),
+            ],
             'limit' => 1
-        ));
+        ]);
 
         if (!isset($data[0])) {
             throw new QUI\Exception('Brick not found');
@@ -484,13 +491,13 @@ public function getBrickByUID($uid)
         $attributes = $data['attributes'];
         $attributes = json_decode($attributes, true);
 
-        $real = QUI::getDataBase()->fetch(array(
+        $real = QUI::getDataBase()->fetch([
             'from'  => $this->getTable(),
-            'where' => array(
+            'where' => [
                 'id' => (int)$brickId
-            ),
+            ],
             'limit' => 1
-        ));
+        ]);
 
         $Original = new Brick($real[0]);
         $Original->setAttribute('id', $brickId);
@@ -532,34 +539,34 @@ public function getAvailableBrickSettingsByBrickType($brickType)
         }
 
 
-        $settings = array();
+        $settings = [];
 
-        $settings[] = array(
+        $settings[] = [
             'name'     => 'width',
-            'text'     => array('quiqqer/bricks', 'site.area.window.settings.setting.width'),
+            'text'     => ['quiqqer/bricks', 'site.area.window.settings.setting.width'],
             'type'     => '',
             'class'    => '',
             'data-qui' => '',
             'options'  => false
-        );
+        ];
 
-        $settings[] = array(
+        $settings[] = [
             'name'     => 'height',
-            'text'     => array('quiqqer/bricks', 'site.area.window.settings.setting.height'),
+            'text'     => ['quiqqer/bricks', 'site.area.window.settings.setting.height'],
             'type'     => '',
             'class'    => '',
             'data-qui' => '',
             'options'  => false
-        );
+        ];
 
-        $settings[] = array(
+        $settings[] = [
             'name'     => 'classes',
-            'text'     => array('quiqqer/bricks', 'site.area.window.settings.setting.classes'),
+            'text'     => ['quiqqer/bricks', 'site.area.window.settings.setting.classes'],
             'type'     => '',
             'class'    => '',
             'data-qui' => '',
             'options'  => false
-        );
+        ];
 
         $xmlFiles = $this->getBricksXMLFiles();
 
@@ -584,7 +591,12 @@ public function getAvailableBrickSettingsByBrickType($brickType)
             }
         }
 
-        QUI\Cache\Manager::set($cache, $settings);
+        try {
+            QUI\Cache\Manager::set($cache, $settings);
+        } catch (\Exception $Exception) {
+            QUI\System\Log::writeException($Exception);
+        }
+
 
         return $settings;
     }
@@ -604,21 +616,21 @@ protected function parseSettingToBrickArray(\DOMElement $Setting)
             $optionElements = $Setting->getElementsByTagName('option');
 
             foreach ($optionElements as $Option) {
-                $options[] = array(
+                $options[] = [
                     'value' => $Option->getAttribute('value'),
                     'text'  => QUI\Utils\DOM::getTextFromNode($Option, false)
-                );
+                ];
             }
         }
 
-        return array(
+        return [
             'name'     => $Setting->getAttribute('name'),
             'text'     => QUI\Utils\DOM::getTextFromNode($Setting, false),
             'type'     => $Setting->getAttribute('type'),
             'class'    => $Setting->getAttribute('class'),
             'data-qui' => $Setting->getAttribute('data-qui'),
             'options'  => $options
-        );
+        ];
     }
 
     /**
@@ -632,7 +644,7 @@ protected function parseSettingToBrickArray(\DOMElement $Setting)
     public function getBricksByArea($brickArea, QUI\Interfaces\Projects\Site $Site)
     {
         if (empty($brickArea)) {
-            return array();
+            return [];
         }
 
         $brickAreas = $Site->getAttribute('quiqqer.bricks.areas');
@@ -641,7 +653,7 @@ public function getBricksByArea($brickArea, QUI\Interfaces\Projects\Site $Site)
         if (!isset($brickAreas[$brickArea]) || empty($brickAreas[$brickArea])) {
             $bricks = $this->getInheritedBricks($brickArea, $Site);
         } else {
-            $bricks    = array();
+            $bricks    = [];
             $brickData = $brickAreas[$brickArea];
 
             foreach ($brickData as $brick) {
@@ -654,7 +666,7 @@ public function getBricksByArea($brickArea, QUI\Interfaces\Projects\Site $Site)
         }
 
 
-        $result = array();
+        $result = [];
 
         foreach ($bricks as $key => $brickData) {
             $brickId = (int)$brickData['brickId'];
@@ -700,15 +712,15 @@ public function getBricksByArea($brickArea, QUI\Interfaces\Projects\Site $Site)
      */
     public function getBricksFromProject(Project $Project)
     {
-        $result = array();
+        $result = [];
 
-        $list = QUI::getDataBase()->fetch(array(
+        $list = QUI::getDataBase()->fetch([
             'from'  => $this->getTable(),
-            'where' => array(
+            'where' => [
                 'project' => $Project->getName(),
                 'lang'    => $Project->getLang()
-            )
-        ));
+            ]
+        ]);
 
         foreach ($list as $entry) {
             $result[] = $this->getBrickById($entry['id']);
@@ -717,6 +729,44 @@ public function getBricksFromProject(Project $Project)
         return $result;
     }
 
+
+    /**
+     * Return a list with \QUI\Bricks\Brick which are assigned to a project
+     *
+     * @param Brick $Brick
+     * @return array
+     */
+    public function getSitesByBrick(Brick $Brick)
+    {
+        $result = [];
+
+        $list = QUI::getDataBase()->fetch([
+            'select' => ['brickId', 'project', 'lang', 'siteId'],
+            'from'   => $this->getUIDTable(),
+            'where'  => [
+                'project' => $Brick->getAttribute('project'),
+                'lang'    => $Brick->getAttribute('lang'),
+                'brickId' => $Brick->getAttribute('id')
+            ]
+        ]);
+
+        $Project = QUI::getProject(
+            $Brick->getAttribute('project'),
+            $Brick->getAttribute('lang')
+        );
+
+        foreach ($list as $entry) {
+            try {
+                $result[] = $Project->get($entry['siteId']);
+            } catch (QUI\Exception $Exception) {
+                QUI\System\Log::writeDebugException($Exception);
+                continue;
+            }
+        }
+
+        return $result;
+    }
+
     /**
      * @param string|integer $brickId - Brick-ID
      * @param array $brickData - Brick data
@@ -727,7 +777,7 @@ public function saveBrick($brickId, array $brickData)
         QUI\Permissions\Permission::checkPermission('quiqqer.bricks.edit');
 
         $Brick      = $this->getBrickById($brickId);
-        $areas      = array();
+        $areas      = [];
         $areaString = '';
 
         if (isset($brickData['id'])) {
@@ -794,7 +844,7 @@ public function saveBrick($brickId, array $brickData)
         }
 
         // custom fields
-        $customfields = array();
+        $customfields = [];
 
         if (isset($brickData['customfields'])) {
             $availableSettings           = $Brick->getSettings();
@@ -816,7 +866,7 @@ public function saveBrick($brickId, array $brickData)
         }
 
         // update
-        QUI::getDataBase()->update($this->getTable(), array(
+        QUI::getDataBase()->update($this->getTable(), [
             'title'         => $Brick->getAttribute('title'),
             'frontendTitle' => $Brick->getAttribute('frontendTitle'),
             'description'   => $Brick->getAttribute('description'),
@@ -828,19 +878,19 @@ public function saveBrick($brickId, array $brickData)
             'height'        => $Brick->getAttribute('height'),
             'width'         => $Brick->getAttribute('width'),
             'classes'       => json_encode($Brick->getCSSClasses())
-        ), array(
+        ], [
             'id' => (int)$brickId
-        ));
+        ]);
 
         // refresh all bricks with this id
-        $uniqueBricks = QUI::getDataBase()->fetch(array(
+        $uniqueBricks = QUI::getDataBase()->fetch([
             'from'  => QUI\Bricks\Manager::getUIDTable(),
-            'where' => array(
+            'where' => [
                 'project' => $Project->getName(),
                 'lang'    => $Project->getLang(),
                 'brickId' => (int)$brickId
-            )
-        ));
+            ]
+        ]);
 
         foreach ($uniqueBricks as $uniqueBrick) {
             $customFieldsUniqueBrick = json_decode($uniqueBrick['customfields'], true);
@@ -851,15 +901,15 @@ public function saveBrick($brickId, array $brickData)
             }
 
             if (!is_array($customFieldsUniqueBrick)) {
-                $customFieldsUniqueBrick = array();
+                $customFieldsUniqueBrick = [];
             }
 
-            QUI::getDataBase()->update(QUI\Bricks\Manager::getUIDTable(), array(
+            QUI::getDataBase()->update(QUI\Bricks\Manager::getUIDTable(), [
                 'customfields' => json_encode($customFieldsUniqueBrick),
                 'attributes'   => json_encode($attributes)
-            ), array(
+            ], [
                 'uid' => $uniqueBrick['uid']
-            ));
+            ]);
         }
     }
 
@@ -872,29 +922,29 @@ public function saveBrick($brickId, array $brickData)
      *
      * @throws QUI\Exception
      */
-    public function copyBrick($brickId, $params = array())
+    public function copyBrick($brickId, $params = [])
     {
         QUI\Permissions\Permission::checkPermission('quiqqer.bricks.create');
 
-        $result = QUI::getDataBase()->fetch(array(
+        $result = QUI::getDataBase()->fetch([
             'from'  => $this->getTable(),
-            'where' => array(
+            'where' => [
                 'id' => $brickId
-            )
-        ));
+            ]
+        ]);
 
         if (!isset($result[0])) {
             throw new QUI\Exception('Brick not found');
         }
 
-        $allowed = array('project', 'lang', 'title', 'description');
+        $allowed = ['project', 'lang', 'title', 'description'];
         $allowed = array_flip($allowed);
         $data    = $result[0];
 
         unset($data['id']);
 
         if (!is_array($params)) {
-            $params = array();
+            $params = [];
         }
 
         foreach ($params as $param => $value) {
@@ -943,26 +993,26 @@ protected function getInheritedBricks($brickArea, QUI\Interfaces\Projects\Site $
             }
 
             if (!$area['inheritance']) {
-                return array();
+                return [];
             }
 
             break;
         }
 
         if (!isset($area) || !isset($area['name'])) {
-            return array();
+            return [];
         }
 
         if ($area['name'] != $brickArea) {
-            return array();
+            return [];
         }
 
         if (!Utils::hasInheritance($Project, $brickArea)) {
-            return array();
+            return [];
         }
 
 
-        $result    = array();
+        $result    = [];
         $parentIds = $Site->getParentIdTree();
         $parentIds = array_reverse($parentIds);
 
@@ -972,13 +1022,13 @@ protected function getInheritedBricks($brickArea, QUI\Interfaces\Projects\Site $
         );
 
         foreach ($parentIds as $parentId) {
-            $bricks = QUI::getDataBase()->fetch(array(
+            $bricks = QUI::getDataBase()->fetch([
                 'from'  => $projectCacheTable,
-                'where' => array(
+                'where' => [
                     'id'   => $parentId,
                     'area' => $brickArea
-                )
-            ));
+                ]
+            ]);
 
             if (empty($bricks) || !is_array($bricks)) {
                 continue;
@@ -999,7 +1049,7 @@ protected function getInheritedBricks($brickArea, QUI\Interfaces\Projects\Site $
             }
 
 
-            $brickIds = array();
+            $brickIds = [];
             $area     = $parentAreas[$brickArea];
 
             foreach ($bricks as $brick) {
diff --git a/src/QUI/Bricks/Utils.php b/src/QUI/Bricks/Utils.php
index fd25302..8544831 100644
--- a/src/QUI/Bricks/Utils.php
+++ b/src/QUI/Bricks/Utils.php
@@ -29,14 +29,14 @@ class Utils
     public static function getBricksFromXML($file)
     {
         if (!file_exists($file)) {
-            return array();
+            return [];
         }
 
         $Dom  = XML::getDomFromXml($file);
         $Path = new \DOMXPath($Dom);
 
         $bricks = $Path->query("//quiqqer/bricks/brick");
-        $list   = array();
+        $list   = [];
 
         if (!$bricks->length) {
             return $list;
@@ -65,7 +65,7 @@ public static function getBricksFromXML($file)
     public static function getTemplateAreasFromXML($file, $layoutType = false)
     {
         if (!file_exists($file)) {
-            return array();
+            return [];
         }
 
         $Dom  = XML::getDomFromXml($file);
@@ -82,7 +82,7 @@ public static function getTemplateAreasFromXML($file, $layoutType = false)
         }
 
 
-        $list = array();
+        $list = [];
 
         if ($globalAreas->length) {
             foreach ($globalAreas as $Area) {
@@ -131,27 +131,27 @@ public static function parseAreaToArray(\DOMElement $Brick, \DOMXPath $Path)
             $hasContent = 0;
         }
 
-        $title       = array();
-        $description = array();
+        $title       = [];
+        $description = [];
 
         $titleLocale = $Path->query('./title/locale', $Brick);
         $descLocale  = $Path->query('./description/locale', $Brick);
 
         if ($titleLocale->length) {
-            $title = array(
+            $title = [
                 'group' => $titleLocale->item(0)->getAttribute('group'),
                 'var'   => $titleLocale->item(0)->getAttribute('var')
-            );
+            ];
         }
 
         if ($descLocale->length) {
-            $description = array(
+            $description = [
                 'group' => $descLocale->item(0)->getAttribute('group'),
                 'var'   => $descLocale->item(0)->getAttribute('var')
-            );
+            ];
         }
 
-        return array(
+        return [
             'control'     => $control,
             'hasContent'  => $hasContent,
             'name'        => $name,
@@ -159,7 +159,7 @@ public static function parseAreaToArray(\DOMElement $Brick, \DOMXPath $Path)
             'description' => $description,
             'inheritance' => $Brick->getAttribute('inheritance'),
             'priority'    => $Brick->getAttribute('priority')
-        );
+        ];
     }
 
     /**
@@ -209,7 +209,7 @@ public static function getBricksXMLFiles()
         $PKM      = QUI::getPackageManager();
         $Projects = QUI::getProjectManager();
         $packages = $PKM->getInstalled();
-        $result   = array();
+        $result   = [];
 
         // package bricks
         foreach ($packages as $package) {
@@ -245,7 +245,7 @@ public static function getBricksXMLFiles()
      */
     public static function getAttributesForBrick(Brick $Brick)
     {
-        $attributes = array();
+        $attributes = [];
         $files      = Panel::getInstance()->getXMLFilesForBricks($Brick);
 
         // main path
-- 
GitLab