diff --git a/ajax/brick/templates/information.html b/ajax/brick/templates/information.html index 92bbebd70a0df154f2e106a5648eef7fdbf75949..985107721da59d4be4f5e19c2e295d12649a58f5 100644 --- a/ajax/brick/templates/information.html +++ b/ajax/brick/templates/information.html @@ -54,4 +54,11 @@ </tr> </tbody> </table> + + <div class="deprecated-messages quiqqer-message quiqqer-message-error" + style="display: none; width: 100%; max-width: 100%"> + <div class="quiqqer-message-text"> + {locale group="quiqqer/bricks" var="brick.deprecated"} + </div> + </div> </form> \ No newline at end of file diff --git a/bin/BrickEdit.js b/bin/BrickEdit.js index 9e1274932b661928a2c88fc11fca8d86fae70040..607ed20f2bf92212a338d2e278685a5ec2a4d1ed 100644 --- a/bin/BrickEdit.js +++ b/bin/BrickEdit.js @@ -451,7 +451,8 @@ define('package/quiqqer/bricks/bin/BrickEdit', [ * @returns {Promise} */ showInformation: function () { - const self = this; + const self = this, + data = self.getAttribute('data'); return this.$hideCategory().then(function () { return Template.get('ajax/brick/templates/information', false, { @@ -460,6 +461,10 @@ define('package/quiqqer/bricks/bin/BrickEdit', [ }).then(function (html) { self.$Container.set('html', html); self.$load(); + + if (typeof data.attributes.deprecated !== 'undefined' && data.attributes.deprecated) { + self.$Container.getElements('.deprecated-messages').setStyle('display', 'inline-block'); + } }).then(function () { return Bricks.getAvailableBricks(); }).then(function (bricks) { diff --git a/bin/Manager.js b/bin/Manager.js index bd3dd1f8d8b7f0e331b0b49cda718c9cb2aff206..d5719f1399e9ec85daae6106a24282ff6969fa5e 100644 --- a/bin/Manager.js +++ b/bin/Manager.js @@ -56,9 +56,9 @@ define('package/quiqqer/bricks/bin/Manager', [ initialize: function (options) { this.parent(options); - this.$Grid = false; + this.$Grid = false; this.$ProjectSelect = false; - this.$ProjectLangs = false; + this.$ProjectLangs = false; this.addEvents({ onCreate : this.$onCreate, @@ -237,27 +237,32 @@ define('package/quiqqer/bricks/bin/Manager', [ ); this.$Grid = new Grid(Container, { - columnModel : [{ - header : QUILocale.get('quiqqer/quiqqer', 'id'), - dataIndex: 'id', - dataType : 'integer', - width : 40 - }, { - header : QUILocale.get('quiqqer/quiqqer', 'title'), - dataIndex: 'title', - dataType : 'string', - width : 140 - }, { - header : QUILocale.get('quiqqer/quiqqer', 'description'), - dataIndex: 'description', - dataType : 'string', - width : 300 - }, { - header : QUILocale.get(lg, 'brick.type'), - dataIndex: 'type', - dataType : 'string', - width : 200 - }], + columnModel : [ + { + header : QUILocale.get('quiqqer/quiqqer', 'id'), + dataIndex: 'id', + dataType : 'integer', + width : 40 + }, + { + header : QUILocale.get('quiqqer/quiqqer', 'title'), + dataIndex: 'title', + dataType : 'string', + width : 140 + }, + { + header : QUILocale.get('quiqqer/quiqqer', 'description'), + dataIndex: 'description', + dataType : 'string', + width : 300 + }, + { + header : QUILocale.get(lg, 'brick.type'), + dataIndex: 'type', + dataType : 'string', + width : 200 + } + ], multipleSelection: true, pagination : true }); @@ -366,7 +371,7 @@ define('package/quiqqer/bricks/bin/Manager', [ } var langs = projects[project].langs; - langs = langs.split(','); + langs = langs.split(','); self.$ProjectLangs.clear(); @@ -424,7 +429,7 @@ define('package/quiqqer/bricks/bin/Manager', [ return; } - var i, len, group, title, val; + var i, len, group, title, val, text; var Select = Body.getElement('select'), Title = Body.getElement('[name="title"]'); @@ -433,15 +438,21 @@ define('package/quiqqer/bricks/bin/Manager', [ if ('group' in title) { group = title.group; - val = title.var; + val = title.var; } else { group = title[0]; - val = title[1]; + val = title[1]; + } + + text = QUILocale.get(group, val); + + if (bricklist[i].deprecated) { + text = text + ' (deprecated)'; } new Element('option', { value: bricklist[i].control, - html : QUILocale.get(group, val) + html : text }).inject(Select); } @@ -584,7 +595,7 @@ define('package/quiqqer/bricks/bin/Manager', [ Bricks.getBrick(brickId).then(function (data) { var Form = Content.getElement('form'); - Form.elements.title.value = data.attributes.title; + Form.elements.title.value = data.attributes.title; Form.elements.description.value = data.attributes.description; Win.Loader.hide(); @@ -598,7 +609,7 @@ define('package/quiqqer/bricks/bin/Manager', [ var Content = Win.getContent(), Form = Content.getElement('form'); - var Select = Content.getElement('.dialog-bricks-copy-languages [data-quiid]'); + var Select = Content.getElement('.dialog-bricks-copy-languages [data-quiid]'); var Language = QUI.Controls.getById(Select.get('data-quiid')); Bricks.copyBrick(brickId, { diff --git a/bricks.xml b/bricks.xml index a946d8036383670a0db1af2284a230215ceb310b..f87f3ccb0984febbd3603f2de9b949c354e7ec12 100644 --- a/bricks.xml +++ b/bricks.xml @@ -366,7 +366,8 @@ <setting name="preloadFirstImage" type="checkbox"> <locale group="quiqqer/bricks" var="brick.control.promosliderWallpaper.settings.preloadFirstImage"/> <description> - <locale group="quiqqer/bricks" var="brick.control.promosliderWallpaper.settings.preloadFirstImage.desc"/> + <locale group="quiqqer/bricks" + var="brick.control.promosliderWallpaper.settings.preloadFirstImage.desc"/> </description> </setting> <setting type="select" name="showarrows"> @@ -495,7 +496,8 @@ <setting name="preloadFirstImage" type="checkbox"> <locale group="quiqqer/bricks" var="brick.control.promosliderWallpaper.settings.preloadFirstImage"/> <description> - <locale group="quiqqer/bricks" var="brick.control.promosliderWallpaper.settings.preloadFirstImage.desc"/> + <locale group="quiqqer/bricks" + var="brick.control.promosliderWallpaper.settings.preloadFirstImage.desc"/> </description> </setting> diff --git a/locale.xml b/locale.xml index 9e8117a8aef4cf79684d45bb75d51ee27135af29..6a2eab8fd0a93faac0ae5e6cdbc181969abcc0cb 100644 --- a/locale.xml +++ b/locale.xml @@ -724,6 +724,16 @@ Error in brick type. The block type is not permitted and is therefore not saved. ]]></en> </locale> + <locale name="brick.deprecated"> + <de><![CDATA[ + Dieser Brick ist deprecated und sollte nicht mehr genutzt werden. + Beachte das in neueren Version dieser Brick nicht mehr einwandfrei funktionieren kann. + ]]></de> + <en><![CDATA[ + This brick is deprecated and should not be used anymore. + Note that in newer versions this brick may not work properly. + ]]></en> + </locale> </groups> <groups name="quiqqer/bricks" datatype="js"> <locale name="brick.type"> diff --git a/src/QUI/Bricks/Brick.php b/src/QUI/Bricks/Brick.php index 22b4abe91f1ffe61483fdb8f5a38a93818825553..01c423d87708bd6b977c11c8d99780eafe3d0004 100644 --- a/src/QUI/Bricks/Brick.php +++ b/src/QUI/Bricks/Brick.php @@ -8,13 +8,13 @@ use Exception; use QUI; - use QUI\Control; use function array_filter; use function array_flip; use function array_merge; use function array_unique; +use function array_values; use function class_exists; use function dirname; use function explode; @@ -108,7 +108,8 @@ public function __construct($params = []) 'classes' => '', 'frontendTitle' => '', 'hasContent' => 1, - 'cacheable' => 1 // if the brick is cacheable or not + 'cacheable' => 1, // if the brick is cacheable or not + 'deprecated' => 0 ]; $this->setAttributes($default); @@ -205,6 +206,26 @@ public function __construct($params = []) } } + // deprecated + $BricksManager = QUI\Bricks\Manager::init(); + $type = $this->getAttribute('type'); + + $brick = array_filter($BricksManager->getAvailableBricks(), function ($brick) use ($type) { + if (!isset($brick['control'])) { + return false; + } + + return $brick['control'] === $type; + }); + + if ($brick) { + $brick = array_values($brick)[0]; + + if (!empty($brick['deprecated'])) { + $this->setAttribute('deprecated', 1); + } + } + $this->hash = $this->createBrickHash(); } diff --git a/src/QUI/Bricks/Manager.php b/src/QUI/Bricks/Manager.php index cbed5148c3d063cee323b324639bc7213f60f9eb..be144eb952711b79f7bd4396e61354c2e5a5cea1 100644 --- a/src/QUI/Bricks/Manager.php +++ b/src/QUI/Bricks/Manager.php @@ -371,7 +371,7 @@ public function getAreasByProject(Project $Project, $layoutType = false): array // get bricks foreach ($templates as $template) { - $brickXML = realpath(OPT_DIR.$template.'/bricks.xml'); + $brickXML = realpath(OPT_DIR . $template . '/bricks.xml'); if (!$brickXML) { continue; @@ -453,7 +453,8 @@ public function getAvailableBricks(): array 'quiqqer/bricks', 'brick.content.description' ], - 'control' => 'content' + 'control' => 'content', + 'deprecated' => 0 ]; foreach ($xmlFiles as $bricksXML) { @@ -590,7 +591,7 @@ public function getBrickByUID(string $uid, ?QUI\Interfaces\Projects\Site $Site = */ public function getAvailableBrickSettingsByBrickType($brickType): array { - $cache = 'quiqqer/bricks/brickType/'.md5($brickType); + $cache = 'quiqqer/bricks/brickType/' . md5($brickType); try { return QUI\Cache\Manager::get($cache); @@ -944,7 +945,7 @@ public function saveBrick($brickId, array $brickData) } if (!empty($areas)) { - $areaString = ','.implode(',', $areas).','; + $areaString = ',' . implode(',', $areas) . ','; } $Brick->setAttributes($brickData); @@ -1098,7 +1099,7 @@ public function saveBrick($brickId, array $brickData) QUI\Cache\Manager::clear($cache); QUI\Cache\Manager::clear( - self::getBrickCacheNamespace().md5($Brick->getType()) + self::getBrickCacheNamespace() . md5($Brick->getType()) ); QUI::getEvents()->fireEvent('quiqqerBricksSave', [$brickId]); @@ -1301,7 +1302,7 @@ public function getAlternateClass($control, $template = false): string // package bricks foreach ($packages as $package) { $packageName = $package['name']; - $bricksXML = OPT_DIR.$packageName.'/bricks.xml'; + $bricksXML = OPT_DIR . $packageName . '/bricks.xml'; if (!file_exists($bricksXML)) { continue; diff --git a/src/QUI/Bricks/Utils.php b/src/QUI/Bricks/Utils.php index 7511a002fba121b0a336c97151df0bcddd9f58c1..1653a5698ae6c3efeaa95283c6bff7af22c11aa6 100644 --- a/src/QUI/Bricks/Utils.php +++ b/src/QUI/Bricks/Utils.php @@ -133,6 +133,12 @@ public static function parseAreaToArray(DOMElement $Brick, DOMXPath $Path): arra $hasContent = 1; $cacheable = 1; + $deprecated = 0; + + if ($Brick->hasAttribute('deprecated') + && (int)$Brick->getAttribute('deprecated') === 1) { + $deprecated = 1; + } if ($Brick->hasAttribute('hasContent') && (int)$Brick->getAttribute('hasContent') === 0) { @@ -172,7 +178,8 @@ public static function parseAreaToArray(DOMElement $Brick, DOMXPath $Path): arra 'title' => $title, 'description' => $description, 'inheritance' => $Brick->getAttribute('inheritance'), - 'priority' => $Brick->getAttribute('priority') + 'priority' => $Brick->getAttribute('priority'), + 'deprecated' => $deprecated ]; }