Skip to content

Commit

Permalink
v0.9.2
Browse files Browse the repository at this point in the history
  • Loading branch information
dragomano committed Feb 1, 2020
1 parent 838884e commit a41ff79
Show file tree
Hide file tree
Showing 29 changed files with 69 additions and 57 deletions.
14 changes: 5 additions & 9 deletions Sources/LightPortal/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @copyright 2019-2020 Bugo
* @license https://opensource.org/licenses/BSD-3-Clause BSD
*
* @version 0.9.1
* @version 0.9.2
*/

if (!defined('SMF'))
Expand Down Expand Up @@ -339,10 +339,8 @@ public static function edit()
$item = !empty($_REQUEST['block_id']) ? (int) $_REQUEST['block_id'] : null;
$item = $item ?: (!empty($_REQUEST['id']) ? (int) $_REQUEST['id'] : null);

if (empty($item)) {
header('HTTP/1.1 404 Not Found');
fatal_lang_error('lp_block_not_found', false);
}
if (empty($item))
fatal_lang_error('lp_block_not_found', false, null, 404);

loadTemplate('LightPortal/ManageBlocks');

Expand Down Expand Up @@ -963,10 +961,8 @@ public static function getData($item)
)
);

if ($smcFunc['db_num_rows']($request) == 0) {
header('HTTP/1.1 404 Not Found');
fatal_lang_error('lp_block_not_found', false);
}
if ($smcFunc['db_num_rows']($request) == 0)
fatal_lang_error('lp_block_not_found', false, null, 404);

while ($row = $smcFunc['db_fetch_assoc']($request)) {
censorText($row['content']);
Expand Down
2 changes: 1 addition & 1 deletion Sources/LightPortal/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @copyright 2019-2020 Bugo
* @license https://opensource.org/licenses/BSD-3-Clause BSD
*
* @version 0.9.1
* @version 0.9.2
*/

if (!defined('SMF'))
Expand Down
6 changes: 3 additions & 3 deletions Sources/LightPortal/Integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @copyright 2019-2020 Bugo
* @license https://opensource.org/licenses/BSD-3-Clause BSD
*
* @version 0.9.1
* @version 0.9.2
*/

if (!defined('SMF'))
Expand Down Expand Up @@ -70,7 +70,7 @@ public static function userInfo()
global $sourcedir;

$lp_constants = [
'LP_VERSION' => '0.9.1',
'LP_VERSION' => '0.9.2',
'LP_NAME' => 'Light Portal',
'LP_ADDONS' => $sourcedir . '/LightPortal/addons'
];
Expand Down Expand Up @@ -110,7 +110,7 @@ public static function loadTheme()
*/
public static function actions(&$actions)
{
global $context, $modSettings;
global $modSettings, $context;

if (!empty($modSettings['lp_frontpage_disable']))
return;
Expand Down
18 changes: 9 additions & 9 deletions Sources/LightPortal/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @copyright 2019-2020 Bugo
* @license https://opensource.org/licenses/BSD-3-Clause BSD
*
* @version 0.9.1
* @version 0.9.2
*/

if (!defined('SMF'))
Expand Down Expand Up @@ -467,6 +467,8 @@ public static function add()
'description' => $txt['lp_pages_add_tab_description']
);

Subs::getForumLanguages();

self::validateData();
self::prepareFormFields();
self::prepareEditor();
Expand All @@ -492,10 +494,8 @@ public static function edit()
$item = !empty($_REQUEST['page_id']) ? (int) $_REQUEST['page_id'] : null;
$item = $item ?: (!empty($_REQUEST['id']) ? (int) $_REQUEST['id'] : null);

if (empty($item)) {
header('HTTP/1.1 404 Not Found');
fatal_lang_error('lp_page_not_found', false);
}
if (empty($item))
fatal_lang_error('lp_page_not_found', false, null, 404);

$context['page_title'] = $txt['lp_portal'] . ' - ' . $txt['lp_pages_edit_title'];

Expand All @@ -509,6 +509,8 @@ public static function edit()
if ($context['lp_current_page']['can_edit'] === false)
fatal_lang_error('lp_page_not_editable', false);

Subs::getForumLanguages();

self::validateData();

$context['page_area_title'] = $txt['lp_pages_edit_title'] . ' - ' . $context['lp_page']['title'];
Expand Down Expand Up @@ -1019,10 +1021,8 @@ public static function getFromDB($params)
)
);

if ($smcFunc['db_num_rows']($request) == 0) {
header('HTTP/1.1 404 Not Found');
fatal_lang_error('lp_page_not_found', false);
}
if ($smcFunc['db_num_rows']($request) == 0)
fatal_lang_error('lp_page_not_found', false, null, 404);

while ($row = $smcFunc['db_fetch_assoc']($request)) {
censorText($row['content']);
Expand Down
5 changes: 4 additions & 1 deletion Sources/LightPortal/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @copyright 2019-2020 Bugo
* @license https://opensource.org/licenses/BSD-3-Clause BSD
*
* @version 0.9.1
* @version 0.9.2
*/

if (!defined('SMF'))
Expand Down Expand Up @@ -305,6 +305,9 @@ private static function loadGeneralSettingParameters($subActions = [], $defaultA
*/
public static function isNewVersionExist()
{
if (!extension_loaded('curl'))
return false;

$ch = curl_init('https://api.github.com/repos/dragomano/light-portal/releases/latest');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
Expand Down
31 changes: 20 additions & 11 deletions Sources/LightPortal/Subs.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @copyright 2019-2020 Bugo
* @license https://opensource.org/licenses/BSD-3-Clause BSD
*
* @version 0.9.1
* @version 0.9.2
*/

if (!defined('SMF'))
Expand Down Expand Up @@ -72,11 +72,12 @@ public static function getTopicsFromSelectedBoards()
// Check whether compatible modifications are installed
// Проверяем, установлены ли совместимые модификации
$topic_rating_bar = class_exists('TopicRatingBar');
$karma_post_rating = class_exists('\Bugo\KarmaPostRating\Subs');
$optimus = class_exists('\Bugo\Optimus\Subs') && !empty($modSettings['optimus_allow_change_desc']);

$request = $smcFunc['db_query']('', '
SELECT
t.id_topic, t.id_board, t.num_views, t.num_replies, t.is_sticky, t.id_first_msg, t.id_member_started, mf.subject, mf.body, mf.smileys_enabled, COALESCE(mem.real_name, mf.poster_name) AS poster_name, mf.poster_time, mf.id_member, ml.id_msg, b.name, ' . ($user_info['is_guest'] ? '0' : 'COALESCE(lt.id_msg, lmr.id_msg, -1) + 1') . ' AS new_from, ml.id_msg_modified' . (!empty($modSettings['lp_show_images_in_articles']) ? ', COALESCE(a.id_attach, 0) AS attach_id' : '') . ($topic_rating_bar ? ', tr.total_votes, tr.total_value' : '') . ($optimus ? ', COALESCE(t.optimus_description, 0) AS optimus_description' : '') . '
t.id_topic, t.id_board, t.num_views, t.num_replies, t.is_sticky, t.id_first_msg, t.id_member_started, mf.subject, mf.body, mf.smileys_enabled, COALESCE(mem.real_name, mf.poster_name) AS poster_name, mf.poster_time, mf.id_member, ml.id_msg, b.name, ' . ($user_info['is_guest'] ? '0' : 'COALESCE(lt.id_msg, lmr.id_msg, -1) + 1') . ' AS new_from, ml.id_msg_modified' . (!empty($modSettings['lp_show_images_in_articles']) ? ', COALESCE(a.id_attach, 0) AS attach_id' : '') . ($topic_rating_bar ? ', tr.total_votes, tr.total_value' : '') . ($karma_post_rating ? ', IF (kpr.rating_plus || kpr.rating_minus, kpr.rating_plus + kpr.rating_minus' . (!empty($modSettings['kpr_num_topics_factor']) ? ' + t.num_replies' : '') . ', 0) AS rating' : '') . ($optimus ? ', COALESCE(t.optimus_description, 0) AS optimus_description' : '') . '
FROM {db_prefix}topics AS t
INNER JOIN {db_prefix}messages AS ml ON (ml.id_msg = t.id_last_msg)
INNER JOIN {db_prefix}messages AS mf ON (mf.id_msg = t.id_first_msg)
Expand All @@ -85,16 +86,22 @@ public static function getTopicsFromSelectedBoards()
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = {int:current_member})
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = t.id_board AND lmr.id_member = {int:current_member})') . (!empty($modSettings['lp_show_images_in_articles']) ? '
LEFT JOIN {db_prefix}attachments AS a ON (a.id_msg = t.id_first_msg AND a.id_thumb <> 0 AND a.width > 0 AND a.height > 0)' : '') . ($topic_rating_bar ? '
LEFT JOIN {db_prefix}topic_ratings AS tr ON (tr.id = t.id_topic)' : '') . '
WHERE t.approved = 1
AND t.id_poll = 0
AND t.id_redirect_topic = 0
AND t.id_board IN ({array_int:select_boards})
LEFT JOIN {db_prefix}topic_ratings AS tr ON (tr.id = t.id_topic)' : '') . ($karma_post_rating ? '
LEFT JOIN {db_prefix}kpr_ratings AS kpr ON (kpr.item_id = t.id_first_msg AND kpr.item = "message")' : '') . '
WHERE t.approved = {int:is_approved}
AND t.id_poll = {int:id_poll}
AND t.id_redirect_topic = {int:id_redirect_topic}
AND t.id_board IN ({array_int:select_boards})' . ($karma_post_rating && !empty($context['kpr_ignored_boards']) ? '
AND t.id_board NOT IN ({array_int:kpr_ignored_boards)' : '') . '
AND {query_wanna_see_board}
ORDER BY t.id_last_msg DESC',
array(
'current_member' => $user_info['id'],
'select_boards' => $boards
'current_member' => $user_info['id'],
'is_approved' => 1,
'id_poll' => 0,
'id_redirect_topic' => 0,
'select_boards' => $boards,
'kpr_ignored_boards' => !empty($context['kpr_ignored_boards']) ? $context['kpr_ignored_boards'] : null
)
);

Expand All @@ -109,6 +116,7 @@ public static function getTopicsFromSelectedBoards()
$row['subject'] = Helpers::cleanBbcode($row['subject']);

$rating = !empty($row['total_votes']) ? number_format($row['total_value'] / $row['total_votes'], 0) : 0;
$kpr_rating = $row['rating'] ?: 0;

$image = null;
if (!empty($modSettings['lp_show_images_in_articles'])) {
Expand All @@ -135,7 +143,7 @@ public static function getTopicsFromSelectedBoards()
'poster_link' => $scripturl . '?action=profile;u=' . $row['id_member'],
'poster_name' => $row['poster_name'],
'time' => Helpers::getFriendlyTime($row['poster_time']),
'subject' => !empty($subject_size) ? shorten_subject($row['subject'], $subject_size - $rating) : $row['subject'],
'subject' => !empty($subject_size) ? shorten_subject($row['subject'], $subject_size - $rating - strlen((string) $kpr_rating)) : $row['subject'],
'preview' => $row['optimus_description'] ?: $row['body'],
'link' => $scripturl . '?topic=' . $row['id_topic'] . ($row['new_from'] > $row['id_msg_modified'] ? '.0' : '.new;topicseen#new'),
'board' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>',
Expand All @@ -145,7 +153,8 @@ public static function getTopicsFromSelectedBoards()
'num_replies' => $row['num_replies'],
'css_class' => $colorClass,
'image' => $image,
'rating' => $rating
'rating' => $rating,
'kpr_rating' => $kpr_rating
);
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/LightPortal/addons/BoardList/BoardList.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @copyright 2019-2020 Bugo
* @license https://opensource.org/licenses/BSD-3-Clause BSD
*
* @version 0.9.1
* @version 0.9.2
*/

if (!defined('SMF'))
Expand Down
2 changes: 1 addition & 1 deletion Sources/LightPortal/addons/BoardNews/BoardNews.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @copyright 2019-2020 Bugo
* @license https://opensource.org/licenses/BSD-3-Clause BSD
*
* @version 0.9.1
* @version 0.9.2
*/

if (!defined('SMF'))
Expand Down
2 changes: 1 addition & 1 deletion Sources/LightPortal/addons/EasyMDE/EasyMDE.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @copyright 2019-2020 Bugo
* @license https://opensource.org/licenses/BSD-3-Clause BSD
*
* @version 0.9.1
* @version 0.9.2
*/

if (!defined('SMF'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @copyright 2019-2020 Bugo
* @license https://opensource.org/licenses/BSD-3-Clause BSD
*
* @version 0.9.1
* @version 0.9.2
*/

if (!defined('SMF'))
Expand Down
2 changes: 1 addition & 1 deletion Sources/LightPortal/addons/Likely/Likely.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @copyright 2019-2020 Bugo
* @license https://opensource.org/licenses/BSD-3-Clause BSD
*
* @version 0.9.1
* @version 0.9.2
*/

if (!defined('SMF'))
Expand Down
2 changes: 1 addition & 1 deletion Sources/LightPortal/addons/Markdown/Markdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @copyright 2019-2020 Bugo
* @license https://opensource.org/licenses/BSD-3-Clause BSD
*
* @version 0.9.1
* @version 0.9.2
*/

if (!defined('SMF'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @copyright 2019-2020 Bugo
* @license https://opensource.org/licenses/BSD-3-Clause BSD
*
* @version 0.9.1
* @version 0.9.2
*/

class MarkdownSMF extends \Michelf\MarkdownExtra
Expand Down
2 changes: 1 addition & 1 deletion Sources/LightPortal/addons/PageList/PageList.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @copyright 2019-2020 Bugo
* @license https://opensource.org/licenses/BSD-3-Clause BSD
*
* @version 0.9.1
* @version 0.9.2
*/

if (!defined('SMF'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @copyright 2019-2020 Bugo
* @license https://opensource.org/licenses/BSD-3-Clause BSD
*
* @version 0.9.1
* @version 0.9.2
*/

if (!defined('SMF'))
Expand Down
2 changes: 1 addition & 1 deletion Sources/LightPortal/addons/RecentPosts/RecentPosts.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @copyright 2019-2020 Bugo
* @license https://opensource.org/licenses/BSD-3-Clause BSD
*
* @version 0.9.1
* @version 0.9.2
*/

if (!defined('SMF'))
Expand Down
2 changes: 1 addition & 1 deletion Sources/LightPortal/addons/RecentTopics/RecentTopics.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @copyright 2019-2020 Bugo
* @license https://opensource.org/licenses/BSD-3-Clause BSD
*
* @version 0.9.1
* @version 0.9.2
*/

if (!defined('SMF'))
Expand Down
2 changes: 1 addition & 1 deletion Sources/LightPortal/addons/ThemeSwitcher/ThemeSwitcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @copyright 2019-2020 Bugo
* @license https://opensource.org/licenses/BSD-3-Clause BSD
*
* @version 0.9.1
* @version 0.9.2
*/

if (!defined('SMF'))
Expand Down
2 changes: 1 addition & 1 deletion Sources/LightPortal/addons/Todays/Todays.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @copyright 2019-2020 Bugo
* @license https://opensource.org/licenses/BSD-3-Clause BSD
*
* @version 0.9.1
* @version 0.9.2
*/

if (!defined('SMF'))
Expand Down
2 changes: 1 addition & 1 deletion Sources/LightPortal/addons/TopBoards/TopBoards.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @copyright 2019-2020 Bugo
* @license https://opensource.org/licenses/BSD-3-Clause BSD
*
* @version 0.9.1
* @version 0.9.2
*/

if (!defined('SMF'))
Expand Down
2 changes: 1 addition & 1 deletion Sources/LightPortal/addons/TopPosters/TopPosters.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @copyright 2019-2020 Bugo
* @license https://opensource.org/licenses/BSD-3-Clause BSD
*
* @version 0.9.1
* @version 0.9.2
*/

if (!defined('SMF'))
Expand Down
2 changes: 1 addition & 1 deletion Sources/LightPortal/addons/TopTopics/TopTopics.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @copyright 2019-2020 Bugo
* @license https://opensource.org/licenses/BSD-3-Clause BSD
*
* @version 0.9.1
* @version 0.9.2
*/

if (!defined('SMF'))
Expand Down
2 changes: 1 addition & 1 deletion Sources/LightPortal/addons/Trumbowyg.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @copyright 2019-2020 Bugo
* @license https://opensource.org/licenses/BSD-3-Clause BSD
*
* @version 0.9.1
* @version 0.9.2
*/

if (!defined('SMF'))
Expand Down
2 changes: 1 addition & 1 deletion Sources/LightPortal/addons/UserInfo/UserInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @copyright 2019-2020 Bugo
* @license https://opensource.org/licenses/BSD-3-Clause BSD
*
* @version 0.9.1
* @version 0.9.2
*/

if (!defined('SMF'))
Expand Down
2 changes: 1 addition & 1 deletion Sources/LightPortal/addons/WhosOnline/WhosOnline.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @copyright 2019-2020 Bugo
* @license https://opensource.org/licenses/BSD-3-Clause BSD
*
* @version 0.9.1
* @version 0.9.2
*/

if (!defined('SMF'))
Expand Down
Loading

0 comments on commit a41ff79

Please sign in to comment.