Skip to content

Commit

Permalink
Merge pull request #241 from dragomano/2.7.2
Browse files Browse the repository at this point in the history
Update to 2.7.2
  • Loading branch information
dragomano authored Sep 28, 2024
2 parents 20299cc + 34c87c2 commit 6eee08e
Show file tree
Hide file tree
Showing 19 changed files with 1,408 additions and 881 deletions.
9 changes: 5 additions & 4 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
"vitepress-plugin-comment-with-giscus": "^1.1.15"
},
"devDependencies": {
"@nolebase/vitepress-plugin-enhanced-readabilities": "2.2.0",
"@nolebase/vitepress-plugin-enhanced-readabilities": "^2.5.0",
"@rive-app/canvas": "^2.21.3",
"release-timeline": "^0.6.0",
"sass": "^1.77.6",
"vitepress": "^1.2.3",
"vitepress-sidebar": "^1.23.2"
"sass": "^1.79.4",
"vitepress": "^1.3.4",
"vitepress-sidebar": "^1.27.1"
},
"scripts": {
"docs:dev": "vitepress dev",
Expand Down
1,297 changes: 873 additions & 424 deletions docs/pnpm-lock.yaml

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,26 @@
},
"dependencies": {
"@github/markdown-toolbar-element": "^2.2.3",
"@vitejs/plugin-vue": "^5.0.5",
"@vueform/multiselect": "^2.6.8",
"@vitejs/plugin-vue": "^5.1.4",
"@vueform/multiselect": "^2.6.10",
"@vueform/toggle": "^2.1.4",
"@vueuse/core": "^10.11.0",
"@vueuse/shared": "^10.11.0",
"@vueuse/core": "^11.1.0",
"@vueuse/shared": "^11.1.0",
"alpinejs": "^3.14.1",
"alpinejs-slug": "^1.1.3",
"axios": "^1.7.2",
"pinia": "^2.1.7",
"sass": "^1.77.6",
"sortablejs": "^1.15.2",
"axios": "^1.7.7",
"pinia": "^2.2.2",
"sass": "^1.79.4",
"sortablejs": "^1.15.3",
"vanilla-lazyload": "^19.1.3",
"virtual-select-plugin": "^1.0.44",
"vite-plugin-minify": "^1.5.2",
"vue": "^3.4.31",
"vue-i18n": "^9.13.1",
"virtual-select-plugin": "^1.0.46",
"vite-plugin-minify": "^2.0.0",
"vue": "^3.5.10",
"vue-i18n": "^10.0.3",
"vue-showdown": "^4.2.0"
},
"devDependencies": {
"vite": "^5.3.2",
"vite-plugin-static-copy": "^1.0.5"
"vite": "^5.4.8",
"vite-plugin-static-copy": "^1.0.6"
}
}
665 changes: 341 additions & 324 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

23 changes: 13 additions & 10 deletions src/Sources/LightPortal/Addons/BlogMode/BlogMode.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,17 @@
* @license https://spdx.org/licenses/GPL-3.0-or-later.html GPL-3.0-or-later
*
* @category addon
* @version 23.06.24
* @version 08.07.24
*/

namespace Bugo\LightPortal\Addons\BlogMode;

use Bugo\Compat\Config;
use Bugo\Compat\Lang;
use Bugo\Compat\User;
use Bugo\Compat\Utils;
use Bugo\Compat\{Config, Lang, User, Utils};
use Bugo\LightPortal\Addons\Plugin;
use Bugo\LightPortal\Areas\Fields\VirtualSelectField;
use Bugo\LightPortal\Enums\Hook;
use Bugo\LightPortal\Enums\Status;
use Bugo\LightPortal\Enums\Tab;
use Bugo\LightPortal\Enums\{Hook, Status, Tab};
use Bugo\LightPortal\Repositories\PageRepository;
use Bugo\LightPortal\Utils\Icon;
use Bugo\LightPortal\Utils\ItemList;
use Bugo\LightPortal\Utils\{Icon, ItemList};
use Nette\Utils\Html;

use function array_column;
Expand Down Expand Up @@ -61,6 +55,7 @@ public function init(): void

$this->applyHook(Hook::actions);
$this->applyHook(Hook::menuButtons);
$this->applyHook(Hook::currentAction);
$this->applyHook(Hook::loadIllegalGuestPermissions);
$this->applyHook(Hook::loadPermissions);

Expand Down Expand Up @@ -172,6 +167,14 @@ public function loadIllegalGuestPermissions(): void
);
}

public function currentAction(string &$action): void
{
if (empty(Utils::$context['lp_page']) || Utils::$context['lp_page']['status'] !== BlogArticle::STATUS)
return;

$action = $this->blogAction;
}

public function loadPermissions(array &$permissionGroups, array &$permissionList): void
{
Lang::$txt['permissionname_light_portal_post_blog_entries'] = Lang::$txt['lp_blog_mode']['permission'];
Expand Down
4 changes: 2 additions & 2 deletions src/Sources/LightPortal/Addons/GalleryBlock/GalleryBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @license https://spdx.org/licenses/GPL-3.0-or-later.html GPL-3.0-or-later
*
* @category addon
* @version 29.06.24
* @version 11.07.24
*/

namespace Bugo\LightPortal\Addons\GalleryBlock;
Expand Down Expand Up @@ -128,7 +128,7 @@ public function prepareContent(object $data, array $parameters): void
if ($data->type !== 'gallery_block')
return;

if (! User::hasPermission('smfgallery_manage')) {
if (! User::hasPermission('smfgallery_view')) {
echo Lang::$txt['cannot_smfgallery_view'];
return;
}
Expand Down
76 changes: 69 additions & 7 deletions src/Sources/LightPortal/Addons/SimpleChat/Chat.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@
* @license https://opensource.org/licenses/MIT MIT
*
* @category addon
* @version 15.06.24
* @version 17.09.24
*/

namespace Bugo\LightPortal\Addons\SimpleChat;

use Bugo\Compat\{BBCodeParser, Config};
use Bugo\Compat\{Db, Time, User, Utils};
use Bugo\LightPortal\Utils\Avatar;
use Bugo\LightPortal\Utils\CacheTrait;
use Bugo\LightPortal\Utils\RequestTrait;
use Bugo\Compat\{User, Utils};
use Bugo\LightPortal\Utils\Avatar;

use function json_encode;
use function time;

if (! defined('LP_NAME'))
die('No direct access...');
Expand All @@ -26,6 +30,64 @@ class Chat
use CacheTrait;
use RequestTrait;

public function prepareTable(): void
{
$tables = [];

Db::extend('packages');

if (! empty(Utils::$smcFunc['db_list_tables'](false, Config::$db_prefix . 'lp_simple_chat_messages')))
return;

$tables[] = [
'name' => 'lp_simple_chat_messages',
'columns' => [
[
'name' => 'id',
'type' => 'int',
'size' => 10,
'unsigned' => true,
'auto' => true
],
[
'name' => 'block_id',
'type' => 'int',
'size' => 10,
'unsigned' => true
],
[
'name' => 'user_id',
'type' => 'int',
'size' => 10,
'unsigned' => true
],
[
'name' => 'message',
'type' => 'varchar',
'size' => 255,
'null' => false
],
[
'name' => 'created_at',
'type' => 'int',
'size' => 10,
'unsigned' => true,
'default' => 0
]
],
'indexes' => [
[
'type' => 'primary',
'columns' => ['id']
]
]
];

foreach ($tables as $table) {
Utils::$smcFunc['db_create_table']('{db_prefix}' . $table['name'], $table['columns'], $table['indexes']);
}
}

public function getMessages(int $block_id = 0): array
{
$result = Utils::$smcFunc['db_query']('', /** @lang text */ '
Expand All @@ -45,8 +107,8 @@ public function getMessages(int $block_id = 0): array
$messages[$row['block_id']][] = [
'id' => $row['id'],
'block_id' => $row['block_id'],
'message' => parse_bbc($row['message']),
'created_at' => timeformat($row['created_at']),
'message' => BBCodeParser::load()->parse($row['message']),
'created_at' => Time::timeformat($row['created_at']),
'author' => [
'id' => $row['user_id'],
'name' => $row['real_name'],
Expand Down Expand Up @@ -88,8 +150,8 @@ public function addMessage(): void

$result = [
'id' => $id,
'message' => parse_bbc($message),
'created_at' => timeformat($time),
'message' => BBCodeParser::load()->parse($message),
'created_at' => Time::timeformat($time),
'author' => [
'id' => User::$info['id'],
'name' => User::$info['name'],
Expand Down
93 changes: 28 additions & 65 deletions src/Sources/LightPortal/Addons/SimpleChat/SimpleChat.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,25 @@
* @license https://opensource.org/licenses/MIT MIT
*
* @category addon
* @version 05.06.24
* @version 24.09.24
*/

namespace Bugo\LightPortal\Addons\SimpleChat;

use Bugo\Compat\{Config, Db, Lang, Theme, Utils};
use Bugo\Compat\{Lang, Theme, Utils};
use Bugo\LightPortal\Addons\Block;
use Bugo\LightPortal\Areas\Fields\CheckboxField;
use Bugo\LightPortal\Areas\Fields\RadioField;
use Bugo\LightPortal\Enums\{Hook, Tab};
use Bugo\LightPortal\Utils\Avatar;

use function array_combine;
use function json_encode;
use function show_chat_block;

use const FILTER_DEFAULT;
use const FILTER_VALIDATE_BOOLEAN;

if (! defined('LP_NAME'))
die('No direct access...');

Expand All @@ -29,6 +37,11 @@ class SimpleChat extends Block
{
public string $icon = 'fas fa-message';

private array $params = [
'show_avatars' => false,
'form_position' => 'bottom',
];

private readonly Chat $chat;

public function __construct()
Expand Down Expand Up @@ -57,23 +70,26 @@ public function actions(): void

public function addSettings(): void
{
$this->prepareTable();
$this->chat->prepareTable();
}

public function prepareBlockParams(array &$params): void
{
if (Utils::$context['current_block']['type'] !== 'simple_chat')
return;

$params['show_avatars'] = false;
$params = $this->params;
}

public function validateBlockParams(array &$params): void
{
if (Utils::$context['current_block']['type'] !== 'simple_chat')
return;

$params['show_avatars'] = FILTER_VALIDATE_BOOLEAN;
$params = [
'show_avatars' => FILTER_VALIDATE_BOOLEAN,
'form_position' => FILTER_DEFAULT,
];
}

public function prepareBlockFields(): void
Expand All @@ -84,6 +100,10 @@ public function prepareBlockFields(): void
CheckboxField::make('show_avatars', Lang::$txt['lp_simple_chat']['show_avatars'])
->setTab(Tab::APPEARANCE)
->setValue(Utils::$context['lp_block']['options']['show_avatars']);

RadioField::make('form_position', Lang::$txt['lp_simple_chat']['form_position'])
->setOptions(array_combine(['bottom', 'top'], Lang::$txt['lp_simple_chat']['form_position_set']))
->setValue(Utils::$context['lp_block']['options']['form_position']);
}

public function getData(int $block_id, array $parameters): array
Expand All @@ -105,7 +125,8 @@ public function prepareContent(object $data, array $parameters): void
Theme::loadCSSFile('admin.css');
Theme::loadJavaScriptFile('light_portal/bundle.min.js', ['defer' => true]);

$parameters['show_avatars'] ??= false;
$parameters['show_avatars'] ??= $this->params['show_avatars'];
$parameters['form_position'] ??= $this->params['form_position'];

$messages = $this->cache('simple_chat_addon_b' . $data->id)
->setLifeTime($data->cacheTime)
Expand All @@ -115,7 +136,7 @@ public function prepareContent(object $data, array $parameters): void

$this->setTemplate();

show_chat_block($data->id, (bool) $parameters['show_avatars'], $this->isInSidebar($data->id));
show_chat_block($data->id, $parameters, $this->isInSidebar($data->id));
}

public function onBlockRemoving(array $items): void
Expand All @@ -128,62 +149,4 @@ public function onBlockRemoving(array $items): void
]
);
}

private function prepareTable(): void
{
$tables = [];

Db::extend('packages');

if (! empty(Utils::$smcFunc['db_list_tables'](false, Config::$db_prefix . 'lp_simple_chat_messages')))
return;

$tables[] = [
'name' => 'lp_simple_chat_messages',
'columns' => [
[
'name' => 'id',
'type' => 'int',
'size' => 10,
'unsigned' => true,
'auto' => true
],
[
'name' => 'block_id',
'type' => 'int',
'size' => 10,
'unsigned' => true
],
[
'name' => 'user_id',
'type' => 'int',
'size' => 10,
'unsigned' => true
],
[
'name' => 'message',
'type' => 'varchar',
'size' => 255,
'null' => false
],
[
'name' => 'created_at',
'type' => 'int',
'size' => 10,
'unsigned' => true,
'default' => 0
]
],
'indexes' => [
[
'type' => 'primary',
'columns' => ['id']
]
]
];

foreach ($tables as $table) {
Utils::$smcFunc['db_create_table']('{db_prefix}' . $table['name'], $table['columns'], $table['indexes']);
}
}
}
Loading

0 comments on commit 6eee08e

Please sign in to comment.