Skip to content

Commit

Permalink
Apply php-cs-fixer changes
Browse files Browse the repository at this point in the history
  • Loading branch information
alxndr-w authored and github-actions[bot] committed Aug 4, 2024
1 parent 689de71 commit ad6fae1
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 50 deletions.
2 changes: 1 addition & 1 deletion install.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php

require(rex_path::addon('speed_up','lib/speed_up.php'));
require rex_path::addon('speed_up', 'lib/speed_up.php');
speed_up::install();
2 changes: 1 addition & 1 deletion lib/rex_var_speed_up.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* REX_SPEED_UP[]
* REX_SPEED_UP[].
*/
class rex_var_speed_up extends rex_var
{
Expand Down
4 changes: 2 additions & 2 deletions lib/rex_var_speed_up_asset.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* REX_SPEED_UP_ASSET[file="file.jpg"] // Datei file.jpg aus dem Assets-Ordner
* REX_SPEED_UP_ASSET[file="file.jpg"] // Datei file.jpg aus dem Assets-Ordner.
*/
class rex_var_speed_up_asset extends rex_var
{
Expand All @@ -10,6 +10,6 @@ protected function getOutput()
return self::quote(speed_up_asset::getUrl($this->getArg('file')));
}

return self::quote("");
return self::quote('');
}
}
58 changes: 25 additions & 33 deletions lib/speed_up.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct($profile = 'auto')
}
$mount_id = rex_yrewrite::getCurrentDomain()->getMountId();
$category_mount_children = [];

if (rex_category::get($mount_id)) {
$category_mount_children = rex_category::get($mount_id)->getChildren(true);
}
Expand All @@ -35,21 +35,20 @@ public function __construct($profile = 'auto')

$category_neighbours = [];

if ($category_parent != null && $category_current->getId() != $mount_id) {
if (null != $category_parent && $category_current->getId() != $mount_id) {
// Nur wenn wir uns nicht in Root befinden oder überhalb eines Mount-Points - andere YRewrite-Domains möchten wir nicht prefetchen.
$category_neighbours = $category_parent->getChildren(true);
}

// Manuelle Einstellungen
$article_prefetch_config = explode(",", speed_up::getConfig('prefetch_articles') ?? "");

if (self::getConfig('profile') === 'auto') {
$article_prefetch_config = explode(',', self::getConfig('prefetch_articles') ?? '');

if ('auto' === self::getConfig('profile')) {
// Mount-Point = oberste Navigationsebene (Startseite könnte auch in einer Unterkategorie sein)
foreach ($category_mount_children as $category) {
$urls[$category->getId()] = $category->getUrl();
}

// Nur das erste Kind-Element
foreach ($category_children as $category) {
$urls[$category->getId()] = $category->getUrl();
Expand All @@ -64,9 +63,9 @@ public function __construct($profile = 'auto')
}
$urls[$category->getId()] = $category->getUrl();
// Nach 2 gefundenen Nachbarn aussteigen
if (++$neighbours == 2) {
if (2 == ++$neighbours) {
break;
};
}
}

$neighbours = 0;
Expand All @@ -76,36 +75,32 @@ public function __construct($profile = 'auto')
continue;
}
$urls[$article->getId()] = $article->getUrl();
if (++$neighbours == 2) {
if (2 == ++$neighbours) {
break;
};
}
}

if ($category_current && $category_current->getId() != $start_id) {
// Startseite hinzufügen
$urls[$start_id] = rex_article::get($start_id)->getUrl();
}
} elseif (self::getConfig('profile') === 'aggressive') {

} elseif ('aggressive' === self::getConfig('profile')) {
// Mount-Point = oberste Navigationsebene (Startseite könnte auch in einer Unterkategorie sein)
foreach ($category_mount_children as $category) {
$urls[$category->getId()] = $category->getUrl();
}

foreach ($category_children as $category) {
$urls[$category->getId()] = $category->getUrl();
}

foreach ($category_articles as $article) {
$urls[$article->getId()] = $article->getUrl();
}



foreach ($category_neighbours as $category) {
$urls[$category->getId()] = $category->getUrl();
}


if ($category_current && $category_current->getId() != $start_id) {
// Startseite hinzufügen
Expand All @@ -123,7 +118,7 @@ public function __construct($profile = 'auto')

$urls = rex_extension::registerPoint(new rex_extension_point(
'PREFETCH_URLS',
$urls
$urls,
));

/*
Expand All @@ -145,43 +140,40 @@ public function __construct($profile = 'auto')
}

unset($urls[rex_yrewrite::getCurrentDomain()->getNotfoundId()]);

$this->urls = $urls;

return $this;
}


public function showOutput()
{
echo $this->getOutput();
return;
}

public function show() /* Alias, BC */
{
return $this->showOutput();
}


public function getOutput()
{
if (self::getConfig('profile') === 'disabled') {
if ('disabled' === self::getConfig('profile')) {
return;
}
$output = PHP_EOL;
$output .= self::getConfig('preload').PHP_EOL;
$output .= self::getConfig('prefetch').PHP_EOL;
$preload_media_config = explode(",", speed_up::getConfig('preload_media') ?? "");
$output = PHP_EOL;
$output .= self::getConfig('preload') . PHP_EOL;
$output .= self::getConfig('prefetch') . PHP_EOL;

$preload_media_config = explode(',', self::getConfig('preload_media') ?? '');

foreach ($preload_media_config as $file) {
if ($media = rex_media::get($file)) {
$output .= '<link rel="preload" href="'. $media->getUrl() .'" as="image" type="'.$media->getType().'">'.PHP_EOL;
$output .= '<link rel="preload" href="' . $media->getUrl() . '" as="image" type="' . $media->getType() . '">' . PHP_EOL;
}
}
if (self::getConfig('profile') === "custom") {

if ('custom' === self::getConfig('profile')) {
return;
}

Expand All @@ -190,7 +182,7 @@ public function getOutput()
if (isset($parsedUrl['scheme']) && !in_array($parsedUrl['scheme'], ['http', 'https'])) {
continue;
}
$output .= '<link rel="prefetch" href="'. $url .'">'.PHP_EOL;
$output .= '<link rel="prefetch" href="' . $url . '">' . PHP_EOL;
}
return $output;
}
Expand Down
8 changes: 5 additions & 3 deletions lib/speed_up_asset.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
<?php

class speed_up_asset {
class speed_up_asset
{
public static function getUrl($file, $show_timestamp = true)
{
if ($show_timestamp) {
$timestamp = '?timestamp='.@filemtime(rex_path::assets($file));
$timestamp = '?timestamp=' . @filemtime(rex_path::assets($file));
}

return rex_url::assets($file) . $timestamp;
}

public static function showUrl($file, $show_timestamp = true) {
public static function showUrl($file, $show_timestamp = true)
{
echo self::getUrl($file, $show_timestamp);
}
}
20 changes: 10 additions & 10 deletions pages/system.speed_up.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
$select->addOption($this->i18n('speed_up_profile_auto'), 'auto');
$select->addOption($this->i18n('speed_up_profile_aggressive'), 'aggressive');

$field = $form->addTextAreaField('prefetch', null, ["class" => "form-control"]);
$field = $form->addTextAreaField('prefetch', null, ['class' => 'form-control']);
$field->setLabel($this->i18n('speed_up_additional_resources_prefetch_label'));
$field->setNotice($this->i18n('speed_up_additional_resources_prefetch_notice'));

$field = $form->addTextAreaField('preload', null, ["class" => "form-control"]);
$field = $form->addTextAreaField('preload', null, ['class' => 'form-control']);
$field->setLabel($this->i18n('speed_up_additional_resources_preload_label'));
$field->setNotice($this->i18n('speed_up_additional_resources_preload_notice'));

Expand All @@ -41,13 +41,13 @@
<div class="col-lg-4">
<?php

$anchor = '<a target="_blank" href="https://donate.alexplus.de/?addon=speed_up"><img src="'.rex_url::addonAssets('speed_up', 'jetzt-beauftragen.svg').'" style="width: 100% max-width: 400px;"></a>';
$anchor = '<a target="_blank" href="https://donate.alexplus.de/?addon=speed_up"><img src="' . rex_url::addonAssets('speed_up', 'jetzt-beauftragen.svg') . '" style="width: 100% max-width: 400px;"></a>';

$fragment = new rex_fragment();
$fragment->setVar('class', 'info', false);
$fragment->setVar('title', $this->i18n('speed_up_donate'), false);
$fragment->setVar('body', '<p>' . $this->i18n('speed_up_info_donate') . '</p>' . $anchor, false);
echo !rex_config::get("alexplusde", "donated") ? $fragment->parse('core/page/section.php') : "";
echo !rex_config::get('alexplusde', 'donated') ? $fragment->parse('core/page/section.php') : '';

if (rex_addon::get('ycom')->isAvailable()) {
echo rex_view::info($this->i18n('speed_up_info_ycom_active'));
Expand All @@ -56,14 +56,14 @@
echo rex_view::info($this->i18n('speed_up_info_url_active'));
}

if (!rex_request::isHttps() && $_SERVER['SERVER_PROTOCOL'] != "HTTP/2.0") {
if (!rex_request::isHttps() && 'HTTP/2.0' != $_SERVER['SERVER_PROTOCOL']) {
echo rex_view::error($this->i18n('speed_up_no_http2') . $_SERVER['SERVER_PROTOCOL']);
}

echo rex_view::info($this->i18n('speed_up_info_ep'));

if (!rex_addon::get('media_manager_responsive')->isAvailable()) {
$anchor = '<a target="_blank" href="https://github.com/alexplusde/media_manager_responsive/">'.$this->i18n('speed_up_info_media_manager_responsive_install').'</a>';
$anchor = '<a target="_blank" href="https://github.com/alexplusde/media_manager_responsive/">' . $this->i18n('speed_up_info_media_manager_responsive_install') . '</a>';
$fragment = new rex_fragment();
$fragment->setVar('class', 'info', false);
$fragment->setVar('title', $this->i18n('speed_up_info_media_manager_responsive_title'), false);
Expand All @@ -77,10 +77,10 @@
if (isset($package['files'])) {
$latest_version = array_pop($updates)['version'];
}
if (rex_version::compare($latest_version, $current_version, ">")) {
echo rex_view::info($this->i18n('speed_up_update_available') . " " .$latest_version);
};
};
if (rex_version::compare($latest_version, $current_version, '>')) {
echo rex_view::info($this->i18n('speed_up_update_available') . ' ' . $latest_version);
}
}
?>
</div>
</div>

0 comments on commit ad6fae1

Please sign in to comment.