Skip to content

Commit

Permalink
Merge pull request #196 from dragomano/develop
Browse files Browse the repository at this point in the history
Update to 2.6.1
  • Loading branch information
dragomano committed Mar 10, 2024
2 parents f7bbe28 + 905571e commit 5a0731d
Show file tree
Hide file tree
Showing 51 changed files with 561 additions and 2,480 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install pnpm
uses: pnpm/action-setup@v2
uses: pnpm/action-setup@v3
with:
version: 8
run_install: false
Expand All @@ -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') }}
Expand All @@ -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: |
Expand All @@ -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

Expand All @@ -81,4 +81,4 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
uses: actions/deploy-pages@v4
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
7 changes: 0 additions & 7 deletions configs/vite.comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
},
},
},
Expand Down
36 changes: 17 additions & 19 deletions src/Sources/LightPortal/Actions/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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'] = [
Expand Down Expand Up @@ -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'] . ' ' . '<a href="' . $entry['link'] . '">' . $entry['title'] . '</a>' .
(empty($entry['description']) ? '' : '<p class="smalltext">' . $entry['description'] . '</p>')
'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'] . ' ' . '<a href="' . $entry['link'] . '">' . $entry['title'] . '</a>' .
(empty($entry['description']) ? '' : '<p class="smalltext">' . $entry['description'] . '</p>')
],
'sort' => [
'default' => 'c.priority',
'reverse' => 'c.priority DESC'
'default' => 'title DESC',
'reverse' => 'title'
]
],
'num_pages' => [
Expand All @@ -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 (
Expand Down Expand Up @@ -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'],
Expand Down
4 changes: 2 additions & 2 deletions src/Sources/LightPortal/Actions/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion src/Sources/LightPortal/Actions/FrontPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
16 changes: 7 additions & 9 deletions src/Sources/LightPortal/Actions/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -191,8 +189,8 @@ public function showAll(): void
'class' => 'centertext'
],
'sort' => [
'default' => 'tag_title DESC',
'reverse' => 'tag_title'
'default' => 'title DESC',
'reverse' => 'title'
]
],
'frequency' => [
Expand All @@ -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)
Expand Down Expand Up @@ -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'],
];
Expand Down
10 changes: 5 additions & 5 deletions src/Sources/LightPortal/Addons/ArticleList/ArticleList.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -194,20 +194,20 @@ 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,
empty($parameters['display_type']) ? 'getTopics' : 'getPages',
$parameters
);

if ($article_list) {
if ($articles) {
echo '
<div class="article_list">';

if (empty($parameters['display_type'])) {
foreach ($article_list as $topic) {
foreach ($articles as $topic) {
$content = '';
if ($topic['image']) {
$content .= '
Expand All @@ -221,7 +221,7 @@ public function prepareContent(object $data, array $parameters): void
echo sprintf(Utils::$context['lp_all_content_classes'][$parameters['body_class']], $content);
}
} else {
foreach ($article_list as $page) {
foreach ($articles as $page) {
if (empty($title = $this->getTranslatedTitle($page['title'])))
continue;

Expand Down
10 changes: 4 additions & 6 deletions src/Sources/LightPortal/Addons/CurrentMonth/CurrentMonth.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
* @license https://spdx.org/licenses/GPL-3.0-or-later.html GPL-3.0-or-later
*
* @category addon
* @version 17.02.24
* @version 01.03.24
*/

namespace Bugo\LightPortal\Addons\CurrentMonth;

use Bugo\Compat\{Config, Lang, Theme, User, Utils};
use Bugo\Compat\{Calendar, Config, Lang, Theme, User, Utils};
use Bugo\LightPortal\Addons\Block;

if (! defined('LP_NAME'))
Expand All @@ -35,9 +35,7 @@ public function prepareBlockParams(array &$params): void

public function getData(): array
{
$this->require('Subs-Calendar');

$today = getTodayInfo();
$today = Calendar::getTodayInfo();
$year = $today['year'];
$month = $today['month'];
$day = $today['day'];
Expand All @@ -58,7 +56,7 @@ public function getData(): array
'show_week_links' => (int) (Config::$modSettings['cal_week_links'] ?? 0)
];

return getCalendarGrid(date_format($startObject, 'Y-m-d'), $options, has_picker: false);
return Calendar::getCalendarGrid(date_format($startObject, 'Y-m-d'), $options, has_picker: false);
}

public function prepareContent(object $data): void
Expand Down
Loading

0 comments on commit 5a0731d

Please sign in to comment.