Skip to content

Commit

Permalink
Merge pull request #95 from dragomano/develop
Browse files Browse the repository at this point in the history
Merge develop with master
  • Loading branch information
dragomano authored May 23, 2022
2 parents cbd9e67 + da63b36 commit 70abc39
Show file tree
Hide file tree
Showing 109 changed files with 1,338 additions and 25,327 deletions.
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
/website export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/*.md export-ignore
/*.md export-ignore
/build.xml export-ignore
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
**/.idea/
**/.vscode/
**/vendor/
**/composer.lock
**/package-lock.json
**/Addons/**/*.less
**/Addons/**/russian.php
**/Addons/**/polish.php
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/417e4cab3c63460dbb5e06ac126f8ebf)](https://www.codacy.com/gh/dragomano/Light-Portal/dashboard?utm_source=github.com&utm_medium=referral&utm_content=dragomano/Light-Portal&utm_campaign=Badge_Grade)
[![Crowdin](https://badges.crowdin.net/light-portal/localized.svg)](https://crowdin.com/project/light-portal)

* **Tested on:** PHP 7.4.29 / MariaDB 10.3.32, 10.6.5, 10.7.3
* **Tested on:** PHP 8.1.5 / MariaDB 10.6.7
* **Languages:** Spanish, Ukrainian, Polish, English, Russian, German, Italian, French, Turkish
* [![](https://img.shields.io/badge/Demo-Forum-brightgreen.svg)](https://demo.dragomano.ru)

Expand Down Expand Up @@ -64,4 +64,4 @@ Light Portal is completely free to use. It is distributed in the hope that it wi
It was made for your convenience, and if you like the project, support the developer. Or give a star ⭐️ to this project.

## About plugins
Some custom addons may have their own licenses.
Some custom addons have their own licenses.
95 changes: 23 additions & 72 deletions Sources/LightPortal/AbstractMain.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,15 @@

namespace Bugo\LightPortal;

use function allowedTo;
use function smf_json_decode;
use function loadCSSFile;
use function loadTemplate;
use function updateSettings;
use function redirectexit;

if (! defined('SMF'))
die('No direct access...');

abstract class AbstractMain
{
use Helper;

abstract public function hooks();

protected function isPortalCanBeLoaded(): bool
{
if (! defined('LP_NAME') || isset($this->context['uninstalling']) || $this->request()->is('printpage')) {
Expand All @@ -40,10 +35,10 @@ protected function isPortalCanBeLoaded(): bool

protected function defineVars()
{
$this->context['allow_light_portal_view'] = allowedTo('light_portal_view');
$this->context['allow_light_portal_manage_own_blocks'] = allowedTo('light_portal_manage_own_blocks');
$this->context['allow_light_portal_manage_own_pages'] = allowedTo('light_portal_manage_own_pages');
$this->context['allow_light_portal_approve_pages'] = allowedTo('light_portal_approve_pages');
$this->context['allow_light_portal_view'] = $this->allowedTo('light_portal_view');
$this->context['allow_light_portal_manage_own_blocks'] = $this->allowedTo('light_portal_manage_own_blocks');
$this->context['allow_light_portal_manage_own_pages'] = $this->allowedTo('light_portal_manage_own_pages');
$this->context['allow_light_portal_approve_pages'] = $this->allowedTo('light_portal_approve_pages');

[$this->context['lp_num_active_blocks'], $this->context['lp_num_active_pages']] = $this->getNumActiveEntities();

Expand All @@ -61,34 +56,34 @@ protected function defineVars()
$this->context['lp_header_panel_width'] = empty($this->modSettings['lp_header_panel_width']) ? 12 : (int) $this->modSettings['lp_header_panel_width'];
$this->context['lp_left_panel_width'] = empty($this->modSettings['lp_left_panel_width'])
? ['md' => 3, 'lg' => 3, 'xl' => 2]
: smf_json_decode($this->modSettings['lp_left_panel_width'], true, false);
: $this->jsonDecode($this->modSettings['lp_left_panel_width'], true, false);
$this->context['lp_right_panel_width'] = empty($this->modSettings['lp_right_panel_width'])
? ['md' => 3, 'lg' => 3, 'xl' => 2]
: smf_json_decode($this->modSettings['lp_right_panel_width'], true, false);
: $this->jsonDecode($this->modSettings['lp_right_panel_width'], true, false);
$this->context['lp_footer_panel_width'] = empty($this->modSettings['lp_footer_panel_width']) ? 12 : (int) $this->modSettings['lp_footer_panel_width'];

$this->context['lp_panel_direction'] = smf_json_decode($this->modSettings['lp_panel_direction'] ?? '', true, false);
$this->context['lp_panel_direction'] = $this->jsonDecode($this->modSettings['lp_panel_direction'] ?? '', true, false);
$this->context['lp_active_blocks'] = (new Entities\Block)->getActive();
$this->context['lp_icon_set'] = (new Lists\IconList)->getAll();
}

protected function loadCssFiles()
protected function loadAssets()
{
if (! empty($this->modSettings['lp_fa_source'])) {
if ($this->modSettings['lp_fa_source'] === 'css_local') {
loadCSSFile('all.min.css', [], 'portal_fontawesome');
$this->loadCSSFile('all.min.css', [], 'portal_fontawesome');
} elseif ($this->modSettings['lp_fa_source'] === 'custom' && $this->modSettings['lp_fa_custom']) {
loadCSSFile(
$this->loadCSSFile(
$this->modSettings['lp_fa_custom'],
['external' => true, 'seed' => false],
'portal_fontawesome'
);
}
}

loadCSSFile('light_portal/flexboxgrid.css');
loadCSSFile('light_portal/portal.css');
loadCSSFile('custom_frontpage.css');
$this->loadCSSFile('light_portal/flexboxgrid.css');
$this->loadCSSFile('light_portal/portal.css');
$this->loadCSSFile('custom_frontpage.css');
}

/**
Expand Down Expand Up @@ -161,18 +156,18 @@ protected function showDebugInfo()

$this->context['lp_load_page_stats'] = sprintf($this->txt['lp_load_page_stats'], round(microtime(true) - $this->context['lp_load_time'], 3), $this->context['lp_num_queries']);

loadTemplate('LightPortal/ViewDebug');
$this->loadTemplate('LightPortal/ViewDebug');

if (empty($key = array_search('lp_portal', $this->context['template_layers']))) {
$this->context['template_layers'][] = 'debug';
return;
}

$this->context['template_layers'] = [
...array_slice($this->context['template_layers'], 0, $key, true),
...['debug'],
...array_slice($this->context['template_layers'], $key, null, true)
];
$this->context['template_layers'] = array_merge(
array_slice($this->context['template_layers'], 0, $key, true),
['debug'],
array_slice($this->context['template_layers'], $key, null, true)
);
}

protected function promoteTopic()
Expand All @@ -188,9 +183,9 @@ protected function promoteTopic()
$this->context['lp_frontpage_topics'][] = $topic;
}

updateSettings(['lp_frontpage_topics' => implode(',', $this->context['lp_frontpage_topics'])]);
$this->updateSettings(['lp_frontpage_topics' => implode(',', $this->context['lp_frontpage_topics'])]);

redirectexit('topic=' . $topic);
$this->redirect('topic=' . $topic);
}

private function getNumActiveEntities(): array
Expand Down Expand Up @@ -228,50 +223,6 @@ private function getNumActiveEntities(): array
return array_values($num_entities);
}

/**
* Get a list of all used classes for blocks with a header
*
* Получаем список всех используемых классов для блоков с заголовком
*/
private function getTitleClasses(): array
{
return [
'cat_bar' => '<div class="cat_bar"><h3 class="catbg">%1$s</h3></div>',
'title_bar' => '<div class="title_bar"><h3 class="titlebg">%1$s</h3></div>',
'sub_bar' => '<div class="sub_bar"><h3 class="subbg">%1$s</h3></div>',
'noticebox' => '<div class="noticebox"><h3>%1$s</h3></div>',
'infobox' => '<div class="infobox"><h3>%1$s</h3></div>',
'descbox' => '<div class="descbox"><h3>%1$s</h3></div>',
'generic_list_wrapper' => '<div class="generic_list_wrapper"><h3>%1$s</h3></div>',
'progress_bar' => '<div class="progress_bar"><h3>%1$s</h3></div>',
'popup_content' => '<div class="popup_content"><h3>%1$s</h3></div>',
'' => '<div>%1$s</div>',
];
}

/**
* Get a list of all used classes for blocks with content
*
* Получаем список всех используемых классов для блоков с контентом
*/
private function getContentClasses(): array
{
return [
'roundframe' => '<div class="roundframe noup" %2$s>%1$s</div>',
'roundframe2' => '<div class="roundframe" %2$s>%1$s</div>',
'windowbg' => '<div class="windowbg noup" %2$s>%1$s</div>',
'windowbg2' => '<div class="windowbg" %2$s>%1$s</div>',
'information' => '<div class="information" %2$s>%1$s</div>',
'errorbox' => '<div class="errorbox" %2$s>%1$s</div>',
'noticebox' => '<div class="noticebox" %2$s>%1$s</div>',
'infobox' => '<div class="infobox" %2$s>%1$s</div>',
'descbox' => '<div class="descbox" %2$s>%1$s</div>',
'bbc_code' => '<div class="bbc_code" %2$s>%1$s</div>',
'generic_list_wrapper' => '<div class="generic_list_wrapper" %2$s>%1$s</div>',
'' => '<div%2$s>%1$s</div>',
];
}

private function getBlockPlacements(): array
{
return array_combine(['header', 'top', 'left', 'right', 'bottom', 'footer'], $this->txt['lp_block_placement_set']);
Expand Down
Loading

0 comments on commit 70abc39

Please sign in to comment.