Skip to content
Code-Schnipsel Gruppen Projekte
Bestätigt Commit 9dc55ca6 erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

refactor: return types, qualifier imports, code cleanup, converts php8.1

Übergeordneter daa34ebc
No related branches found
No related tags found
3 Merge Requests!26fix(Accordion): consider given entries parameter,!25fix(Accordion): consider given entries parameter,!24feat!: quiqqer v2
werden angezeigt mit 92 Ergänzungen und 71 Löschungen
......@@ -13,7 +13,7 @@
'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 {
......
......@@ -17,7 +17,7 @@
function ($brickId, $brickUID, $row) {
$BrickManager = QUI\Bricks\Manager::init();
if (isset($brickUID) && !empty($brickUID)) {
if (!empty($brickUID)) {
$Brick = $BrickManager->getBrickById($brickUID);
} else {
$Brick = $BrickManager->getBrickById($brickId);
......@@ -38,11 +38,7 @@ function ($brickId, $brickUID, $row) {
// generate rows
$loadingRows = 1;
if (
isset($settings['loadingrows'])
&& !empty($settings['loadingrows'])
&& (int)$settings['loadingrows']
) {
if (!empty($settings['loadingrows']) && (int)$settings['loadingrows']) {
$loadingRows = (int)$settings['loadingrows'];
}
......@@ -62,6 +58,5 @@ function ($brickId, $brickUID, $row) {
return $result;
},
['brickId', 'brickUID', 'row'],
false
['brickId', 'brickUID', 'row']
);
......@@ -16,15 +16,15 @@
'package_quiqqer_bricks_ajax_brick_save',
function ($brickId, $data) {
$BrickManager = QUI\Bricks\Manager::init();
$data = json_decode($data, true);
$data = json_decode($data, true);
$BrickManager->saveBrick($brickId, $data);
$Brick = $BrickManager->getBrickById($brickId);
return [
'attributes' => $Brick->getAttributes(),
'settings' => $Brick->getSettings(),
'customfields' => $Brick->getCustomFields(),
'attributes' => $Brick->getAttributes(),
'settings' => $Brick->getSettings(),
'customfields' => $Brick->getCustomFields(),
'availableSettings' => $BrickManager->getAvailableBrickSettingsByBrickType(
$Brick->getAttribute('type')
)
......
......@@ -34,19 +34,20 @@ function ($brickId, $project, $siteId, $message, $name, $email, $privacyPolicyAc
// If SimpleContact was used in a brick
$privacyPolicyCheckboxBrick = false;
$Brick = null;
if (!empty($brickId)) {
$BrickManager = QUI\Bricks\Manager::init();
$Brick = $BrickManager->getBrickByID($brickId);
$BrickManager = QUI\Bricks\Manager::init();
$Brick = $BrickManager->getBrickByID($brickId);
$privacyPolicyCheckboxBrick = $Brick->getSetting('showPrivacyPolicyCheckbox');
}
$Project = QUI::getProjectManager()->decode($project);
$Site = $Project->get((int)$siteId);
$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'));
$useCaptcha = boolval($Site->getAttribute('quiqqer.settings.sitetypes.contact.useCaptcha'));
if (($privacyPolicyCheckbox || $privacyPolicyCheckboxBrick) && !(int)$privacyPolicyAccepted) {
throw new QUI\Exception(
......@@ -73,7 +74,7 @@ function ($brickId, $project, $siteId, $message, $name, $email, $privacyPolicyAc
$receiver = $Site->getAttribute('quiqqer.settings.sitetypes.contact.email');
} else {
// Contact form (brick)
$receiver = $Brick->getSetting('mailTo');
$receiver = $Brick?->getSetting('mailTo');
}
// fallback: admin email
......@@ -88,8 +89,8 @@ function ($brickId, $project, $siteId, $message, $name, $email, $privacyPolicyAc
$Mailer->setSubject($Site->getAttribute('title') . ' ' . $Site->getUrlRewritten());
$body = "
<span style=\"font-weight: bold;\">From:</span> {$name}<br />
<span style=\"font-weight: bold;\">E-mail:</span> {$email}<br />
<span style=\"font-weight: bold;\">From:</span> $name<br />
<span style=\"font-weight: bold;\">E-mail:</span> $email<br />
";
if ($privacyPolicyAccepted) {
......@@ -119,6 +120,5 @@ function ($brickId, $project, $siteId, $message, $name, $email, $privacyPolicyAc
return true;
},
['brickId', 'project', 'siteId', 'message', 'name', 'email', 'privacyPolicyAccepted', 'captchaResponse'],
false
['brickId', 'project', 'siteId', 'message', 'name', 'email', 'privacyPolicyAccepted', 'captchaResponse']
);
......@@ -14,7 +14,6 @@
'package_quiqqer_bricks_ajax_getAvailableBricks',
function () {
$BricksManager = QUI\Bricks\Manager::init();
return $BricksManager->getAvailableBricks();
},
false,
......
......@@ -8,6 +8,8 @@
* @return String
*/
use QUI\Projects\Site;
QUI::$Ajax->registerFunction(
'package_quiqqer_bricks_ajax_getSitesFromBrick',
function ($brickId, $options) {
......@@ -17,7 +19,7 @@ function ($brickId, $options) {
$sites = $Bricks->getSitesByBrick($Brick);
$result = array_map(function ($Site) {
/* @var $Site \QUI\Projects\Site */
/* @var $Site Site */
return [
'project' => $Site->getProject()->getName(),
'lang' => $Site->getProject()->getLang(),
......
......@@ -16,7 +16,7 @@
'package_quiqqer_bricks_ajax_project_createBrick',
function ($project, $data) {
$Project = QUI::getProjectManager()->decode($project);
$Brick = new QUI\Bricks\Brick(json_decode($data, true));
$Brick = new QUI\Bricks\Brick(json_decode($data, true));
$BrickManager = QUI\Bricks\Manager::init();
......
......@@ -15,7 +15,7 @@
QUI::$Ajax->registerFunction(
'package_quiqqer_bricks_ajax_project_getAreas',
function ($project, $layout, $siteType) {
$Project = QUI::getProjectManager()->decode($project);
$Project = QUI::getProjectManager()->decode($project);
$BrickManager = QUI\Bricks\Manager::init();
return $BrickManager->getAreasByProject($Project, $layout, $siteType);
......
......@@ -15,7 +15,7 @@
QUI::$Ajax->registerFunction(
'package_quiqqer_bricks_ajax_project_getBricks',
function ($project, $area = false) {
$Project = QUI::getProjectManager()->decode($project);
$Project = QUI::getProjectManager()->decode($project);
$BrickManager = QUI\Bricks\Manager::init();
$bricks = $BrickManager->getBricksFromProject($Project);
......
......@@ -7,6 +7,7 @@
namespace QUI\Bricks\Controls\Children;
use QUI;
use QUI\Database\Exception;
/**
* Class Infinite
......@@ -19,7 +20,7 @@ class Infinite extends QUI\Control
*
* @param array $attributes
*/
public function __construct($attributes = [])
public function __construct(array $attributes = [])
{
$childrenPerRow = $this->getAttribute('childrenPerRow');
$rows = $this->getAttribute('rows');
......@@ -126,7 +127,7 @@ public function getBody(): string
*
* @return string
*/
public function getTemplate()
public function getTemplate(): string
{
return dirname(__FILE__) . '/Infinite.html';
}
......@@ -136,7 +137,7 @@ public function getTemplate()
*
* @return string
*/
public function getRowTemplate()
public function getRowTemplate(): string
{
return dirname(__FILE__) . '/InfiniteRow.html';
}
......@@ -146,12 +147,13 @@ public function getRowTemplate()
*
* @param int $start
* @return array
* @throws Exception
*/
protected function getChildren($start = 0)
protected function getChildren(int $start = 0): array
{
$max = $this->getAttribute('childrenPerRow');
$children = QUI\Projects\Site\Utils::getSitesByInputList(
return QUI\Projects\Site\Utils::getSitesByInputList(
$this->getProject(),
$this->getAttribute('site'),
[
......@@ -159,16 +161,16 @@ protected function getChildren($start = 0)
'order' => $this->getAttribute('order')
]
);
return $children;
}
/**
* Return the number of children
*
* @return int
* @throws Exception
* @throws \Exception
*/
protected function countChildren()
protected function countChildren(): int
{
$result = QUI\Projects\Site\Utils::getSitesByInputList(
$this->getProject(),
......@@ -184,11 +186,12 @@ protected function countChildren()
*
* @param integer $row
* @return array
* @throws Exception
*/
public function getRow($row)
public function getRow(int $row): array
{
$perRow = $this->getAttribute('childrenPerRow');
$start = (int)$row * $perRow;
$start = $row * $perRow;
return $this->getChildren($start);
}
......
......@@ -20,7 +20,7 @@ class Image extends QUI\Control
*
* @param array $attributes
*/
public function __construct($attributes = [])
public function __construct(array $attributes = [])
{
// default options
$this->setAttributes([
......
......@@ -7,6 +7,8 @@
namespace QUI\Bricks\Controls;
use QUI;
use QUI\Database\Exception;
use QUI\Interfaces\Projects\Site;
/**
* Class SocialBox
......@@ -20,7 +22,7 @@ class SideBox1 extends QUI\Control
*
* @param array $attributes
*/
public function __construct($attributes = [])
public function __construct(array $attributes = [])
{
// default options
$this->setAttributes([
......@@ -40,9 +42,9 @@ public function __construct($attributes = [])
}
/**
* (non-PHPdoc)
*
* @see \QUI\Control::create()
* @return string
* @throws Exception
* @throws QUI\Exception
*/
public function getBody(): string
{
......@@ -59,9 +61,12 @@ public function getBody(): string
/**
* Return the site object
*
* @return QUI\Projects\Site
* @return Site
* @throws Exception
* @throws QUI\Exception
* @throws \Exception
*/
public function getSite()
public function getSite(): QUI\Interfaces\Projects\Site
{
$Project = $this->getProject();
$site = $this->getAttribute('site');
......
......@@ -20,7 +20,7 @@ class SideBox2 extends QUI\Control
*
* @param array $attributes
*/
public function __construct($attributes = [])
public function __construct(array $attributes = [])
{
// default options
$this->setAttributes([
......
......@@ -20,7 +20,7 @@ class SideBox3 extends QUI\Control
*
* @param array $attributes
*/
public function __construct($attributes = [])
public function __construct(array $attributes = [])
{
// default options
$this->setAttributes([
......
......@@ -20,7 +20,7 @@ class SideBox4 extends QUI\Control
*
* @param array $attributes
*/
public function __construct($attributes = [])
public function __construct(array $attributes = [])
{
// default options
$this->setAttributes([
......
......@@ -6,6 +6,7 @@
namespace QUI\Bricks\Controls;
use Exception;
use QUI;
use QUI\Captcha\Handler as CaptchaHandler;
......@@ -22,8 +23,9 @@ class SimpleContact extends QUI\Control
* constructor
*
* @param array $attributes
* @throws QUI\Exception
*/
public function __construct($attributes = [])
public function __construct(array $attributes = [])
{
$this->setAttributes([
'class' => 'quiqqer-simple-contact',
......@@ -134,7 +136,7 @@ public function getBody(): string
if (!$error) {
try {
$this->sendMail($Engine);
} catch (\Exception $Exception) {
} catch (Exception $Exception) {
$Engine->assign([
'errorMessage' => $Exception->getMessage()
]);
......@@ -207,7 +209,7 @@ public function getBody(): string
* @param QUI\Interfaces\Template\EngineInterface $Engine
* @throws QUI\Exception
*/
public function sendMail($Engine)
public function sendMail(QUI\Interfaces\Template\EngineInterface $Engine): void
{
$Site = $this->getSite();
$privacyPolicyCheckbox = boolval(
......@@ -268,7 +270,7 @@ public function sendMail($Engine)
'brick.control.simpleContact.successful'
)
]);
} catch (\Exception $Exception) {
} catch (Exception $Exception) {
QUI\System\Log::writeException($Exception);
throw new QUI\Exception(
......@@ -285,7 +287,7 @@ public function sendMail($Engine)
*
* @return QUI\Projects\Site|false
*/
protected function getPrivacyPolicySite()
protected function getPrivacyPolicySite(): bool|QUI\Projects\Site
{
try {
$Project = QUI::getRewrite()->getProject();
......@@ -296,7 +298,7 @@ protected function getPrivacyPolicySite()
],
'limit' => 1
]);
} catch (\Exception $Exception) {
} catch (Exception $Exception) {
QUI\System\Log::writeException($Exception);
return false;
......@@ -314,7 +316,7 @@ protected function getPrivacyPolicySite()
*
* @throws QUI\Exception
*/
public function getSite()
public function getSite(): mixed
{
if ($this->getAttribute('Site')) {
return $this->getAttribute('Site');
......
......@@ -20,7 +20,7 @@ class SimpleGoogleMaps extends QUI\Control
*
* @param array $attributes
*/
public function __construct($attributes = [])
public function __construct(array $attributes = [])
{
// default options
$this->setAttributes([
......@@ -55,7 +55,7 @@ public function getBody(): string
$query = http_build_query([
'key' => trim($this->getAttribute('api')),
'q' => "{$brickPlace},{$brickZip},{$brickStreet},{$brickCity}"
'q' => "$brickPlace,$brickZip,$brickStreet,$brickCity"
]);
// prevent load map
......
......@@ -9,6 +9,10 @@
use QUI;
use QUI\Projects\Media\Utils;
use function is_array;
use function is_string;
use function json_decode;
/**
* Class AbstractPromoslider
* Abstact parent class for all sliders
......@@ -21,12 +25,12 @@ class AbstractPromoslider extends QUI\Control
/**
* @var array
*/
protected $mobileSlides = [];
protected array $mobileSlides = [];
/**
* @var array
*/
protected $desktopSlides = [];
protected array $desktopSlides = [];
/**
* Add a slide for the desktop view
......@@ -38,8 +42,14 @@ class AbstractPromoslider extends QUI\Control
* @param string $url - index.php? or extern url
* @param boolean $newTab - should the url be opened in a new tab?
*/
public function addSlide($image, $title, $text, $type = 'right', $url = '', $newTab = false)
{
public function addSlide(
string $image,
string $title,
string $text,
string $type = 'right',
string $url = '',
bool $newTab = false
): void {
if (Utils::isMediaUrl($image)) {
try {
$Image = Utils::getMediaItemByUrl($image);
......@@ -62,7 +72,7 @@ public function addSlide($image, $title, $text, $type = 'right', $url = '', $new
if (Utils::isImage($Title)) {
$title = $Title;
}
} catch (QUI\Exception $Exception) {
} catch (QUI\Exception) {
$title = '';
}
} else {
......@@ -94,8 +104,13 @@ public function addSlide($image, $title, $text, $type = 'right', $url = '', $new
* @param string $url - index.php? or extern url
* @param boolean $newTab - should the url be opened in a new tab?
*/
public function addMobileSlide($image, $title, $text, $url = '', $newTab = false)
{
public function addMobileSlide(
string $image,
string $title,
string $text,
string $url = '',
bool $newTab = false
): void {
if (Utils::isMediaUrl($image)) {
try {
$Image = Utils::getMediaItemByUrl($image);
......@@ -120,7 +135,7 @@ public function addMobileSlide($image, $title, $text, $url = '', $newTab = false
if (Utils::isImage($Title)) {
$title = $Title;
}
} catch (QUI\Exception $Exception) {
} catch (QUI\Exception) {
$title = false;
}
}
......@@ -140,18 +155,18 @@ public function addMobileSlide($image, $title, $text, $url = '', $newTab = false
* @param mixed $slides
* @param string $type
*/
protected function parseSlides($slides, $type = 'desktop')
protected function parseSlides(mixed $slides, string $type = 'desktop'): void
{
if (empty($slides)) {
return;
}
// desktop slides
if (\is_string($slides)) {
$slides = \json_decode($slides, true);
if (is_string($slides)) {
$slides = json_decode($slides, true);
}
if (!\is_array($slides)) {
if (!is_array($slides)) {
return;
}
......
......@@ -53,7 +53,6 @@ public function getBody(): string
$images = [];
$sliderContent = $this->getAttribute('sliderContent');
$imgLeft = false;
$dotsNav = false;
if (!$mediaFolder) {
return '';
......@@ -70,7 +69,6 @@ public function getBody(): string
$mediaFolder
);
} catch (QUI\Exception) {
$Folder = false;
}
}
......
......@@ -6,6 +6,7 @@
namespace QUI\Bricks\Controls\Slider;
use Exception;
use QUI;
use QUI\Projects\Media\Utils;
......@@ -54,6 +55,7 @@ public function __construct(array $attributes = [])
/**
* @return string
* @throws Exception
*/
public function create(): string
{
......
0% oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren