Skip to content

Commit

Permalink
Merge pull request #20 from dragomano/develop
Browse files Browse the repository at this point in the history
Update to 1 .4.1
  • Loading branch information
dragomano authored Dec 14, 2020
2 parents 262428f + f468ff8 commit a2454e8
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 18 deletions.
7 changes: 5 additions & 2 deletions Sources/LightPortal/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/LightPortal/Integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
2 changes: 0 additions & 2 deletions Sources/LightPortal/Notify.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ public function execute()
array('id_alert')
);

$smcFunc['lp_num_queries']++;

updateMemberData($notifies['alert'], array('alerts' => '+'));
}
}
Expand Down
13 changes: 11 additions & 2 deletions Sources/LightPortal/addons/EhPortal/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);

Expand All @@ -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']);
}

Expand Down
27 changes: 20 additions & 7 deletions Sources/LightPortal/addons/TinyPortal/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -234,15 +234,15 @@ 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);

$comments = $this->getComments($pages);

$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,
Expand All @@ -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']))
Expand Down Expand Up @@ -425,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,
Expand Down Expand Up @@ -455,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
Expand All @@ -466,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,
Expand Down
6 changes: 3 additions & 3 deletions Themes/default/scripts/light_portal/view_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ class Comment {
allComments.insertAdjacentHTML('beforeend', comment);
allComments.style.transition = 'height 3s';
} else {
pageComments.insertAdjacentHTML('afterbegin', '<ul class="comment_list row"></ul>');
pageComments.querySelector('ul.comment_list').insertAdjacentHTML('beforeend', comment);
pageComments.querySelector('ul.comment_list').style.transition = 'height 3s';
refs.page_comments.insertAdjacentHTML('afterbegin', '<ul class="comment_list row"></ul>');
refs.page_comments.querySelector('ul.comment_list').insertAdjacentHTML('beforeend', comment);
refs.page_comments.querySelector('ul.comment_list').style.transition = 'height 3s';
}
}

Expand Down

0 comments on commit a2454e8

Please sign in to comment.