Skip to content

Commit 052bb62

Browse files
authored
Merge pull request #246 from dragomano/hot_fixes
Add some fixes
2 parents 72faf3e + 8f88b43 commit 052bb62

File tree

22 files changed

+57
-63
lines changed

22 files changed

+57
-63
lines changed

docs/src/plugins/create-new.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Plugins for importing and exporting various portal elements.
5353

5454
### `block_options` | `page_options`
5555

56-
Plugins that add additional parameters for the corresponding entity (block or .page).
56+
Plugins that add additional parameters for the corresponding entity (block or page).
5757

5858
### `icons`
5959

rector.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?php declare(strict_types=1);
22

33
use Rector\Config\RectorConfig;
4-
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
54
use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector;
65

76
return RectorConfig::configure()
@@ -13,9 +12,6 @@
1312
__DIR__ . '**/Tasks/Notifier.php',
1413
__DIR__ . '**/Libs/*',
1514
__DIR__ . '**/vendor/*',
16-
__DIR__ . '**/langs/*',
17-
__DIR__ . '**/index.php',
18-
StringClassNameToClassConstantRector::class,
1915
NullToStrictStringFuncCallArgRector::class,
2016
])
2117
->withParallel(360)

src/Sources/LightPortal/Actions/Block.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function show(): void
6969
$icon = Icon::parse(Utils::$context['lp_blocks'][$data['placement']][$item]['icon']);
7070

7171
if (! empty($data['parameters']['link_in_title'])) {
72-
$title = Str::html('a')->href($data['parameters']['link_in_title'])->setText($title);
72+
$title = Str::html('a', $title)->href($data['parameters']['link_in_title']);
7373
}
7474
} else {
7575
$title = $icon = '';

src/Sources/LightPortal/Actions/Category.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,9 @@ public function showAll(): void
196196
'value' => Lang::$txt['lp_category']
197197
],
198198
'data' => [
199-
'function' => static fn($entry) => $entry['icon'] . ' ' . Str::html('a')
200-
->href($entry['link'])
201-
->setText($entry['title']) . (empty($entry['description']) ? '' :
202-
Str::html('p', ['class' => 'smalltext'])
203-
->setText($entry['description']))
199+
'function' => static fn($entry) => $entry['icon'] . ' ' . Str::html('a', $entry['title'])
200+
->href($entry['link']) . (empty($entry['description']) ? '' :
201+
Str::html('p', $entry['description'])->class('smalltext'))
204202
],
205203
'sort' => [
206204
'default' => 'title DESC',

src/Sources/LightPortal/Actions/FrontPage.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,10 +404,7 @@ private function simplePaginate(string $url, int $total, int $limit): string
404404

405405
$paginate = '';
406406

407-
$button = Str::html('a', [
408-
'class' => 'button',
409-
'href' => '%s;start=%s',
410-
]);
407+
$button = Str::html('a')->class('button')->href('%s;start=%s');
411408

412409
if ($prev >= 0) {
413410
$title = Icon::get('arrow_left') . ' ' . Lang::$txt['prev'];

src/Sources/LightPortal/Actions/Page.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,9 @@ public function getList(): array
233233
'value' => Lang::$txt['lp_title']
234234
],
235235
'data' => [
236-
'function' => static fn($entry) => Str::html('a', [
237-
'class' => 'bbc_link' . ($entry['is_front'] ? ' new_posts' : ''),
238-
'href' => $entry['is_front'] ? Config::$scripturl : (LP_PAGE_URL . $entry['slug']),
239-
])->setText($entry['title']),
236+
'function' => static fn($entry) => Str::html('a', $entry['title'])
237+
->class('bbc_link' . ($entry['is_front'] ? ' new_posts' : ''))
238+
->href($entry['is_front'] ? Config::$scripturl : (LP_PAGE_URL . $entry['slug'])),
240239
'class' => 'word_break'
241240
],
242241
'sort' => [
@@ -251,9 +250,8 @@ public function getList(): array
251250
'data' => [
252251
'function' => static fn($entry) => empty($entry['author']['name'])
253252
? Lang::$txt['guest_title']
254-
: Str::html('a')
255-
->href($entry['author']['link'])
256-
->setText($entry['author']['name']),
253+
: Str::html('a', $entry['author']['name'])
254+
->href($entry['author']['link']),
257255
'class' => 'centertext'
258256
],
259257
'sort' => [

src/Sources/LightPortal/Actions/Tag.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,8 @@ public function showAll(): void
193193
'value' => Lang::$txt['lp_tag_column']
194194
],
195195
'data' => [
196-
'function' => static fn($entry) => $entry['icon'] . ' ' . Str::html('a')
197-
->href($entry['link'])
198-
->setText($entry['title']),
196+
'function' => static fn($entry) => $entry['icon'] . ' ' . Str::html('a', $entry['title'])
197+
->href($entry['link']),
199198
],
200199
'sort' => [
201200
'default' => 'title DESC',

src/Sources/LightPortal/Areas/PluginArea.php

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ private function handleToggle(): void
139139
)
140140
]);
141141

142-
$this->updateAssetMtime(Utils::$context['lp_plugins'][$pluginId]);
142+
$this->removeAssets();
143143

144144
$this->cache()->flush();
145145

@@ -342,20 +342,10 @@ private function prepareJsonData(): void
342342
]);
343343
}
344344

345-
private function updateAssetMtime(string $plugin): void
345+
private function removeAssets(): void
346346
{
347-
$path = LP_ADDON_DIR . DIRECTORY_SEPARATOR . $plugin . DIRECTORY_SEPARATOR;
348-
349-
$assets = [
350-
$path . 'style.css',
351-
$path . 'script.js',
352-
];
353-
354-
foreach ($assets as $asset) {
355-
if (is_file($asset)) {
356-
touch($asset);
357-
}
358-
}
347+
unlink(Theme::$current->settings['default_theme_dir'] . '/css/light_portal/plugins.css');
348+
unlink(Theme::$current->settings['default_theme_dir'] . '/scripts/light_portal/plugins.js');
359349
}
360350

361351
private function extendPluginList(): void

src/Sources/LightPortal/Hooks/CommonChecks.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ trait CommonChecks
3131

3232
protected function isPortalCanBeLoaded(): bool
3333
{
34-
if (! defined('LP_NAME') || $this->request()->is('printpage')) {
34+
if (! defined('LP_NAME') || isset(Utils::$context['uninstalling']) || $this->request()->is('printpage')) {
3535
Config::$modSettings['minimize_files'] = 0;
3636
return false;
3737
}

src/Sources/LightPortal/Hooks/PreCssOutput.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ class PreCssOutput
2525
{
2626
public function __invoke(): void
2727
{
28+
if (isset(Utils::$context['uninstalling']))
29+
return;
30+
2831
echo "\n\t" . Str::html('link')
2932
->rel('preconnect')
3033
->href('//cdn.jsdelivr.net');

src/Sources/LightPortal/Integration.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
namespace Bugo\LightPortal;
1414

15-
use Bugo\Compat\Utils;
1615
use Bugo\LightPortal\Enums\Hook;
1716
use Bugo\LightPortal\Hooks\Actions;
1817
use Bugo\LightPortal\Hooks\AlertTypes;
@@ -49,9 +48,6 @@ final class Integration
4948

5049
public function __invoke(): void
5150
{
52-
if (isset(Utils::$context['uninstalling']))
53-
return;
54-
5551
if (str_starts_with(SMF_VERSION, '3.0')) {
5652
$this->applyHook(Hook::preLoad, PreLoad::class);
5753
$this->applyHook(Hook::permissionsList, PermissionsList::class);

src/Sources/LightPortal/Plugins/CustomTranslate/CustomTranslate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function init(): void
4141

4242
public function menuButtons(): void
4343
{
44-
if ($this->request()->has('xml'))
44+
if (isset(Utils::$context['uninstalling']) || $this->request()->has('xml'))
4545
return;
4646

4747
if (empty(Utils::$context['lp_custom_translate_plugin']['languages']))

src/Sources/LightPortal/Plugins/HelloPortal/steps.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
intro: "' . Lang::$txt['lp_hello_portal']['basic_settings_tour'][1] . '"
1515
},' . (! empty(Config::$modSettings['lp_frontpage_mode']) && Config::$modSettings['lp_frontpage_mode'] !== 'chosen_page' ? ('
1616
{
17-
element: document.getElementById("lp_frontpage_order_by_replies"),
17+
element: document.getElementById("caption_lp_frontpage_order_by_replies"),
1818
intro: "' . Lang::$txt['lp_hello_portal']['basic_settings_tour'][2] . '"
1919
},') : '') . '
2020
{
21-
element: document.getElementById("setting_lp_standalone_mode").parentNode.parentNode.parentNode,
21+
element: document.querySelector("[data-tab=standalone]"),
2222
intro: "' . Lang::$txt['lp_hello_portal']['basic_settings_tour'][3] . '"
2323
},
2424
{
25-
element: document.getElementById("setting_light_portal_view").parentNode.parentNode,
25+
element: document.querySelector("[data-tab=permissions]"),
2626
intro: "' . Lang::$txt['lp_hello_portal']['basic_settings_tour'][4] . '"
2727
},
2828
{
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
.lp_addon_hello_portal * {
22
font-size: 1.4em;
3+
}
4+
5+
.introjs-helperLayer {
6+
background: transparent !important;
37
}

src/Sources/LightPortal/Plugins/ThemeSwitcher/ThemeSwitcher.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* @license https://spdx.org/licenses/GPL-3.0-or-later.html GPL-3.0-or-later
99
*
1010
* @category plugin
11-
* @version 08.11.24
11+
* @version 09.11.24
1212
*/
1313

1414
namespace Bugo\LightPortal\Plugins\ThemeSwitcher;
@@ -50,18 +50,15 @@ public function prepareContent(Event $e): void
5050

5151
$id = $e->args->data->id;
5252

53-
$container = Str::html('div')
54-
->class('themeswitcher centertext');
53+
$container = Str::html('div')->class('themeswitcher centertext');
5554

5655
$select = Str::html('select')
5756
->id("lp_block_{$id}_themeswitcher")
5857
->setAttribute('onchange', "lp_block_{$id}_themeswitcher_change();")
5958
->setAttribute('disabled', count($themes) < 2 ? 'disabled' : null);
6059

6160
foreach ($themes as $themeId => $name) {
62-
$option = Str::html('option')
63-
->value($themeId)
64-
->setText($name);
61+
$option = Str::html('option', $name)->value($themeId);
6562

6663
if (Theme::$current->settings['theme_id'] === $themeId) {
6764
$option->setAttribute('selected', 'selected');

src/Sources/LightPortal/Repositories/AbstractRepository.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ protected function saveOptions(int $item, string $method = ''): void
137137

138138
protected function prepareTitles(): void
139139
{
140+
if (empty(Utils::$context['lp_' . $this->entity]['titles']))
141+
return;
142+
140143
// Remove all punctuation symbols
141144
Utils::$context['lp_' . $this->entity]['titles'] = preg_replace(
142145
"#[[:punct:]]#", "", (array) Utils::$context['lp_' . $this->entity]['titles']

src/Sources/LightPortal/Repositories/BlockRepository.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ public function getAll(): array
6565
'areas' => str_replace(',', PHP_EOL, (string) $row['areas']),
6666
];
6767

68-
$currentBlocks[$row['placement']][$row['block_id']]['titles'][$row['lang']] = $row['title'];
68+
if (! empty($row['lang'])) {
69+
$currentBlocks[$row['placement']][$row['block_id']]['titles'][$row['lang']] = $row['title'];
70+
}
6971

7072
$this->prepareMissingBlockTypes($row['type']);
7173
}

src/Sources/LightPortal/Repositories/PageRepository.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ final class PageRepository extends AbstractRepository
5252

5353
protected string $entity = 'page';
5454

55+
private CommentRepository $commentRepository;
56+
5557
public function __construct()
5658
{
5759
$this->commentRepository = new CommentRepository();
@@ -670,9 +672,7 @@ private function updateData(int $item): void
670672
if (Utils::$context['lp_page']['author_id'] !== User::$info['id']) {
671673
$title = Utils::$context['lp_page']['titles'][User::$info['language']];
672674
Logging::logAction('update_lp_page', [
673-
'page' => Str::html('a')
674-
->href(LP_PAGE_URL . Utils::$context['lp_page']['slug'])
675-
->setText($title)
675+
'page' => Str::html('a', $title)->href(LP_PAGE_URL . Utils::$context['lp_page']['slug'])
676676
]);
677677
}
678678

src/Sources/LightPortal/Utils/Str.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public static function getImageFromText(string $text): string
7171
return $result;
7272
}
7373

74-
public static function html(string $name, array $params = []): Html
74+
public static function html(string $name, array|string|null $params = null): Html
7575
{
7676
return Html::el($name, $params);
7777
}

src/Themes/default/LightPortal/ManageBlocks.template.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,16 @@ function show_block_entry(int $id, array $data): void
101101
if (empty($id) || empty($data))
102102
return;
103103

104+
$title = $data['note'] ?? '';
105+
106+
if (isset($data['titles'])) {
107+
if (! empty($data['titles'][Utils::$context['user']['language']])) {
108+
$title = $data['titles'][Utils::$context['user']['language']];
109+
} elseif (! empty($data['titles'][Config::$language])) {
110+
$title = $data['titles'][Config::$language];
111+
}
112+
}
113+
104114
echo '
105115
<tr
106116
class="windowbg"
@@ -112,7 +122,7 @@ class="windowbg"
112122
', $data['icon'], '
113123
</td>
114124
<td class="title">
115-
<div class="hidden-xs hidden-sm hidden-md">', $title = $data['note'] ?: ($data['titles'][Utils::$context['user']['language']] ?? $data['titles'][Config::$language] ?? ''), '</div>
125+
<div class="hidden-xs hidden-sm hidden-md">', $title, '</div>
116126
<div class="hidden-lg hidden-xl">
117127
<table class="table_grid">
118128
<tbody>

src/Themes/default/LightPortal/ManageFeedback.template.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
use Bugo\Compat\{Config, Lang, Utils};
3+
use Bugo\Compat\{Config, Db, Lang, Utils};
44

55
function template_feedback(): void
66
{
@@ -22,6 +22,7 @@ function template_feedback(): void
2222
<input type="hidden" name="portal_version" value="', LP_VERSION, '">
2323
<input type="hidden" name="smf_version" value="', SMF_VERSION, '">
2424
<input type="hidden" name="php_version" value="', PHP_VERSION, '">
25+
<input type="hidden" name="database" value="', Utils::$smcFunc['db_title'] . ' ' . Db::$db->get_version(), '">
2526
<input type="hidden" name="enabled_plugins" value="', str_replace(',', "\n", (string) Config::$modSettings['lp_enabled_plugins']), '">
2627
<input type="hidden" name="language" value="', Utils::$context['user']['language'], '">
2728
<input type="checkbox" name="botcheck" class="hidden" style="display: none">

src/package-info.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
<require-dir name="Sources/LightPortal" destination="$sourcedir" />
1919
<require-dir name="Themes/default" destination="$themes_dir" />
2020
<require-file name="portal.php" destination="$boarddir" />
21-
<hook hook="integrate_pre_include" file="$sourcedir/LightPortal/app.php" />
21+
<hook hook="integrate_pre_include" function="$sourcedir/LightPortal/app.php" />
2222
<redirect url="?action=admin;area=lp_settings" timeout="3000" />
2323
</install>
2424

2525
<uninstall for="2.1.*, 3.0.*">
26-
<hook hook="integrate_pre_include" file="$sourcedir/LightPortal/app.php" reverse="true" />
26+
<hook hook="integrate_pre_include" function="$sourcedir/LightPortal/app.php" reverse="true" />
2727
<code>uninstall.php</code>
2828
<database>uninstall-optional.php</database>
2929
<remove-dir name="$themedir/LightPortal" />

0 commit comments

Comments
 (0)