Skip to content
Permalink
Browse files

Convert main panels

  • Loading branch information...
OtakuMegane committed Mar 15, 2019
1 parent 77d16c8 commit 5e06707ec9b99aa345c7d1709e9ea9801881446f
@@ -23,7 +23,8 @@ function nel_module_dispatch(array $inputs, Domain $domain)
{
$session = new \Nelliel\Session();
$session->login();
nel_render_main_panel($domain, $session->sessionUser());
$output_main_panel = new \Nelliel\Output\OutputPanelMain($domain);
$output_main_panel->render(['user' => $session->sessionUser()]);
}
break;
@@ -73,11 +74,13 @@ function nel_module_dispatch(array $inputs, Domain $domain)
if ($domain->id() !== '')
{
nel_render_main_board_panel($domain);
$output_board_panel = new \Nelliel\Output\OutputPanelBoard($domain);
$output_board_panel->render(['user' => $session->sessionUser()]);
}
else
{
nel_render_main_panel($domain, $session->sessionUser());
$output_main_panel = new \Nelliel\Output\OutputPanelMain($domain);
$output_main_panel->render(['user' => $session->sessionUser()]);
}
break;
@@ -121,7 +124,8 @@ function nel_module_dispatch(array $inputs, Domain $domain)
$language->extractLanguageStrings($domain, $session->sessionUser(), LANGUAGES_FILE_PATH . 'extracted/extraction' . date('Y-m-d_H-i-s') . '.pot');
}
nel_render_main_panel($domain, $session->sessionUser());
$output_main_panel = new \Nelliel\Output\OutputPanelMain($domain);
$output_main_panel->render(['user' => $session->sessionUser()]);
break;
case 'reports':
@@ -296,7 +300,8 @@ function nel_module_dispatch(array $inputs, Domain $domain)
$regen->siteCache($domain);
}
nel_render_main_board_panel($domain);
$output_board_panel = new \Nelliel\Output\OutputPanelBoard($domain);
$output_board_panel->render(['user' => $session->sessionUser()]);
break;
case 'templates':
@@ -4,8 +4,6 @@
die("NOPE.AVI");
}
require_once INCLUDE_PATH . 'output/management/main_panel.php';
function nel_verify_login()
{
$database = nel_database();
@@ -0,0 +1,134 @@
<?php
namespace Nelliel\Output;
if (!defined('NELLIEL_VERSION'))
{
die("NOPE.AVI");
}
use Nelliel\Domain;
class OutputPanelBoard extends OutputCore
{
private $database;
function __construct(Domain $domain)
{
$this->domain = $domain;
$this->utilitySetup();
}
public function render(array $parameters = array())
{
$this->prepare('management/board_panel.html');
$output_header = new \Nelliel\Output\OutputHeader($this->domain);
$extra_data = ['header' => _gettext('Board Management'), 'sub_header' => _gettext('Options')];
$output_header->render(['header_type' => 'general', 'dotdot' => '', 'extra_data' => $extra_data]);
$manage_options = $this->dom->getElementById('manage-options');
$settings = $this->dom->getElementById('module-board-settings');
$session = new \Nelliel\Session(true);
$user = $session->sessionUser();
if ($user->domainPermission($this->domain, 'perm_board_config_access'))
{
$settings_elements = $settings->getElementsByAttributeName('data-parse-id', true);
$settings_elements['board-settings-link']->extSetAttribute('href',
MAIN_SCRIPT . '?module=board-settings&board_id=' . $this->domain->id());
}
else
{
$settings->remove();
}
$bans = $this->dom->getElementById('module-bans');
if ($user->domainPermission($this->domain, 'perm_ban_access'))
{
$bans_elements = $bans->getElementsByAttributeName('data-parse-id', true);
$bans_elements['bans-link']->extSetAttribute('href', MAIN_SCRIPT . '?module=bans&board_id=' . $this->domain->id());
}
else
{
$bans->remove();
}
$threads = $this->dom->getElementById('module-threads');
if ($user->domainPermission($this->domain, 'perm_threads_access'))
{
$threads_elements = $threads->getElementsByAttributeName('data-parse-id', true);
$threads_elements['threads-link']->extSetAttribute('href',
MAIN_SCRIPT . '?module=threads-admin&board_id=' . $this->domain->id());
}
else
{
$threads->remove();
}
$modmode = $this->dom->getElementById('module-modmode');
if ($user->domainPermission($this->domain, 'perm_modmode_access'))
{
$modmode_elements = $modmode->getElementsByAttributeName('data-parse-id', true);
$modmode_elements['modmode-link']->extSetAttribute('href',
MAIN_SCRIPT . '?module=render&action=view-index&index=0&board_id=' . $this->domain->id() . '&modmode=true');
}
else
{
$modmode->remove();
}
$reports = $this->dom->getElementById('module-reports');
if ($user->domainPermission($this->domain, 'perm_reports_access'))
{
$reports_elements = $reports->getElementsByAttributeName('data-parse-id', true);
$reports_elements['reports-link']->extSetAttribute('href',
MAIN_SCRIPT . '?module=reports&board_id=' . $this->domain->id());
}
else
{
$reports->remove();
}
$file_filters = $this->dom->getElementById('module-file-filters');
if ($user->domainPermission($this->domain, 'perm_file_filters_access'))
{
$file_filters_elements = $file_filters->getElementsByAttributeName('data-parse-id', true);
$file_filters_elements['file-filters-link']->extSetAttribute('href',
MAIN_SCRIPT . '?module=file-filters&board_id=' . $this->domain->id());
}
else
{
$file_filters->remove();
}
if ($user->domainPermission($this->domain, 'perm_regen_pages'))
{
$this->dom->getElementById('regen-all-pages')->extSetAttribute('href',
MAIN_SCRIPT . '?module=regen&action=board-all-pages&board_id=' . $this->domain->id());
}
else
{
$this->dom->getElementById('regen-all-pages')->parentNode->remove();
}
if ($user->domainPermission($this->domain, 'perm_regen_cache'))
{
$this->dom->getElementById('regen-all-caches')->extSetAttribute('href',
MAIN_SCRIPT . '?module=regen&action=board-all-caches&board_id=' . $this->domain->id());
}
else
{
$this->dom->getElementById('regen-all-caches')->parentNode->remove();
}
$this->domain->translator()->translateDom($this->dom);
$this->render_instance->appendHTMLFromDOM($this->dom);
nel_render_general_footer($this->domain);
echo $this->render_instance->outputRenderSet();
nel_clean_exit();
}
}
@@ -0,0 +1,188 @@
<?php
namespace Nelliel\Output;
if (!defined('NELLIEL_VERSION'))
{
die("NOPE.AVI");
}
use Nelliel\Domain;
use PDO;
class OutputPanelMain extends OutputCore
{
private $database;
function __construct(Domain $domain)
{
$this->database = $domain->database();
$this->domain = $domain;
$this->utilitySetup();
}
public function render(array $parameters = array())
{
$user = $parameters['user'];
$this->prepare('management/main_panel.html');
$output_header = new \Nelliel\Output\OutputHeader($this->domain);
$extra_data = ['header' => _gettext('General Management'), 'sub_header' => _gettext('Options')];
$output_header->render(['header_type' => 'general', 'dotdot' => '', 'extra_data' => $extra_data]);
$board_entry = $this->dom->getElementById('board-entry');
$insert_before = $board_entry->parentNode->lastChild;
$boards = $this->database->executeFetchAll('SELECT * FROM "' . BOARD_DATA_TABLE . '"', PDO::FETCH_ASSOC);
if ($boards !== false)
{
foreach ($boards as $board)
{
$entry = $board_entry->cloneNode(true);
$board_entry->parentNode->insertBefore($entry, $insert_before);
$entry->removeAttribute('id');
$entry_elements = $entry->getElementsByAttributeName('data-parse-id', true);
$entry_elements['board-link']->extSetAttribute('href',
MAIN_SCRIPT . '?module=main-panel&board_id=' . $board['board_id']);
$entry_elements['board-link']->extSetAttribute('title', $board['board_id']);
$entry_elements['board-link']->setContent('/' . $board['board_id'] . '/');
}
}
$board_entry->remove();
$manage_options = $this->dom->getElementById('manage-options');
$manage_options_nodes = $manage_options->getElementsByAttributeName('data-parse-id', true);
if ($user->domainPermission($this->domain, 'perm_manage_boards_access'))
{
$manage_options_nodes['module-link-manage-boards']->extSetAttribute('href', MAIN_SCRIPT . '?module=manage-boards');
}
else
{
$manage_options_nodes['module-link-manage-boards']->remove();
}
if ($user->domainPermission($this->domain, 'perm_user_access'))
{
$manage_options_nodes['module-link-users']->extSetAttribute('href', MAIN_SCRIPT . '?module=users');
}
else
{
$manage_options_nodes['module-link-users']->remove();
}
if ($user->domainPermission($this->domain, 'perm_role_access'))
{
$manage_options_nodes['module-link-roles']->extSetAttribute('href', MAIN_SCRIPT . '?module=roles');
}
else
{
$manage_options_nodes['module-link-roles']->remove();
}
if ($user->domainPermission($this->domain, 'perm_site_config_access'))
{
$manage_options_nodes['module-link-site-settings']->extSetAttribute('href', MAIN_SCRIPT . '?module=site-settings');
}
else
{
$manage_options_nodes['module-link-site-settings']->remove();
}
if ($user->domainPermission($this->domain, 'perm_file_filters_access'))
{
$manage_options_nodes['module-link-file-filters']->extSetAttribute('href', MAIN_SCRIPT . '?module=file-filters');
}
else
{
$manage_options_nodes['module-link-file-filters']->remove();
}
if ($user->domainPermission($this->domain, 'perm_board_defaults_access'))
{
$manage_options_nodes['module-link-board-defaults']->extSetAttribute('href',
MAIN_SCRIPT . '?module=default-board-settings');
}
else
{
$manage_options_nodes['module-link-board-defaults']->remove();
}
if ($user->domainPermission($this->domain, 'perm_reports_access'))
{
$manage_options_nodes['module-link-reports']->extSetAttribute('href', MAIN_SCRIPT . '?module=reports');
}
else
{
$manage_options_nodes['module-link-reports']->remove();
}
if ($user->domainPermission($this->domain, 'perm_templates_access'))
{
$manage_options_nodes['module-link-templates']->extSetAttribute('href', MAIN_SCRIPT . '?module=templates');
}
else
{
$manage_options_nodes['module-link-templates']->remove();
}
if ($user->domainPermission($this->domain, 'perm_filetypes_access'))
{
$manage_options_nodes['module-link-filetypes']->extSetAttribute('href', MAIN_SCRIPT . '?module=filetypes');
}
else
{
$manage_options_nodes['module-link-filetypes']->remove();
}
if ($user->domainPermission($this->domain, 'perm_styles_access'))
{
$manage_options_nodes['module-link-styles']->extSetAttribute('href', MAIN_SCRIPT . '?module=styles');
}
else
{
$manage_options_nodes['module-link-styles']->remove();
}
if ($user->domainPermission($this->domain, 'perm_permissions_access'))
{
$manage_options_nodes['module-link-permissions']->extSetAttribute('href', MAIN_SCRIPT . '?module=permissions');
}
else
{
$manage_options_nodes['module-link-permissions']->remove();
}
if ($user->domainPermission($this->domain, 'perm_icon_sets_access'))
{
$manage_options_nodes['module-link-icon-sets']->extSetAttribute('href', MAIN_SCRIPT . '?module=icon-sets');
}
else
{
$manage_options_nodes['module-link-icon-sets']->remove();
}
if ($user->domainPermission($this->domain, 'perm_news_access'))
{
$manage_options_nodes['module-link-news']->extSetAttribute('href', MAIN_SCRIPT . '?module=news');
}
else
{
$manage_options_nodes['module-link-news']->remove();
}
if ($user->domainPermission($this->domain, 'perm_extract_gettext'))
{
$manage_options_nodes['module-extract-gettext']->extSetAttribute('href',
MAIN_SCRIPT . '?module=language&action=extract-gettext');
}
else
{
$manage_options_nodes['module-extract-gettext']->remove();
}
$this->domain->translator()->translateDom($this->dom);
$this->render_instance->appendHTMLFromDOM($this->dom);
nel_render_general_footer($this->domain);
echo $this->render_instance->outputRenderSet();
nel_clean_exit();
}
}
Oops, something went wrong.

0 comments on commit 5e06707

Please sign in to comment.
You can’t perform that action at this time.