Commit 0ca897fb authored by Henning Leutz's avatar Henning Leutz 🥋

Merge branch 'dev'

parents 0299085f a05c38d1
......@@ -20,11 +20,11 @@ QUI::$Ajax->registerFunction(
$newId = $BrickManager->copyBrick(
$brickId,
json_decode($params, true)
\json_decode($params, true)
);
return $BrickManager->getBrickById($newId)->getAttributes();
},
array('brickId', 'params'),
['brickId', 'params'],
'Permission::checkAdminUser'
);
......@@ -13,12 +13,11 @@ QUI::$Ajax->registerFunction(
'package_quiqqer_bricks_ajax_brick_delete',
function ($brickIds) {
$BrickManager = QUI\Bricks\Manager::init();
$brickIds = json_decode($brickIds, true);
$brickIds = \json_decode($brickIds, true);
foreach ($brickIds as $brickId) {
try {
$BrickManager->deleteBrick($brickId);
} catch (QUI\Exception $Exception) {
QUI::getMessagesHandler()->addAttention(
$Exception->getMessage()
......@@ -26,6 +25,6 @@ QUI::$Ajax->registerFunction(
}
}
},
array('brickIds'),
['brickIds'],
'Permission::checkAdminUser'
);
......@@ -23,7 +23,7 @@ QUI::$Ajax->registerFunction(
$Brick = $BrickManager->getBrickById($brickId);
}
$settings = array_merge(
$settings = \array_merge(
$Brick->getAttributes(),
$Brick->getSettings()
);
......@@ -48,12 +48,12 @@ QUI::$Ajax->registerFunction(
$result = '';
for ($i = 0; $i < $loadingRows; $i++) {
$Engine->assign(array(
$Engine->assign([
'children' => $Infinite->getRow((int)$row),
'row' => (int)$row,
'this' => $Infinite,
'gridClass' => $Infinite->getAttribute('gridClass')
));
]);
$result .= $Engine->fetch($Infinite->getRowTemplate());
$row++;
......@@ -61,6 +61,6 @@ QUI::$Ajax->registerFunction(
return $result;
},
array('brickId', 'brickUID', 'row'),
['brickId', 'brickUID', 'row'],
false
);
......@@ -16,12 +16,12 @@ QUI::$Ajax->registerFunction(
'package_quiqqer_bricks_ajax_brick_save',
function ($brickId, $data) {
$BrickManager = QUI\Bricks\Manager::init();
$BrickManager->saveBrick($brickId, json_decode($data, true));
$BrickManager->saveBrick($brickId, \json_decode($data, true));
$Brick = $BrickManager->getBrickById($brickId);
return $Brick->getAttributes();
},
array('brickId', 'data'),
['brickId', 'data'],
'Permission::checkAdminUser'
);
......@@ -43,8 +43,8 @@ QUI::$Ajax->registerFunction(
$Project = QUI::getProjectManager()->decode($project);
$Site = $Project->get((int)$siteId);
$privacyPolicyCheckbox = boolval($Site->getAttribute('quiqqer.settings.sitetypes.contact.showPrivacyPolicyCheckbox'));
$useCaptcha = boolval($Site->getAttribute('quiqqer.settings.sitetypes.contact.useCaptcha'));
$privacyPolicyCheckbox = \boolval($Site->getAttribute('quiqqer.settings.sitetypes.contact.showPrivacyPolicyCheckbox'));
$useCaptcha = \boolval($Site->getAttribute('quiqqer.settings.sitetypes.contact.useCaptcha'));
if (($privacyPolicyCheckbox || $privacyPolicyCheckboxBrick) && !(int)$privacyPolicyAccepted) {
throw new QUI\Exception(
......
......@@ -17,15 +17,15 @@ QUI::$Ajax->registerFunction(
$BrickManager = QUI\Bricks\Manager::init();
$Brick = $BrickManager->getBrickById($brickId);
return array(
return [
'attributes' => $Brick->getAttributes(),
'settings' => $Brick->getSettings(),
'customfields' => $Brick->getCustomFields(),
'availableSettings' => $BrickManager->getAvailableBrickSettingsByBrickType(
$Brick->getAttribute('type')
)
);
];
},
array('brickId'),
['brickId'],
'Permission::checkAdminUser'
);
......@@ -21,6 +21,6 @@ QUI::$Ajax->registerFunction(
return $categories;
},
array('brickId'),
['brickId'],
'Permission::checkAdminUser'
);
......@@ -12,6 +12,6 @@ QUI::$Ajax->registerFunction(
function ($brickId, $category) {
return QUI\Bricks\Panel::getInstance()->getCategoryFromBrick($brickId, $category);
},
array('brickId', 'category'),
['brickId', 'category'],
'Permission::checkAdminUser'
);
......@@ -10,12 +10,12 @@
QUI::$Ajax->registerFunction(
'package_quiqqer_bricks_ajax_getSitesFromBrick',
function ($brickId, $options) {
$options = json_decode($options, true);
$options = \json_decode($options, true);
$Bricks = QUI\Bricks\Manager::init();
$Brick = $Bricks->getBrickById($brickId);
$sites = $Bricks->getSitesByBrick($Brick);
$result = array_map(function ($Site) {
$result = \array_map(function ($Site) {
/* @var $Site \QUI\Projects\Site */
return [
'project' => $Site->getProject()->getName(),
......@@ -29,7 +29,7 @@ QUI::$Ajax->registerFunction(
$Grid = new QUI\Utils\Grid();
return $Grid->parseResult($result, count($sites));
return $Grid->parseResult($result, \count($sites));
},
['brickId', 'options'],
'Permission::checkAdminUser'
......
......@@ -22,6 +22,6 @@ QUI::$Ajax->registerFunction(
return $BrickManager->createBrickForProject($Project, $Brick);
},
array('project', 'data'),
['project', 'data'],
'Permission::checkAdminUser'
);
......@@ -20,6 +20,6 @@ QUI::$Ajax->registerFunction(
return $BrickManager->getAreasByProject($Project, $layout);
},
array('project', 'layout'),
['project', 'layout'],
'Permission::checkAdminUser'
);
......@@ -19,7 +19,7 @@ QUI::$Ajax->registerFunction(
$BrickManager = QUI\Bricks\Manager::init();
$bricks = $BrickManager->getBricksFromProject($Project);
$result = array();
$result = [];
foreach ($bricks as $Brick) {
/* @var $Brick QUI\Bricks\Brick */
......@@ -30,13 +30,13 @@ QUI::$Ajax->registerFunction(
$areas = $Brick->getAttribute('areas');
if (strpos($areas, ',' . $area . ',') !== false) {
if (\strpos($areas, ','.$area.',') !== false) {
$result[] = $Brick->getAttributes();
}
}
return $result;
},
array('project', 'area'),
['project', 'area'],
'Permission::checkAdminUser'
);
......@@ -1517,6 +1517,12 @@ M&ouml;chten Sie die Bausteine aus der Bausteinzone entfernen?</p>]]></de>
<pl><![CDATA[Pokaż godzinę]]></pl>
</locale>
<!-- show pagination / sheets -->
<locale name="brick.showSheets">
<de><![CDATA[Seitennummerierung anzeigen]]></de>
<en><![CDATA[Show sheets (pagination)]]></en>
</locale>
<!-- show images -->
<locale name="brick.showImages">
<de><![CDATA[Bild anzeigen]]></de>
......
<div {$classesStr}>
{if $this->getAttribute('showTitle') && $this->getAttribute('title')}
<header>
<h2>{$this->getAttribute('title')}</h2>
{if $this->getAttribute('showTitle') && $this->getAttribute('frontendTitle')}
<header class="control-header">
<h1>{$this->getAttribute('frontendTitle')}</h1>
</header>
{/if}
{$this->getAttribute('content')}
{if $this->getAttribute('content') != ""}
<div class="control-content">
{$this->getAttribute('content')}
</div>
{/if}
</div>
\ No newline at end of file
......@@ -37,14 +37,14 @@ class Brick extends QUI\QDOM
*
* @var array
*/
protected $settings = array();
protected $settings = [];
/**
* Fields can be overwritten by another user
*
* @var array
*/
protected $customfields = array();
protected $customfields = [];
/**
* Internal control
......@@ -58,17 +58,17 @@ class Brick extends QUI\QDOM
*
* @var array
*/
protected $cssClasses = array();
protected $cssClasses = [];
/**
* Constructor
*
* @param array $params - brick params
*/
public function __construct($params = array())
public function __construct($params = [])
{
// default
$default = array(
$default = [
'type' => 'content',
'content' => '',
'title' => '',
......@@ -81,7 +81,7 @@ class Brick extends QUI\QDOM
'classes' => '',
'frontendTitle' => '',
'hasContent' => 1
);
];
$this->setAttributes($default);
......@@ -100,10 +100,10 @@ class Brick extends QUI\QDOM
}
if (isset($params['classes'])) {
$cssClasses = json_decode($params['classes'], true);
$cssClasses = \json_decode($params['classes'], true);
if (!$cssClasses) {
$cssClasses = array();
$cssClasses = [];
}
foreach ($cssClasses as $cssClass) {
......@@ -133,7 +133,7 @@ class Brick extends QUI\QDOM
// control default settings
if (is_object($Control)) {
if (\is_object($Control)) {
$controlSettings = $Control->getAttributes();
foreach ($this->settings as $key => $value) {
......@@ -147,11 +147,11 @@ class Brick extends QUI\QDOM
if (isset($params['settings'])) {
$settings = $params['settings'];
if (is_string($settings)) {
$settings = json_decode($settings, true);
if (\is_string($settings)) {
$settings = \json_decode($settings, true);
}
if (is_array($settings)) {
if (\is_array($settings)) {
foreach ($this->settings as $key => $value) {
if (isset($settings[$key])) {
$this->settings[$key] = $settings[$key];
......@@ -164,11 +164,11 @@ class Brick extends QUI\QDOM
if (isset($params['customfields'])) {
$customfields = $params['customfields'];
if (is_string($customfields)) {
$customfields = json_decode($customfields, true);
if (\is_string($customfields)) {
$customfields = \json_decode($customfields, true);
}
if (is_array($customfields)) {
if (\is_array($customfields)) {
$this->customfields = $customfields;
}
}
......@@ -183,11 +183,11 @@ class Brick extends QUI\QDOM
{
$Control = $this->getControl();
if (is_object($Control)) {
return get_class($Control);
if (\is_object($Control)) {
return \get_class($Control);
}
return get_class($this);
return \get_class($this);
}
/**
......@@ -200,7 +200,7 @@ class Brick extends QUI\QDOM
{
$Control = $this->getControl();
if (is_object($Control)) {
if (\is_object($Control)) {
return $Control instanceof $className;
}
......@@ -210,8 +210,8 @@ class Brick extends QUI\QDOM
/**
* Check, if control canbe created
*
* @throws QUI\Exception
* @return QUI\Bricks\Brick
* @throws QUI\Exception
*/
public function check()
{
......@@ -240,15 +240,15 @@ class Brick extends QUI\QDOM
public function create()
{
if ($this->getAttribute('type') == 'content') {
$_classes = array(
$_classes = [
'brick-'.$this->id
);
];
//check if is json
if (is_string($this->cssClasses)) {
$jsonArray = json_decode($this->cssClasses);
if (\is_string($this->cssClasses)) {
$jsonArray = \json_decode($this->cssClasses);
if (is_array($jsonArray)) {
if (\is_array($jsonArray)) {
$this->cssClasses = $jsonArray;
}
}
......@@ -260,36 +260,36 @@ class Brick extends QUI\QDOM
$oldCssClasses = $this->getAttribute('classes');
$oldCssClassesJson = json_decode($oldCssClasses, true);
$oldCssClassesJson = \json_decode($oldCssClasses, true);
if (is_array($oldCssClassesJson)) {
if (\is_array($oldCssClassesJson)) {
$oldCssClasses = $oldCssClassesJson;
}
$classes = $oldCssClasses ;
$classes = $oldCssClasses;
if (is_string($oldCssClasses)) {
$classes = explode(' ', $oldCssClasses);
if (\is_string($oldCssClasses)) {
$classes = \explode(' ', $oldCssClasses);
}
foreach ($classes as $class) {
$class = trim($class);
$class = \trim($class);
$_classes[] = $class;
}
$_classes = array_unique($_classes);
$classesStr = implode($_classes, ' ');
$_classes = \array_unique($_classes);
$classesStr = \implode($_classes, ' ');
$classesStr = 'class="'.$classesStr.'"';
$Engine = QUI::getTemplateManager()->getEngine();
$Engine->assign(array(
$Engine->assign([
'this' => $this,
'classesStr' => $classesStr
));
]);
return $Engine->fetch(dirname(__FILE__).'/Brick.html');
return $Engine->fetch(\dirname(__FILE__).'/Brick.html');
}
$Control = $this->getControl();
......@@ -341,13 +341,13 @@ class Brick extends QUI\QDOM
return true;
}
if (!is_callable($Ctrl) && !class_exists($Ctrl)) {
if (!\is_callable($Ctrl) && !\class_exists($Ctrl)) {
return false;
}
/* @var $Control \QUI\Control */
$Control = new $Ctrl(
array_merge($this->getSettings(), $this->getAttributes())
\array_merge($this->getSettings(), $this->getAttributes())
);
$Control->setAttribute('height', $this->getAttribute('height'));
......@@ -459,7 +459,7 @@ class Brick extends QUI\QDOM
*/
public function addCSSClass($cssClass)
{
if (!is_string($cssClass)) {
if (!\is_string($cssClass)) {
return;
}
......@@ -468,9 +468,9 @@ class Brick extends QUI\QDOM
}
$classes = QUI\ControlUtils::clearClassName($cssClass);
$classes = explode(' ', $classes);
$classes = \explode(' ', $classes);
$keys = array_flip($this->cssClasses);
$keys = \array_flip($this->cssClasses);
foreach ($classes as $cssClass) {
if (!isset($keys[$cssClass])) {
......@@ -485,7 +485,7 @@ class Brick extends QUI\QDOM
*/
public function clearCSSClasses()
{
$this->cssClasses = array();
$this->cssClasses = [];
}
/**
......@@ -508,7 +508,7 @@ class Brick extends QUI\QDOM
public function hasCSSClass($pattern)
{
if ($this->getAttribute('classes')
&& fnmatch($pattern, $this->getAttribute('classes'))
&& \fnmatch($pattern, $this->getAttribute('classes'))
) {
return true;
}
......@@ -518,7 +518,7 @@ class Brick extends QUI\QDOM
}
foreach ($this->cssClasses as $cssClass) {
if (fnmatch($pattern, $cssClass)) {
if (\fnmatch($pattern, $cssClass)) {
return true;
}
}
......
......@@ -29,7 +29,7 @@
>&nbsp;</div>
{elseif $slide.image}
<div class="quiqqer-bricks-promoslider-slide-image">
{image image=$slide.image}
{image image=$slide.image width=$imageSize}
</div>
{/if}
......@@ -78,7 +78,7 @@
>&nbsp;</div>
{elseif $slide.image}
<div class="quiqqer-bricks-promoslider-slide-mobile-image">
{image image=$slide.image}
{image image=$slide.image width=$imageSize}
</div>
{/if}
......
......@@ -21,10 +21,10 @@ class Promoslider extends AbstractPromoslider
*
* @param array $attributes
*/
public function __construct($attributes = array())
public function __construct($attributes = [])
{
// default options
$this->setAttributes(array(
$this->setAttributes([
'title' => '',
'text' => '',
'class' => 'quiqqer-bricks-promoslider',
......@@ -36,8 +36,9 @@ class Promoslider extends AbstractPromoslider
'image-wallpaper-attachment' => false,
'autostart' => false,
'delay' => 5000,
'isMobileSlidesEnabled' => false
));
'isMobileSlidesEnabled' => false,
'imageSize' => false // false = use original size, do not create srcset
]);
$this->addCSSFile(
dirname(__FILE__) . '/Promoslider.css'
......@@ -46,7 +47,6 @@ class Promoslider extends AbstractPromoslider
$this->addCSSClass('grid-100');
$this->addCSSClass('mobile-grid-100');
parent::__construct($attributes);
}
......@@ -169,12 +169,13 @@ class Promoslider extends AbstractPromoslider
$this->parseSlides($this->getAttribute('desktopslides'), 'desktop');
$options = array(
$options = [
'this' => $this,
'desktopSlides' => $this->desktopSlides,
'Utils' => new Utils()
);
'Utils' => new Utils(),
'imageSize' => $this->getAttribute('imageSize')
];
if ($this->getAttribute('isMobileSlidesEnabled') === "true") {
$this->parseSlides($this->getAttribute('mobileslides'), 'mobile');
......
......@@ -17,7 +17,7 @@ use QUI\Projects\Site\Edit;
*/
class Events
{
protected static $saved = array();
protected static $saved = [];
/**
* Event : on site save
......@@ -35,7 +35,7 @@ class Events
QUI\Permissions\Permission::checkPermission('quiqqer.bricks.assign');
$areas = $Site->getAttribute('quiqqer.bricks.areas');
$areas = json_decode($areas, true);
$areas = \json_decode($areas, true);
if (!$areas || empty($areas)) {
return;
......@@ -49,7 +49,7 @@ class Events
$projectTable = QUI::getDBProjectTableName(Manager::TABLE_CACHE, $Project);
$uidTable = QUI\Bricks\Manager::getUIDTable();
$availableUniqueIds = array();
$availableUniqueIds = [];
foreach ($projectAreas as $area) {
if (!$area['inheritance']) {
......@@ -67,18 +67,18 @@ class Events
$bricks = $areas[$area['name']];
// clear area and new data set
QUI::getDataBase()->delete($projectTable, array(
QUI::getDataBase()->delete($projectTable, [
'id' => $Site->getId(),
'area' => $area['name']
));
]);
// check if deactivated
if (isset($bricks[0]) && isset($bricks[0]['deactivate'])) {
QUI::getDataBase()->insert($projectTable, array(
QUI::getDataBase()->insert($projectTable, [
'id' => $Site->getId(),
'area' => $area['name'],
'brick' => -1
));
]);
continue;
}
......@@ -103,14 +103,14 @@ class Events
$availableUniqueIds[] = $uid;
$customFields = array();
$customFields = [];
// Custom data cache
if (isset($brick['customfields']) && is_string($brick['customfields'])) {
$customFields = json_decode($brick['customfields'], true);
if (isset($brick['customfields']) && \is_string($brick['customfields'])) {
$customFields = \json_decode($brick['customfields'], true);
}
if (isset($brick['customfields']) && is_array($brick['customfields'])) {
if (isset($brick['customfields']) && \is_array($brick['customfields'])) {
$customFields = $brick['customfields'];
}
......@@ -118,45 +118,45 @@ class Events
continue;
}
QUI::getDataBase()->insert($projectTable, array(
QUI::getDataBase()->insert($projectTable, [
'id' => $Site->getId(),
'area' => $area['name'],
'brick' => (int)$brick['brickId']
));
]);
}
}
// cleanup unique ids
$uniquerIdsInDataBase = QUI::getDataBase()->fetch(array(
$uniquerIdsInDataBase = QUI::getDataBase()->fetch([
'select' => 'uid',
'from' => $uidTable,
'where' => array(
'where' => [
'project' => $Project->getName(),
'lang' => $Project->getLang(),
'siteId' => $Site->getId()
)
));
]
]);
$uniquerIdsInDataBase = array_map(function ($uid) {
$uniquerIdsInDataBase = \array_map(function ($uid) {
return $uid['uid'];
}, $uniquerIdsInDataBase);
$availableUniqueIds = array_flip($availableUniqueIds);
$availableUniqueIds = \array_flip($availableUniqueIds);
foreach ($uniquerIdsInDataBase as $uid) {
if (isset($availableUniqueIds[$uid])) {
continue;
}
QUI::getDataBase()->delete($uidTable, array(
QUI::getDataBase()->delete($uidTable, [
'uid' => $uid
));
]);
}
self::$saved[$Site->getId()] = true;
// save bricks with unique ids
$Site->setAttribute('quiqqer.bricks.areas', json_encode($areas));
$Site->setAttribute('quiqqer.bricks.areas', \json_encode($areas));
$Site->save();
}
......@@ -191,7 +191,7 @@ class Events
return '';
}
$smarty->assign($params['assign'], array());
$smarty->assign($params['assign'], []);
return '';
}
......@@ -224,12 +224,12 @@ class Events
$php = 'php';
if (defined('PHP_BINARY')) {
if (\defined('PHP_BINARY')) {
$php = PHP_BINARY;
}
try {
shell_exec($php.' '.OPT_DIR.'quiqqer/bricks/patches/uniqueIds.php');
\shell_exec($php.' '.OPT_DIR.'quiqqer/bricks/patches/uniqueIds.php');
} catch (\Exception $Exception) {
QUI\System\Log::writeException($Exception);
}
......
This diff is collapsed.
......@@ -71,11 +71,11 @@ class Panel extends QUI\Utils\Singleton
$Settings = QUI\Utils\XML\Settings::getInstance();
$Settings->setXMLPath($path);
$categories = array();
$categories = [];
foreach ($xmlFiles as $file) {
$panel = $Settings->getPanel($file);
$categories = array_merge(
$categories = \array_merge(
$categories,
$panel['categories']->toArray()
);
......@@ -83,7 +83,7 @@ class Panel extends QUI\Utils\Singleton
// locale
foreach ($categories as $key => $category) {
if (isset($category['title']) && is_array($category['title'])) {
if (isset($category['title']) && \is_array($category['title'])) {
$categories[$key]['text'] = QUI::getLocale()->get(
$category['title'][0],
$category['title'][1]
......@@ -112,7 +112,7 @@ class Panel extends QUI\Utils\Singleton
$path = $this->getPath($Brick);
$xmlFiles = Utils::getBricksXMLFiles();
$result = array();
$result = [];
foreach ($xmlFiles as $xmlFile) {
try {
......@@ -138,7 +138,7 @@ class Panel extends QUI\Utils\Singleton
protected function getPath(Brick $Brick)
{