From 1875c27713348f4a9fa61f5584b68e493740f71a Mon Sep 17 00:00:00 2001 From: Bugo Date: Sun, 19 Jan 2020 03:48:14 +0500 Subject: [PATCH] v0.6 --- Sources/LightPortal/Block.php | 64 +++- Sources/LightPortal/Helpers.php | 60 +++- Sources/LightPortal/Integration.php | 46 ++- Sources/LightPortal/Page.php | 186 +++++++---- Sources/LightPortal/Settings.php | 51 ++- Sources/LightPortal/Subs.php | 295 +++++++++++++++--- .../addons/BoardList/BoardList.php | 41 ++- .../GoogleTranslate/GoogleTranslate.php | 73 +++++ .../addons/GoogleTranslate/index.php | 9 + .../addons/GoogleTranslate/langs/english.php | 4 + .../addons/GoogleTranslate/langs/index.php | 9 + .../addons/GoogleTranslate/langs/russian.php | 4 + .../GoogleTranslate/langs/ukrainian.php | 4 + Sources/LightPortal/addons/Likely/Likely.php | 4 +- .../addons/Parsedown/Parsedown.php | 2 +- .../addons/RecentPosts/RecentPosts.php | 74 ++++- .../addons/RecentPosts/langs/english.php | 4 +- .../addons/RecentPosts/langs/russian.php | 4 +- .../addons/RecentPosts/langs/ukrainian.php | 4 +- .../addons/RecentTopics/RecentTopics.php | 41 ++- Sources/LightPortal/addons/SimpleMDE.php | 2 +- .../addons/ThemeSwitcher/ThemeSwitcher.php | 54 ++-- .../addons/TopBoards/TopBoards.php | 49 ++- .../addons/TopBoards/langs/english.php | 5 +- .../addons/TopBoards/langs/russian.php | 5 +- .../addons/TopBoards/langs/ukrainian.php | 5 +- .../addons/TopPosters/TopPosters.php | 45 ++- .../addons/TopPosters/langs/english.php | 7 +- .../addons/TopPosters/langs/russian.php | 7 +- .../addons/TopPosters/langs/ukrainian.php | 7 +- .../addons/TopTopics/TopTopics.php | 55 +++- .../addons/TopTopics/langs/english.php | 11 +- .../addons/TopTopics/langs/russian.php | 11 +- .../addons/TopTopics/langs/ukrainian.php | 11 +- Sources/LightPortal/addons/Trumbowyg.php | 2 +- .../YandexTranslate/YandexTranslate.php | 143 +++++++++ .../addons/YandexTranslate/index.php | 9 + .../addons/YandexTranslate/langs/english.php | 7 + .../addons/YandexTranslate/langs/index.php | 9 + .../addons/YandexTranslate/langs/russian.php | 7 + .../YandexTranslate/langs/ukrainian.php | 7 + .../default/LightPortal/Credits.template.php | 7 +- .../LightPortal/ManageBlocks.template.php | 29 +- .../LightPortal/ManagePages.template.php | 14 +- .../LightPortal/ViewBlock.template.php | 9 +- .../default/LightPortal/ViewPage.template.php | 172 +++++++++- .../default/css/light_portal/light_portal.css | 31 +- Themes/default/images/lp_default_image.png | Bin 0 -> 155 bytes .../languages/LightPortal/.english.php | 17 +- .../languages/LightPortal/.russian.php | 17 +- .../languages/LightPortal/.ukrainian.php | 17 +- .../light_portal/jquery.matchHeight-min.js | 12 + package-info.xml | 2 +- 53 files changed, 1418 insertions(+), 346 deletions(-) create mode 100644 Sources/LightPortal/addons/GoogleTranslate/GoogleTranslate.php create mode 100644 Sources/LightPortal/addons/GoogleTranslate/index.php create mode 100644 Sources/LightPortal/addons/GoogleTranslate/langs/english.php create mode 100644 Sources/LightPortal/addons/GoogleTranslate/langs/index.php create mode 100644 Sources/LightPortal/addons/GoogleTranslate/langs/russian.php create mode 100644 Sources/LightPortal/addons/GoogleTranslate/langs/ukrainian.php create mode 100644 Sources/LightPortal/addons/YandexTranslate/YandexTranslate.php create mode 100644 Sources/LightPortal/addons/YandexTranslate/index.php create mode 100644 Sources/LightPortal/addons/YandexTranslate/langs/english.php create mode 100644 Sources/LightPortal/addons/YandexTranslate/langs/index.php create mode 100644 Sources/LightPortal/addons/YandexTranslate/langs/russian.php create mode 100644 Sources/LightPortal/addons/YandexTranslate/langs/ukrainian.php create mode 100644 Themes/default/images/lp_default_image.png create mode 100644 Themes/default/scripts/light_portal/jquery.matchHeight-min.js diff --git a/Sources/LightPortal/Block.php b/Sources/LightPortal/Block.php index 69b36de0c..84ebca904 100644 --- a/Sources/LightPortal/Block.php +++ b/Sources/LightPortal/Block.php @@ -11,7 +11,7 @@ * @copyright 2019-2020 Bugo * @license https://opensource.org/licenses/BSD-3-Clause BSD * - * @version 0.5 + * @version 0.6 */ if (!defined('SMF')) @@ -21,6 +21,7 @@ class Block { /** * Display blocks in their designated areas + * * Отображаем блоки в предназначенных им областях * * @param string $area @@ -28,7 +29,7 @@ class Block */ public static function display($area = 'portal') { - global $context; + global $context, $modSettings; if (empty($context['template_layers'])) return; @@ -38,7 +39,7 @@ public static function display($area = 'portal') return isset($block['areas']['all']) || isset($block['areas'][$area]) || isset($block['areas']['page=' . filter_input(INPUT_GET, 'page', FILTER_SANITIZE_STRING)]); }); - if (empty($blocks)) + if (empty($blocks) || (!empty($modSettings['lp_hide_blocks_in_admin_section']) && $context['current_action'] == 'admin')) return; foreach ($blocks as $item => $data) { @@ -59,7 +60,6 @@ public static function display($area = 'portal') loadTemplate('LightPortal/ViewBlock'); - // Zen for layers | Дзен для слоев $counter = 0; foreach ($context['template_layers'] as $position => $name) { $counter++; @@ -76,6 +76,7 @@ public static function display($area = 'portal') /** * Manage blocks + * * Управление блоками * * @return void @@ -102,6 +103,7 @@ public static function manage() /** * Get a list of all blocks sorted by placement + * * Получаем список всех блоков с разбивкой по размещению * * @return void @@ -131,6 +133,7 @@ public static function getAll() ); $context['lp_current_blocks'][$row['placement']][$row['block_id']]['title'][$row['lang']] = $row['title']; + Helpers::findMissingBlockTypes($row['type']); } $smcFunc['db_free_result']($request); @@ -138,6 +141,7 @@ public static function getAll() /** * Possible actions with blocks + * * Возможные действия с блоками * * @return void @@ -163,6 +167,7 @@ private static function postActions() /** * Deleting a block + * * Удаление блока * * @return void @@ -214,6 +219,7 @@ private static function remove() /** * Changing the block status + * * Смена статуса блока * * @param int $item @@ -240,6 +246,7 @@ public static function toggleStatus($item, $status) /** * Update priority + * * Обновление приоритета * * @return void @@ -290,6 +297,7 @@ private static function updatePriority() /** * Adding a block + * * Добавление блока * * @return void @@ -330,6 +338,7 @@ public static function add() /** * Editing a block + * * Редактирование блока * * @return void @@ -375,6 +384,7 @@ public static function edit() /** * Get the parameters of all blocks + * * Получаем параметры всех блоков * * @return array @@ -400,6 +410,7 @@ private static function getOptions() /** * Validating the sent data + * * Валидируем отправляемые данные * * @return void @@ -438,6 +449,10 @@ private static function validateData() } $options = self::getOptions(); + + if (empty($options[$context['current_block']['type']])) + $options[$context['current_block']['type']] = []; + $block_options = $context['current_block']['options'] ?? $options; $context['lp_block'] = array( @@ -474,6 +489,7 @@ private static function validateData() /** * Check that the fields are filled in correctly + * * Проверям правильность заполнения полей * * @param array $data @@ -499,6 +515,7 @@ private static function findErrors($data) /** * Adding special fields to the form + * * Добавляем свои поля для формы * * @return void @@ -652,6 +669,7 @@ private static function prepareFormFields() /** * Run the desired editor + * * Подключаем нужный редактор * * @return void @@ -666,6 +684,7 @@ private static function prepareEditor() /** * Preview + * * Предварительный просмотр * * @return void @@ -695,8 +714,39 @@ private static function showPreview() $context['preview_title'] = self::getIcon() . Helpers::getPreviewTitle(); } + /** + * Get correct priority for a new block + * + * Получаем правильный приоритет для нового блока + * + * @param string $placement + * @return int + */ + private static function calculatePriority($placement) + { + global $smcFunc; + + if (empty($placement)) + return 0; + + $request = $smcFunc['db_query']('', ' + SELECT MAX(priority) + 1 + FROM {db_prefix}lp_blocks + WHERE placement = {string:placement}', + array( + 'placement' => $placement + ) + ); + + list ($priority) = $smcFunc['db_fetch_row']($request); + $smcFunc['db_free_result']($request); + + return $priority; + } + /** * Creating or updating a block + * * Создаем или обновляем блок * * @param int $item @@ -714,6 +764,8 @@ public static function setData($item = null) if (empty($item)) { $max_length = Helpers::getMaxMessageLength(); + $priority = self::calculatePriority($context['lp_block']['placement']); + $item = $smcFunc['db_insert']('', '{db_prefix}lp_blocks', array( @@ -734,7 +786,7 @@ public static function setData($item = null) $context['lp_block']['type'], $context['lp_block']['content'], $context['lp_block']['placement'], - $context['lp_block']['priority'], + $context['lp_block']['priority'] ?: $priority, $context['lp_block']['permissions'], $context['lp_block']['areas'], $context['lp_block']['title_class'], @@ -860,6 +912,7 @@ public static function setData($item = null) /** * Get the block fields + * * Получаем поля блока * * @param mixed $item @@ -924,6 +977,7 @@ public static function getData($item) /** * Get the block icon + * * Получаем иконку блока * * @param string $icon diff --git a/Sources/LightPortal/Helpers.php b/Sources/LightPortal/Helpers.php index 261939c4b..7bd402838 100644 --- a/Sources/LightPortal/Helpers.php +++ b/Sources/LightPortal/Helpers.php @@ -11,7 +11,7 @@ * @copyright 2019-2020 Bugo * @license https://opensource.org/licenses/BSD-3-Clause BSD * - * @version 0.5 + * @version 0.6 */ if (!defined('SMF')) @@ -21,6 +21,7 @@ class Helpers { /** * Get language of the current user + * * Получаем язык текущего пользователя * * @return string @@ -34,6 +35,7 @@ public static function getUserLanguage() /** * Get the maximum possible length of the message, in accordance with the settings of the forum + * * Получаем максимально возможную длину сообщения, в соответствии с настройками форума * * @return int @@ -47,6 +49,7 @@ public static function getMaxMessageLength() /** * Remove BBCode from transmitted data + * * Убираем ББ-код из переданных данных * * @param array|string $data @@ -62,6 +65,7 @@ public static function cleanBbcode($data) /** * Get a title for preview block + * * Получаем заголовок блока превью * * @return string @@ -75,6 +79,7 @@ public static function getPreviewTitle() /** * Get text within span that is floating by defined direction + * * Получаем текст внутри тега span, с float = $direction (left|right) * * @param string $text @@ -88,7 +93,9 @@ private static function getFloatSpan($text, $direction = 'left') /** * The correct declination of words + * * Правильное склонение слов + * * https://developer.mozilla.org/en-US/docs/Mozilla/Localization/Localization_and_Plurals * http://docs.translatehouse.org/projects/localization-guide/en/latest/l10n/pluralforms.html * @@ -162,6 +169,7 @@ public static function correctDeclension(int $num, $str) /** * Get the time in the format "Yesterday", "Today", "X minutes ago", etc. + * * Получаем время в формате «Вчера», «Сегодня», «X минут назад» и т. д. * * @param integer $a — Unix time @@ -179,7 +187,8 @@ public static function getFriendlyTime(int $a) $sec = $time - $a; $last = round(($sec) / 60); - // Future time? | Будущее время? + // Future time? + // Будущее время? if ($a > $time) { $days = ($a - $time) / 60 / 60 / 24; @@ -211,4 +220,51 @@ public static function getFriendlyTime(int $a) else return timeformat($a); } + + /** + * Using cache + * + * Используем кэш + * + * @param string $data + * @param string $getData + * @param string $class + * @param int $time (in seconds) + * @param array $vars + * @return mixed + */ + public static function useCache($data, $getData, $class = 'self', $time = 3600, $vars = []) + { + if (($$data = cache_get_data('light_portal_' . $data, $time)) == null) { + $$data = null; + + if (method_exists($class, $getData)) { + if ($class == 'self') + $$data = self::$getData($vars); + else + $$data = $class::$getData($vars); + } elseif (function_exists($getData)) { + $$data = $getData($vars);} + + cache_put_data('light_portal_' . $data, $$data, $time); + } + + return $$data; + } + + /** + * Form a list of addons that not installed + * + * Формируем список неустановленных плагинов + * + * @param string $type + * @return void + */ + public static function findMissingBlockTypes($type) + { + global $txt, $context; + + if (empty($txt['lp_block_types'][$type])) + $context['lp_missing_block_types'][$type] = sprintf($txt['lp_addon_not_installed'], str_replace('_', '', ucwords($type, '_'))); + } } diff --git a/Sources/LightPortal/Integration.php b/Sources/LightPortal/Integration.php index 090bce517..da6ef176d 100644 --- a/Sources/LightPortal/Integration.php +++ b/Sources/LightPortal/Integration.php @@ -11,7 +11,7 @@ * @copyright 2019-2020 Bugo * @license https://opensource.org/licenses/BSD-3-Clause BSD * - * @version 0.5 + * @version 0.6 */ if (!defined('SMF')) @@ -21,6 +21,7 @@ class Integration { /** * Used hooks + * * Подключаем используемые хуки * * @return void @@ -45,6 +46,7 @@ public static function hooks() /** * Setup for autoloading of used classes + * * Настраиваем поиск файлов используемых классов для автоподключения * * @param array $classMap @@ -58,6 +60,7 @@ public static function autoload(&$classMap) /** * Determine used constants + * * Определяем необходимые константы * * @return void @@ -67,7 +70,7 @@ public static function userInfo() global $sourcedir; $lp_constants = [ - 'LP_VERSION' => '0.5', + 'LP_VERSION' => '0.6', 'LP_NAME' => 'Light Portal', 'LP_ADDONS' => $sourcedir . '/LightPortal/addons' ]; @@ -78,6 +81,7 @@ public static function userInfo() /** * Load the mod languages, addons, blocks & styles + * * Подключаем языковой файл, скрипты и стили, используемые модом * * @return void @@ -98,6 +102,7 @@ public static function loadTheme() /** * Add "action=portal" + * * Подключаем action «portal» * * @param array $actions @@ -107,10 +112,11 @@ public static function actions(&$actions) { global $context, $modSettings; - if (!empty($modSettings['lp_main_page_disable'])) + if (!empty($modSettings['lp_frontpage_disable'])) return; - // Fix for Pretty URLs | Если установлен Pretty URLs, добавляем обработку области "portal" + // Fix for Pretty URLs + // Если установлен Pretty URLs, добавляем обработку области "portal" if (!empty($context['pretty']['action_array'])) { if (!in_array('portal', array_values($context['pretty']['action_array']))) $context['pretty']['action_array'][] = 'portal'; @@ -129,6 +135,7 @@ public static function actions(&$actions) /** * Access the page or call the default method + * * Обращаемся к странице или вызываем метод по умолчанию * * @return void @@ -142,7 +149,7 @@ public static function defaultAction() return Page::show($alias); } - if (empty($modSettings['lp_main_page_disable'])) + if (empty($modSettings['lp_frontpage_disable'])) return Page::show(); require_once($sourcedir . '/BoardIndex.php'); @@ -152,6 +159,7 @@ public static function defaultAction() /** * Add a selection of the "Forum" menu item when viewing boards and topics + * * Добавляем выделение кнопки «Форум» при просмотре разделов и тем * * @param string $current_action @@ -161,7 +169,7 @@ public static function currentAction(&$current_action) { global $modSettings, $context; - if (!empty($modSettings['lp_main_page_disable'])) + if (!empty($modSettings['lp_frontpage_disable'])) return; if (empty($_REQUEST['action'])) @@ -173,6 +181,7 @@ public static function currentAction(&$current_action) /** * Manage the display of items in the main menu + * * Управляем отображением пунктов в главном меню * * @param array $buttons @@ -187,7 +196,8 @@ public static function menuButtons(&$buttons) $context['allow_light_portal_manage'] = allowedTo('light_portal_manage'); - // Display "Portal settings" in Main Menu => Admin | Отображение пункта "Настройки портала" + // Display "Portal settings" in Main Menu => Admin + // Отображение пункта "Настройки портала" if ($context['allow_light_portal_manage']) { $buttons['admin']['show'] = true; $counter = 0; @@ -236,13 +246,14 @@ public static function menuButtons(&$buttons) if (!empty($context['current_action'])) Block::display($context['current_action']); - else if (!empty($_REQUEST['board']) || !empty($_REQUEST['topic']) || (!empty($modSettings['lp_main_page_disable']) && empty($context['current_action']) && empty($_GET['page']))) + else if (!empty($_REQUEST['board']) || !empty($_REQUEST['topic']) || (!empty($modSettings['lp_frontpage_disable']) && empty($context['current_action']) && empty($_GET['page']))) Block::display('forum'); - if (!empty($modSettings['lp_main_page_disable'])) + if (!empty($modSettings['lp_frontpage_disable'])) return; - // Display "Portal" item in Main Menu | Отображение пункта "Портал" + // Display "Portal" item in Main Menu + // Отображение пункта "Портал" $buttons = array_merge( array_slice($buttons, 0, 0, true), array( @@ -258,13 +269,14 @@ public static function menuButtons(&$buttons) array_slice($buttons, 0, null, true) ); - // "Forum" | "Форум" + // "Forum" $buttons['home']['title'] = $txt['lp_forum']; $buttons['home']['href'] = $scripturl . '?action=forum'; $buttons['home']['icon'] = 'im_on'; $buttons['home']['is_last'] = false; - // Standalone mode | Автономный режим + // Standalone mode + // Автономный режим if (!empty($modSettings['lp_standalone'])) { $buttons['home']['title'] = $txt['lp_portal']; $buttons['home']['href'] = $scripturl; @@ -288,7 +300,8 @@ public static function menuButtons(&$buttons) Subs::unsetUnusedActions($buttons); } - // Correct canonical urls | Правильные канонические адреса + // Correct canonical urls + // Правильные канонические адреса if ($context['current_action'] == 'portal' || (empty($context['current_action']) && empty($_REQUEST['page']))) $context['canonical_url'] = $scripturl; if ($context['current_action'] == 'forum') @@ -297,6 +310,7 @@ public static function menuButtons(&$buttons) /** * Guests cannot to manage the portal! + * * Гости могут только просматривать портал * * @return void @@ -315,6 +329,7 @@ public static function loadIllegalGuestPermissions() /** * Determine permissions + * * Определяем права доступа * * @param array $permissionGroups @@ -332,6 +347,7 @@ public static function loadPermissions(&$permissionGroups, &$permissionList, &$l /** * We reset the cache when changing user data (for example, when a user is changing the current language) + * * Сбрасываем кэш при изменении пользовательских данных (например, текущего языка) * * @return void @@ -343,6 +359,7 @@ public static function changeMemberData() /** * The mod credits for action=credits + * * Отображаем копирайты на странице action=credits * * @return void @@ -368,6 +385,7 @@ public static function credits() /** * Display current actions of members (on portal area) + * * Показываем, кто что делает на портале * * @param array $actions @@ -378,7 +396,7 @@ public static function whosOnline($actions) global $modSettings, $txt, $scripturl; $result = ''; - if (empty($modSettings['lp_main_page_disable'])) { + if (empty($modSettings['lp_frontpage_disable'])) { if (empty($actions['action'])) $result = sprintf($txt['lp_who_main'], $scripturl); diff --git a/Sources/LightPortal/Page.php b/Sources/LightPortal/Page.php index 21f23db63..f17639d09 100644 --- a/Sources/LightPortal/Page.php +++ b/Sources/LightPortal/Page.php @@ -11,7 +11,7 @@ * @copyright 2019-2020 Bugo * @license https://opensource.org/licenses/BSD-3-Clause BSD * - * @version 0.5 + * @version 0.6 */ if (!defined('SMF')) @@ -21,6 +21,7 @@ class Page { /** * The page name must begin with a Latin letter and consist of lowercase Latin letters and numbers + * * Имя страницы должно начинаться с латинской буквы и состоять из строчных латинских букв и цифр * * @var string @@ -29,6 +30,7 @@ class Page /** * Display the page by its alias + * * Просматриваем страницу по её алиасу * * @param string $alias @@ -55,7 +57,7 @@ public static function show($alias = '/') Block::display(); if ($alias === '/') { - $context['page_title'] = $modSettings['lp_main_page_title_' . $context['user']['language']] ?? $txt['lp_portal']; + $context['page_title'] = $modSettings['lp_frontpage_title_' . $context['user']['language']] ?? $txt['lp_portal']; } else { $context['page_title'] = $context['lp_page']['title']; $context['canonical_url'] = $scripturl . '?page=' . $alias; @@ -65,9 +67,23 @@ public static function show($alias = '/') 'name' => $context['page_title'] ); - $context['sub_template'] = 'show_page'; - - self::updateNumViews(); + if (!empty($modSettings['lp_frontpage_mode']) && empty($_GET['page'])) { + $limit = !empty($modSettings['lp_num_per_page']) ? (int) $modSettings['lp_num_per_page'] : 10; + $context['lp_frontpage_layout'] = 12 / (!empty($modSettings['lp_frontpage_layout']) ? (int) $modSettings['lp_frontpage_layout'] : 2); + if ($limit == 1) + $context['lp_frontpage_layout'] = 12; + + if ($modSettings['lp_frontpage_mode'] == 1) { + Subs::prepareArticles('topics'); + $context['sub_template'] = 'show_topics_as_articles'; + } else { + Subs::prepareArticles(); + $context['sub_template'] = 'show_pages_as_articles'; + } + } else { + $context['sub_template'] = 'show_page'; + self::updateNumViews(); + } if (isset($_REQUEST['page'])) { if ($_REQUEST['page'] !== $alias) @@ -79,6 +95,7 @@ public static function show($alias = '/') /** * Manage pages + * * Управление страницами * * @return void @@ -101,9 +118,11 @@ public static function manage() self::postActions(); + $context['lp_main_page'] = self::getData('/'); + $listOptions = array( 'id' => 'pages', - 'items_per_page' => $modSettings['lp_num_per_page'] ?? 10, + 'items_per_page' => 10, 'title' => $txt['lp_extra_pages'], 'no_items_label' => $txt['lp_no_items'], 'base_href' => $scripturl . '?action=admin;area=lp_pages', @@ -148,7 +167,7 @@ public static function manage() 'data' => array( 'function' => function ($entry) use ($txt) { - return $txt['lp_page_types'][$entry['type']]; + return $txt['lp_page_types'][$entry['type']] ?? strtoupper($entry['type']); }, 'class' => 'centertext' ), @@ -231,6 +250,7 @@ public static function manage() /** * Get the list of pages + * * Получаем список страниц * * @param int $start @@ -240,16 +260,21 @@ public static function manage() */ public static function getAll($start, $items_per_page, $sort) { - global $smcFunc, $context; + global $smcFunc, $user_info; $request = $smcFunc['db_query']('', ' - SELECT page_id, author_id, title, alias, type, status, num_views, GREATEST(created_at, updated_at) AS date - FROM {db_prefix}lp_pages' . (allowedTo('admin_forum') ? '' : ' - WHERE author_id = {int:user_id}') . ' - ORDER BY ' . $sort . ', page_id + SELECT + p.page_id, p.author_id, p.title, p.alias, p.type, p.permissions, p.status, p.num_views, + GREATEST(created_at, updated_at) AS date + 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}' . (allowedTo('admin_forum') ? '' : ' + AND p.author_id = {int:user_id}') . ' + ORDER BY ' . $sort . ', p.page_id LIMIT ' . $start . ', ' . $items_per_page, array( - 'user_id' => $context['user']['id'] + 'alias' => '/', + 'user_id' => $user_info['id'] ) ); @@ -268,26 +293,19 @@ public static function getAll($start, $items_per_page, $sort) $smcFunc['db_free_result']($request); - foreach ($items as $key => $item) { - if ($item['alias'] == '/') { - $context['lp_main_page'] = $item; - unset($items[$key]); - break; - } - } - return $items; } /** * Get the total number of pages + * * Подсчитываем общее количество страниц * * @return int */ public static function getTotalQuantity() { - global $smcFunc, $context; + global $smcFunc, $user_info; $request = $smcFunc['db_query']('', ' SELECT COUNT(page_id) @@ -296,7 +314,7 @@ public static function getTotalQuantity() AND author_id = {int:user_id}'), array( 'alias' => '/', - 'user_id' => $context['user']['id'] + 'user_id' => $user_info['id'] ) ); @@ -308,6 +326,7 @@ public static function getTotalQuantity() /** * Possible actions with pages + * * Возможные действия со страницами * * @return void @@ -322,7 +341,7 @@ private static function postActions() $status = str_replace('toggle_status ', '', $_POST['toggle_status']); if ($item == 1) - updateSettings(array('lp_main_page_disable' => $status == 'off' ? 0 : 1)); + updateSettings(array('lp_frontpage_disable' => $status == 'off' ? 0 : 1)); self::toggleStatus($item, $status == 'off' ? 1 : 0); } @@ -330,6 +349,7 @@ private static function postActions() /** * Deleting a page + * * Удаление страницы * * @param int $item @@ -353,6 +373,7 @@ private static function remove($item) /** * Changing the page status + * * Смена статуса страницы * * @param int $item @@ -379,6 +400,7 @@ public static function toggleStatus($item, $status) /** * Adding a page + * * Добавление страницы * * @return void @@ -409,6 +431,7 @@ public static function add() /** * Editing a page + * * Редактирование страницы * * @return void @@ -454,6 +477,7 @@ public static function edit() /** * Validating the sent data + * * Валидируем отправляемые данные * * @return void @@ -495,12 +519,13 @@ private static function validateData() if ($context['lp_page']['alias'] == '/') { foreach ($context['languages'] as $lang) - $context['lp_page']['title_' . $lang['filename']] = $post_data['title_' . $lang['filename']] ?? $modSettings['lp_main_page_title_' . $lang['filename']] ?? ''; + $context['lp_page']['title_' . $lang['filename']] = $post_data['title_' . $lang['filename']] ?? $modSettings['lp_frontpage_title_' . $lang['filename']] ?? ''; } } /** * Check that the fields are filled in correctly + * * Проверям правильность заполнения полей * * @param array $data @@ -546,6 +571,7 @@ private static function findErrors($data) /** * Adding special fields to the form + * * Добавляем свои поля для формы * * @return void @@ -664,6 +690,7 @@ private static function prepareFormFields() /** * Run the desired editor + * * Подключаем нужный редактор * * @return void @@ -680,6 +707,7 @@ private static function prepareEditor() /** * Preview + * * Предварительный просмотр * * @return void @@ -710,6 +738,7 @@ private static function showPreview() /** * Creating or updating a page + * * Создаем или обновляем страницу * * @param int $item @@ -775,7 +804,7 @@ public static function setData($item = null) $main_page_title = []; foreach ($context['languages'] as $lang) - $main_page_title['lp_main_page_title_' . $lang['filename']] = $context['lp_page']['title_' . $lang['filename']]; + $main_page_title['lp_frontpage_title_' . $lang['filename']] = $context['lp_page']['title_' . $lang['filename']]; updateSettings($main_page_title); } @@ -786,6 +815,7 @@ public static function setData($item = null) /** * Get the correct autoincrement value from lp_pages table + * * Получаем правильное значение столбца page_id для создания новой записи * * @return int @@ -804,8 +834,63 @@ private static function getAutoIncrementValue() return (int) $value + 1; } + /** + * Get the page data from lp_pages table + * + * Получаем данные страницы из таблицы в базе данных + * + * @param array $params + * @return void + */ + public static function getFromPages($params) + { + global $smcFunc, $user_info; + + [$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} + LIMIT 1', + array( + 'item' => $item + ) + ); + + if ($smcFunc['db_num_rows']($request) == 0) { + header('HTTP/1.1 404 Not Found'); + fatal_lang_error('lp_page_not_found', false); + } + + while ($row = $smcFunc['db_fetch_assoc']($request)) { + censorText($row['content']); + + $data = array( + 'id' => $row['page_id'], + 'author_id' => $row['author_id'], + 'title' => $row['title'], + 'alias' => $row['alias'], + 'description' => $row['description'], + 'keywords' => $row['keywords'], + 'content' => $row['content'], + 'type' => $row['type'], + 'permissions' => $row['permissions'], + 'status' => $row['status'], + 'num_views' => $row['num_views'], + 'created_at' => $row['created_at'], + 'updated_at' => $row['updated_at'] + ); + } + + $smcFunc['db_free_result']($request); + + return $data; + } + /** * Get the page fields + * * Получаем поля страницы * * @param mixed $item @@ -814,51 +899,18 @@ private static function getAutoIncrementValue() */ public static function getData($item, $useAlias = true) { - global $smcFunc, $user_info; + global $user_info; if (empty($item)) return; - if (($data = cache_get_data('light_portal_page_' . $item, 3600)) == null) { - $request = $smcFunc['db_query']('', ' - SELECT page_id, author_id, title, alias, description, keywords, content, type, permissions, status, created_at, updated_at - FROM {db_prefix}lp_pages - WHERE ' . ($useAlias ? 'alias = {string' : 'page_id = {int') . ':item} - LIMIT 1', - array( - 'item' => $item - ) - ); + $data = Helpers::useCache('light_portal_page_' . ($item == '/' ? 'main' : $item), 'getFromPages', __CLASS__, 3600, array($item, $useAlias)); - if ($smcFunc['db_num_rows']($request) == 0) { - header('HTTP/1.1 404 Not Found'); - fatal_lang_error('lp_page_not_found', false); - } - - while ($row = $smcFunc['db_fetch_assoc']($request)) { - censorText($row['content']); - - $data = array( - 'id' => $row['page_id'], - 'author_id' => $row['author_id'], - 'title' => $row['title'], - 'alias' => $row['alias'], - 'description' => $row['description'], - 'keywords' => $row['keywords'], - 'content' => $row['content'], - 'type' => $row['type'], - 'permissions' => $row['permissions'], - 'status' => $row['status'], - 'created_at' => $row['created_at'], - 'updated_at' => $row['updated_at'], - 'can_show' => Subs::canShowItem($row['permissions']), - 'can_edit' => $user_info['is_admin'] || (allowedTo('light_portal_manage') && $row['author_id'] == $user_info['id']) - ); - } - - $smcFunc['db_free_result']($request); - - cache_put_data('light_portal_page_' . $item, $data, 3600); + if (!empty($data)) { + $data['created'] = Helpers::getFriendlyTime($data['created_at']); + $data['updated'] = Helpers::getFriendlyTime($data['updated_at']); + $data['can_show'] = Subs::canShowItem($data['permissions']); + $data['can_edit'] = $user_info['is_admin'] || (allowedTo('light_portal_manage') && $data['author_id'] == $user_info['id']); } return $data; @@ -866,6 +918,7 @@ public static function getData($item, $useAlias = true) /** * We check whether there is already such an alias in the database + * * Проверяем, нет ли уже такого алиаса в базе * * @param array $data @@ -894,6 +947,7 @@ private static function isUnique($data) /** * Increasing the number of page views + * * Увеличиваем количество просмотров страницы * * @return void diff --git a/Sources/LightPortal/Settings.php b/Sources/LightPortal/Settings.php index 111a5f7fc..6fdd6bdd6 100644 --- a/Sources/LightPortal/Settings.php +++ b/Sources/LightPortal/Settings.php @@ -11,7 +11,7 @@ * @copyright 2019-2020 Bugo * @license https://opensource.org/licenses/BSD-3-Clause BSD * - * @version 0.5 + * @version 0.6 */ if (!defined('SMF')) @@ -21,6 +21,7 @@ class Settings { /** * Make a section with the mod settings in the admin panel + * * Формируем раздел с настройками мода в админке * * @param array $admin_areas @@ -33,10 +34,12 @@ public static function adminAreas(&$admin_areas) require_once($sourcedir . '/ManageSettings.php'); loadLanguage('ManageSettings'); - // Looking for the "Forum" section... | Ищем раздел "Форум"... + // Looking for the "Forum" section.. + // Ищем раздел "Форум"... $counter = array_search('layout', array_keys($admin_areas)) + 1; - // ... and add a "Portal" section from the right | ... и добавляем справа раздел "Портал" + // ... and add a "Portal" section from the right + //... и добавляем справа раздел "Портал" $admin_areas = array_merge( array_slice($admin_areas, 0, $counter, true), array( @@ -86,6 +89,7 @@ public static function adminAreas(&$admin_areas) /** * Easy access to the mod settings via a quick search in the admin panel + * * Легкий доступ к настройкам мода через быстрый поиск в админке * * @param array $language_files @@ -100,6 +104,7 @@ public static function adminSearch(&$language_files, &$include_files, &$settings /** * Output general settings + * * Выводим общие настройки * * @param boolean $return_config @@ -122,12 +127,19 @@ public static function settingArea($return_config = false) $context['settings_title'] = $txt['settings']; $context['post_url'] = $scripturl . '?action=admin;area=lp_settings;save'; - // Initial settings | Устанавливаем первоначальные настройки + // Initial settings + // Устанавливаем первоначальные настройки $add_settings = []; - if (!isset($modSettings['lp_standalone_excluded_actions'])) - $add_settings['lp_standalone_excluded_actions'] = 'home,admin,profile,pm,signup,logout'; + if (!isset($modSettings['lp_frontpage_layout'])) + $add_settings['lp_frontpage_layout'] = 2; + if (!isset($modSettings['lp_subject_size'])) + $add_settings['lp_subject_size'] = 22; + if (!isset($modSettings['lp_teaser_size'])) + $add_settings['lp_teaser_size'] = 100; if (!isset($modSettings['lp_num_per_page'])) $add_settings['lp_num_per_page'] = 10; + if (!isset($modSettings['lp_standalone_excluded_actions'])) + $add_settings['lp_standalone_excluded_actions'] = 'home,admin,profile,pm,signup,logout'; if (!empty($add_settings)) updateSettings($add_settings); @@ -135,19 +147,30 @@ public static function settingArea($return_config = false) $config_vars = []; foreach ($context['languages'] as $lang) { - $txt['lp_main_page_title_' . $lang['filename']] = $txt['lp_main_page_title'] . ' [' . $lang['filename'] . ']'; - $config_vars[] = array('text', 'lp_main_page_title_' . $lang['filename'], 80, 'disabled' => !empty($modSettings['lp_main_page_disable'])); + $txt['lp_frontpage_title_' . $lang['filename']] = $txt['lp_frontpage_title'] . ' [' . $lang['filename'] . ']'; + $config_vars[] = array('text', 'lp_frontpage_title_' . $lang['filename'], 80, 'disabled' => !empty($modSettings['lp_frontpage_disable'])); } + $frontpage_disabled = empty($modSettings['lp_frontpage_mode']) || !empty($modSettings['lp_frontpage_disable']); + $config_vars = array_merge( $config_vars, array( - array('check', 'lp_main_page_disable', 'disabled' => !empty($modSettings['lp_standalone'])), - array('check', 'lp_standalone', 'subtext' => $txt['lp_standalone_help'], 'disabled' => !empty($modSettings['lp_main_page_disable'])), + array('check', 'lp_frontpage_disable', 'disabled' => !empty($modSettings['lp_standalone'])), + array('select', 'lp_frontpage_mode', $txt['lp_frontpage_mode_set'], 'disabled' => !empty($modSettings['lp_frontpage_disable'])), + array('boards', 'lp_frontpage_boards', 'disabled' => $frontpage_disabled), + array('int', 'lp_frontpage_layout', 'min' => 2, 'max' => 3, 'disabled' => $frontpage_disabled), + array('check', 'lp_show_images_in_articles', 'disabled' => $frontpage_disabled), + array('int', 'lp_subject_size', 'min' => 0, 'disabled' => $frontpage_disabled), + array('int', 'lp_teaser_size', 'min' => 0, 'disabled' => $frontpage_disabled), + array('int', 'lp_num_per_page', 'disabled' => $frontpage_disabled), + '', + array('check', 'lp_standalone', 'subtext' => $txt['lp_standalone_help'], 'disabled' => !empty($modSettings['lp_frontpage_disable'])), 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('int', 'lp_num_per_page'), array('select', 'lp_page_og_image', $txt['lp_page_og_image_set']), + array('check', 'lp_hide_blocks_in_admin_section'), array('title', 'edit_permissions'), array('permissions', 'light_portal_view'), array('permissions', 'light_portal_manage') @@ -165,7 +188,7 @@ public static function settingArea($return_config = false) $save_vars = $config_vars; saveDBSettings($save_vars); - Page::toggleStatus(1, isset($_POST['lp_main_page_disable']) ? 0 : 1); + Page::toggleStatus(1, isset($_POST['lp_frontpage_disable']) ? 0 : 1); clean_cache(); redirectexit('action=admin;area=lp_settings'); @@ -176,6 +199,7 @@ public static function settingArea($return_config = false) /** * Getting information about the database engine/version + * * Получаем информацию о движке и версии базы данных * * @return array @@ -189,6 +213,7 @@ private static function getDbInfo() /** * The list of available areas to control the blocks + * * Список доступных областей для управления блоками * * @return void @@ -206,6 +231,7 @@ public static function blockArea() /** * The list of available fields to control the pages + * * Список доступных областей для управления страницами * * @return void @@ -223,6 +249,7 @@ public static function pageArea() /** * Calls the requested subaction if it does exist; otherwise, calls the default action + * * Вызывает метод, если он существует; в противном случае вызывается метод по умолчанию * * @param array $subActions diff --git a/Sources/LightPortal/Subs.php b/Sources/LightPortal/Subs.php index 330b5eeb9..2c16cf478 100644 --- a/Sources/LightPortal/Subs.php +++ b/Sources/LightPortal/Subs.php @@ -11,7 +11,7 @@ * @copyright 2019-2020 Bugo * @license https://opensource.org/licenses/BSD-3-Clause BSD * - * @version 0.5 + * @version 0.6 */ if (!defined('SMF')) @@ -20,32 +20,220 @@ class Subs { /** - * Using cache - * Используем кэш + * Form an array of articles * - * @param string $data - * @param string $getData - * @param int $time - * @return mixed + * Формируем массив статей + * + * @param string $source (pages|topics) + * @return void */ - public static function useCache($data, $getData, $time = 3600) + public static function prepareArticles($source = 'pages') { - if (($$data = cache_get_data('light_portal_' . $data, $time)) == null) { - $$data = null; + global $user_info, $modSettings, $context, $scripturl; + + $articles = Helpers::useCache('frontpage_' . $source . '_u' . $user_info['id'], $source == 'topics' ? 'getTopicsFromSelectedBoards' : 'getActivePages', __CLASS__); + + $total_items = count($articles); + $limit = !empty($modSettings['lp_num_per_page']) ? (int) $modSettings['lp_num_per_page'] : 10; + $context['page_index'] = constructPageIndex($scripturl . '?action=portal', $_REQUEST['start'], $total_items, $limit); + $context['start'] = &$_REQUEST['start']; + $start = (int) $_REQUEST['start']; + + $context['lp_frontpage_articles'] = array_slice($articles, $start, $limit); + } + + /** + * Get topics from selected boards + * + * Получаем темы из выбранных разделов + * + * @return array + */ + public static function getTopicsFromSelectedBoards() + { + global $modSettings, $smcFunc, $user_info, $scripturl, $settings; + + $boards = !empty($modSettings['lp_frontpage_boards']) ? explode(',', $modSettings['lp_frontpage_boards']) : []; + + if (empty($boards)) + return []; - if (method_exists(__CLASS__, $getData)) - $$data = self::$getData(); - elseif (function_exists($getData)) - $$data = $getData(); + // Check whether compatible modifications are installed + // Проверяем, установлены ли совместимые модификации + $topic_rating_bar = class_exists('TopicRatingBar'); + $optimus = class_exists('\Bugo\Optimus\Subs') && !empty($modSettings['optimus_allow_change_desc']); - cache_put_data('light_portal_' . $data, $$data, $time); + $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' : '') . ' + 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) + LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = mf.id_member) + LEFT JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)' . ($user_info['is_guest'] ? '' : ' + 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}) + AND {query_wanna_see_board} + ORDER BY t.id_last_msg DESC', + array( + 'current_member' => $user_info['id'], + 'select_boards' => $boards + ) + ); + + $subject_size = !empty($modSettings['lp_subject_size']) ? (int) $modSettings['lp_subject_size'] : 0; + $teaser_size = !empty($modSettings['lp_teaser_size']) ? (int) $modSettings['lp_teaser_size'] : 0; + + $topics = []; + while ($row = $smcFunc['db_fetch_assoc']($request)) { + censorText($row['subject']); + censorText($row['body']); + + $rating = !empty($row['total_votes']) ? number_format($row['total_value'] / $row['total_votes'], 0) : 0; + + $image = null; + if (!empty($modSettings['lp_show_images_in_articles'])) { + $body = parse_bbc($row['body'], false); + $first_post_image = preg_match('/' . $row['name'] . '', + 'is_sticky' => !empty($row['is_sticky']), + 'is_new' => $row['new_from'] <= $row['id_msg_modified'], + 'num_views' => $row['num_views'], + 'num_replies' => $row['num_replies'], + 'css_class' => $colorClass, + 'image' => $image, + 'rating' => $rating + ); } - return $$data; + $smcFunc['db_free_result']($request); + + return $topics; + } + + /** + * Get active pages (except the main one) + * + * Получаем активные страницы + * + * @return array + */ + public static function getActivePages() + { + global $smcFunc, $txt, $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 + 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 + ) + ); + + $subject_size = !empty($modSettings['lp_subject_size']) ? (int) $modSettings['lp_subject_size'] : 0; + $teaser_size = !empty($modSettings['lp_teaser_size']) ? (int) $modSettings['lp_teaser_size'] : 0; + + $pages = []; + while ($row = $smcFunc['db_fetch_assoc']($request)) { + //Subs::parseContent($row['content'], $row['type']); + + $image = null; + if (!empty($modSettings['lp_show_images_in_articles'])) { + $first_post_image = preg_match('/' . LP_NAME . ' | © 2019–2020, Bugo | Licensed under BSD'; + return '' . LP_NAME . ' | © 2019–2020, Bugo | Licensed under the BSD 3-Clause License'; } /** * Collect information about used components + * * Формируем информацию об используемых компонентах * * @return void @@ -472,7 +653,7 @@ public static function getComponentCredits() ) ); $links[] = array( - 'title' => 'Sortable', + 'title' => 'Sortable.js', 'link' => 'https://github.com/SortableJS/Sortable', 'license' => array( 'name' => 'the MIT License (MIT)', @@ -487,8 +668,18 @@ public static function getComponentCredits() 'link' => 'https://github.com/FortAwesome/Font-Awesome/blob/master/LICENSE.txt' ) ); + $links[] = array( + 'title' => 'jquery.matchHeight.js', + 'link' => 'https://github.com/liabru/jquery-match-height', + 'author' => '2015 Liam Brummitt', + 'license' => array( + 'name' => 'the MIT License (MIT)', + 'link' => 'https://github.com/liabru/jquery-match-height/blob/master/LICENSE' + ) + ); - // Adding copyrights of used plugins | Возможность добавить копирайты используемых плагинов + // Adding copyrights of used plugins + // Возможность добавить копирайты используемых плагинов self::runAddons('credits', array(&$links)); $context['lp_components'] = $links; diff --git a/Sources/LightPortal/addons/BoardList/BoardList.php b/Sources/LightPortal/addons/BoardList/BoardList.php index 29beec6b4..e63c69d44 100644 --- a/Sources/LightPortal/addons/BoardList/BoardList.php +++ b/Sources/LightPortal/addons/BoardList/BoardList.php @@ -2,6 +2,8 @@ namespace Bugo\LightPortal\Addons\BoardList; +use Bugo\LightPortal\Helpers; + /** * BoardList * @@ -11,7 +13,7 @@ * @copyright 2019-2020 Bugo * @license https://opensource.org/licenses/BSD-3-Clause BSD * - * @version 0.5 + * @version 0.6 */ if (!defined('SMF')) @@ -121,6 +123,26 @@ public static function prepareBlockFields() } } + /** + * Получаем список разделов, с учётом прав доступа и списка игнора + * + * @return array + */ + public static function getBoardList() + { + global $sourcedir; + + require_once($sourcedir . '/Subs-MessageIndex.php'); + + $boardListOptions = array( + 'ignore_boards' => true, + 'use_permissions' => true, + 'not_redirection' => true + ); + + return getBoardList($boardListOptions); + } + /** * Формируем контент блока * @@ -131,26 +153,13 @@ public static function prepareBlockFields() */ public static function prepareContent(&$content, $type, $block_id) { - global $context, $sourcedir; + global $context; if ($type !== 'boardlist') return; $context['current_board'] = $context['current_board'] ?? 0; - - if (($context['lp_boardlist'] = cache_get_data('light_portal_boardlist_addon', 3600)) == null) { - require_once($sourcedir . '/Subs-MessageIndex.php'); - - $boardListOptions = array( - 'ignore_boards' => true, - 'use_permissions' => true, - 'not_redirection' => true - ); - - $context['lp_boardlist'] = getBoardList($boardListOptions); - - cache_put_data('light_portal_boardlist_addon', $context['lp_boardlist'], 3600); - } + $context['lp_boardlist'] = Helpers::useCache('boardlist_addon_u' . $context['user']['id'], 'getBoardList', __CLASS__); $parameters = $context['lp_active_blocks'][$block_id]['parameters'] ?? $context['lp_block']['options']['parameters']; diff --git a/Sources/LightPortal/addons/GoogleTranslate/GoogleTranslate.php b/Sources/LightPortal/addons/GoogleTranslate/GoogleTranslate.php new file mode 100644 index 000000000..60fc2ca3c --- /dev/null +++ b/Sources/LightPortal/addons/GoogleTranslate/GoogleTranslate.php @@ -0,0 +1,73 @@ + + * @copyright 2019-2020 Bugo + * @license https://opensource.org/licenses/BSD-3-Clause BSD + * + * @version 0.6 + */ + +if (!defined('SMF')) + die('Hacking attempt...'); + +class GoogleTranslate +{ + /** + * Нельзя выбрать класс для оформления контента этого блока + * + * @var bool + */ + private static $no_content_class = true; + + /** + * Добавляем параметры блока + * + * @param array $options + * @return void + */ + public static function blockOptions(&$options) + { + $options['google_translate'] = array( + 'no_content_class' => static::$no_content_class + ); + } + + /** + * Формируем контент блока + * + * @param string $content + * @param string $type + * @return void + */ + public static function prepareContent(&$content, $type) + { + global $language; + + if ($type !== 'google_translate') + return; + + ob_start(); + + echo ' + +
+
+ +
'; + + $content = ob_get_clean(); + } +} diff --git a/Sources/LightPortal/addons/GoogleTranslate/index.php b/Sources/LightPortal/addons/GoogleTranslate/index.php new file mode 100644 index 000000000..69278ce68 --- /dev/null +++ b/Sources/LightPortal/addons/GoogleTranslate/index.php @@ -0,0 +1,9 @@ + \ No newline at end of file diff --git a/Sources/LightPortal/addons/GoogleTranslate/langs/english.php b/Sources/LightPortal/addons/GoogleTranslate/langs/english.php new file mode 100644 index 000000000..f0d599000 --- /dev/null +++ b/Sources/LightPortal/addons/GoogleTranslate/langs/english.php @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/Sources/LightPortal/addons/GoogleTranslate/langs/russian.php b/Sources/LightPortal/addons/GoogleTranslate/langs/russian.php new file mode 100644 index 000000000..f4d2b3e86 --- /dev/null +++ b/Sources/LightPortal/addons/GoogleTranslate/langs/russian.php @@ -0,0 +1,4 @@ + static::$no_content_class, 'parameters' => array( - 'num_posts' => static::$num_posts + 'num_posts' => static::$num_posts, + 'link_type' => static::$type ) ); } @@ -57,7 +73,8 @@ public static function validateBlockData(&$args) return; $args['parameters'] = array( - 'num_posts' => FILTER_VALIDATE_INT + 'num_posts' => FILTER_VALIDATE_INT, + 'link_type' => FILTER_SANITIZE_STRING ); } @@ -82,6 +99,36 @@ public static function prepareBlockFields() 'value' => $context['lp_block']['options']['parameters']['num_posts'] ) ); + + $context['posting_fields']['link_type']['label']['text'] = $txt['lp_recent_posts_addon_type']; + $context['posting_fields']['link_type']['input'] = array( + 'type' => 'select', + 'attributes' => array( + 'id' => 'link_type' + ), + 'options' => array() + ); + + foreach ($txt['lp_recent_posts_addon_type_set'] as $key => $value) { + $context['posting_fields']['link_type']['input']['options'][$value] = array( + 'value' => $key, + 'selected' => $key == $context['lp_block']['options']['parameters']['link_type'] + ); + } + } + + /** + * Получаем последние сообщения форума + * + * @param int $num_posts + * @return void + */ + public static function getRecentPosts($num_posts) + { + global $boarddir; + + require_once($boarddir . '/SSI.php'); + return ssi_recentPosts($num_posts, null, null, 'array'); } /** @@ -94,29 +141,28 @@ public static function prepareBlockFields() */ public static function prepareContent(&$content, $type, $block_id) { - global $context, $boarddir, $txt; + global $context, $txt; if ($type !== 'recent_posts') return; - $parameters = $context['lp_active_blocks'][$block_id]['parameters'] ?? $context['lp_block']['options']['parameters']; - - if (($recent_posts = cache_get_data('light_portal_recent_posts_addon', 3600)) == null) { - require_once($boarddir . '/SSI.php'); - $recent_posts = ssi_recentPosts($parameters['num_posts'], null, null, 'array'); - cache_put_data('light_portal_recent_posts_addon', $recent_posts, 3600); - } + $parameters = $context['lp_active_blocks'][$block_id]['parameters'] ?? $context['lp_block']['options']['parameters']; + $recent_posts = Helpers::useCache('recent_posts_addon_u' . $context['user']['id'], 'getRecentPosts', __CLASS__, 3600, $parameters['num_posts']); ob_start(); if (!empty($recent_posts)) { echo ' -
    '; +
      '; foreach ($recent_posts as $post) { + $post['preview'] = '' . shorten_subject($post['preview'], 20) . ''; + echo ' -
    • - ', ($post['is_new'] ? '' . $txt['new'] . ' ' : ''), $post['link'], ' ', $txt['by'], ' ', $post['poster']['link'], '
      ', Helpers::getFriendlyTime($post['timestamp']), ' +
    • + ', ($post['is_new'] ? '' . $txt['new'] . ' ' : ''), $post[$parameters['link_type']], ' +
      ', $txt['by'], ' ', $post['poster']['link'], ' +
      ', Helpers::getFriendlyTime($post['timestamp']), '
    • '; } diff --git a/Sources/LightPortal/addons/RecentPosts/langs/english.php b/Sources/LightPortal/addons/RecentPosts/langs/english.php index 4acdc9751..b4265d932 100644 --- a/Sources/LightPortal/addons/RecentPosts/langs/english.php +++ b/Sources/LightPortal/addons/RecentPosts/langs/english.php @@ -3,4 +3,6 @@ $txt['lp_block_types']['recent_posts'] = 'Recent Posts'; $txt['lp_block_types_descriptions']['recent_posts'] = 'Displays a list of recent forum posts.'; -$txt['lp_recent_posts_addon_num_posts'] = 'Number of posts to display'; \ No newline at end of file +$txt['lp_recent_posts_addon_num_posts'] = 'Number of posts to display'; +$txt['lp_recent_posts_addon_type'] = 'What to display as a link to a post'; +$txt['lp_recent_posts_addon_type_set'] = array('link' => 'Message subject', 'preview' => 'Message preview'); \ No newline at end of file diff --git a/Sources/LightPortal/addons/RecentPosts/langs/russian.php b/Sources/LightPortal/addons/RecentPosts/langs/russian.php index 52ffa55ed..06a71b173 100644 --- a/Sources/LightPortal/addons/RecentPosts/langs/russian.php +++ b/Sources/LightPortal/addons/RecentPosts/langs/russian.php @@ -3,4 +3,6 @@ $txt['lp_block_types']['recent_posts'] = 'Последние сообщения'; $txt['lp_block_types_descriptions']['recent_posts'] = 'Отображает список последних сообщений форума.'; -$txt['lp_recent_posts_addon_num_posts'] = 'Количество сообщений для отображения'; \ No newline at end of file +$txt['lp_recent_posts_addon_num_posts'] = 'Количество сообщений для отображения'; +$txt['lp_recent_posts_addon_type'] = 'Что отображать в виде ссылки на пост'; +$txt['lp_recent_posts_addon_type_set'] = array('link' => 'Заголовок сообщения', 'preview' => 'Превью сообщения'); \ No newline at end of file diff --git a/Sources/LightPortal/addons/RecentPosts/langs/ukrainian.php b/Sources/LightPortal/addons/RecentPosts/langs/ukrainian.php index dd10535ae..e91102827 100644 --- a/Sources/LightPortal/addons/RecentPosts/langs/ukrainian.php +++ b/Sources/LightPortal/addons/RecentPosts/langs/ukrainian.php @@ -3,4 +3,6 @@ $txt['lp_block_types']['recent_posts'] = 'Останні повідомлення'; $txt['lp_block_types_descriptions']['recent_posts'] = 'Відображає список останніх повідомлень форуму.'; -$txt['lp_recent_posts_addon_num_posts'] = 'Кількість повідомлень для відображення'; \ No newline at end of file +$txt['lp_recent_posts_addon_num_posts'] = 'Кількість повідомлень для відображення'; +$txt['lp_recent_posts_addon_type'] = 'Що відображати у вигляді посилання на пост'; +$txt['lp_recent_posts_addon_type_set'] = array('link' => 'Заголовок повідомлення', 'preview' => 'Превью повідомлення'); \ No newline at end of file diff --git a/Sources/LightPortal/addons/RecentTopics/RecentTopics.php b/Sources/LightPortal/addons/RecentTopics/RecentTopics.php index 7d591bbb5..702267d70 100644 --- a/Sources/LightPortal/addons/RecentTopics/RecentTopics.php +++ b/Sources/LightPortal/addons/RecentTopics/RecentTopics.php @@ -13,7 +13,7 @@ * @copyright 2019-2020 Bugo * @license https://opensource.org/licenses/BSD-3-Clause BSD * - * @version 0.5 + * @version 0.6 */ if (!defined('SMF')) @@ -21,6 +21,13 @@ class RecentTopics { + /** + * Нельзя выбрать класс для оформления контента этого блока + * + * @var bool + */ + private static $no_content_class = true; + /** * Максимальное количество тем для вывода * @@ -37,6 +44,7 @@ class RecentTopics public static function blockOptions(&$options) { $options['recent_topics'] = array( + 'no_content_class' => static::$no_content_class, 'parameters' => array( 'num_topics' => static::$num_topics ) @@ -84,6 +92,20 @@ public static function prepareBlockFields() ); } + /** + * Получаем последние темы форума + * + * @param int $num_topics + * @return void + */ + public static function getRecentTopics($num_topics) + { + global $boarddir; + + require_once($boarddir . '/SSI.php'); + return ssi_recentTopics($num_topics, null, null, 'array'); + } + /** * Формируем контент блока * @@ -99,24 +121,21 @@ public static function prepareContent(&$content, $type, $block_id) if ($type !== 'recent_topics') return; - $parameters = $context['lp_active_blocks'][$block_id]['parameters'] ?? $context['lp_block']['options']['parameters']; - - if (($recent_topics = cache_get_data('light_portal_recent_topics_addon', 3600)) == null) { - require_once($boarddir . '/SSI.php'); - $recent_topics = ssi_recentTopics($parameters['num_topics'], null, null, 'array'); - cache_put_data('light_portal_recent_topics_addon', $recent_topics, 3600); - } + $parameters = $context['lp_active_blocks'][$block_id]['parameters'] ?? $context['lp_block']['options']['parameters']; + $recent_topics = Helpers::useCache('recent_topics_addon_u' . $context['user']['id'], 'getRecentTopics', __CLASS__, 3600, $parameters['num_topics']); ob_start(); if (!empty($recent_topics)) { echo ' -
        '; +
          '; foreach ($recent_topics as $topic) { echo ' -
        • - ', ($topic['is_new'] ? '' . $txt['new'] . '' : ''), $topic['icon'], ' ', $topic['link'], ' ', $txt['by'], ' ', $topic['poster']['link'], '
          ', Helpers::getFriendlyTime($topic['timestamp']), ' +
        • + ', ($topic['is_new'] ? '' . $txt['new'] . '' : ''), $topic['icon'], ' ', $topic['link'], ' +
          ', $txt['by'], ' ', $topic['poster']['link'], ' +
          ', Helpers::getFriendlyTime($topic['timestamp']), '
        • '; } diff --git a/Sources/LightPortal/addons/SimpleMDE.php b/Sources/LightPortal/addons/SimpleMDE.php index f2618cae7..28aa45a3c 100644 --- a/Sources/LightPortal/addons/SimpleMDE.php +++ b/Sources/LightPortal/addons/SimpleMDE.php @@ -11,7 +11,7 @@ * @copyright 2019-2020 Bugo * @license https://opensource.org/licenses/BSD-3-Clause BSD * - * @version 0.5 + * @version 0.6 */ if (!defined('SMF')) diff --git a/Sources/LightPortal/addons/ThemeSwitcher/ThemeSwitcher.php b/Sources/LightPortal/addons/ThemeSwitcher/ThemeSwitcher.php index 1207767c8..801ef4081 100644 --- a/Sources/LightPortal/addons/ThemeSwitcher/ThemeSwitcher.php +++ b/Sources/LightPortal/addons/ThemeSwitcher/ThemeSwitcher.php @@ -2,6 +2,8 @@ namespace Bugo\LightPortal\Addons\ThemeSwitcher; +use Bugo\LightPortal\Helpers; + /** * ThemeSwitcher * @@ -11,7 +13,7 @@ * @copyright 2019-2020 Bugo * @license https://opensource.org/licenses/BSD-3-Clause BSD * - * @version 0.5 + * @version 0.6 */ if (!defined('SMF')) @@ -20,14 +22,32 @@ class ThemeSwitcher { /** - * Добавляем параметры блока + * Получаем список активных шаблонов форума * - * @param array $options - * @return void + * @return array */ - public static function blockOptions(&$options) + public static function getAvailableThemes() { - $options['themeswitcher'] = array(); + global $smcFunc, $modSettings; + + $request = $smcFunc['db_query']('', ' + SELECT id_theme, value + FROM {db_prefix}themes + WHERE id_member = 0 + AND variable = \'name\' + AND id_theme IN ({array_int:themes})', + array( + 'themes' => explode(',', $modSettings['knownThemes']) + ) + ); + + $available_themes = []; + while ($row = $smcFunc['db_fetch_row']($request)) + $available_themes[$row[0]] = $row[1]; + + $smcFunc['db_free_result']($request); + + return $available_themes; } /** @@ -45,26 +65,7 @@ public static function prepareContent(&$content, $type, $block_id) if ($type !== 'themeswitcher') return; - if (($available_themes = cache_get_data('light_portal_themeswitcher_addon', 3600)) == null) { - $request = $smcFunc['db_query']('', ' - SELECT id_theme, value - FROM {db_prefix}themes - WHERE id_member = 0 - AND variable = \'name\' - AND id_theme IN ({array_int:themes})', - array( - 'themes' => explode(',', $modSettings['knownThemes']) - ) - ); - - $available_themes = []; - while ($row = $smcFunc['db_fetch_row']($request)) - $available_themes[$row[0]] = $row[1]; - - $smcFunc['db_free_result']($request); - - cache_put_data('light_portal_themeswitcher_addon', $available_themes, 3600); - } + $available_themes = Helpers::useCache('themeswitcher_addon', 'getAvailableThemes', __CLASS__); ob_start(); @@ -91,7 +92,6 @@ function lp_block_', $block_id, '_themeswitcher_change() { if (search != "") { search = search.replace("?", "") + ";"; } - console.log(search); window.location = smf_prepareScriptUrl(smf_scripturl) + search + "theme=" + lp_block_', $block_id, '_themeswitcher_theme_id; } '; diff --git a/Sources/LightPortal/addons/TopBoards/TopBoards.php b/Sources/LightPortal/addons/TopBoards/TopBoards.php index 16a04cc78..0fa8a04eb 100644 --- a/Sources/LightPortal/addons/TopBoards/TopBoards.php +++ b/Sources/LightPortal/addons/TopBoards/TopBoards.php @@ -13,7 +13,7 @@ * @copyright 2019-2020 Bugo * @license https://opensource.org/licenses/BSD-3-Clause BSD * - * @version 0.5 + * @version 0.6 */ if (!defined('SMF')) @@ -28,6 +28,13 @@ class TopBoards */ private static $num_boards = 10; + /** + * Отображать только цифры, или нет + * + * @var bool + */ + private static $show_numbers_only = false; + /** * Добавляем параметры блока * @@ -38,7 +45,8 @@ public static function blockOptions(&$options) { $options['top_boards'] = array( 'parameters' => array( - 'num_boards' => static::$num_boards + 'num_boards' => static::$num_boards, + 'show_numbers_only' => static::$show_numbers_only ) ); } @@ -57,7 +65,8 @@ public static function validateBlockData(&$args) return; $args['parameters'] = array( - 'num_boards' => FILTER_VALIDATE_INT + 'num_boards' => FILTER_VALIDATE_INT, + 'show_numbers_only' => FILTER_VALIDATE_BOOLEAN ); } @@ -82,6 +91,29 @@ public static function prepareBlockFields() 'value' => $context['lp_block']['options']['parameters']['num_boards'] ) ); + + $context['posting_fields']['show_numbers_only']['label']['text'] = $txt['lp_top_posters_addon_show_numbers_only']; + $context['posting_fields']['show_numbers_only']['input'] = array( + 'type' => 'checkbox', + 'attributes' => array( + 'id' => 'show_numbers_only', + 'checked' => !empty($context['lp_block']['options']['parameters']['show_numbers_only']) + ) + ); + } + + /** + * Получаем список популярных разделов + * + * @param int $num_boards + * @return void + */ + public static function getTopBoards($num_boards) + { + global $boarddir; + + require_once($boarddir . '/SSI.php'); + return ssi_topBoards($num_boards, 'array'); } /** @@ -94,18 +126,13 @@ public static function prepareBlockFields() */ public static function prepareContent(&$content, $type, $block_id) { - global $context, $boarddir, $txt; + global $context, $txt; if ($type !== 'top_boards') return; $parameters = $context['lp_active_blocks'][$block_id]['parameters'] ?? $context['lp_block']['options']['parameters']; - - if (($top_boards = cache_get_data('light_portal_top_boards_addon', 3600)) == null) { - require_once($boarddir . '/SSI.php'); - $top_boards = ssi_topBoards($parameters['num_boards'], 'array'); - cache_put_data('light_portal_top_boards_addon', $top_boards, 3600); - } + $top_boards = Helpers::useCache('top_boards_addon_u' . $context['user']['id'], 'getTopBoards', __CLASS__, 3600, $parameters['num_boards']); ob_start(); @@ -122,7 +149,7 @@ public static function prepareContent(&$content, $type, $block_id)
          ', $board['link'], '
          - ', Helpers::correctDeclension($board['num_topics'], $txt['lp_top_boards_addon_topics']), ' + ', $parameters['show_numbers_only'] ? $board['num_topics'] : Helpers::correctDeclension($board['num_topics'], $txt['lp_top_boards_addon_topics']), '
          '; } diff --git a/Sources/LightPortal/addons/TopBoards/langs/english.php b/Sources/LightPortal/addons/TopBoards/langs/english.php index 9f19deb27..6678e2a76 100644 --- a/Sources/LightPortal/addons/TopBoards/langs/english.php +++ b/Sources/LightPortal/addons/TopBoards/langs/english.php @@ -3,5 +3,6 @@ $txt['lp_block_types']['top_boards'] = 'Top Boards'; $txt['lp_block_types_descriptions']['top_boards'] = 'Displays a list of popular boards.'; -$txt['lp_top_boards_addon_num_boards'] = 'Number of boards to display'; -$txt['lp_top_boards_addon_topics'] = array('topic', 'topics'); \ No newline at end of file +$txt['lp_top_boards_addon_num_boards'] = 'Number of boards to display'; +$txt['lp_top_boards_addon_show_numbers_only'] = 'Only display numbers, without words'; +$txt['lp_top_boards_addon_topics'] = array('topic', 'topics'); \ No newline at end of file diff --git a/Sources/LightPortal/addons/TopBoards/langs/russian.php b/Sources/LightPortal/addons/TopBoards/langs/russian.php index 92c6c2803..1e8fcb31a 100644 --- a/Sources/LightPortal/addons/TopBoards/langs/russian.php +++ b/Sources/LightPortal/addons/TopBoards/langs/russian.php @@ -3,5 +3,6 @@ $txt['lp_block_types']['top_boards'] = 'Популярные разделы'; $txt['lp_block_types_descriptions']['top_boards'] = 'Отображает список популярных разделов форума.'; -$txt['lp_top_boards_addon_num_boards'] = 'Количество разделов для отображения'; -$txt['lp_top_boards_addon_topics'] = array('тема', 'темы', 'тем'); \ No newline at end of file +$txt['lp_top_boards_addon_num_boards'] = 'Количество разделов для отображения'; +$txt['lp_top_boards_addon_show_numbers_only'] = 'Отображать только цифры, без слов'; +$txt['lp_top_boards_addon_topics'] = array('тема', 'темы', 'тем'); \ No newline at end of file diff --git a/Sources/LightPortal/addons/TopBoards/langs/ukrainian.php b/Sources/LightPortal/addons/TopBoards/langs/ukrainian.php index 4a20cfaac..6f0ba7d90 100644 --- a/Sources/LightPortal/addons/TopBoards/langs/ukrainian.php +++ b/Sources/LightPortal/addons/TopBoards/langs/ukrainian.php @@ -3,5 +3,6 @@ $txt['lp_block_types']['top_boards'] = 'Популярні розділи'; $txt['lp_block_types_descriptions']['top_boards'] = 'Відображає список популярних розділів форуму.'; -$txt['lp_top_boards_addon_num_boards'] = 'Кількість розділів для відображення'; -$txt['lp_top_boards_addon_topics'] = array('тема', 'теми', 'тем'); \ No newline at end of file +$txt['lp_top_boards_addon_num_boards'] = 'Кількість розділів для відображення'; +$txt['lp_top_boards_addon_show_numbers_only'] = 'Відображати тільки цифри, без слів'; +$txt['lp_top_boards_addon_topics'] = array('тема', 'теми', 'тем'); \ No newline at end of file diff --git a/Sources/LightPortal/addons/TopPosters/TopPosters.php b/Sources/LightPortal/addons/TopPosters/TopPosters.php index 70b9512ee..066af6c56 100644 --- a/Sources/LightPortal/addons/TopPosters/TopPosters.php +++ b/Sources/LightPortal/addons/TopPosters/TopPosters.php @@ -13,7 +13,7 @@ * @copyright 2019-2020 Bugo * @license https://opensource.org/licenses/BSD-3-Clause BSD * - * @version 0.5 + * @version 0.6 */ if (!defined('SMF')) @@ -35,6 +35,13 @@ class TopPosters */ private static $num_posters = 10; + /** + * Отображать только цифры, или нет + * + * @var bool + */ + private static $show_numbers_only = false; + /** * Добавляем параметры блока * @@ -45,8 +52,9 @@ public static function blockOptions(&$options) { $options['top_posters'] = array( 'parameters' => array( - 'show_avatars' => static::$show_avatars, - 'num_posters' => static::$num_posters + 'show_avatars' => static::$show_avatars, + 'num_posters' => static::$num_posters, + 'show_numbers_only' => static::$show_numbers_only ) ); } @@ -65,8 +73,9 @@ public static function validateBlockData(&$args) return; $args['parameters'] = array( - 'show_avatars' => FILTER_VALIDATE_BOOLEAN, - 'num_posters' => FILTER_VALIDATE_INT + 'show_avatars' => FILTER_VALIDATE_BOOLEAN, + 'num_posters' => FILTER_VALIDATE_INT, + 'show_numbers_only' => FILTER_VALIDATE_BOOLEAN ); } @@ -100,19 +109,29 @@ public static function prepareBlockFields() 'value' => $context['lp_block']['options']['parameters']['num_posters'] ) ); + + $context['posting_fields']['show_numbers_only']['label']['text'] = $txt['lp_top_posters_addon_show_numbers_only']; + $context['posting_fields']['show_numbers_only']['input'] = array( + 'type' => 'checkbox', + 'attributes' => array( + 'id' => 'show_numbers_only', + 'checked' => !empty($context['lp_block']['options']['parameters']['show_numbers_only']) + ) + ); } /** * Получаем список лучших пользователей * - * @param int $num_posters - * @param bool $show_avatars + * @param array $params * @return array */ - public static function getTopPosters($num_posters = 1, $show_avatars = true) + public static function getTopPosters($params) { global $smcFunc, $scripturl, $modSettings; + [$num_posters, $show_avatars] = $params; + $request = $smcFunc['db_query']('', ' SELECT mem.id_member, mem.real_name, mem.posts' . ($show_avatars ? ', mem.avatar, a.id_attach, a.attachment_type, a.filename' : '') . ' FROM {db_prefix}members AS mem' . ($show_avatars ? ' @@ -153,12 +172,8 @@ public static function prepareContent(&$content, $type, $block_id) if ($type !== 'top_posters') return; - $parameters = $context['lp_active_blocks'][$block_id]['parameters'] ?? $context['lp_block']['options']['parameters']; - - if (($top_posters = cache_get_data('light_portal_top_posters_addon', 3600)) == null) { - $top_posters = self::getTopPosters($parameters['num_posters'], (bool) $parameters['show_avatars']); - cache_put_data('light_portal_top_posters_addon', $top_posters, 3600); - } + $parameters = $context['lp_active_blocks'][$block_id]['parameters'] ?? $context['lp_block']['options']['parameters']; + $top_posters = Helpers::useCache('top_posters_addon_u' . $context['user']['id'], 'getTopPosters', __CLASS__, 3600, array($parameters['num_posters'], (bool) $parameters['show_avatars'])); ob_start(); @@ -184,7 +199,7 @@ public static function prepareContent(&$content, $type, $block_id)
          - ', Helpers::correctDeclension($poster['posts'], $txt['lp_top_posters_addon_posts']), ' + ', $parameters['show_numbers_only'] ? $poster['posts'] : Helpers::correctDeclension($poster['posts'], $txt['lp_top_posters_addon_posts']), '
          '; } diff --git a/Sources/LightPortal/addons/TopPosters/langs/english.php b/Sources/LightPortal/addons/TopPosters/langs/english.php index eaa8fbfef..c557f972d 100644 --- a/Sources/LightPortal/addons/TopPosters/langs/english.php +++ b/Sources/LightPortal/addons/TopPosters/langs/english.php @@ -3,6 +3,7 @@ $txt['lp_block_types']['top_posters'] = 'Top Posters'; $txt['lp_block_types_descriptions']['top_posters'] = 'Displays a list of top posters.'; -$txt['lp_top_posters_addon_show_avatars'] = 'Display user avatars'; -$txt['lp_top_posters_addon_num_posters'] = 'Number of posters to display'; -$txt['lp_top_posters_addon_posts'] = array('posts', 'posts'); \ No newline at end of file +$txt['lp_top_posters_addon_show_avatars'] = 'Display user avatars'; +$txt['lp_top_posters_addon_num_posters'] = 'Number of posters to display'; +$txt['lp_top_posters_addon_show_numbers_only'] = 'Only display numbers, without words'; +$txt['lp_top_posters_addon_posts'] = array('posts', 'posts'); \ No newline at end of file diff --git a/Sources/LightPortal/addons/TopPosters/langs/russian.php b/Sources/LightPortal/addons/TopPosters/langs/russian.php index 568a12600..f30236fdb 100644 --- a/Sources/LightPortal/addons/TopPosters/langs/russian.php +++ b/Sources/LightPortal/addons/TopPosters/langs/russian.php @@ -3,6 +3,7 @@ $txt['lp_block_types']['top_posters'] = 'Лучшие пользователи'; $txt['lp_block_types_descriptions']['top_posters'] = 'Отображает список пользователей с наибольшим количеством сообщений.'; -$txt['lp_top_posters_addon_show_avatars'] = 'Отображать аватарки пользователей'; -$txt['lp_top_posters_addon_num_posters'] = 'Количество пользователей для отображения'; -$txt['lp_top_posters_addon_posts'] = array('сообщение', 'сообщения', 'сообщений'); \ No newline at end of file +$txt['lp_top_posters_addon_show_avatars'] = 'Отображать аватарки пользователей'; +$txt['lp_top_posters_addon_num_posters'] = 'Количество пользователей для отображения'; +$txt['lp_top_posters_addon_show_numbers_only'] = 'Отображать только цифры, без слов'; +$txt['lp_top_posters_addon_posts'] = array('сообщение', 'сообщения', 'сообщений'); \ No newline at end of file diff --git a/Sources/LightPortal/addons/TopPosters/langs/ukrainian.php b/Sources/LightPortal/addons/TopPosters/langs/ukrainian.php index 6bb2412b0..670d92de0 100644 --- a/Sources/LightPortal/addons/TopPosters/langs/ukrainian.php +++ b/Sources/LightPortal/addons/TopPosters/langs/ukrainian.php @@ -3,6 +3,7 @@ $txt['lp_block_types']['top_posters'] = 'Кращі користувачі'; $txt['lp_block_types_descriptions']['top_posters'] = 'Відображає список користувачів з найбільшою кількістю повідомлень.'; -$txt['lp_top_posters_addon_show_avatars'] = 'Відображати аватарки користувачів'; -$txt['lp_top_posters_addon_num_posters'] = 'Кількість користувачів для відображення'; -$txt['lp_top_posters_addon_posts'] = array('повідомлення', 'повідомлення', 'повідомлень'); \ No newline at end of file +$txt['lp_top_posters_addon_show_avatars'] = 'Відображати аватарки користувачів'; +$txt['lp_top_posters_addon_num_posters'] = 'Кількість користувачів для відображення'; +$txt['lp_top_posters_addon_show_numbers_only'] = 'Відображати тільки цифри, без слів'; +$txt['lp_top_posters_addon_posts'] = array('повідомлення', 'повідомлення', 'повідомлень'); \ No newline at end of file diff --git a/Sources/LightPortal/addons/TopTopics/TopTopics.php b/Sources/LightPortal/addons/TopTopics/TopTopics.php index feb1c4508..3faa346ff 100644 --- a/Sources/LightPortal/addons/TopTopics/TopTopics.php +++ b/Sources/LightPortal/addons/TopTopics/TopTopics.php @@ -13,7 +13,7 @@ * @copyright 2019-2020 Bugo * @license https://opensource.org/licenses/BSD-3-Clause BSD * - * @version 0.5 + * @version 0.6 */ if (!defined('SMF')) @@ -35,6 +35,13 @@ class TopTopics */ private static $num_topics = 10; + /** + * Отображать только цифры, или нет + * + * @var bool + */ + private static $show_numbers_only = false; + /** * Добавляем параметры блока * @@ -45,8 +52,9 @@ public static function blockOptions(&$options) { $options['top_topics'] = array( 'parameters' => array( - 'popularity_type' => static::$type, - 'num_topics' => static::$num_topics + 'popularity_type' => static::$type, + 'num_topics' => static::$num_topics, + 'show_numbers_only' => static::$show_numbers_only ) ); } @@ -65,8 +73,9 @@ public static function validateBlockData(&$args) return; $args['parameters'] = array( - 'popularity_type' => FILTER_SANITIZE_STRING, - 'num_topics' => FILTER_VALIDATE_INT + 'popularity_type' => FILTER_SANITIZE_STRING, + 'num_topics' => FILTER_VALIDATE_INT, + 'show_numbers_only' => FILTER_VALIDATE_BOOLEAN ); } @@ -107,6 +116,31 @@ public static function prepareBlockFields() 'value' => $context['lp_block']['options']['parameters']['num_topics'] ) ); + + $context['posting_fields']['show_numbers_only']['label']['text'] = $txt['lp_top_posters_addon_show_numbers_only']; + $context['posting_fields']['show_numbers_only']['input'] = array( + 'type' => 'checkbox', + 'attributes' => array( + 'id' => 'show_numbers_only', + 'checked' => !empty($context['lp_block']['options']['parameters']['show_numbers_only']) + ) + ); + } + + /** + * Получаем список популярных тем + * + * @param array $params + * @return void + */ + public static function getTopTopics($params) + { + global $boarddir; + + [$popularity_type, $num_topics] = $params; + + require_once($boarddir . '/SSI.php'); + return ssi_topTopics($popularity_type, $num_topics, 'array'); } /** @@ -119,18 +153,13 @@ public static function prepareBlockFields() */ public static function prepareContent(&$content, $type, $block_id) { - global $context, $boarddir, $txt; + global $context, $txt; if ($type !== 'top_topics') return; $parameters = $context['lp_active_blocks'][$block_id]['parameters'] ?? $context['lp_block']['options']['parameters']; - - if (($top_topics = cache_get_data('light_portal_top_topics_addon', 3600)) == null) { - require_once($boarddir . '/SSI.php'); - $top_topics = ssi_topTopics($parameters['popularity_type'], $parameters['num_topics'], 'array'); - cache_put_data('light_portal_top_topics_addon', $top_topics, 3600); - } + $top_topics = Helpers::useCache('top_topics_addon_u' . $context['user']['id'], 'getTopTopics', __CLASS__, 3600, array($parameters['popularity_type'], $parameters['num_topics'])); ob_start(); @@ -147,7 +176,7 @@ public static function prepareContent(&$content, $type, $block_id)
          ', $topic['link'], '
          - ', Helpers::correctDeclension($topic['num_' . $parameters['popularity_type']], $txt['lp_top_topics_addon_' . $parameters['popularity_type']]), ' + ', $parameters['show_numbers_only'] ? $topic['num_' . $parameters['popularity_type']] : Helpers::correctDeclension($topic['num_' . $parameters['popularity_type']], $txt['lp_top_topics_addon_' . $parameters['popularity_type']]), '
          '; } diff --git a/Sources/LightPortal/addons/TopTopics/langs/english.php b/Sources/LightPortal/addons/TopTopics/langs/english.php index 52452b50c..af3431daa 100644 --- a/Sources/LightPortal/addons/TopTopics/langs/english.php +++ b/Sources/LightPortal/addons/TopTopics/langs/english.php @@ -3,8 +3,9 @@ $txt['lp_block_types']['top_topics'] = 'Top Topics'; $txt['lp_block_types_descriptions']['top_topics'] = 'Displays a list of popular topics.'; -$txt['lp_top_topics_addon_type'] = 'Calculation of the popularity'; -$txt['lp_top_topics_addon_type_set'] = array('replies' => 'By replies', 'views' => 'By views'); -$txt['lp_top_topics_addon_num_topics'] = 'Number of topics to display'; -$txt['lp_top_topics_addon_replies'] = array('reply', 'replies'); -$txt['lp_top_topics_addon_views'] = array('view', 'views'); \ No newline at end of file +$txt['lp_top_topics_addon_type'] = 'Calculation of the popularity'; +$txt['lp_top_topics_addon_type_set'] = array('replies' => 'By replies', 'views' => 'By views'); +$txt['lp_top_topics_addon_num_topics'] = 'Number of topics to display'; +$txt['lp_top_topics_addon_show_numbers_only'] = 'Only display numbers, without words'; +$txt['lp_top_topics_addon_replies'] = array('reply', 'replies'); +$txt['lp_top_topics_addon_views'] = array('view', 'views'); \ No newline at end of file diff --git a/Sources/LightPortal/addons/TopTopics/langs/russian.php b/Sources/LightPortal/addons/TopTopics/langs/russian.php index dd8b3dcc1..1aa136b0b 100644 --- a/Sources/LightPortal/addons/TopTopics/langs/russian.php +++ b/Sources/LightPortal/addons/TopTopics/langs/russian.php @@ -3,8 +3,9 @@ $txt['lp_block_types']['top_topics'] = 'Популярные темы'; $txt['lp_block_types_descriptions']['top_topics'] = 'Отображает список популярных тем форума.'; -$txt['lp_top_topics_addon_type'] = 'Расчёт популярности'; -$txt['lp_top_topics_addon_type_set'] = array('replies' => 'По количеству ответов', 'views' => 'По количеству ответов'); -$txt['lp_top_topics_addon_num_topics'] = 'Количество тем для отображения'; -$txt['lp_top_topics_addon_replies'] = array('ответ', 'ответа', 'ответов'); -$txt['lp_top_topics_addon_views'] = array('просмотр', 'просмотра', 'просмотров'); \ No newline at end of file +$txt['lp_top_topics_addon_type'] = 'Расчёт популярности'; +$txt['lp_top_topics_addon_type_set'] = array('replies' => 'По количеству ответов', 'views' => 'По количеству ответов'); +$txt['lp_top_topics_addon_num_topics'] = 'Количество тем для отображения'; +$txt['lp_top_topics_addon_show_numbers_only'] = 'Отображать только цифры, без слов'; +$txt['lp_top_topics_addon_replies'] = array('ответ', 'ответа', 'ответов'); +$txt['lp_top_topics_addon_views'] = array('просмотр', 'просмотра', 'просмотров'); \ No newline at end of file diff --git a/Sources/LightPortal/addons/TopTopics/langs/ukrainian.php b/Sources/LightPortal/addons/TopTopics/langs/ukrainian.php index a5e48542d..7a84ce2b1 100644 --- a/Sources/LightPortal/addons/TopTopics/langs/ukrainian.php +++ b/Sources/LightPortal/addons/TopTopics/langs/ukrainian.php @@ -3,8 +3,9 @@ $txt['lp_block_types']['top_topics'] = 'Популярні теми'; $txt['lp_block_types_descriptions']['top_topics'] = 'Відображає список популярних тем форуму.'; -$txt['lp_top_topics_addon_type'] = 'Розрахунок популярності'; -$txt['lp_top_topics_addon_type_set'] = array('replies' => 'За кількістю відповідей', 'views' => 'За кількістю відповідей'); -$txt['lp_top_topics_addon_num_topics'] = 'Кількість тем для відображення'; -$txt['lp_top_topics_addon_replies'] = array('відповідь', 'відповіді', 'відповідей'); -$txt['lp_top_topics_addon_views'] = array('перегляд', 'перегляду', 'переглядів'); \ No newline at end of file +$txt['lp_top_topics_addon_type'] = 'Розрахунок популярності'; +$txt['lp_top_topics_addon_type_set'] = array('replies' => 'За кількістю відповідей', 'views' => 'За кількістю відповідей'); +$txt['lp_top_topics_addon_num_topics'] = 'Кількість тем для відображення'; +$txt['lp_top_topics_addon_show_numbers_only'] = 'Відображати тільки цифри, без слів'; +$txt['lp_top_topics_addon_replies'] = array('відповідь', 'відповіді', 'відповідей'); +$txt['lp_top_topics_addon_views'] = array('перегляд', 'перегляду', 'переглядів'); \ No newline at end of file diff --git a/Sources/LightPortal/addons/Trumbowyg.php b/Sources/LightPortal/addons/Trumbowyg.php index 5c21975e7..9984ac46c 100644 --- a/Sources/LightPortal/addons/Trumbowyg.php +++ b/Sources/LightPortal/addons/Trumbowyg.php @@ -11,7 +11,7 @@ * @copyright 2019-2020 Bugo * @license https://opensource.org/licenses/BSD-3-Clause BSD * - * @version 0.5 + * @version 0.6 */ if (!defined('SMF')) diff --git a/Sources/LightPortal/addons/YandexTranslate/YandexTranslate.php b/Sources/LightPortal/addons/YandexTranslate/YandexTranslate.php new file mode 100644 index 000000000..9d6af93ed --- /dev/null +++ b/Sources/LightPortal/addons/YandexTranslate/YandexTranslate.php @@ -0,0 +1,143 @@ + + * @copyright 2019-2020 Bugo + * @license https://opensource.org/licenses/BSD-3-Clause BSD + * + * @version 0.6 + */ + +if (!defined('SMF')) + die('Hacking attempt...'); + +class YandexTranslate +{ + /** + * Нельзя выбрать класс для оформления контента этого блока + * + * @var bool + */ + private static $no_content_class = true; + + /** + * Цветовая тема виджета (light|dark) + * + * @var string + */ + private static $widget_theme = 'light'; + + /** + * Автоматический перевод (если выключен, то требуется нажатие на кнопку «Перевести») + * + * @var bool + */ + private static $auto_mode = false; + + /** + * Добавляем параметры блока + * + * @param array $options + * @return void + */ + public static function blockOptions(&$options) + { + $options['yandex_translate'] = array( + 'no_content_class' => static::$no_content_class, + 'parameters' => array( + 'widget_theme' => static::$widget_theme, + 'auto_mode' => static::$auto_mode + ) + ); + } + + /** + * Валидируем параметры + * + * @param array $args + * @return void + */ + public static function validateBlockData(&$args) + { + global $context; + + if ($context['current_block']['type'] !== 'yandex_translate') + return; + + $args['parameters'] = array( + 'widget_theme' => FILTER_SANITIZE_STRING, + 'auto_mode' => FILTER_VALIDATE_BOOLEAN + ); + } + + /** + * Добавляем поля конкретно для этого блока + * + * @return void + */ + public static function prepareBlockFields() + { + global $context, $txt; + + if ($context['lp_block']['type'] !== 'yandex_translate') + return; + + $context['posting_fields']['widget_theme']['label']['text'] = $txt['lp_yandex_translate_addon_widget_theme']; + $context['posting_fields']['widget_theme']['input'] = array( + 'type' => 'select', + 'attributes' => array( + 'id' => 'widget_theme' + ), + 'options' => array( + 'light' => array( + 'value' => 'light', + 'selected' => 'light' == $context['lp_block']['options']['parameters']['widget_theme'] + ), + 'dark' => array( + 'value' => 'dark', + 'selected' => 'dark' == $context['lp_block']['options']['parameters']['widget_theme'] + ) + ) + ); + + $context['posting_fields']['auto_mode']['label']['text'] = $txt['lp_yandex_translate_addon_auto_mode']; + $context['posting_fields']['auto_mode']['input'] = array( + 'type' => 'checkbox', + 'attributes' => array( + 'id' => 'auto_mode', + 'checked' => !empty($context['lp_block']['options']['parameters']['auto_mode']) + ) + ); + } + + /** + * Формируем контент блока + * + * @param string $content + * @param string $type + * @return void + */ + public static function prepareContent(&$content, $type, $block_id) + { + global $context, $language; + + if ($type !== 'yandex_translate') + return; + + $parameters = $context['lp_active_blocks'][$block_id]['parameters'] ?? $context['lp_block']['options']['parameters']; + + ob_start(); + + echo ' +
          + '; + + $content = ob_get_clean(); + } +} diff --git a/Sources/LightPortal/addons/YandexTranslate/index.php b/Sources/LightPortal/addons/YandexTranslate/index.php new file mode 100644 index 000000000..69278ce68 --- /dev/null +++ b/Sources/LightPortal/addons/YandexTranslate/index.php @@ -0,0 +1,9 @@ + \ No newline at end of file diff --git a/Sources/LightPortal/addons/YandexTranslate/langs/english.php b/Sources/LightPortal/addons/YandexTranslate/langs/english.php new file mode 100644 index 000000000..6b2bdded1 --- /dev/null +++ b/Sources/LightPortal/addons/YandexTranslate/langs/english.php @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/Sources/LightPortal/addons/YandexTranslate/langs/russian.php b/Sources/LightPortal/addons/YandexTranslate/langs/russian.php new file mode 100644 index 000000000..748a5612c --- /dev/null +++ b/Sources/LightPortal/addons/YandexTranslate/langs/russian.php @@ -0,0 +1,7 @@ +

          ', $txt['lp_used_components'], '

          -
          +
            '; foreach ($context['lp_components'] as $item) { echo ' -
          • +
          • ' . $item['title'] . ' ' . (isset($item['author']) ? ' | © ' . $item['author'] : '') . ' | Licensed under ' . $item['license']['name'] . '
          • '; } diff --git a/Themes/default/LightPortal/ManageBlocks.template.php b/Themes/default/LightPortal/ManageBlocks.template.php index 32cf39745..01f6a4e77 100644 --- a/Themes/default/LightPortal/ManageBlocks.template.php +++ b/Themes/default/LightPortal/ManageBlocks.template.php @@ -1,6 +1,7 @@ '; } -// Displaying a table with blocks | Отображение таблицы с блоками +// Displaying a table with blocks +// Отображение таблицы с блоками function show_block_table() { global $context, $txt, $settings, $scripturl; @@ -131,7 +133,7 @@ function show_block_table() ', $data['title'][$context['user']['language']], ' - ', $txt['lp_block_types'][$data['type']], ' + ', $txt['lp_block_types'][$data['type']] ?? $context['lp_missing_block_types'][$data['type']], ' ', $data['areas'], ' @@ -176,10 +178,11 @@ function show_block_table() } } -// The page for adding blocks | Страница добавления блоков +// The page for adding blocks +// Страница добавления блоков function template_block_add() { - global $txt, $context; + global $txt, $context, $settings; echo '
            @@ -207,6 +210,7 @@ function template_block_add()
            +
            '; } -// Block creation/editing template | Шаблон создания/редактирования блока +// Block creation/editing template +// Шаблон создания/редактирования блока function template_post_block() { global $context, $txt; diff --git a/Themes/default/LightPortal/ManagePages.template.php b/Themes/default/LightPortal/ManagePages.template.php index 8463a685c..672e5d15b 100644 --- a/Themes/default/LightPortal/ManagePages.template.php +++ b/Themes/default/LightPortal/ManagePages.template.php @@ -1,11 +1,12 @@ - ', $context['lp_main_page']['created_at'], ' + ', $context['lp_main_page']['created'], ' ', $context['lp_main_page']['num_views'], ' @@ -47,10 +48,10 @@ function template_manage_pages_above() ', $txt['lp_page_types'][$context['lp_main_page']['type']], ' - ', (empty($modSettings['lp_main_page_disable']) ? '' . $context['lp_main_page']['alias'] . '' : $context['lp_main_page']['alias']), ' + ', (empty($modSettings['lp_frontpage_disable']) ? '' . $context['lp_main_page']['alias'] . '' : $context['lp_main_page']['alias']), ' - ', (!empty($modSettings['lp_main_page_title_' . $user_info['language']]) ? $modSettings['lp_main_page_title_' . $user_info['language']] : $context['lp_main_page']['title']), ' + ', (!empty($modSettings['lp_frontpage_title_' . $user_info['language']]) ? $modSettings['lp_frontpage_title_' . $user_info['language']] : $context['lp_main_page']['title']), ' ', empty($context['lp_main_page']['status']) ? ('') : (''); @@ -105,7 +106,8 @@ function template_manage_pages_below() '; } -// Page creation/editing template | Шаблон создания/редактирования страницы +// Page creation/editing template +// Шаблон создания/редактирования страницы function template_post_page() { global $context, $txt; diff --git a/Themes/default/LightPortal/ViewBlock.template.php b/Themes/default/LightPortal/ViewBlock.template.php index d71e68687..7d63fadc1 100644 --- a/Themes/default/LightPortal/ViewBlock.template.php +++ b/Themes/default/LightPortal/ViewBlock.template.php @@ -1,6 +1,7 @@ '; } -// The output of blocks AFTER content | Вывод блоков после контента +// The output of blocks AFTER content +// Вывод блоков ПОСЛЕ контента function template_portal_below() { global $context; @@ -133,7 +135,8 @@ function template_portal_below()
          '; } -// Output the title and content of the block | Вывод заголовка и содержимого блока +// Output the title and content of the block +// Вывод заголовка и содержимого блока function lp_show_block($block) { global $context, $scripturl, $txt; diff --git a/Themes/default/LightPortal/ViewPage.template.php b/Themes/default/LightPortal/ViewPage.template.php index fc240a39c..e40002b64 100644 --- a/Themes/default/LightPortal/ViewPage.template.php +++ b/Themes/default/LightPortal/ViewPage.template.php @@ -1,6 +1,7 @@

          ', $context['page_title'], $context['lp_page']['can_edit'] ? '' : '', '

          -
          +
          ', $context['lp_page']['content'], '
          '; } + +// Topics from selected boards as sources of articles +// Темы из выбранных разделов в виде статей +function template_show_topics_as_articles() +{ + global $context, $txt; + + if (!empty($context['lp_frontpage_articles'])) { + echo ' +
          '; + + echo ' +
          +
          + +
          +
          '; + + foreach ($context['lp_frontpage_articles'] as $topic) { + echo ' +
          +
          +

          + ', $topic['is_new'] ? '' . $txt['new'] . ' ' : '', '', $topic['subject'], '', ' +

          +
          +
          +
          '; + + if (!empty($topic['poster_id'])) + echo ' + ' . $topic['poster_name'] . ''; + else + echo $topic['poster_name']; + + echo ' + ', $topic['board'], ' +
          +
          + ', $topic['time'], '', $txt['views'], ': ', $topic['num_views'], ' +
          + +
          '; + + if (!empty($topic['image'])) + echo ' + ', $topic['subject'], ''; + + echo ' + ', $topic['preview'], ' +
          +
          +
          +
          '; + } + + echo ' +
          +
          + +
          +
          '; + + echo ' +
          '; + + portal_frontpage_scripts(); + } +} + +// Pages as sources of articles +// Страницы в виде статей +function template_show_pages_as_articles() +{ + global $context, $txt, $scripturl; + + if (!empty($context['lp_frontpage_articles'])) { + echo ' +
          '; + + echo ' +
          +
          + +
          +
          '; + + foreach ($context['lp_frontpage_articles'] as $page) { + if ($page['can_show']) { + echo ' +
          +
          +

          + ', $page['is_new'] ? '' . $txt['new'] . ' ' : '', '', $page['title'], '', ' + ', $page['can_edit'] ? '' : '', ' +

          +
          +
          +
          '; + + if (!empty($page['author_id'])) + echo ' + ' . $page['author_name'] . ''; + else + echo $page['author_name']; + + echo ' +
          +
          ', $page['created_at'], '', $txt['views'], ': ', $page['num_views'], '
          + +
          '; + + if (!empty($topic['image'])) + echo ' + ', $page['title'], ''; + + echo ' + ', $page['description'], ' +
          +
          +
          +
          '; + } + } + + echo ' +
          +
          + +
          +
          '; + + echo ' +
          '; + + portal_frontpage_scripts(); + } +} + +// Possibility to load various scripts +// Возможность загружать различные скрипты +function portal_frontpage_scripts() +{ + global $settings, $context; + + echo ' + + '; +} diff --git a/Themes/default/css/light_portal/light_portal.css b/Themes/default/css/light_portal/light_portal.css index 8ff0b468c..1c1247c04 100644 --- a/Themes/default/css/light_portal/light_portal.css +++ b/Themes/default/css/light_portal/light_portal.css @@ -51,6 +51,21 @@ width: 14%; } +.article_link:hover { + text-decoration: none; +} + +.article_content:hover { + box-shadow: 0 1px 4px rgba(0,0,0,0.3),0 0 40px rgba(0,0,0,0.1) inset; +} + +.article_image { + display: block; + height: auto; + max-width: 100%; + margin: 0 auto; +} + @media (max-width: 600px) { .lp_current_blocks th.type, .lp_current_blocks td.type, .lp_current_blocks th.areas, .lp_current_blocks td.areas { display: none; @@ -69,8 +84,16 @@ } } -/* Addons */ +/* Topic Rating Bar */ +.lp_frontpage_articles .topic_stars_main { + float: right; +} +.lp_frontpage_articles .topic_stars { + background-image: url(../../images/trb/one_star.png); + background-repeat: no-repeat; +} +/* Addons */ .likely__widget { opacity: 0.5 !important; -webkit-filter: grayscale(100%); @@ -83,10 +106,8 @@ } .recent_posts li, .recent_topics li { - border-bottom: 1px solid #777; -} -.recent_posts li:last-child, .recent_topics li:last-child { - border: none; + margin: 4px 0 0 0; + padding: 6px 12px; } dl.top_posters dt img { diff --git a/Themes/default/images/lp_default_image.png b/Themes/default/images/lp_default_image.png new file mode 100644 index 0000000000000000000000000000000000000000..72f117a9b44e5f0fec76beea699c98c7ee9f8522 GIT binary patch literal 155 zcmeAS@N?(olHy`uVBq!ia0vp^j3CUx1SBVv2j2s6ii6yp7}lMWc?smOq&xaLGB9lH z=l+w(3gmMZctjR6Fz_7)VaDV6D^h@h5+$w?CBgY=CFO}lsSE{)nRz98d8s7|CVGZ? rrYY_bAZvI$T^vIs!jmnEpYbrToMB3x?661xD9+&N>gTe~DWM4fjm0K< literal 0 HcmV?d00001 diff --git a/Themes/default/languages/LightPortal/.english.php b/Themes/default/languages/LightPortal/.english.php index 6aff2faf9..a95356960 100644 --- a/Themes/default/languages/LightPortal/.english.php +++ b/Themes/default/languages/LightPortal/.english.php @@ -13,18 +13,26 @@ // Settings $txt['lp_settings'] = 'Portal settings'; $txt['lp_php_mysql_info'] = 'The mod version: %1$s, PHP version: %2$s, %3$s version: %4$s.'; -$txt['lp_main_page_title'] = 'The main page title'; -$txt['lp_main_page_disable'] = 'Disable the main page'; +$txt['lp_frontpage_title'] = 'The frontpage title'; +$txt['lp_frontpage_disable'] = 'Disable the frontpage'; +$txt['lp_frontpage_mode'] = 'What is should displayed as the frontpage'; +$txt['lp_frontpage_mode_set'] = array('The main page', 'All topics from selected boards'); +$txt['lp_frontpage_boards'] = 'Boards as sources of articles for the frontpage'; +$txt['lp_frontpage_layout'] = 'Number of columns for displaying articles'; +$txt['lp_show_images_in_articles'] = 'Show images that found in articles'; +$txt['lp_subject_size'] = 'The max size of article titles (in symbols)'; +$txt['lp_teaser_size'] = 'The max size of article teasers (in symbols)'; +$txt['lp_num_per_page'] = 'Maximum number of items (for pagination)'; $txt['lp_standalone'] = 'Standalone mode'; $txt['lp_standalone_help'] = 'Everything except portal pages and ignored areas will be disabled.'; $txt['lp_standalone_excluded_actions'] = 'Ignored actions'; $txt['lp_standalone_excluded_actions_subtext'] = 'Specify the areas that should remain available offline.'; $txt['lp_page_editor_type_default'] = 'The type of page editor by default'; -$txt['lp_num_per_page'] = 'Maximum number of items in the page list (for pagination)'; $txt['lp_page_og_image'] = 'Use an image within the page content for the og-image metatag'; $txt['lp_page_og_image_set'] = array('None', 'First found', 'Last found'); +$txt['lp_hide_blocks_in_admin_section'] = 'Hide active blocks in admin section'; $txt['groups_light_portal_view'] = 'Who can view the portal elements'; -$txt['groups_light_portal_manage'] = 'Who can manage the portal'; +$txt['groups_light_portal_manage'] = 'Who can manage blocks and pages'; // Actions $txt['lp_title'] = 'Title'; @@ -113,6 +121,7 @@ $txt['lp_post_error_no_content'] = 'The content not specified! It is required.'; $txt['lp_post_error_no_areas'] = 'The areas field was not filled out. It is required.'; $txt['lp_page_not_editable'] = 'You are not allowed to edit this page!'; +$txt['lp_addon_not_installed'] = 'Plugin %1$s not installed'; // Who $txt['lp_who_main'] = 'Viewing the main portal page.'; diff --git a/Themes/default/languages/LightPortal/.russian.php b/Themes/default/languages/LightPortal/.russian.php index c95fc1000..f6a3f4a5d 100644 --- a/Themes/default/languages/LightPortal/.russian.php +++ b/Themes/default/languages/LightPortal/.russian.php @@ -13,18 +13,26 @@ // Settings $txt['lp_settings'] = 'Настройки портала'; $txt['lp_php_mysql_info'] = 'Версия мода: %1$s, версия PHP: %2$s, версия %3$s: %4$s.'; -$txt['lp_main_page_title'] = 'Заголовок главной страницы'; -$txt['lp_main_page_disable'] = 'Отключить главную страницу'; +$txt['lp_frontpage_title'] = 'Заголовок главной страницы'; +$txt['lp_frontpage_disable'] = 'Отключить главную страницу'; +$txt['lp_frontpage_mode'] = 'Что должно отображаться в качестве первой страницы'; +$txt['lp_frontpage_mode_set'] = array('Главная страница', 'Все темы из выбранных разделов', 'Все страницы (кроме первой)'); +$txt['lp_frontpage_boards'] = 'Разделы-источники статей для первой страницы'; +$txt['lp_frontpage_layout'] = 'Количество колонок для вывода статей'; +$txt['lp_show_images_in_articles'] = 'Показывать изображения, найденные в статьях'; +$txt['lp_subject_size'] = 'Размер заголовка статей (в символах)'; +$txt['lp_teaser_size'] = 'Размер тизера статей (в символах)'; +$txt['lp_num_per_page'] = 'Максимальное количество элементов (для пагинации)'; $txt['lp_standalone'] = 'Автономный режим'; $txt['lp_standalone_help'] = 'Будет отключено всё, кроме страниц портала и игнорируемых областей.'; $txt['lp_standalone_excluded_actions'] = 'Игнорируемые области'; $txt['lp_standalone_excluded_actions_subtext'] = 'Укажите области, которые должны оставаться доступными в автономном режиме.'; $txt['lp_page_editor_type_default'] = 'Тип редактора страниц по умолчанию'; -$txt['lp_num_per_page'] = 'Максимальное количество элементов в списке страниц (для пагинации)'; $txt['lp_page_og_image'] = 'Использовать изображение в тексте статьи для мета-тега og-image'; $txt['lp_page_og_image_set'] = array('Нет', 'Первое найденное', 'Последнее найденное'); +$txt['lp_hide_blocks_in_admin_section'] = 'Скрывать активные блоки в админке'; $txt['groups_light_portal_view'] = 'Кто может просматривать элементы портала'; -$txt['groups_light_portal_manage'] = 'Кто может управлять порталом'; +$txt['groups_light_portal_manage'] = 'Кто может управлять блоками и страницами'; // Actions $txt['lp_title'] = 'Заголовок'; @@ -113,6 +121,7 @@ $txt['lp_post_error_no_content'] = 'Не указано содержание!'; $txt['lp_post_error_no_areas'] = 'Не указана область размещения!'; $txt['lp_page_not_editable'] = 'Вам запрещено редактирование этой страницы!'; +$txt['lp_addon_not_installed'] = 'Плагин %1$s не установлен'; // Who $txt['lp_who_main'] = 'Просматривает главную страницу портала.'; diff --git a/Themes/default/languages/LightPortal/.ukrainian.php b/Themes/default/languages/LightPortal/.ukrainian.php index b59a93222..0e49db121 100644 --- a/Themes/default/languages/LightPortal/.ukrainian.php +++ b/Themes/default/languages/LightPortal/.ukrainian.php @@ -13,18 +13,26 @@ // Settings $txt['lp_settings'] = 'Налаштування порталу'; $txt['lp_php_mysql_info'] = 'Версія моду: %1$s, версія PHP: %2$s, версія %3$s: %4$s.'; -$txt['lp_main_page_title'] = 'Заголовок головної сторінки'; -$txt['lp_main_page_disable'] = 'Відключити головну сторінку'; +$txt['lp_frontpage_title'] = 'Заголовок головної сторінки'; +$txt['lp_frontpage_disable'] = 'Відключити головну сторінку'; +$txt['lp_frontpage_mode'] = 'Що повинно відображатися як перша сторінка'; +$txt['lp_frontpage_mode_set'] = array('Головна сторінка', 'Всі теми з обраних розділів'); +$txt['lp_frontpage_boards'] = 'Розділи-джерела статей для першої сторінки'; +$txt['lp_frontpage_layout'] = 'Кількість колонок для виведення статей'; +$txt['lp_show_images_in_articles'] = 'Показувати зображення, знайдені в статтях'; +$txt['lp_subject_size'] = 'Розмір заголовка статей (у символах)'; +$txt['lp_teaser_size'] = 'Розмір тизера статей (у символах)'; +$txt['lp_num_per_page'] = 'Максимальна кількість елементів у списку сторінок (для пагінації)'; $txt['lp_standalone'] = 'Автономний режим'; $txt['lp_standalone_help'] = 'Буде відключено все, крім сторінок порталу та областей, що ігноруються'; $txt['lp_standalone_excluded_actions'] = 'Області, що ігноруються'; $txt['lp_standalone_excluded_actions_subtext'] = 'Вкажіть області, які повинні залишатися доступними в автономному режимі.'; $txt['lp_page_editor_type_default'] = 'Тип редактора сторінок за замовчуванням'; -$txt['lp_num_per_page'] = 'Максимальна кількість елементів у списку сторінок (для пагінації)'; $txt['lp_page_og_image'] = 'Використовувати зображення в тексті статті для мета-тегу og-image'; $txt['lp_page_og_image_set'] = array('Ні', 'Перше знайдене', 'Останнє знайдене'); +$txt['lp_hide_blocks_in_admin_section'] = 'Приховувати активні блоки в адмінці'; $txt['groups_light_portal_view'] = 'Хто може переглядати елементи порталу'; -$txt['groups_light_portal_manage'] = 'Хто може керувати порталом'; +$txt['groups_light_portal_manage'] = 'Хто може керувати блоками та сторінками'; // Actions $txt['lp_title'] = 'Заголовок'; @@ -113,6 +121,7 @@ $txt['lp_post_error_no_content'] = 'Не вказано зміст!'; $txt['lp_post_error_no_areas'] = 'Не вказана область разташування!'; $txt['lp_page_not_editable'] = 'Вам заборонено редагування цієї сторінки!'; +$txt['lp_addon_not_installed'] = 'Плагін %1$s не встановлений'; // Who $txt['lp_who_main'] = 'Переглядає головну сторінку порталу.'; diff --git a/Themes/default/scripts/light_portal/jquery.matchHeight-min.js b/Themes/default/scripts/light_portal/jquery.matchHeight-min.js new file mode 100644 index 000000000..50936e8fe --- /dev/null +++ b/Themes/default/scripts/light_portal/jquery.matchHeight-min.js @@ -0,0 +1,12 @@ +/* +* jquery-match-height 0.7.2 by @liabru +* http://brm.io/jquery-match-height/ +* License MIT +*/ +!function(t){"use strict";"function"==typeof define&&define.amd?define(["jquery"],t):"undefined"!=typeof module&&module.exports?module.exports=t(require("jquery")):t(jQuery)}(function(t){var e=-1,o=-1,n=function(t){return parseFloat(t)||0},a=function(e){var o=1,a=t(e),i=null,r=[];return a.each(function(){var e=t(this),a=e.offset().top-n(e.css("margin-top")),s=r.length>0?r[r.length-1]:null;null===s?r.push(e):Math.floor(Math.abs(i-a))<=o?r[r.length-1]=s.add(e):r.push(e),i=a}),r},i=function(e){var o={ +byRow:!0,property:"height",target:null,remove:!1};return"object"==typeof e?t.extend(o,e):("boolean"==typeof e?o.byRow=e:"remove"===e&&(o.remove=!0),o)},r=t.fn.matchHeight=function(e){var o=i(e);if(o.remove){var n=this;return this.css(o.property,""),t.each(r._groups,function(t,e){e.elements=e.elements.not(n)}),this}return this.length<=1&&!o.target?this:(r._groups.push({elements:this,options:o}),r._apply(this,o),this)};r.version="0.7.2",r._groups=[],r._throttle=80,r._maintainScroll=!1,r._beforeUpdate=null, +r._afterUpdate=null,r._rows=a,r._parse=n,r._parseOptions=i,r._apply=function(e,o){var s=i(o),h=t(e),l=[h],c=t(window).scrollTop(),p=t("html").outerHeight(!0),u=h.parents().filter(":hidden");return u.each(function(){var e=t(this);e.data("style-cache",e.attr("style"))}),u.css("display","block"),s.byRow&&!s.target&&(h.each(function(){var e=t(this),o=e.css("display");"inline-block"!==o&&"flex"!==o&&"inline-flex"!==o&&(o="block"),e.data("style-cache",e.attr("style")),e.css({display:o,"padding-top":"0", +"padding-bottom":"0","margin-top":"0","margin-bottom":"0","border-top-width":"0","border-bottom-width":"0",height:"100px",overflow:"hidden"})}),l=a(h),h.each(function(){var e=t(this);e.attr("style",e.data("style-cache")||"")})),t.each(l,function(e,o){var a=t(o),i=0;if(s.target)i=s.target.outerHeight(!1);else{if(s.byRow&&a.length<=1)return void a.css(s.property,"");a.each(function(){var e=t(this),o=e.attr("style"),n=e.css("display");"inline-block"!==n&&"flex"!==n&&"inline-flex"!==n&&(n="block");var a={ +display:n};a[s.property]="",e.css(a),e.outerHeight(!1)>i&&(i=e.outerHeight(!1)),o?e.attr("style",o):e.css("display","")})}a.each(function(){var e=t(this),o=0;s.target&&e.is(s.target)||("border-box"!==e.css("box-sizing")&&(o+=n(e.css("border-top-width"))+n(e.css("border-bottom-width")),o+=n(e.css("padding-top"))+n(e.css("padding-bottom"))),e.css(s.property,i-o+"px"))})}),u.each(function(){var e=t(this);e.attr("style",e.data("style-cache")||null)}),r._maintainScroll&&t(window).scrollTop(c/p*t("html").outerHeight(!0)), +this},r._applyDataApi=function(){var e={};t("[data-match-height], [data-mh]").each(function(){var o=t(this),n=o.attr("data-mh")||o.attr("data-match-height");n in e?e[n]=e[n].add(o):e[n]=o}),t.each(e,function(){this.matchHeight(!0)})};var s=function(e){r._beforeUpdate&&r._beforeUpdate(e,r._groups),t.each(r._groups,function(){r._apply(this.elements,this.options)}),r._afterUpdate&&r._afterUpdate(e,r._groups)};r._update=function(n,a){if(a&&"resize"===a.type){var i=t(window).width();if(i===e)return;e=i; +}n?o===-1&&(o=setTimeout(function(){s(a),o=-1},r._throttle)):s(a)},t(r._applyDataApi);var h=t.fn.on?"on":"bind";t(window)[h]("load",function(t){r._update(!1,t)}),t(window)[h]("resize orientationchange",function(t){r._update(!0,t)})}); \ No newline at end of file diff --git a/package-info.xml b/package-info.xml index 01cb192a6..4aa2c088d 100644 --- a/package-info.xml +++ b/package-info.xml @@ -3,7 +3,7 @@ Bugo:LightPortal Light Portal - 0.5 + 0.6 modification