Skip to content

Commit

Permalink
v0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
dragomano committed Jan 27, 2020
1 parent 9d42033 commit 9326590
Show file tree
Hide file tree
Showing 50 changed files with 1,183 additions and 355 deletions.
42 changes: 21 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
# Light Portal
![SMF 2.1](https://img.shields.io/badge/SMF-2.1-blue.svg?style=flat&color=ed6033)
![SMF 2.1](https://img.shields.io/badge/SMF-2.1-ed6033.svg?style=flat)
![License](https://img.shields.io/github/license/dragomano/light-portal)
![PHP](https://img.shields.io/badge/php-^7.2-red.svg?style=flat&color=blue)
![PHP](https://img.shields.io/badge/PHP-^7.2-blue.svg?style=flat)
![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.3.14 / 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, 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
* Using Flexbox to output blocks
* Caching
* Support for addons
* Standalone mode.
* Blocks with multilingual titles and FontAwesome icons.
* Article system: portal pages, forum topics, or 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.
* Using Flexbox to output blocks.
* Caching.
* Support for addons.

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

### Особенности:
* Автономный режим
* Блоки с многоязычными заголовками и иконками FontAwesome
* Статьи на главной: отображение тем из выбранных разделов или страниц портала
* Доступные панели: шапка, левый и правый сайдбары, центр (верх и низ), подвал
* Drag-n-drop перетаскивание блоков между панелями, с обновлением приоритета
* Страницы с поддержкой различного контента
* Использование Flexbox для вывода блоков
* Кэширование
* Поддержка плагинов
* Автономный режим.
* Блоки с многоязычными заголовками и иконками FontAwesome.
* Статьи на главной: отображение тем, разделов или страниц портала.
* Доступные панели: шапка, левый и правый сайдбары, центр (верх и низ), подвал.
* Drag-n-drop перетаскивание блоков между панелями, с обновлением приоритета.
* Страницы с поддержкой различного контента.
* Использование Flexbox для вывода блоков.
* Кэширование.
* Поддержка плагинов.
153 changes: 74 additions & 79 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.8.1
* @version 0.9
*/

if (!defined('SMF'))
Expand Down Expand Up @@ -53,7 +53,7 @@ public static function display($area = 'portal')
Subs::parseContent($data['content'], $data['type']);

$context['lp_blocks'][$data['placement']][$item] = $data;
$icon = self::getIcon($context['lp_blocks'][$data['placement']][$item]['icon']);
$icon = Helpers::getIcon($context['lp_blocks'][$data['placement']][$item]['icon']);
$context['lp_blocks'][$data['placement']][$item]['title'] = $icon . $context['lp_blocks'][$data['placement']][$item]['title'][$context['user']['language']];
}
}
Expand Down Expand Up @@ -124,7 +124,7 @@ public static function getAll()
while ($row = $smcFunc['db_fetch_assoc']($request)) {
if (!isset($context['lp_current_blocks'][$row['placement']][$row['block_id']]))
$context['lp_current_blocks'][$row['placement']][$row['block_id']] = array(
'icon' => self::getIcon($row['icon']),
'icon' => Helpers::getIcon($row['icon']),
'type' => $row['type'],
'priority' => $row['priority'],
'permissions' => $row['permissions'],
Expand Down Expand Up @@ -174,50 +174,36 @@ private static function postActions()
*/
private static function remove()
{
global $db_type, $smcFunc;
global $smcFunc;

$item = filter_input(INPUT_POST, 'del_block', FILTER_VALIDATE_INT);

if (empty($item))
return;

if ($db_type == 'postgresql') {
$smcFunc['db_query']('', '
DELETE FROM {db_prefix}lp_blocks
WHERE block_id = {int:id}',
array(
'id' => $item
)
);
$smcFunc['db_query']('', '
DELETE FROM {db_prefix}lp_block_titles
WHERE block_id = {int:id}',
array(
'id' => $item
)
);
$smcFunc['db_query']('', '
DELETE FROM {db_prefix}lp_params
WHERE item_id = {int:id}
AND type = {string:type}',
array(
'id' => $item,
'type' => 'block'
)
);
} else {
$smcFunc['db_query']('', '
DELETE FROM {db_prefix}lp_blocks, {db_prefix}lp_block_titles, {db_prefix}lp_params
USING {db_prefix}lp_blocks
LEFT JOIN {db_prefix}lp_block_titles ON ({db_prefix}lp_block_titles.block_id = {db_prefix}lp_blocks.block_id)
LEFT JOIN {db_prefix}lp_params ON ({db_prefix}lp_params.item_id = {db_prefix}lp_blocks.block_id AND {db_prefix}lp_params.type = {string:type})
WHERE {db_prefix}lp_blocks.block_id = {int:id}',
array(
'type' => 'block',
'id' => $item
)
);
}
$smcFunc['db_query']('', '
DELETE FROM {db_prefix}lp_blocks
WHERE block_id = {int:id}',
array(
'id' => $item
)
);
$smcFunc['db_query']('', '
DELETE FROM {db_prefix}lp_block_titles
WHERE block_id = {int:id}',
array(
'id' => $item
)
);
$smcFunc['db_query']('', '
DELETE FROM {db_prefix}lp_params
WHERE item_id = {int:id}
AND type = {string:type}',
array(
'id' => $item,
'type' => 'block'
)
);
}

/**
Expand Down Expand Up @@ -547,7 +533,7 @@ private static function prepareFormFields()
$context['posting_fields']['icon']['label']['after'] = $txt['lp_block_icon_cheatsheet'];
$context['posting_fields']['icon']['input'] = array(
'type' => 'text',
'after' => '<span id="block_icon">' . self::getIcon() . '</span>',
'after' => '<span id="block_icon">' . Helpers::getIcon() . '</span>',
'attributes' => array(
'id' => 'icon',
'maxlength' => 30,
Expand All @@ -566,10 +552,17 @@ private static function prepareFormFields()
);

foreach ($txt['lp_block_placement_set'] as $level => $title) {
$context['posting_fields']['placement']['input']['options'][$title] = array(
'value' => $level,
'selected' => $level == $context['lp_block']['placement']
);
if (!defined('JQUERY_VERSION')) {
$context['posting_fields']['placement']['input']['options'][$title]['attributes'] = array(
'value' => $level,
'selected' => $level == $context['lp_block']['placement']
);
} else {
$context['posting_fields']['placement']['input']['options'][$title] = array(
'value' => $level,
'selected' => $level == $context['lp_block']['placement']
);
}
}

$context['posting_fields']['permissions']['label']['text'] = $txt['edit_permissions'];
Expand All @@ -582,10 +575,17 @@ private static function prepareFormFields()
);

foreach ($txt['lp_permissions'] as $level => $title) {
$context['posting_fields']['permissions']['input']['options'][$title] = array(
'value' => $level,
'selected' => $level == $context['lp_block']['permissions']
);
if (!defined('JQUERY_VERSION')) {
$context['posting_fields']['permissions']['input']['options'][$title]['attributes'] = array(
'value' => $level,
'selected' => $level == $context['lp_block']['permissions']
);
} else {
$context['posting_fields']['permissions']['input']['options'][$title] = array(
'value' => $level,
'selected' => $level == $context['lp_block']['permissions']
);
}
}

$context['posting_fields']['areas']['label']['text'] = $txt['lp_block_areas'];
Expand All @@ -610,10 +610,17 @@ private static function prepareFormFields()
);

foreach ($context['lp_all_title_classes'] as $key => $data) {
$context['posting_fields']['title_class']['input']['options'][$key] = array(
'value' => $key,
'selected' => $key == $context['lp_block']['title_class']
);
if (!defined('JQUERY_VERSION')) {
$context['posting_fields']['title_class']['input']['options'][$key]['attributes'] = array(
'value' => $key,
'selected' => $key == $context['lp_block']['title_class']
);
} else {
$context['posting_fields']['title_class']['input']['options'][$key] = array(
'value' => $key,
'selected' => $key == $context['lp_block']['title_class']
);
}
}

$context['posting_fields']['title_style']['label']['text'] = $txt['lp_block_title_style'];
Expand All @@ -637,10 +644,17 @@ private static function prepareFormFields()
);

foreach ($context['lp_all_content_classes'] as $key => $data) {
$context['posting_fields']['content_class']['input']['options'][$key] = array(
'value' => $key,
'selected' => $key == $context['lp_block']['content_class']
);
if (!defined('JQUERY_VERSION')) {
$context['posting_fields']['content_class']['input']['options'][$key]['attributes'] = array(
'value' => $key,
'selected' => $key == $context['lp_block']['content_class']
);
} else {
$context['posting_fields']['content_class']['input']['options'][$key] = array(
'value' => $key,
'selected' => $key == $context['lp_block']['content_class']
);
}
}

$context['posting_fields']['content_style']['label']['text'] = $txt['lp_block_content_style'];
Expand All @@ -659,6 +673,7 @@ private static function prepareFormFields()
$context['posting_fields']['content']['input'] = array(
'type' => 'textarea',
'attributes' => array(
'id' => 'content',
'maxlength' => Helpers::getMaxMessageLength(),
'value' => $context['lp_block']['content']
)
Expand Down Expand Up @@ -721,7 +736,7 @@ private static function showPreview()
Subs::parseContent($context['preview_content'], $context['lp_block']['type']);

$context['page_title'] = $txt['preview'] . ($context['preview_title'] ? ' - ' . $context['preview_title'] : '');
$context['preview_title'] = Helpers::getPreviewTitle(self::getIcon());
$context['preview_title'] = Helpers::getPreviewTitle(Helpers::getIcon());
}

/**
Expand Down Expand Up @@ -984,24 +999,4 @@ public static function getData($item)

return $data;
}

/**
* Get the block icon
*
* Получаем иконку блока
*
* @param string $icon
* @return string
*/
public static function getIcon($icon = null)
{
global $context;

$icon = $icon ?? ($context['lp_block']['icon'] ?? '');

if (!empty($icon))
return '<i class="fas fa-' . $icon . '"></i> ';
else
return '';
}
}
25 changes: 22 additions & 3 deletions 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.8
* @version 0.9
*/

if (!defined('SMF'))
Expand Down Expand Up @@ -188,7 +188,6 @@ public static function getFriendlyTime(int $a)
$last = round(($sec) / 60);

// Future time?
// Будущее время?
if ($a > $time) {
$days = ($a - $time) / 60 / 60 / 24;

Expand All @@ -215,7 +214,7 @@ public static function getFriendlyTime(int $a)
return $txt['yesterday'] . $tm;
elseif ($y == date('Y', $time))
return $d . ' ' . $txt['months'][date('n', $a)] . ', ' . $tm;
elseif ($tm == '00:00')
elseif ($tm == '00:00' || $y < date('Y', $time))
return $d . ' ' . $txt['months'][date('n', $a)] . ' ' . $y;
else
return timeformat($a);
Expand Down Expand Up @@ -267,4 +266,24 @@ public static function findMissingBlockTypes($type)
if (empty($txt['lp_block_types'][$type]))
$context['lp_missing_block_types'][$type] = sprintf($txt['lp_addon_not_installed'], str_replace('_', '', ucwords($type, '_')));
}

/**
* Get the block icon
*
* Получаем иконку блока
*
* @param string $icon
* @return string
*/
public static function getIcon($icon = null)
{
global $context;

$icon = $icon ?? ($context['lp_block']['icon'] ?? '');

if (!empty($icon))
return '<i class="fas fa-' . $icon . '"></i> ';
else
return '';
}
}
Loading

0 comments on commit 9326590

Please sign in to comment.