Skip to content

Commit

Permalink
Merge pull request #36 from dragomano/develop
Browse files Browse the repository at this point in the history
Update to 1.9.4
  • Loading branch information
dragomano authored Oct 5, 2021
2 parents 49be87a + d6f8302 commit bf125de
Show file tree
Hide file tree
Showing 44 changed files with 445 additions and 133 deletions.
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* Use bug report or feature request templates.

## How to submit a pull request
* Check if the develop branch exists. If it exist use it to pull your request into.
* If you want to send a bug fix, use `Fix` word in the title of your PR (i.e. "Fix page permissions").
* If you want to send a new feature or a new translation, use `Add` word in the title of your PR (i.e `Add a new frontpage template`, `Add Chinese translation`).
In any case, the title of each of your commits should continue such a phrase — `If applied, this commit will ...` (`Update Polish`, etc.)
Expand Down Expand Up @@ -67,7 +68,7 @@ $test = isset($variable) ? $variable : 'default_value';
* Use [HTML5](https://www.w3schools.com/html/html5_syntax.asp)

### CSS Styleguide
* You can use CSS or LESS
* Use LESS (portal.less) to modify desired rules.

```less
#comment_form {
Expand Down
12 changes: 4 additions & 8 deletions Sources/LightPortal/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,11 @@ public static function getText(int $num, $str): string
$str = array_map('trim', $str);

// Plural rule #0 (Chinese, Japanese, Persian, Turkish, Thai, Indonesian, Malay)
$rule_zero = array('zh', 'ja', 'fa', 'tr', 'th', 'id', 'ms');
if (in_array($txt['lang_dictionary'], $rule_zero))
if (in_array($txt['lang_dictionary'], array('zh', 'ja', 'fa', 'tr', 'th', 'id', 'ms')))
return $num . ' ' . $str[0];

// Plural rule #2 (French, Portuguese_brazilian)
$rule_two = array('fr', 'pt');
if (in_array($txt['lang_dictionary'], $rule_two))
if (in_array($txt['lang_dictionary'], array('fr', 'pt')))
return $num . ' ' . $str[($num == 0 || $num == 1) ? 0 : 1];

// Just in case
Expand All @@ -247,15 +245,13 @@ public static function getText(int $num, $str): string
}

// Plural rule #7 (Bosnian, Croatian, Serbian, Russian, Ukrainian)
$rule_seven = array('bs', 'hr', 'sr', 'ru', 'uk');
if (in_array($txt['lang_dictionary'], $rule_seven)) {
if (in_array($txt['lang_dictionary'], array('bs', 'hr', 'sr', 'ru', 'uk'))) {
$cases = array(2, 0, 1, 1, 1, 2);
return $num . ' ' . $str[($num % 100 > 4 && $num % 100 < 20) ? 2 : $cases[min($num % 10, 5)]];
}

// Plural rule #8 (Czech, Slovak)
$rule_eight = array('cs', 'sk');
if (in_array($txt['lang_dictionary'], $rule_eight))
if (in_array($txt['lang_dictionary'], array('cs', 'sk')))
return $num . ' ' . $str[$num == 1 ? 0 : (in_array($num, array(2, 3, 4)) ? 1 : 2)];

// Plural rule #9 (Polish)
Expand Down
4 changes: 2 additions & 2 deletions Sources/LightPortal/Integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ public function userInfo()

$lp_constants = [
'LP_NAME' => 'Light Portal',
'LP_VERSION' => '1.9.3',
'LP_RELEASE_DATE' => '2021-09-29',
'LP_VERSION' => '1.9.4',
'LP_RELEASE_DATE' => '2021-10-05',
'LP_ADDON_DIR' => $sourcedir . '/LightPortal/addons',
'LP_CACHE_TIME' => $modSettings['lp_cache_update_interval'] ?? 3600,
'LP_ACTION' => $modSettings['lp_portal_action'] ?? 'portal',
Expand Down
2 changes: 1 addition & 1 deletion Sources/LightPortal/ManagePlugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ private function prepareAddonChart()
labels: ["' . implode('", "', $context['lp_plugin_types']) . '"],
datasets: [{
data: [' . implode(', ', $typeCount) . '],
backgroundColor: ["#667d99", "#48bf83", "#9354ca", "#91ae26", "#ef564f", "#d68b4f", "#4b93d1", "#414141"]
backgroundColor: ["#667d99", "#48bf83", "#9354ca", "#91ae26", "#ef564f", "#d68b4f", "#4b93d1", "#414141", "#8597ad", "#52647a"]
}]
},
options: {
Expand Down
35 changes: 24 additions & 11 deletions Sources/LightPortal/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,25 +151,38 @@ private function setMeta()
if (empty($context['lp_page']))
return;

$context['meta_description'] = $context['lp_page']['description'];

$keywords = [];
if (!empty($context['lp_page']['keywords'])) {
$keywords = [];
foreach ($context['lp_page']['keywords'] as $id => $key) {
$keywords[] = $key['name'];
}
$keywords = array_column($context['lp_page']['keywords'], 'name');

$modSettings['meta_keywords'] = implode(', ', $keywords);
}

$context['meta_description'] = $context['lp_page']['description'];

$context['optimus_og_type']['article'] = array(
'published_time' => date('Y-m-d\TH:i:s', $context['lp_page']['created_at']),
'modified_time' => !empty($context['lp_page']['updated_at']) ? date('Y-m-d\TH:i:s', $context['lp_page']['updated_at']) : null,
'author' => $context['lp_page']['author']
$context['meta_tags'][] = array('prefix' => 'article: http://ogp.me/ns/article#', 'property' => 'og:type', 'content' => 'article');
$context['meta_tags'][] = array('prefix' => 'article: http://ogp.me/ns/article#', 'property' => 'article:author', 'content' => $context['lp_page']['author']);
$context['meta_tags'][] = array(
'prefix' => 'article: http://ogp.me/ns/article#',
'property' => 'article:published_time',
'content' => date('Y-m-d\TH:i:s', $context['lp_page']['created_at'])
);

if (!empty($context['lp_page']['updated_at']))
$context['meta_tags'][] = array(
'prefix' => 'article: http://ogp.me/ns/article#',
'property' => 'article:modified_time',
'content' => date('Y-m-d\TH:i:s', $context['lp_page']['updated_at'])
);

if (!empty($context['lp_page']['category']))
$context['optimus_og_type']['article']['section'] = $context['lp_page']['category'];
$context['meta_tags'][] = array('prefix' => 'article: http://ogp.me/ns/article#', 'property' => 'article:section', 'content' => $context['lp_page']['category']);

if (!empty($keywords)) {
foreach ($keywords as $value) {
$context['meta_tags'][] = array('prefix' => 'article: http://ogp.me/ns/article#', 'property' => 'article:tag', 'content' => $value);
}
}

if (!empty($modSettings['lp_page_og_image']) && !empty($context['lp_page']['image']))
$settings['og_image'] = $context['lp_page']['image'];
Expand Down
24 changes: 18 additions & 6 deletions Sources/LightPortal/Subs.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,27 @@ public static function loadCssFiles()
global $modSettings;

if (empty($modSettings['lp_fa_source']) || $modSettings['lp_fa_source'] == 'css_cdn') {
loadCSSFile('https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5/css/all.min.css', array('external' => true, 'seed' => false));
loadCSSFile(
'https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5/css/all.min.css',
array('external' => true, 'seed' => false),
'portal_fontawesome'
);
} elseif ($modSettings['lp_fa_source'] == 'js_cdn') {
loadJavaScriptFile('https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5/js/all.min.js', array('external' => true, 'defer' => true, 'seed' => false));
loadJavaScriptFile(
'https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5/js/all.min.js',
array('external' => true, 'defer' => true, 'seed' => false),
'portal_fontawesome'
);
} elseif ($modSettings['lp_fa_source'] == 'css_local') {
loadCSSFile('all.min.css');
loadCSSFile('all.min.css', [], 'portal_fontawesome');
} elseif ($modSettings['lp_fa_source'] == 'js_local') {
loadJavaScriptFile('all.min.js', array('defer' => true));
loadJavaScriptFile('all.min.js', array('defer' => true), 'portal_fontawesome');
} elseif ($modSettings['lp_fa_source'] == 'custom' && !empty($modSettings['lp_fa_custom'])) {
loadJavaScriptFile($modSettings['lp_fa_custom'], array('external' => true, 'defer' => true, 'seed' => false, 'attributes' => array('crossorigin' => 'anonymous')));
loadJavaScriptFile(
$modSettings['lp_fa_custom'],
array('external' => true, 'defer' => true, 'seed' => false, 'attributes' => array('crossorigin' => 'anonymous')),
'portal_fontawesome'
);
}

loadCSSFile('light_portal/flexboxgrid.css');
Expand Down Expand Up @@ -311,7 +323,7 @@ public static function getPluginTypes(): array
{
global $txt;

return array_combine(array('block', 'editor', 'comment', 'parser', 'article', 'frontpage', 'impex', 'other'), $txt['lp_plugins_types']);
return array_combine(array('block', 'editor', 'comment', 'parser', 'article', 'frontpage', 'impex', 'other', 'block_options', 'page_options'), $txt['lp_plugins_types']);
}

/**
Expand Down
81 changes: 81 additions & 0 deletions Sources/LightPortal/addons/BootstrapIcons/BootstrapIcons.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php

/**
* BootstrapIcons
*
* @package Light Portal
* @link https://github.com/dragomano/Light-Portal
* @author Bugo <bugo@dragomano.ru>
* @copyright 2021 Bugo
* @license https://spdx.org/licenses/GPL-3.0-or-later.html GPL-3.0-or-later
*
* @version 1.9
*/

namespace Bugo\LightPortal\Addons\BootstrapIcons;

use Bugo\LightPortal\Addons\Plugin;
use Bugo\LightPortal\Helpers;

/**
* Generated by Plugin Maker
*/
class BootstrapIcons extends Plugin
{
/** @var string */
public $type = 'other';

/**
* @return void
*/
public function init()
{
loadCSSFile('https://cdn.jsdelivr.net/npm/bootstrap-icons@1/font/bootstrap-icons.min.css', array('external' => true, 'seed' => false));
}

/**
* @param string $template
* @param string $icon
* @return void
*/
public function prepareIconTemplate(string &$template, string $icon)
{
$template = '<i class="bi bi-' . $icon . '"></i> ';
}

/**
* @param array $all_icons
* @param string $template
* @return void
*/
public function prepareIconList(array &$all_icons, string &$template)
{
$content = file_get_contents('https://raw.githubusercontent.com/twbs/icons/main/font/bootstrap-icons.json');
$icons = json_decode($content);

if (!empty($icons)) {
foreach ($icons as $icon => $id) {
$all_icons[] = $icon;
}
}

$template = '<i class="bi bi-%1$s"></i>&nbsp;%1$s';
}

/**
* @param array $links
* @return void
*/
public function credits(array &$links)
{
$links[] = array(
'title' => 'Bootstrap Icons',
'link' => 'https://github.com/twbs/icons',
'author' => 'The Bootstrap Authors',
'license' => array(
'name' => 'the MIT License',
'link' => 'https://github.com/twbs/icons/blob/main/LICENSE.md'
)
);
}
}
9 changes: 9 additions & 0 deletions Sources/LightPortal/addons/BootstrapIcons/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

// Try to handle it with the upper level index.php. (it should know what to do.)
if (file_exists(dirname(dirname(__FILE__)) . '/index.php'))
include (dirname(dirname(__FILE__)) . '/index.php');
else
exit;

?>
5 changes: 5 additions & 0 deletions Sources/LightPortal/addons/BootstrapIcons/langs/english.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

return [
'description' => 'Support for <a class="bbc_link" href="https://icons.getbootstrap.com/" target="_blank" rel="noopener">Bootstrap Icons</a>.',
];
9 changes: 9 additions & 0 deletions Sources/LightPortal/addons/BootstrapIcons/langs/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

// Try to handle it with the upper level index.php. (it should know what to do.)
if (file_exists(dirname(dirname(__FILE__)) . '/index.php'))
include (dirname(dirname(__FILE__)) . '/index.php');
else
exit;

?>
5 changes: 5 additions & 0 deletions Sources/LightPortal/addons/BootstrapIcons/langs/russian.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

return [
'description' => 'Поддержка иконок <a class="bbc_link" href="https://getbootstrap.su" target="_blank" rel="noopener">Bootstrap</a>.',
];
1 change: 1 addition & 0 deletions Sources/LightPortal/addons/Disqus/langs/english.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

return [
'description' => 'Adds the ability to display Disqus comments on portal pages.',
'shortname' => 'Website shortname',
'shortname_subtext' => 'This is used to uniquely identify your website on Disqus.<br>Copy your site <strong>shortname</strong> from <a class="bbc_link" href="https://disqus.com/admin/settings/general/" target="_blank" rel="noopener">the Disqus settings</a> and paste here.',
];
1 change: 1 addition & 0 deletions Sources/LightPortal/addons/Disqus/langs/russian.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

return [
'description' => 'Добавляет возможность отображать комментарии Disqus на страницах портала.',
'shortname' => 'Короткое имя сайта',
'shortname_subtext' => 'Используется для идентификации вашего сайта в Disqus.<br>Скопируйте значение <strong>shortname</strong> из <a class="bbc_link" href="https://disqus.com/admin/settings/general/" target="_blank" rel="noopener">настроек сайта в Disqus</a> и вставьте сюда.',
];
Loading

0 comments on commit bf125de

Please sign in to comment.