Skip to content

Commit 8f7f4da

Browse files
authored
Merge pull request #33 from dragomano/develop
Update to 1.9.2
2 parents cca2030 + a54b28c commit 8f7f4da

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+2379
-479
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* **Author:** Bugo [dragomano.ru](https://dragomano.ru/mods/light-portal)
77
* **License:** [GNU GPLv3](https://github.com/dragomano/Light-Portal/blob/master/LICENSE)
88
* **Compatible with:** SMF 2.1 RC4+ / PHP 7.3+
9-
* **Tested on:** PHP 8.0.9 / MariaDB 10.5.10 / MySQL 5.7.25 / PostgreSQL 9.6.18
9+
* **Tested on:** PHP 7.4.23 / MariaDB 10.5.10 / PostgreSQL 9.6.22
1010
* **Hooks only:** Yes
1111
* **Languages:** English, Russian, Ukrainian, Polish, Spanish, French, Turkish
1212
* **Demo:** [Demo Forum](http://toster12.qlihost.ru/)

Sources/LightPortal/Block.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ private function getFilteredByAreas(): array
169169
if (isset($block['areas']['all']) || isset($block['areas'][$area]))
170170
return true;
171171

172-
if (!empty($context['lp_page']) && (isset($block['areas']['pages']) || isset($block['areas'][LP_PAGE_ACTION . '=' . $context['lp_page']['alias']])))
172+
if (!empty($context['lp_page']) && (isset($block['areas']['pages']) || isset($block['areas'][LP_PAGE_PARAM . '=' . $context['lp_page']['alias']])))
173173
return true;
174174

175175
if (empty($context['current_board']))

Sources/LightPortal/Credits.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,16 @@ public function prepareComponents()
140140
'name' => 'the MIT License',
141141
'link' => 'https://github.com/brianvoe/slim-select/blob/master/LICENSE'
142142
)
143-
)
143+
),
144+
array(
145+
'title' => 'jscolor Color Picker',
146+
'link' => 'https://jscolor.com',
147+
'author' => 'Jan Odvárko – East Desire',
148+
'license' => array(
149+
'name' => 'GNU GPL v3',
150+
'link' => 'http://www.gnu.org/licenses/gpl-3.0.txt'
151+
)
152+
),
144153
);
145154

146155
// Adding copyrights of used plugins

Sources/LightPortal/FrontPage.php

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,10 @@ class FrontPage
2727
*/
2828
public function show()
2929
{
30-
global $context, $modSettings, $scripturl, $txt;
30+
global $modSettings, $context, $scripturl, $txt, $settings;
3131

3232
isAllowedTo('light_portal_view');
3333

34-
$context['lp_need_lower_case'] = $this->isLowerCaseForDates();
35-
3634
switch ($modSettings['lp_frontpage_mode']) {
3735
case 'chosen_page':
3836
return call_user_func(array(new Page, 'show'));
@@ -79,6 +77,10 @@ public function show()
7977

8078
loadTemplate('LightPortal/ViewFrontPage');
8179

80+
// Also, theme makers can load their own layouts from the special template file
81+
if (is_file($settings['default_theme_dir'] . '/CustomFrontPage.template.php'))
82+
loadTemplate('CustomFrontPage');
83+
8284
obExit();
8385
}
8486

@@ -105,7 +107,7 @@ public function prepare(string $entity = '')
105107
return;
106108

107109
$start = Helpers::request('start');
108-
$limit = $modSettings['lp_num_items_per_page'] ?? 12;
110+
$limit = (int) $modSettings['lp_num_items_per_page'] ?? 12;
109111

110112
$entityClass->init();
111113

@@ -133,18 +135,6 @@ public function prepare(string $entity = '')
133135
Addons::run('frontAssets');
134136
}
135137

136-
/**
137-
* Check whether need to display dates in lowercase for the current language
138-
*
139-
* Проверяем, нужно ли для текущего языка отображать даты в нижнем регистре
140-
*/
141-
public function isLowerCaseForDates(): bool
142-
{
143-
global $txt;
144-
145-
return in_array($txt['lang_dictionary'], ['pl', 'es', 'ru', 'uk']);
146-
}
147-
148138
/**
149139
* Get the number columns for the frontpage layout
150140
*
@@ -194,6 +184,10 @@ public static function getLayouts(): array
194184

195185
require_once $settings['default_theme_dir'] . '/LightPortal/ViewFrontPage.template.php';
196186

187+
// Support of custom templates
188+
if (is_file($custom_templates = $settings['default_theme_dir'] . '/CustomFrontPage.template.php'))
189+
require_once $custom_templates;
190+
197191
$frontPageFunctions = array_values(array_diff(get_defined_functions()['user'], $allFunctions));
198192

199193
preg_match_all('/template_show_([a-z]+)(.*)/', implode("\n", $frontPageFunctions), $matches);

Sources/LightPortal/Helpers.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -600,10 +600,6 @@ public static function parseContent(string &$content, string $type = 'bbc')
600600
case 'bbc':
601601
$content = parse_bbc($content);
602602

603-
if (strpos($content, '<pre') !== false) {
604-
$content = strtr($content, array('<br>' => "\n"));
605-
}
606-
607603
// Integrate with the Paragrapher mod
608604
call_integration_hook('integrate_paragrapher_string', array(&$content));
609605

Sources/LightPortal/Integration.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ public function userInfo()
7878

7979
$lp_constants = [
8080
'LP_NAME' => 'Light Portal',
81-
'LP_VERSION' => '1.9.1',
82-
'LP_RELEASE_DATE' => '2021-09-01',
81+
'LP_VERSION' => '1.9.2',
82+
'LP_RELEASE_DATE' => '2021-09-09',
8383
'LP_ADDON_DIR' => $sourcedir . '/LightPortal/addons',
8484
'LP_CACHE_TIME' => $modSettings['lp_cache_update_interval'] ?? 3600,
8585
'LP_ACTION' => $modSettings['lp_portal_action'] ?? 'portal',
86-
'LP_PAGE_ACTION' => $modSettings['lp_page_action'] ?? 'page'
86+
'LP_PAGE_PARAM' => $modSettings['lp_page_param'] ?? 'page'
8787
];
8888

8989
foreach ($lp_constants as $key => $value)
@@ -172,7 +172,7 @@ public function defaultAction()
172172
{
173173
global $modSettings;
174174

175-
if (Helpers::request()->filled(LP_PAGE_ACTION))
175+
if (Helpers::request()->filled(LP_PAGE_PARAM))
176176
return call_user_func(array(new Page, 'show'));
177177

178178
if (empty($modSettings['lp_frontpage_mode']) || (!empty($modSettings['lp_standalone_mode']) && !empty($modSettings['lp_standalone_url']))) {
@@ -205,10 +205,10 @@ public function currentAction(string &$current_action)
205205
if (!empty($modSettings['lp_standalone_mode']) && !empty($modSettings['lp_standalone_url']) && $modSettings['lp_standalone_url'] != Helpers::server('REQUEST_URL'))
206206
$current_action = 'forum';
207207

208-
if (Helpers::request()->filled(LP_PAGE_ACTION)) {
208+
if (Helpers::request()->filled(LP_PAGE_PARAM)) {
209209
$current_action = LP_ACTION;
210210

211-
$page = Helpers::request(LP_PAGE_ACTION);
211+
$page = Helpers::request(LP_PAGE_PARAM);
212212
if (isset(Subs::getPagesInMenu()[$page]))
213213
$current_action = 'portal_' . $page;
214214
}
@@ -292,7 +292,7 @@ public function menuButtons(array &$buttons)
292292
foreach ($pages_in_menu as $alias => $item) {
293293
$pages[$compat_theme ? $item['icon'] : ('portal_' . $alias)] = array(
294294
'title' => Helpers::getTitle($item),
295-
'href' => $scripturl . '?' . LP_PAGE_ACTION . '=' . $alias,
295+
'href' => $scripturl . '?' . LP_PAGE_PARAM . '=' . $alias,
296296
'icon' => empty($item['icon']) ? null : ('" style="display: none"></span><span class="portal_menu_icons ' . $item['icon']),
297297
'show' => Helpers::canViewItem($item['permissions'])
298298
);
@@ -481,7 +481,7 @@ public function validLikes(string $type, int $content)
481481
return [
482482
'type' => $type,
483483
'flush_cache' => 'light_portal_likes_page_' . $content . '_' . $user_info['id'],
484-
'redirect' => LP_PAGE_ACTION . '=' . $alias,
484+
'redirect' => LP_PAGE_PARAM . '=' . $alias,
485485
'can_like' => $user_info['id'] == $author ? 'cannot_like_content' : (allowedTo('likes_like') ? true : 'cannot_like_content')
486486
];
487487
}
@@ -668,8 +668,8 @@ public function whoisOnline(array $actions): string
668668
if (!empty($actions['action']) && $actions['action'] == 'forum')
669669
$result = sprintf($txt['who_index'], $scripturl . '?action=forum', $context['forum_name']);
670670

671-
if (!empty($actions[LP_PAGE_ACTION]))
672-
$result = sprintf($txt['lp_who_viewing_page'], $scripturl . '?' . LP_PAGE_ACTION . '=' . $actions[LP_PAGE_ACTION]);
671+
if (!empty($actions[LP_PAGE_PARAM]))
672+
$result = sprintf($txt['lp_who_viewing_page'], $scripturl . '?' . LP_PAGE_PARAM . '=' . $actions[LP_PAGE_PARAM]);
673673

674674
if (!empty($actions['action']) && $actions['action'] == 'lp_settings')
675675
$result = sprintf($txt['lp_who_viewing_portal_settings'], $scripturl . '?action=admin;area=lp_settings');

Sources/LightPortal/ManageBlocks.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,11 @@ public static function toggleStatus(array $items = [])
223223
if (empty($items))
224224
return;
225225

226+
$new_status = $smcFunc['db_title'] === POSTGRE_TITLE ? 'CASE WHEN status = 1 THEN 0 ELSE 1 END' : '!status';
227+
226228
$smcFunc['db_query']('', '
227229
UPDATE {db_prefix}lp_blocks
228-
SET status = !status
230+
SET status = ' . $new_status . '
229231
WHERE block_id IN ({array_int:items})',
230232
array(
231233
'items' => $items
@@ -547,7 +549,7 @@ private function prepareFormFields()
547549

548550
checkSubmitOnce('register');
549551

550-
$this->improveSelectFields();
552+
$this->prepareIconList();
551553

552554
foreach ($context['languages'] as $lang) {
553555
$context['posting_fields']['title_' . $lang['filename']]['label']['text'] = $txt['lp_title'] . (count($context['languages']) > 1 ? ' [' . $lang['name'] . ']' : '');
@@ -694,7 +696,7 @@ private function getAreasInfo(): string
694696
'all',
695697
'custom_action',
696698
'pages',
697-
LP_PAGE_ACTION . '=alias',
699+
LP_PAGE_PARAM . '=alias',
698700
'boards',
699701
'board=id',
700702
'board=id1-id3',

Sources/LightPortal/ManagePages.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class ManagePages
4848
*/
4949
public function main()
5050
{
51-
global $context, $txt, $smcFunc, $scripturl;
51+
global $context, $txt, $smcFunc, $scripturl, $modSettings;
5252

5353
loadLanguage('Packages');
5454
loadTemplate('LightPortal/ManagePages');
@@ -172,8 +172,8 @@ public function main()
172172

173173
return '<i class="' . ($context['lp_' . $entry['type']]['icon'] ?? 'fab fa-bimobject') . '" title="' . $type_hint . '"></i> <a class="bbc_link' . (
174174
$entry['is_front']
175-
? ' new_posts" href="' . $scripturl
176-
: '" href="' . $scripturl . '?' . LP_PAGE_ACTION . '=' . $entry['alias']
175+
? ' highlight" href="' . $scripturl
176+
: '" href="' . $scripturl . '?' . LP_PAGE_PARAM . '=' . $entry['alias']
177177
) . '">' . $entry['title'] . '</a>';
178178
},
179179
'class' => 'word_break'
@@ -293,7 +293,9 @@ public function main()
293293
</a>
294294
</span>' . $listOptions['title'];
295295

296-
296+
if (!empty($modSettings['lp_show_comment_block']) && $modSettings['lp_show_comment_block'] != 'default') {
297+
unset($listOptions['columns']['num_comments']);
298+
}
297299

298300
Helpers::require('Subs-List');
299301
createList($listOptions);
@@ -491,9 +493,11 @@ public static function toggleStatus(array $items = [])
491493
if (empty($items))
492494
return;
493495

496+
$new_status = $smcFunc['db_title'] === POSTGRE_TITLE ? 'CASE WHEN status = 1 THEN 0 ELSE 1 END' : '!status';
497+
494498
$smcFunc['db_query']('', '
495499
UPDATE {db_prefix}lp_pages
496-
SET status = !status
500+
SET status = ' . $new_status . '
497501
WHERE page_id IN ({array_int:items})',
498502
array(
499503
'items' => $items
@@ -780,7 +784,7 @@ private function prepareFormFields()
780784

781785
checkSubmitOnce('register');
782786

783-
$this->improveSelectFields();
787+
$this->prepareIconList();
784788

785789
$languages = empty($modSettings['userLanguage']) ? [$language] : [$context['user']['language'], $language];
786790

Sources/LightPortal/ManagePlugins.php

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ public function main()
3333
loadLanguage('ManageMaintenance');
3434
loadTemplate('LightPortal/ManagePlugins');
3535

36+
loadJavaScriptFile('https://cdn.jsdelivr.net/npm/@eastdesire/jscolor@2/jscolor.min.js', array('external' => true));
37+
3638
$context['page_title'] = $txt['lp_portal'] . ' - ' . $txt['lp_plugins_manage'];
3739

3840
$context[$context['admin_menu_name']]['tab_data'] = array(
@@ -54,12 +56,11 @@ public function main()
5456
// You can add settings for your plugins
5557
Addons::run('addSettings', array(&$config_vars), $context['lp_plugins']);
5658

57-
$context['all_lp_plugins'] = array_map(function ($item) use ($txt, $context, $config_vars) {
58-
$custom_type = '';
59-
$author = '';
60-
$link = '';
59+
$context['all_lp_plugins'] = array_map(function ($item) use ($txt, &$context, $config_vars) {
6160
$requires = [];
6261

62+
$snake_name = Helpers::getSnakeName($item);
63+
6364
try {
6465
$className = __NAMESPACE__ . '\Addons\\' . $item . '\\' . $item;
6566
$addonClass = new \ReflectionClass($className);
@@ -73,22 +74,27 @@ public function main()
7374
if ($addonClass->hasProperty('requires'))
7475
$requires = $addonClass->getProperty('requires')->getValue(new $className);
7576
} catch (\ReflectionException $e) {
76-
if (isset($context['lp_can_donate'][$item]))
77-
$custom_type = $txt['lp_can_donate'];
77+
if (isset($context['lp_can_donate'][$item])) {
78+
$context['lp_' . $snake_name]['type'] = $context['lp_can_donate'][$item]['type'] ?? 'other';
79+
$special = $txt['lp_can_donate'];
80+
}
7881

79-
if (isset($context['lp_can_download'][$item]))
80-
$custom_type = $txt['lp_can_download'];
82+
if (isset($context['lp_can_download'][$item])) {
83+
$context['lp_' . $snake_name]['type'] = $context['lp_can_download'][$item]['type'] ?? 'other';
84+
$special = $txt['lp_can_download'];
85+
}
8186
}
8287

8388
return [
8489
'name' => $item,
85-
'snake_name' => $snake_name = Helpers::getSnakeName($item),
90+
'snake_name' => $snake_name,
8691
'label_class' => $this->getLabelClass($snake_name),
8792
'desc' => $txt['lp_' . $snake_name]['description'] ?? '',
88-
'author' => $author ?: '',
89-
'link' => $link ?: '',
93+
'author' => $author ?? '',
94+
'link' => $link ?? '',
9095
'status' => in_array($item, $context['lp_enabled_plugins']) ? 'on' : 'off',
91-
'types' => $custom_type ?: $this->getTypes($snake_name),
96+
'type' => $this->getType($snake_name),
97+
'special' => $special ?? '',
9298
'settings' => $config_vars[$snake_name] ?? [],
9399
'requires' => array_diff($requires, $context['lp_enabled_plugins'])
94100
];
@@ -103,7 +109,7 @@ public function main()
103109
$context['all_lp_plugins'] = array_filter($context['all_lp_plugins'], function ($item) use ($context) {
104110
$filter = Helpers::post('filter');
105111

106-
if (!in_array($filter, array_keys($context['lp_plugin_types'])) || strpos($item['types'], $context['lp_plugin_types'][$filter]) !== false) {
112+
if (!in_array($filter, array_keys($context['lp_plugin_types'])) || strpos($item['type'], $context['lp_plugin_types'][$filter]) !== false) {
107113
return true;
108114
}
109115
});
@@ -246,7 +252,7 @@ private function getLabelClass(string $snake_name): string
246252
* @param string $snake_name
247253
* @return string
248254
*/
249-
private function getTypes(string $snake_name): string
255+
private function getType(string $snake_name): string
250256
{
251257
global $txt, $context;
252258

@@ -282,12 +288,13 @@ private function prepareAddonChart()
282288

283289
$typeCount = [];
284290
foreach ($context['all_lp_plugins'] as $plugin) {
285-
$key = array_search($plugin['types'], $txt['lp_plugins_types']);
286-
287-
$types = explode(' + ', $plugin['types']);
291+
$types = explode(' + ', $plugin['type']);
288292
foreach ($types as $type) {
289293
$key = array_search($type, $txt['lp_plugins_types']);
290294

295+
if ($key === false)
296+
$key = 7;
297+
291298
if (!isset($typeCount[$key]))
292299
$typeCount[$key] = 0;
293300

@@ -319,7 +326,7 @@ private function prepareAddonChart()
319326
responsive: true,
320327
plugins: {
321328
legend: {
322-
position: "top",
329+
position: "top"
323330
}
324331
}
325332
}

0 commit comments

Comments
 (0)