Skip to content

Commit

Permalink
v0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
dragomano committed Jan 21, 2020
1 parent 1875c27 commit b96d32d
Show file tree
Hide file tree
Showing 59 changed files with 4,965 additions and 4,465 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
# Light Portal
![SMF 2.1](https://img.shields.io/badge/SMF-2.1-blue.svg?style=flat-square&color=ed6033)![License](https://img.shields.io/github/license/dragomano/light-portal)![PHP](https://img.shields.io/badge/php-^7.2-red.svg?style=flat-square&color=blue)![Downloads](https://img.shields.io/github/downloads/dragomano/light-portal/total)

* **Author:** Bugo [dragomano.ru](https://dragomano.ru/mods/light-portal)
* **License:** [BSD 3](https://github.com/dragomano/Light-Portal/blob/master/LICENSE)
* **Compatible with:** SMF 2.1 RC2+ / PHP 7.2+
* **Tested on:** PHP 7.3.13 / MariaDB 10.3.13 / PostgreSQL 9.6.12
* **Tested on:** PHP 7.4.1 / MariaDB 10.3.13 / PostgreSQL 9.6.12
* **Hooks only:** Yes
* **Languages:** English, Russian, Ukrainian

## Description
Transform your forum into a portal: the main page, separate additional pages and blocks. Support for BBC/HTML/PHP content. Nothing extra.
Transform your forum into a portal: the main page, separate additional pagesand blocks, as well as the article system. Support for BBC, HTML and PHP content. Nothing extra.

### Features:
* Standalone mode
* Blocks with multilingual titles and FontAwesome icons
* Article system: portal pages or topics from selected boards
* Available panels: header, left and right sidebars, center (top and bottom), footer
* Manage blocks in Admin: Drag-n-drop of blocks, easy updating of the priority
* Pages with support for various content
Expand All @@ -20,11 +23,12 @@ Transform your forum into a portal: the main page, separate additional pages and
* Support for addons

## Описание
Модификация добавляет форуму функциональность портала: главная страница, отдельные дополнительные страницы и блоки. Поддержка контента типа BBC/HTML/PHP. Ничего лишнего.
Модификация добавляет форуму функциональность портала: главная страница, отдельные дополнительные страницы и блоки, статьи. Поддержка контента с ББ-кодом, HTML и PHP-тегами. Ничего лишнего.

### Особенности:
* Автономный режим
* Блоки с многоязычными заголовками и иконками FontAwesome
* Статьи на главной: отображение тем из выбранных разделов или страниц портала
* Доступные панели: шапка, левый и правый сайдбары, центр (верх и низ), подвал
* Drag-n-drop перетаскивание блоков между панелями, с обновлением приоритета
* Страницы с поддержкой различного контента
Expand Down
2 changes: 1 addition & 1 deletion 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.6
* @version 0.7
*/

if (!defined('SMF'))
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.6
* @version 0.7
*/

if (!defined('SMF'))
Expand Down
12 changes: 6 additions & 6 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.6
* @version 0.7
*/

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

$lp_constants = [
'LP_VERSION' => '0.6',
'LP_VERSION' => '0.7',
'LP_NAME' => 'Light Portal',
'LP_ADDONS' => $sourcedir . '/LightPortal/addons'
];
Expand Down Expand Up @@ -373,7 +373,7 @@ public static function credits()
if (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'light_portal') {
Subs::getComponentCredits();

loadTemplate('LightPortal/Credits');
loadTemplate('LightPortal/ViewPage');

$context['sub_template'] = 'portal_credits';
$context['robot_no_index'] = true;
Expand All @@ -398,14 +398,14 @@ public static function whosOnline($actions)
$result = '';
if (empty($modSettings['lp_frontpage_disable'])) {
if (empty($actions['action']))
$result = sprintf($txt['lp_who_main'], $scripturl);
$result = sprintf($txt['lp_who_viewing_frontpage'], $scripturl);

if (!empty($actions['action']) && $actions['action'] == 'portal')
$result = sprintf($txt['lp_who_main'], $scripturl . '?action=portal');
$result = sprintf($txt['lp_who_viewing_frontpage'], $scripturl . '?action=portal');
}

if (!empty($actions['page']))
$result = sprintf($txt['lp_who_page'], $scripturl . '?page=' . $actions['page']);
$result = sprintf($txt['lp_who_viewing_page'], $scripturl . '?page=' . $actions['page']);

return $result;
}
Expand Down
33 changes: 24 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.6
* @version 0.7
*/

if (!defined('SMF'))
Expand Down Expand Up @@ -50,7 +50,6 @@ public static function show($alias = '/')
if ($context['lp_page']['can_show'] === false && !$context['user']['is_admin'])
fatal_lang_error('cannot_light_portal_view_page', false);

Subs::parseContent($context['lp_page']['content'], $context['lp_page']['type']);
Subs::setMeta();

if (empty($context['current_action']))
Expand Down Expand Up @@ -842,16 +841,19 @@ private static function getAutoIncrementValue()
* @param array $params
* @return void
*/
public static function getFromPages($params)
public static function getFromDB($params)
{
global $smcFunc, $user_info;
global $smcFunc, $modSettings;

[$item, $useAlias] = $params;

$request = $smcFunc['db_query']('', '
SELECT page_id, author_id, title, alias, description, keywords, content, type, permissions, status, num_views, created_at, updated_at
FROM {db_prefix}lp_pages
WHERE ' . ($useAlias ? 'alias = {string' : 'page_id = {int') . ':item}
SELECT
p.page_id, p.author_id, p.title, p.alias, p.description, p.keywords, p.content, p.type, p.permissions, p.status, p.num_views, p.created_at, p.updated_at,
COALESCE(mem.real_name, 0) AS author_name
FROM {db_prefix}lp_pages AS p
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = p.author_id)
WHERE ' . ($useAlias ? 'p.alias = {string' : 'p.page_id = {int') . ':item}
LIMIT 1',
array(
'item' => $item
Expand All @@ -864,11 +866,23 @@ public static function getFromPages($params)
}

while ($row = $smcFunc['db_fetch_assoc']($request)) {
Subs::parseContent($row['content'], $row['type']);
censorText($row['content']);

$og_image = null;
if (!empty($modSettings['lp_page_og_image'])) {
$image_found = preg_match_all('/<img(.*)src(.*)=(.*)"(.*)"/U', $row['content'], $values);
if ($image_found && is_array($values)) {
$all_images = array_pop($values);
$image = $modSettings['lp_page_og_image'] == 1 ? array_shift($all_images) : array_pop($all_images);
$og_image = $smcFunc['htmlspecialchars']($image);
}
}

$data = array(
'id' => $row['page_id'],
'author_id' => $row['author_id'],
'author' => $row['author_name'],
'title' => $row['title'],
'alias' => $row['alias'],
'description' => $row['description'],
Expand All @@ -879,7 +893,8 @@ public static function getFromPages($params)
'status' => $row['status'],
'num_views' => $row['num_views'],
'created_at' => $row['created_at'],
'updated_at' => $row['updated_at']
'updated_at' => $row['updated_at'],
'image' => $og_image
);
}

Expand All @@ -904,7 +919,7 @@ public static function getData($item, $useAlias = true)
if (empty($item))
return;

$data = Helpers::useCache('light_portal_page_' . ($item == '/' ? 'main' : $item), 'getFromPages', __CLASS__, 3600, array($item, $useAlias));
$data = Helpers::useCache('light_portal_page_' . ($item == '/' ? 'main' : $item), 'getFromDB', __CLASS__, 3600, array($item, $useAlias));

if (!empty($data)) {
$data['created'] = Helpers::getFriendlyTime($data['created_at']);
Expand Down
7 changes: 5 additions & 2 deletions 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.6
* @version 0.7
*/

if (!defined('SMF'))
Expand Down Expand Up @@ -169,8 +169,11 @@ public static function settingArea($return_config = false)
array('text', 'lp_standalone_excluded_actions', 80, 'subtext' => $txt['lp_standalone_excluded_actions_subtext']),
'',
array('select', 'lp_page_editor_type_default', $txt['lp_page_types']),
array('select', 'lp_page_og_image', $txt['lp_page_og_image_set']),
array('check', 'lp_hide_blocks_in_admin_section'),
array('title', 'lp_open_graph'),
array('select', 'lp_page_og_image', $txt['lp_page_og_image_set']),
array('text', 'lp_page_itemprop_address', 80),
array('text', 'lp_page_itemprop_phone', 80),
array('title', 'edit_permissions'),
array('permissions', 'light_portal_view'),
array('permissions', 'light_portal_manage')
Expand Down
37 changes: 14 additions & 23 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.6
* @version 0.7
*/

if (!defined('SMF'))
Expand Down Expand Up @@ -150,19 +150,18 @@ public static function getTopicsFromSelectedBoards()
*/
public static function getActivePages()
{
global $smcFunc, $txt, $modSettings, $scripturl, $settings, $user_info;
global $smcFunc, $modSettings, $scripturl, $settings, $user_info;

$request = $smcFunc['db_query']('', '
SELECT
p.page_id, p.author_id, p.title, p.alias, p.description, p.type, p.permissions, p.status, p.num_views,
GREATEST(created_at, updated_at) AS date, COALESCE(mem.real_name, {string:guest}) AS author_name
p.page_id, p.author_id, p.title, p.alias, p.content, p.description, p.type, p.permissions, p.status, p.num_views,
GREATEST(created_at, updated_at) AS date, COALESCE(mem.real_name, 0) AS author_name
FROM {db_prefix}lp_pages AS p
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = p.author_id)
WHERE p.alias != {string:alias}
AND p.status = {int:status}
ORDER BY date DESC',
array(
'guest' => $txt['guest'],
'alias' => '/',
'status' => 1
)
Expand All @@ -173,7 +172,7 @@ public static function getActivePages()

$pages = [];
while ($row = $smcFunc['db_fetch_assoc']($request)) {
//Subs::parseContent($row['content'], $row['type']);
self::parseContent($row['content'], $row['type']);

$image = null;
if (!empty($modSettings['lp_show_images_in_articles'])) {
Expand All @@ -192,14 +191,13 @@ public static function getActivePages()
'title' => !empty($subject_size) ? shorten_subject($row['title'], $subject_size) : $row['title'],
'alias' => $row['alias'],
'description' => $row['description'],
'content' => $row['content'],
'type' => $row['type'],
'num_views' => $row['num_views'],
'created_at' => Helpers::getFriendlyTime($row['date']),
'is_new' => $user_info['last_login'] < $row['date'] && $row['author_id'] != $user_info['id'],
'link' => $scripturl . '?page=' . $row['alias'],
'image' => $image,
'can_show' => Subs::canShowItem($row['permissions']),
'can_show' => self::canShowItem($row['permissions']),
'can_edit' => $user_info['is_admin'] || (allowedTo('light_portal_manage') && $row['author_id'] == $user_info['id'])
);
}
Expand Down Expand Up @@ -500,26 +498,19 @@ public static function canShowItem($permissions)
*/
public static function setMeta()
{
global $context, $modSettings, $settings, $smcFunc;
global $context, $modSettings, $settings;

if (empty($context['lp_page']))
return;

$context['meta_description'] = $context['lp_page']['description'];
$modSettings['meta_keywords'] = $context['lp_page']['keywords'];
$context['optimus_og_type']['article']['published_time'] = date('Y-m-d\TH:i:s', $context['lp_page']['created_at']);
$context['optimus_og_type']['article']['modified_time'] = date('Y-m-d\TH:i:s', $context['lp_page']['updated_at']);

// Looking for an image in the page content
// Ищем ссылку на последнее изображение в тексте страницы
if (!empty($modSettings['lp_page_og_image'])) {
$image_found = preg_match_all('/<img(.*)src(.*)=(.*)"(.*)"/U', $context['lp_page']['content'], $values);
if ($image_found && is_array($values)) {
$all_images = array_pop($values);
$image = $modSettings['lp_page_og_image'] == 1 ? array_shift($all_images) : array_pop($all_images);
$settings['og_image'] = $smcFunc['htmlspecialchars']($image);
}
}
$context['meta_description'] = $context['lp_page']['description'];
$context['optimus_og_type']['article']['published_time'] = date('c', $context['lp_page']['created_at']);
$context['optimus_og_type']['article']['modified_time'] = date('c', $context['lp_page']['updated_at']);
$context['optimus_og_type']['article']['author'] = $context['lp_page']['author'];

if (!empty($modSettings['lp_page_og_image']) && !empty($context['lp_page']['image']))
$settings['og_image'] = $context['lp_page']['image'];
}

/**
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.6
* @version 0.7
*/

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

0 comments on commit b96d32d

Please sign in to comment.