diff --git a/ajax/brick/copy.php b/ajax/brick/copy.php new file mode 100644 index 0000000000000000000000000000000000000000..e5b7e601d2b3e81e9fbc095c002fcb905b57ede8 --- /dev/null +++ b/ajax/brick/copy.php @@ -0,0 +1,30 @@ +<?php + +/** + * This file contains package_quiqqer_bricks_ajax_brick_save + */ + +/** + * saves the brick + * + * @param string|Integer $brickId - Brick-ID + * @param string $title - title of the new brick + * @param string $description - description of the new brick + * + * @return array + */ +QUI::$Ajax->registerFunction( + 'package_quiqqer_bricks_ajax_brick_copy', + function ($brickId, $params) { + $BrickManager = QUI\Bricks\Manager::init(); + + $newId = $BrickManager->copyBrick( + $brickId, + json_decode($params, true) + ); + + return $BrickManager->getBrickById($newId)->getAttributes(); + }, + array('brickId', 'params'), + 'Permission::checkAdminUser' +); diff --git a/bin/Manager.Copy.css b/bin/Manager.Copy.css new file mode 100644 index 0000000000000000000000000000000000000000..26f43cab72b2d8f52210b1eedece39bf06c0b25c --- /dev/null +++ b/bin/Manager.Copy.css @@ -0,0 +1,16 @@ +.dialog-bricks-copy { + margin-top: 20px; +} + +.dialog-bricks-copy .data-table-flexbox { + border: none; +} + +.dialog-bricks-copy .data-table-flexbox td { + padding-left: 0; + padding-right: 0; +} + +.dialog-bricks-copy [name="description"] { + height: 100px; +} \ No newline at end of file diff --git a/bin/Manager.Copy.html b/bin/Manager.Copy.html new file mode 100644 index 0000000000000000000000000000000000000000..4709353f6f255061d235f0e06d6abd0e232a1d77 --- /dev/null +++ b/bin/Manager.Copy.html @@ -0,0 +1,32 @@ +{{text}} + +<form class="dialog-bricks-copy" action="" method="POST"> + <table class="data-table data-table-flexbox"> + <tbody> + <tr> + <td> + <label class="field-container"> + <span class="field-container-item">Sprache</span> + <span class="dialog-bricks-copy-languages field-container-field field-container-field-no-padding"></span> + </label> + </td> + </tr> + <tr> + <td> + <label class="field-container"> + <span class="field-container-item">Titel</span> + <input name="title" class="field-container-field"/> + </label> + </td> + </tr> + <tr> + <td> + <label class="field-container"> + <span class="field-container-item">Beschreibung</span> + <textarea name="description" class="field-container-field"></textarea> + </label> + </td> + </tr> + </tbody> + </table> +</form> diff --git a/bin/Manager.js b/bin/Manager.js index 3fd66e5bd5269459b8733649c217b9c73d5bc1c2..7979104592168d98f03660351ede2d67a21e63ef 100644 --- a/bin/Manager.js +++ b/bin/Manager.js @@ -16,10 +16,14 @@ define('package/quiqqer/bricks/bin/Manager', [ 'Locale', 'Projects', 'Ajax', + 'Mustache', + 'text!package/quiqqer/bricks/bin/Manager.Copy.html', + 'css!package/quiqqer/bricks/bin/Manager.Copy.css', 'css!package/quiqqer/bricks/bin/Manager.css' -], function (QUI, QUIPanel, QUISelect, QUIButton, QUISeparator, QUIConfirm, Grid, QUILocale, Projects, Ajax) { +], function (QUI, QUIPanel, QUISelect, QUIButton, QUISeparator, QUIConfirm, Grid, QUILocale, Projects, Ajax, + Mustache, templateCopy) { "use strict"; var lg = 'quiqqer/bricks'; @@ -36,6 +40,7 @@ define('package/quiqqer/bricks/bin/Manager', [ '$onCreate', '$onResize', '$openCreateDialog', + '$openCopyDialog', '$openDeleteDialog', '$onDblClick', '$onClick' @@ -102,11 +107,13 @@ define('package/quiqqer/bricks/bin/Manager', [ var selected = this.$Grid.getSelectedData(), AddButton = this.getButtons('brick-add'), EditButton = this.getButtons('brick-edit'), + CopyButton = this.getButtons('brick-copy'), DelButton = this.getButtons('brick-delete'); if (!selected.length) { AddButton.enable(); DelButton.disable(); + CopyButton.disable(); EditButton.disable(); return; } @@ -114,12 +121,14 @@ define('package/quiqqer/bricks/bin/Manager', [ AddButton.enable(); DelButton.enable(); - if (selected.length == 1) { + if (selected.length === 1) { EditButton.enable(); + CopyButton.enable(); } if (selected.length > 1) { - AddButton.disable(); + EditButton.disable(); + CopyButton.disable(); } }, @@ -164,19 +173,40 @@ define('package/quiqqer/bricks/bin/Manager', [ }) ); + this.addButton(new QUISeparator()); + this.addButton( new QUIButton({ textimage: 'fa fa-edit', - text : QUILocale.get(lg, 'manager.button.edit'), - title : QUILocale.get(lg, 'manager.button.edit'), + text : QUILocale.get(lg, 'manager.button.edit.text'), + title : QUILocale.get(lg, 'manager.button.edit.title'), name : 'brick-edit', disabled : true, events : { onClick: function () { - this.editBrick( - this.$Grid.getSelectedData()[0].id + self.editBrick( + self.$Grid.getSelectedData()[0].id ); - }.bind(this) + } + } + }) + ); + + this.addButton( + new QUIButton({ + textimage: 'fa fa-copy', + text : QUILocale.get(lg, 'manager.button.copy.text'), + title : QUILocale.get(lg, 'manager.button.copy.title'), + name : 'brick-copy', + disabled : true, + events : { + onClick: function () { + var data = self.$Grid.getSelectedData(); + + if (data.length === 1) { + self.$openCopyDialog(data[0].id); + } + } } }) ); @@ -290,7 +320,7 @@ define('package/quiqqer/bricks/bin/Manager', [ }, /** - * Refresh the project language dropdown + * Refresh the project language DropDown */ $refreshProjectLanguages: function () { var self = this, @@ -302,7 +332,7 @@ define('package/quiqqer/bricks/bin/Manager', [ continue; } - if (activeProject != project) { + if (activeProject !== project) { continue; } @@ -476,6 +506,97 @@ define('package/quiqqer/bricks/bin/Manager', [ }).open(); }, + /** + * opens the copy dialog + */ + $openCopyDialog: function (brickId) { + var self = this; + + new QUIConfirm({ + title : QUILocale.get(lg, 'dialog.copy.title', { + id: brickId + }), + icon : 'fa fa-copy', + maxHeight: 600, + maxWidth : 800, + autoclose: false, + + events: { + onOpen: function (Win) { + Win.Loader.show(); + + var Content = Win.getContent(), + project = self.$ProjectSelect.getValue(), + lang = self.$ProjectLangs.getValue(), + Project = Projects.get(project); + + Content.set('html', Mustache.render(templateCopy, { + text: QUILocale.get(lg, 'dialog.copy.message') + })); + + Project.getConfig().then(function (config) { + var Select = new QUISelect({ + name: 'language-select' + }); + + var langs = config.langs.split(','); + + for (var i = 0, len = langs.length; i < len; i++) { + Select.appendChild( + QUILocale.get('quiqqer/system', 'language.' + langs[i]), + langs[i], + URL_BIN_DIR + '16x16/flags/' + langs[i] + '.png' + ); + } + + Select.inject(Content.getElement('.dialog-bricks-copy-languages')); + Select.getElm().setStyle('width', '100%'); + Select.getElm().setStyle('border', 0); + + Select.setValue(lang); + + Ajax.get('package_quiqqer_bricks_ajax_getBrick', function (data) { + var Form = Content.getElement('form'); + + Form.elements.title.value = data.attributes.title; + Form.elements.description.value = data.attributes.description; + + Win.Loader.hide(); + }, { + 'package': 'quiqqer/bricks', + brickId : brickId + }); + }); + }, + + onSubmit: function (Win) { + Win.Loader.show(); + + var Content = Win.getContent(), + Form = Content.getElement('form'); + + var Select = Content.getElement('.dialog-bricks-copy-languages [data-quiid]'); + var Language = QUI.Controls.getById(Select.get('data-quiid')); + + Ajax.post('package_quiqqer_bricks_ajax_brick_copy', function (data) { + self.refresh(); + Win.close(); + + self.editBrick(data['id']); + }, { + 'package': 'quiqqer/bricks', + brickId : brickId, + params : JSON.encode({ + 'lang' : Language.getValue(), + 'title' : Form.elements.title.value, + 'description': Form.elements.description.value + }) + }); + } + } + }).open(); + }, + /** * Opens the brick panel * @@ -623,7 +744,7 @@ define('package/quiqqer/bricks/bin/Manager', [ brickId = brickIds[i]; for (c = 0, clen = panels.length; c < clen; c++) { - if (panels[c].getAttribute('id') == brickId) { + if (panels[c].getAttribute('id') === brickId) { panels[c].destroy(); } } diff --git a/locale.xml b/locale.xml index a06d82115be9f9262a9d4af2749754d56c893851..956c49956e7e318fdf9aedd405a14d6db0b7c5c6 100644 --- a/locale.xml +++ b/locale.xml @@ -608,9 +608,21 @@ Möchten Sie die Bausteine aus der Bausteinzone entfernen?</p>]]></de> <de><![CDATA[Baustein hinzufügen]]></de> <en><![CDATA[Add a Brick]]></en> </locale> - <locale name="manager.button.edit"> - <de><![CDATA[Baustein bearbeiten]]></de> - <en><![CDATA[Edit a Brick]]></en> + <locale name="manager.button.edit.title"> + <de><![CDATA[Markierten Baustein bearbeiten]]></de> + <en><![CDATA[Edit marked Brick]]></en> + </locale> + <locale name="manager.button.edit.text"> + <de><![CDATA[Bearbeiten]]></de> + <en><![CDATA[Edit]]></en> + </locale> + <locale name="manager.button.copy.title"> + <de><![CDATA[Markierten Baustein kopieren]]></de> + <en><![CDATA[Copy marked Brick]]></en> + </locale> + <locale name="manager.button.copy.text"> + <de><![CDATA[Kopieren]]></de> + <en><![CDATA[Copy]]></en> </locale> <locale name="manager.button.delete"> <de><![CDATA[Markierte Bausteine löschen]]></de> @@ -713,7 +725,25 @@ Möchten Sie die Bausteine aus der Bausteinzone entfernen?</p>]]></de> <de><![CDATA[Slide bearbieten]]></de> <en><![CDATA[Edit Slide]]></en> </locale> + + <locale name="dialog.copy.title"> + <de><![CDATA[Baustein #[id] kopieren]]></de> + <en><![CDATA[Copy brick #[id]]]></en> + </locale> + <locale name="dialog.copy.message"> + <de><![CDATA[ + Bitte geben Sie an in welche Sprache der Baustein kopieren werden soll. + Zusätzlich können Sie Titel und Beschreibung für den neuen Baustein angeben. + Alle anderen Einstellungen werden in den neuen Baustein kopiert. + ]]></de> + <en><![CDATA[ + Please specify in which language the block should be copied. + You can also specify the title and description for the new module. +           All other settings are copied to the new block. + ]]></en> + </locale> </groups> + <groups name="quiqqer/bricks" datatype="js,php"> <locale name="brick.control.navigation.setting.content"> <de><![CDATA[Text über dem Kontaktformular]]></de> diff --git a/patches/uniqueIds.php b/patches/uniqueIds.php index 8b83912e559858f4473320e3a9c5cec5db1856e4..0a1ab6afd9177804ccbaa7f519f30fc79bfb95d2 100644 --- a/patches/uniqueIds.php +++ b/patches/uniqueIds.php @@ -6,13 +6,27 @@ // workaround for older patch $Bricks = QUI\Bricks\Manager::init(); + +// database table +$columns = QUI::getDataBase()->table()->getColumns($Bricks->getUIDTable()); +$columns = array_flip($columns); + +if (isset($columns['id'])) { + QUI::getDataBase()->table()->deleteColumn( + $Bricks->getUIDTable(), + 'id' + ); + + QUI::getPackage('quiqqer/bricks')->setup(); +} + $result = QUI::getDataBase()->fetch(array( 'count' => 'count', 'from' => $Bricks->getUIDTable(), )); // if unique ids already exist, the pages no longer have to be passed through -if (false && isset($result[0]) && isset($result[0]['count']) && $result[0]['count']) { +if (isset($result[0]) && isset($result[0]['count']) && $result[0]['count']) { echo 'Already executed'.PHP_EOL; return; diff --git a/src/QUI/Bricks/Controls/Slider/PromosliderWallpaper2Content.css b/src/QUI/Bricks/Controls/Slider/PromosliderWallpaper2Content.css index e54716aa04003c536e7586a6ab4e9144a9f99b13..99c972aacb2d73d5f6fbd61d2e818b20151a01ff 100644 --- a/src/QUI/Bricks/Controls/Slider/PromosliderWallpaper2Content.css +++ b/src/QUI/Bricks/Controls/Slider/PromosliderWallpaper2Content.css @@ -15,3 +15,11 @@ width: 100%; } } + +.quiqqer-bricks-promoslider-wallpaper-container .quiqqer-bricks-promoslider-wallpaper2Content-noScriptImage { + object-fit:contain; + object-position:0 0; + position: absolute; + top: 0; + width: 100%; +} diff --git a/src/QUI/Bricks/Controls/Slider/PromosliderWallpaper2Content.html b/src/QUI/Bricks/Controls/Slider/PromosliderWallpaper2Content.html index 8e4d92fc55397a3542446160841948b2fecf1510..e28d2cd7f41c5ddf0237fabd77ec9c1d5351f449 100644 --- a/src/QUI/Bricks/Controls/Slider/PromosliderWallpaper2Content.html +++ b/src/QUI/Bricks/Controls/Slider/PromosliderWallpaper2Content.html @@ -17,6 +17,18 @@ {/if} </div> </div> + + {if $key === 0} + <noscript> + {if $slide.url} + <a href="{$slide.url}"> + {/if} + {image image=$slide.image class="quiqqer-bricks-promoslider-wallpaper2Content-noScriptImage"} + {if $slide.url} + </a> + {/if} + </noscript> + {/if} </li> {/foreach} </ul> @@ -40,6 +52,18 @@ {/if} </div> </div> + + {if $key === 0} + <noscript> + {if $slide.url} + <a href="{$slide.url}"> + {/if} + {image image=$slide.image class="quiqqer-bricks-promoslider-wallpaper2Content-noScriptImage"} + {if $slide.url} + </a> + {/if} + </noscript> + {/if} </li> {/foreach} </ul> @@ -54,4 +78,15 @@ <div class="quiqqer-bricks-promoslider-wallpaper-next hide-on-mobile"> <span class="fa fa-chevron-right"></span> </div> -{/if} \ No newline at end of file + +<noscript> + {literal} + <style> + .quiqqer-bricks-promoslider-wallpaper-next, + .quiqqer-bricks-promoslider-wallpaper-prev { + display: none; + } + </style> + {/literal} +</noscript> +{/if} diff --git a/src/QUI/Bricks/Events.php b/src/QUI/Bricks/Events.php index 9e2cc208c39d860c6f9f7b3ce87141ad4b4ab4ea..f09520db89fa486da65d1321a806d5c743d9dac9 100644 --- a/src/QUI/Bricks/Events.php +++ b/src/QUI/Bricks/Events.php @@ -219,5 +219,7 @@ public static function onPackageSetup(QUI\Package\Package $Package) if ($Package->getName() !== 'quiqqer/bricks') { return; } + + shell_exec('php '.OPT_DIR.'quiqqer/bricks/patches/uniqueIds.php'); } } diff --git a/src/QUI/Bricks/Manager.php b/src/QUI/Bricks/Manager.php index 851fe95f56f6e22d6c882e907cf34ad8eef170d2..5daf2a018b34134c5481cfc65bd341775b1a1ffd 100644 --- a/src/QUI/Bricks/Manager.php +++ b/src/QUI/Bricks/Manager.php @@ -83,6 +83,24 @@ public function __construct($init = false) } } + /** + * Returns the bricks table name + * + * @return String + */ + public static function getTable() + { + return QUI::getDBTableName(self::TABLE); + } + + /** + * @return string + */ + public static function getUIDTable() + { + return QUI::getDBTableName(self::TABLE_UID); + } + /** * Creates a new brick for the project * @@ -842,21 +860,52 @@ public function saveBrick($brickId, array $brickData) } /** - * Returns the bricks table name + * Copy a brick * - * @return String + * @param integer|string $brickId + * @param array $params - project, lang, title, description + * @return integer + * + * @throws QUI\Exception */ - public static function getTable() + public function copyBrick($brickId, $params = array()) { - return QUI::getDBTableName(self::TABLE); - } + QUI\Permissions\Permission::checkPermission('quiqqer.bricks.create'); - /** - * @return string - */ - public static function getUIDTable() - { - return QUI::getDBTableName(self::TABLE_UID); + $result = QUI::getDataBase()->fetch(array( + 'from' => $this->getTable(), + 'where' => array( + 'id' => $brickId + ) + )); + + if (!isset($result[0])) { + throw new QUI\Exception('Brick not found'); + } + + $allowed = array('project', 'lang', 'title', 'description'); + $allowed = array_flip($allowed); + $data = $result[0]; + + unset($data['id']); + + if (!is_array($params)) { + $params = array(); + } + + foreach ($params as $param => $value) { + if (!isset($allowed[$param])) { + continue; + } + + $data[$param] = $value; + } + + QUI::getDataBase()->insert($this->getTable(), $data); + + $lastId = QUI::getPDO()->lastInsertId(); + + return $lastId; } /** @@ -989,7 +1038,16 @@ protected function getInheritedBricks($brickArea, Site $Site) } foreach ($area as $brick) { - if (isset($brick['brickId']) && isset($brickIds[$brick['brickId']])) { + $customFields = json_decode($brick['customfields'], true); + + if ($customFields + && isset($customFields['inheritance']) + && $customFields['inheritance'] === false) { + continue; + } + + if (isset($brick['brickId']) + && isset($brickIds[$brick['brickId']])) { $result[] = $brick; } }