From 79aeae23bfb1f632a27838bc3a5a07bf97bcae2b Mon Sep 17 00:00:00 2001 From: Bugo Date: Sat, 12 Dec 2020 17:03:17 +0500 Subject: [PATCH 1/5] Fix EhPortal and TinyPortal addons --- Sources/LightPortal/addons/EhPortal/Import.php | 13 +++++++++++-- Sources/LightPortal/addons/TinyPortal/Import.php | 15 ++++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/Sources/LightPortal/addons/EhPortal/Import.php b/Sources/LightPortal/addons/EhPortal/Import.php index 865f3efb3..6524d88f5 100644 --- a/Sources/LightPortal/addons/EhPortal/Import.php +++ b/Sources/LightPortal/addons/EhPortal/Import.php @@ -222,7 +222,7 @@ public function getTotalQuantity() */ protected function run() { - global $db_temp_cache, $db_cache, $language, $smcFunc; + global $db_temp_cache, $db_cache, $language, $modSettings, $smcFunc; if (Helpers::post()->isEmpty('pages') && Helpers::post()->has('import_all') === false) return; @@ -234,7 +234,7 @@ protected function run() $db_temp_cache = $db_cache; $db_cache = []; - $pages = !empty(Helpers::post('pages')) && Helpers::post()->has('export_all') === false ? Helpers::post('pages') : null; + $pages = !empty(Helpers::post('pages')) && Helpers::post()->has('import_all') === false ? Helpers::post('pages') : null; $items = $this->getItems($pages); @@ -247,6 +247,15 @@ protected function run() 'title' => $item['title'] ]; + if ($language != 'english' && !empty($modSettings['userLanguage'])) { + $titles[] = [ + 'item_id' => $page_id, + 'type' => 'page', + 'lang' => 'english', + 'title' => $item['title'] + ]; + } + unset($items[$page_id]['title']); } diff --git a/Sources/LightPortal/addons/TinyPortal/Import.php b/Sources/LightPortal/addons/TinyPortal/Import.php index 7b9ae0672..908fbb7ed 100644 --- a/Sources/LightPortal/addons/TinyPortal/Import.php +++ b/Sources/LightPortal/addons/TinyPortal/Import.php @@ -222,7 +222,7 @@ public function getTotalQuantity() */ protected function run() { - global $db_temp_cache, $db_cache, $language, $smcFunc; + global $db_temp_cache, $db_cache, $language, $modSettings, $smcFunc; if (Helpers::post()->isEmpty('pages') && Helpers::post()->has('import_all') === false) return; @@ -234,7 +234,7 @@ protected function run() $db_temp_cache = $db_cache; $db_cache = []; - $pages = !empty(Helpers::post('pages')) && Helpers::post()->has('export_all') === false ? Helpers::post('pages') : null; + $pages = !empty(Helpers::post('pages')) && Helpers::post()->has('import_all') === false ? Helpers::post('pages') : null; $items = $this->getItems($pages); @@ -242,7 +242,7 @@ protected function run() $titles = $params = []; foreach ($items as $page_id => $item) { - $items[$page_id]['num_comments'] = sizeof($comments[$page_id]); + $items[$page_id]['num_comments'] = !empty($comments[$page_id]) ? sizeof($comments[$page_id]) : 0; $titles[] = [ 'item_id' => $page_id, @@ -251,6 +251,15 @@ protected function run() 'title' => $item['subject'] ]; + if ($language != 'english' && !empty($modSettings['userLanguage'])) { + $titles[] = [ + 'item_id' => $page_id, + 'type' => 'page', + 'lang' => 'english', + 'title' => $item['subject'] + ]; + } + unset($items[$page_id]['subject']); if (in_array('author', $items[$page_id]['options']) || in_array('date', $items[$page_id]['options'])) From 764abbc70718921723450319181d8abfb69bec03 Mon Sep 17 00:00:00 2001 From: Bugo Date: Sat, 12 Dec 2020 21:10:50 +0500 Subject: [PATCH 2/5] Fix import comments for TinyPortal --- Sources/LightPortal/addons/TinyPortal/Import.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Sources/LightPortal/addons/TinyPortal/Import.php b/Sources/LightPortal/addons/TinyPortal/Import.php index 908fbb7ed..704efcec1 100644 --- a/Sources/LightPortal/addons/TinyPortal/Import.php +++ b/Sources/LightPortal/addons/TinyPortal/Import.php @@ -434,7 +434,7 @@ private function getItems($pages) 'page_id' => $row['id'], 'author_id' => $row['author_id'], 'alias' => $row['shortname'] ?: ('page_' . $row['id']), - 'description' => $row['intro'], + 'description' => strip_tags($row['intro']), 'content' => $row['body'], 'type' => $row['type'], 'permissions' => $perm, @@ -464,9 +464,10 @@ private function getComments($pages) $request = $smcFunc['db_query']('', ' SELECT * - FROM {db_prefix}tp_comments - WHERE item_type = {string:type}' . (!empty($pages) ? ' - AND item_id IN ({array_int:pages})' : ''), + FROM {db_prefix}tp_comments AS com + INNER JOIN {db_prefix}members AS mem ON (com.member_id = mem.id_member) + WHERE com.item_type = {string:type}' . (!empty($pages) ? ' + AND com.item_id IN ({array_int:pages})' : ''), array( 'type' => 'article_comment', 'pages' => $pages @@ -475,6 +476,9 @@ private function getComments($pages) $comments = []; while ($row = $smcFunc['db_fetch_assoc']($request)) { + if ($row['item_id'] < 0 || empty($row['comment'])) + continue; + $comments[$row['item_id']][] = array( 'id' => $row['id'], 'parent_id' => 0, From 35f1c1d8d7c128a4aaef284861a70157cbe3baa6 Mon Sep 17 00:00:00 2001 From: Bugo Date: Sun, 13 Dec 2020 16:52:54 +0500 Subject: [PATCH 3/5] Add default value for getTeaser helper --- Sources/LightPortal/Helpers.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Sources/LightPortal/Helpers.php b/Sources/LightPortal/Helpers.php index 4913725df..17e26a7a2 100644 --- a/Sources/LightPortal/Helpers.php +++ b/Sources/LightPortal/Helpers.php @@ -541,13 +541,16 @@ public static function getSnakeName(string $value, string $delimiter = '_') * * Получаем тизер статьи * - * @param string $text + * @param string|null $text * @return string */ - public static function getTeaser(string $text) + public static function getTeaser($text = '') { global $modSettings; + if (empty($text)) + return ''; + return !empty($modSettings['lp_teaser_size']) ? shorten_subject(trim($text), $modSettings['lp_teaser_size']) : trim($text); } From 369a22b1a0de8d538fc2957eb9411e2553281e73 Mon Sep 17 00:00:00 2001 From: Bugo Date: Sun, 13 Dec 2020 18:23:40 +0500 Subject: [PATCH 4/5] Fix issue with first comments --- Themes/default/scripts/light_portal/view_page.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Themes/default/scripts/light_portal/view_page.js b/Themes/default/scripts/light_portal/view_page.js index cc1027425..f9576bec4 100644 --- a/Themes/default/scripts/light_portal/view_page.js +++ b/Themes/default/scripts/light_portal/view_page.js @@ -101,9 +101,9 @@ class Comment { allComments.insertAdjacentHTML('beforeend', comment); allComments.style.transition = 'height 3s'; } else { - pageComments.insertAdjacentHTML('afterbegin', '
    '); - pageComments.querySelector('ul.comment_list').insertAdjacentHTML('beforeend', comment); - pageComments.querySelector('ul.comment_list').style.transition = 'height 3s'; + refs.page_comments.insertAdjacentHTML('afterbegin', '
      '); + refs.page_comments.querySelector('ul.comment_list').insertAdjacentHTML('beforeend', comment); + refs.page_comments.querySelector('ul.comment_list').style.transition = 'height 3s'; } } From f468ff89c92761db80f9c3987c2db841cb5db4f5 Mon Sep 17 00:00:00 2001 From: Bugo Date: Mon, 14 Dec 2020 08:47:16 +0500 Subject: [PATCH 5/5] Update to 1.4.1 --- Sources/LightPortal/Integration.php | 4 ++-- Sources/LightPortal/Notify.php | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Sources/LightPortal/Integration.php b/Sources/LightPortal/Integration.php index a32676c7b..1389a53f6 100644 --- a/Sources/LightPortal/Integration.php +++ b/Sources/LightPortal/Integration.php @@ -82,8 +82,8 @@ public function userInfo() $lp_constants = [ 'LP_NAME' => 'Light Portal', - 'LP_VERSION' => '1.4', - 'LP_RELEASE_DATE' => '2020-12-12', + 'LP_VERSION' => '1.4.1', + 'LP_RELEASE_DATE' => '2020-12-14', 'LP_DEBUG' => !empty($modSettings['lp_show_debug_info']) && !empty($user_info['is_admin']), 'LP_CACHE_TIME' => $modSettings['lp_cache_update_interval'] ?? 3600, 'RC2_CLEAN' => !defined('JQUERY_VERSION'), diff --git a/Sources/LightPortal/Notify.php b/Sources/LightPortal/Notify.php index 8a211f37a..fc4b867b2 100644 --- a/Sources/LightPortal/Notify.php +++ b/Sources/LightPortal/Notify.php @@ -100,8 +100,6 @@ public function execute() array('id_alert') ); - $smcFunc['lp_num_queries']++; - updateMemberData($notifies['alert'], array('alerts' => '+')); } }