diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ef0de4d47..c20673818 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -25,7 +25,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Node uses: actions/setup-node@v4 @@ -33,7 +33,7 @@ jobs: node-version: 20 - name: Install pnpm - uses: pnpm/action-setup@v2 + uses: pnpm/action-setup@v3 with: version: 8 run_install: false @@ -44,7 +44,7 @@ jobs: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - name: Setup pnpm cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ${{ env.STORE_PATH }} key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} @@ -57,7 +57,7 @@ jobs: pnpm install - name: Setup Pages - uses: actions/configure-pages@v3 + uses: actions/configure-pages@v4 - name: Build with VitePress run: | @@ -66,7 +66,7 @@ jobs: touch .vitepress/dist/.nojekyll - name: Upload artifact - uses: actions/upload-pages-artifact@v2 + uses: actions/upload-pages-artifact@v3 with: path: docs/.vitepress/dist @@ -81,4 +81,4 @@ jobs: steps: - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v2 + uses: actions/deploy-pages@v4 diff --git a/README.md b/README.md index 44e413f08..e637c89c3 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ [![](https://img.shields.io/badge/Demo-Forum-brightgreen.svg)](https://demo.dragomano.ru) [![](https://img.shields.io/badge/Docs-Site-orange.svg)](https://dragomano.github.io/Light-Portal/) -- **Tested on:** PHP 8.3.1 / MariaDB 10.11.6 +- **Tested on:** PHP 8.0.30, 8.1.27, 8.2.16, 8.3.3 / MariaDB 10.11.6 - **Languages:** Russian, English, Polish, Spanish, French, Turkish, Ukrainian, German, Italian, Portuguese, Greek, Czech, Danish, Dutch, Norwegian, Swedish, Arabic ## Description ([обзор на русском](https://dragomano.ru/mods/light-portal)) diff --git a/configs/vite.comments.js b/configs/vite.comments.js index 8dc27936a..86514bd64 100644 --- a/configs/vite.comments.js +++ b/configs/vite.comments.js @@ -10,17 +10,10 @@ export default defineConfig({ outDir: dist, emptyOutDir: false, rollupOptions: { - external: ['vue', 'vue-i18n', 'pinia', 'vue-showdown'], input: 'src/Themes/default/scripts/light_portal/app_comments.js', output: { entryFileNames: 'bundle_comments.js', format: 'esm', - globals: { - vue: 'Vue', - 'vue-i18n': 'VueI18n', - pinia: 'Pinia', - 'vue-showdown': 'VueShowdown', - }, }, }, }, diff --git a/src/Sources/LightPortal/Actions/Category.php b/src/Sources/LightPortal/Actions/Category.php index 903c01ff7..265aaa861 100644 --- a/src/Sources/LightPortal/Actions/Category.php +++ b/src/Sources/LightPortal/Actions/Category.php @@ -26,8 +26,9 @@ final class Category extends AbstractPageList { public function show(PageInterface $page): void { - if ($this->request()->hasNot('id')) + if ($this->request()->hasNot('id')) { $this->showAll(); + } $category = [ 'id' => (int) $this->request('id', 0) @@ -70,9 +71,6 @@ public function show(PageInterface $page): void $listOptions['get_items'] = [ 'function' => [$this, 'getPages'] ]; - $listOptions['get_count'] = [ - 'function' => [$this, 'getTotalCount'] - ]; if (isset($category['description'])) { $listOptions['additional_rows'] = [ @@ -183,30 +181,30 @@ public function showAll(): void 'function' => fn() => count($this->getAll()) ], 'columns' => [ - 'title' => [ + 'priority' => [ 'header' => [ - 'value' => Lang::$txt['lp_category'] + 'value' => Lang::$txt['lp_block_priority'] ], 'data' => [ - 'function' => static fn($entry) => $entry['icon'] . ' ' . '' . $entry['title'] . '' . - (empty($entry['description']) ? '' : '
' . $entry['description'] . '
') + 'db' => 'priority', + 'class' => 'centertext' ], 'sort' => [ - 'default' => 't.title DESC', - 'reverse' => 't.title' + 'default' => 'c.priority', + 'reverse' => 'c.priority DESC' ] ], - 'priority' => [ + 'title' => [ 'header' => [ - 'value' => Lang::$txt['lp_block_priority'] + 'value' => Lang::$txt['lp_category'] ], 'data' => [ - 'db' => 'priority', - 'class' => 'centertext' + 'function' => static fn($entry) => $entry['icon'] . ' ' . '' . $entry['title'] . '' . + (empty($entry['description']) ? '' : '' . $entry['description'] . '
') ], 'sort' => [ - 'default' => 'c.priority', - 'reverse' => 'c.priority DESC' + 'default' => 'title DESC', + 'reverse' => 'title' ] ], 'num_pages' => [ @@ -233,12 +231,12 @@ public function showAll(): void Utils::obExit(); } - public function getAll(int $start = 0, int $limit = 0, string $sort = 't.title'): array + public function getAll(int $start = 0, int $limit = 0, string $sort = 'title'): array { $result = Db::$db->query('', ' SELECT COALESCE(c.category_id, 0) AS category_id, c.icon, c.description, c.priority, - COUNT(p.page_id) AS frequency, COALESCE(t.title, tf.title) AS cat_title + COUNT(p.page_id) AS frequency, COALESCE(t.title, tf.title) AS title FROM {db_prefix}lp_pages AS p LEFT JOIN {db_prefix}lp_categories AS c ON (p.category_id = c.category_id) LEFT JOIN {db_prefix}lp_titles AS t ON ( @@ -271,7 +269,7 @@ public function getAll(int $start = 0, int $limit = 0, string $sort = 't.title') while ($row = Db::$db->fetch_assoc($result)) { $items[$row['category_id']] = [ 'icon' => $this->getIcon($row['icon']), - 'title' => $row['cat_title'] ?: Lang::$txt['lp_no_category'], + 'title' => $row['title'] ?: Lang::$txt['lp_no_category'], 'description' => $row['description'] ?? '', 'link' => LP_BASE_URL . ';sa=categories;id=' . $row['category_id'], 'priority' => (int) $row['priority'], diff --git a/src/Sources/LightPortal/Actions/Comment.php b/src/Sources/LightPortal/Actions/Comment.php index 16550c096..dcbee2c19 100644 --- a/src/Sources/LightPortal/Actions/Comment.php +++ b/src/Sources/LightPortal/Actions/Comment.php @@ -113,7 +113,7 @@ private function add(): void exit(json_encode($result)); $parentId = $this->filterVar($data['parent_id'], 'int'); - $message = Utils::$smcFunc['htmlspecialchars']($data['message']); + $message = Utils::htmlspecialchars($data['message']); $author = $this->filterVar($data['author'], 'int'); $pageId = Utils::$context['lp_page']['id']; $pageUrl = Utils::$context['canonical_url']; @@ -179,7 +179,7 @@ private function update(): void exit(json_encode($result)); $item = $data['comment_id']; - $message = Utils::$smcFunc['htmlspecialchars']($data['message']); + $message = Utils::htmlspecialchars($data['message']); if (empty($item) || empty($message) || empty(trim($message))) exit(json_encode($result)); diff --git a/src/Sources/LightPortal/Actions/FrontPage.php b/src/Sources/LightPortal/Actions/FrontPage.php index 7143b96b6..4b715fbc7 100644 --- a/src/Sources/LightPortal/Actions/FrontPage.php +++ b/src/Sources/LightPortal/Actions/FrontPage.php @@ -81,7 +81,7 @@ public function prepare(ArticleInterface $article): void $article->init(); - $key = 'articles_u' . Utils::$context['user']['id'] . '_' . $start . '_' . $limit; + $key = 'articles_u' . User::$info['id'] . '_' . User::$info['language'] . '_' . $start . '_' . $limit; if (($data = $this->cache()->get($key)) === null) { $data['total'] = $article->getTotalCount(); diff --git a/src/Sources/LightPortal/Actions/Tag.php b/src/Sources/LightPortal/Actions/Tag.php index 9b95c243d..9c277d29e 100644 --- a/src/Sources/LightPortal/Actions/Tag.php +++ b/src/Sources/LightPortal/Actions/Tag.php @@ -26,8 +26,9 @@ final class Tag extends AbstractPageList { public function show(PageInterface $page): void { - if ($this->request()->hasNot('id')) + if ($this->request()->hasNot('id')) { $this->showAll(); + } $tag = [ 'id' => (int) $this->request('id', 0) @@ -64,9 +65,6 @@ public function show(PageInterface $page): void $listOptions['get_items'] = [ 'function' => [$this, 'getPages'] ]; - $listOptions['get_count'] = [ - 'function' => [$this, 'getTotalCount'] - ]; new ItemList($listOptions); @@ -191,8 +189,8 @@ public function showAll(): void 'class' => 'centertext' ], 'sort' => [ - 'default' => 'tag_title DESC', - 'reverse' => 'tag_title' + 'default' => 'title DESC', + 'reverse' => 'title' ] ], 'frequency' => [ @@ -219,10 +217,10 @@ public function showAll(): void Utils::obExit(); } - public function getAll(int $start = 0, int $limit = 0, string $sort = 'tag_title'): array + public function getAll(int $start = 0, int $limit = 0, string $sort = 'title'): array { $result = Db::$db->query('', ' - SELECT tag.tag_id, tag.icon, COALESCE(tt.title, tf.title) AS tag_title, COUNT(tag.tag_id) AS frequency + SELECT tag.tag_id, tag.icon, COALESCE(tt.title, tf.title) AS title, COUNT(tag.tag_id) AS frequency FROM {db_prefix}lp_pages AS p INNER JOIN {db_prefix}lp_page_tags AS pt ON (p.page_id = pt.page_id) INNER JOIN {db_prefix}lp_tags AS tag ON (pt.tag_id = tag.tag_id) @@ -256,7 +254,7 @@ public function getAll(int $start = 0, int $limit = 0, string $sort = 'tag_title while ($row = Db::$db->fetch_assoc($result)) { $items[$row['tag_id']] = [ 'icon' => $this->getIcon($row['icon']), - 'title' => $row['tag_title'], + 'title' => $row['title'], 'link' => LP_BASE_URL . ';sa=tags;id=' . $row['tag_id'], 'frequency' => (int) $row['frequency'], ]; diff --git a/src/Sources/LightPortal/Addons/ArticleList/ArticleList.php b/src/Sources/LightPortal/Addons/ArticleList/ArticleList.php index d1c08551d..b0a046f86 100644 --- a/src/Sources/LightPortal/Addons/ArticleList/ArticleList.php +++ b/src/Sources/LightPortal/Addons/ArticleList/ArticleList.php @@ -10,7 +10,7 @@ * @license https://spdx.org/licenses/GPL-3.0-or-later.html GPL-3.0-or-later * * @category addon - * @version 20.02.24 + * @version 01.03.24 */ namespace Bugo\LightPortal\Addons\ArticleList; @@ -194,7 +194,7 @@ public function prepareContent(object $data, array $parameters): void if ($data->type !== 'article_list') return; - $article_list = $this->cache('article_list_addon_b' . $data->id . '_u' . User::$info['id']) + $articles = $this->cache('article_list_addon_b' . $data->id . '_u' . User::$info['id']) ->setLifeTime($data->cacheTime) ->setFallback( self::class, @@ -202,12 +202,12 @@ public function prepareContent(object $data, array $parameters): void $parameters ); - if ($article_list) { + if ($articles) { echo 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc porttitor posuere accumsan. Aliquam erat volutpat. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Phasellus vel blandit dui. Aliquam nunc est, vehicula sit amet eleifend in, scelerisque quis sem. In aliquam nec lorem nec volutpat. Sed eu blandit erat. Suspendisse elementum lectus a ligula commodo, at lobortis justo accumsan. Aliquam mollis lectus ultricies, semper urna eu, fermentum eros. Sed a interdum odio. Quisque sit amet feugiat enim. Curabitur aliquam lectus at metus tristique tempus. Sed vitae nisi ultricies, tincidunt lacus non, ultrices ante.
Duis ac ex sed dolor suscipit vulputate at eu ligula. Aliquam efficitur ac ante convallis ultricies. Nullam pretium vitae purus dapibus tempor. Aenean vel fringilla eros. Proin lectus velit, tristique ut condimentum eu, semper sed ipsum. Duis venenatis dolor lectus, et ullamcorper tortor varius eu. Vestibulum quis nisi ut nunc mollis fringilla. Sed consectetur semper magna, eget blandit nulla commodo sed. Aenean sem ipsum, auctor eget enim id, scelerisque malesuada nibh. Nulla ornare pharetra laoreet. Phasellus dignissim nisl nec arcu cursus luctus.
Aliquam in quam ut diam consectetur semper. Aliquam commodo mi purus, bibendum laoreet massa tristique eget. Suspendisse ut purus nisi. Mauris euismod dolor nec scelerisque ullamcorper. Praesent imperdiet semper neque, ac luctus nunc ultricies eget. Praesent sodales ante sed dignissim vulputate. Ut vel ligula id sem feugiat sollicitudin non at metus. Aliquam vel est non sapien sodales semper. Suspendisse potenti. Sed convallis quis turpis eu pulvinar. Vivamus nulla elit, condimentum vitae commodo eu, pellentesque ullamcorper enim. Maecenas faucibus dolor nec enim interdum, quis iaculis lacus suscipit. Pellentesque aliquam, lectus id volutpat euismod, ante tellus mollis dui, sed placerat erat arcu sit amet purus.
', 'html', 3, time() +Duis ac ex sed dolor suscipit vulputate at eu ligula. Aliquam efficitur ac ante convallis ultricies. Nullam pretium vitae purus dapibus tempor. Aenean vel fringilla eros. Proin lectus velit, tristique ut condimentum eu, semper sed ipsum. Duis venenatis dolor lectus, et ullamcorper tortor varius eu. Vestibulum quis nisi ut nunc mollis fringilla. Sed consectetur semper magna, eget blandit nulla commodo sed. Aenean sem ipsum, auctor eget enim id, scelerisque malesuada nibh. Nulla ornare pharetra laoreet. Phasellus dignissim nisl nec arcu cursus luctus.
Aliquam in quam ut diam consectetur semper. Aliquam commodo mi purus, bibendum laoreet massa tristique eget. Suspendisse ut purus nisi. Mauris euismod dolor nec scelerisque ullamcorper. Praesent imperdiet semper neque, ac luctus nunc ultricies eget. Praesent sodales ante sed dignissim vulputate. Ut vel ligula id sem feugiat sollicitudin non at metus. Aliquam vel est non sapien sodales semper. Suspendisse potenti. Sed convallis quis turpis eu pulvinar. Vivamus nulla elit, condimentum vitae commodo eu, pellentesque ullamcorper enim. Maecenas faucibus dolor nec enim interdum, quis iaculis lacus suscipit. Pellentesque aliquam, lectus id volutpat euismod, ante tellus mollis dui, sed placerat erat arcu sit amet purus.
', 'html', 3, time() ] ], 'keys' => ['page_id'] @@ -467,7 +467,7 @@ [ 'name' => 'icon', 'type' => 'varchar', - 'size' => 60, + 'size' => 255, 'null' => true ], [ @@ -505,7 +505,7 @@ [ 'name' => 'lang', 'type' => 'varchar', - 'size' => 60, + 'size' => 20, 'null' => false ], [ @@ -525,11 +525,14 @@ 'columns' => [ 'item_id' => 'int', 'type' => 'string-10', - 'lang' => 'string-60', + 'lang' => 'string-20', 'title' => 'string-255' ], - 'values' => [ - [1, 'page', $language, $mbname] + 'values' => empty($modSettings['userLanguage']) ? [ + [1, 'page', $language, $mbname], + ] : [ + [1, 'page', $language, $mbname], + [1, 'page', $user_info['language'], $mbname], ], 'keys' => ['item_id', 'type', 'lang'] ] diff --git a/src/package-info.xml b/src/package-info.xml index 10e0b27d6..bb4865d50 100644 --- a/src/package-info.xml +++ b/src/package-info.xml @@ -3,7 +3,7 @@