Skip to content

Commit

Permalink
Merge pull request #3670 from Spuds/Working
Browse files Browse the repository at this point in the history
Boom Baby
  • Loading branch information
Spuds committed Sep 28, 2022
2 parents dc98ab7 + cb51523 commit 6d3b525
Show file tree
Hide file tree
Showing 79 changed files with 1,042 additions and 859 deletions.
9 changes: 3 additions & 6 deletions sources/ElkArte/AdminController/AddonSettings.php
Expand Up @@ -57,13 +57,10 @@ public function action_index()
// END $this->loadGeneralSettingParameters();

// Load up all the tabs...
$context[$context['admin_menu_name']]['tab_data'] = array(
'title' => $txt['admin_modifications'],
$context[$context['admin_menu_name']]['object']->prepareTabData([
'title' => 'admin_modifications',
'help' => 'addonsettings',
'description' => $txt['modification_settings_desc'],
'tabs' => array(
'general' => array(),
),
'description' => 'modification_settings_desc']
);

// Set up the action controller
Expand Down
55 changes: 33 additions & 22 deletions sources/ElkArte/AdminController/Admin.php
Expand Up @@ -91,7 +91,10 @@ public function action_index()
$admin_include_data = $this->loadMenu();
$this->buildLinktree($admin_include_data);

callMenu($admin_include_data);
// And off we go, only one action, the chosen menu area
$action = new Action();
$action->initialize(['action' => $admin_include_data]);
$action->dispatch('action');
}

/**
Expand Down Expand Up @@ -170,9 +173,9 @@ private function loadMenu()
'subsections' => array(
'browse' => array($txt['browse_packages']),
'installed' => array($txt['installed_packages']),
'options' => array($txt['package_settings']),
'servers' => array($txt['download_packages']),
'upload' => array($txt['upload_packages']),
'options' => array($txt['package_settings']),
),
),
'packageservers' => array(
Expand All @@ -188,7 +191,8 @@ private function loadMenu()
'function' => 'action_search',
'permission' => array('admin_forum'),
'class' => 'i-search i-admin',
'select' => 'index'
'select' => 'index',
'hidden' => true,
),
'adminlogoff' => array(
'controller' => '\\ElkArte\\AdminController\\Admin',
Expand Down Expand Up @@ -362,8 +366,8 @@ private function loadMenu()
'class' => 'i-search i-admin',
'permission' => array('admin_forum'),
'subsections' => array(
'weights' => array($txt['search_weights']),
'method' => array($txt['search_method']),
'weights' => array($txt['search_weights']),
'managesphinx' => array($txt['search_sphinx']),
'settings' => array($txt['settings']),
),
Expand Down Expand Up @@ -543,11 +547,13 @@ private function loadMenu()
);

// Actually create the menu!
$menu = new Menu();
$menu->addMenuData($admin_areas);
$menu->addOptions($menuOptions);
$admin_include_data = $menu->prepareMenu();
$menu->setContext();
$admin_include_data = (new Menu())
->addMenuData($admin_areas)
->addOptions($menuOptions)
->prepareMenu()
->setContext()
->getIncludeData();

unset($admin_areas);

// Make a note of the Unique ID for this menu.
Expand Down Expand Up @@ -632,12 +638,12 @@ public function action_home()
$context['can_admin'] = allowedTo('admin_forum');
$context['sub_template'] = 'admin';
$context['page_title'] = $txt['admin_center'];
$context[$context['admin_menu_name']]['tab_data'] = array(
'title' => $txt['admin_center'],
$context[$context['admin_menu_name']]['object']->prepareTabData([
'title' => 'admin_center',
'description' => '
<span class="bbc_strong">' . $txt['hello_guest'] . ' ' . $context['user']['name'] . '!</span>
' . sprintf($txt['admin_main_welcome'], $txt['admin_control_panel']),
);
]);

// Load in the admin quick tasks
$context['quick_admin_tasks'] = getQuickAdminTasks();
Expand Down Expand Up @@ -672,9 +678,10 @@ public function action_credits()
}

// Load credits.
$context[$context['admin_menu_name']]['tab_data'] = array(
'title' => $txt['support_credits_title'],
);
$context[$context['admin_menu_name']]['object']->prepareTabData([
'title' => 'support_credits_title',
'description' => 'support_credits_desc',
]);
Txt::load('Who');
$context += prepareCreditsData();

Expand Down Expand Up @@ -831,15 +838,19 @@ public function action_search_internal()
$this->_events->trigger('search', array('language_files' => &$language_files, 'include_files' => &$include_files, 'settings_search' => &$settings_search));

// Go through all the search data trying to find this text!
$search_term = strtolower(un_htmlspecialchars($context['search_term']));
$search = new AdminSettingsSearch($language_files, $include_files, $settings_search);
$search->initSearch($context['admin_menu_name'], array(
array('COPPA', 'area=regcenter;sa=settings'),
array('CAPTCHA', 'area=securitysettings;sa=spam'),
));
$context['search_results'] = [];
if (isset($context['search_term']))
{
$search_term = strtolower(un_htmlspecialchars($context['search_term'] ?? ''));
$search = new AdminSettingsSearch($language_files, $include_files, $settings_search);
$search->initSearch($context['admin_menu_name'], array(
array('COPPA', 'area=regcenter;sa=settings'),
array('CAPTCHA', 'area=securitysettings;sa=spam'),
));
$context['search_results'] = $search->doSearch($search_term);
}

$context['page_title'] = $txt['admin_search_results'];
$context['search_results'] = $search->doSearch($search_term);
}

/**
Expand Down
42 changes: 21 additions & 21 deletions sources/ElkArte/AdminController/AdminLog.php
Expand Up @@ -68,36 +68,36 @@ public function action_index()
'function' => 'action_pruningSettings_display'),
);

// Setup the tabs.
$context[$context['admin_menu_name']]['tab_data'] = array(
'title' => $txt['logs'],
'description' => $txt['maintain_info'],
'tabs' => array(
'errorlog' => array(
// Setup the custom tabs.
$context[$context['admin_menu_name']]['object']->prepareTabData([
'title' => 'logs',
'description' => 'maintain_info',
'tabs' => [
'errorlog' => [
'url' => getUrl('admin', ['action' => 'admin', 'area' => 'logs', 'sa' => 'errorlog', 'desc']),
'description' => sprintf($txt['errlog_desc'], $txt['remove']),
'disabled' => empty($modSettings['enableErrorLogging']),
),
'adminlog' => array(
],
'adminlog' => [
'description' => $txt['admin_log_desc'],
),
'modlog' => array(
],
'modlog' => [
'description' => $txt['moderation_log_desc'],
'disabled' => !featureEnabled('ml') || empty($modSettings['modlog_enabled']),
),
'banlog' => array(
],
'banlog' => [
'description' => $txt['ban_log_description'],
),
'spiderlog' => array(
],
'spiderlog' => [
'description' => $txt['spider_log_desc'],
),
'tasklog' => array(
],
'tasklog' => [
'description' => $txt['scheduled_log_desc'],
),
'pruning' => array(
],
'pruning' => [
'description' => $txt['pruning_log_desc'],
),
),
],
]]
);

// If there is no sa set it must have come here for first time,
Expand All @@ -120,7 +120,7 @@ public function action_index()
/**
* Allow to edit the settings on the pruning screen.
*
* @event integrate_prune_settings add additonal settings to the auto pruning display. If you add any
* @event integrate_prune_settings add additional settings to the auto pruning display. If you add any
* additional logs make sure to add them at the end. Additionally, make sure you add them to the
* weekly scheduled task.
* @uses _pruningSettings form.
Expand Down
10 changes: 6 additions & 4 deletions sources/ElkArte/AdminController/CoreFeatures.php
Expand Up @@ -125,10 +125,12 @@ public function action_features()

$context['sub_template'] = 'core_features';
$context['page_title'] = $txt['core_settings_title'];
$context[$context['admin_menu_name']]['tab_data'] = array(
'title' => $txt['core_settings_title'],
'description' => $txt['core_settings_desc'],
);

$context[$context['admin_menu_name']]['object']->prepareTabData([
'title' => 'core_settings_title',
'description' => 'core_settings_desc',
]);

theme()->addJavascriptVar(array(
'token_name' => '',
'token_value' => '',
Expand Down
17 changes: 5 additions & 12 deletions sources/ElkArte/AdminController/Maintenance.php
Expand Up @@ -92,18 +92,11 @@ public function action_index()
theme()->getTemplates()->load('Maintenance');

// This uses admin tabs - as it should!
$context[$context['admin_menu_name']]['tab_data'] = array(
'title' => $txt['maintain_title'],
'class' => 'i-cog',
'description' => $txt['maintain_info'],
'tabs' => array(
'routine' => array(),
'database' => array(),
'members' => array(),
'topics' => array(),
'hooks' => array(),
'attachments' => array('label' => $txt['maintain_sub_attachments']),
),
// Create the tabs
$context[$context['admin_menu_name']]['object']->prepareTabData([
'title' => 'maintain_title',
'description' => 'maintain_info',
'class' => 'i-cog']
);

// So many things you can do - but frankly I won't let you - just these!
Expand Down
14 changes: 7 additions & 7 deletions sources/ElkArte/AdminController/ManageAttachments.php
Expand Up @@ -116,17 +116,17 @@ public function action_index()
// Default page title is good.
$context['page_title'] = $txt['attachments_avatars'];

// This uses admin tabs - as it should!
$context[$context['admin_menu_name']]['tab_data'] = array(
'title' => $txt['attachments_avatars'],
'help' => 'manage_files',
'description' => $txt['attachments_desc'],
);

// Get the subAction, call integrate_sa_manage_attachments
$subAction = $action->initialize($subActions, 'browse');
$context['sub_action'] = $subAction;

// This uses admin tabs - as it should!
$context[$context['admin_menu_name']]['object']->prepareTabData([
'title' => 'attachments_avatars',
'help' => 'manage_files',
'description' => 'attachments_desc',
]);

// Finally, go to where we want to go
$action->dispatch($subAction);
}
Expand Down
47 changes: 22 additions & 25 deletions sources/ElkArte/AdminController/ManageBans.php
Expand Up @@ -64,42 +64,39 @@ public function action_index()
// Default the sub-action to 'view ban list'.
$subAction = $action->initialize($subActions, 'list');

// Make the call to integrate-manage_bans
call_integration_hook('integrate_manage_bans', array(&$subActions));

// Prepare some items for the template
$context['page_title'] = $txt['ban_title'];
$context['sub_action'] = $subAction;

// Tabs for browsing the different ban functions.
$context[$context['admin_menu_name']]['tab_data'] = array(
'title' => $txt['ban_title'],
$context[$context['admin_menu_name']]['object']->prepareTabData([
'title' => 'ban_title',
'help' => 'ban_members',
'description' => $txt['ban_description'],
'tabs' => array(
'list' => array(
'description' => 'ban_description',
'tabs' => [
'list' => [
'description' => $txt['ban_description'],
'href' => getUrl('admin', ['action' => 'admin', 'area' => 'ban', 'sa' => 'list']),
'is_selected' => $subAction === 'list' || $subAction === 'edit' || $subAction === 'edittrigger',
),
'add' => array(
'selected' => $subAction === 'list' || $subAction === 'edit' || $subAction === 'edittrigger',
],
'add' => [
'description' => $txt['ban_description'],
'href' => getUrl('admin', ['action' => 'admin', 'area' => 'ban', 'sa' => 'add']),
'is_selected' => $subAction == 'add',
),
'browse' => array(
],
'browse' => [
'description' => $txt['ban_trigger_browse_description'],
'href' => getUrl('admin', ['action' => 'admin', 'area' => 'ban', 'sa' => 'browse']),
'is_selected' => $subAction == 'browse',
),
'log' => array(
],
'log' => [
'description' => $txt['ban_log_description'],
'href' => getUrl('admin', ['action' => 'admin', 'area' => 'ban', 'sa' => 'log']),
'is_selected' => $subAction == 'log',
'is_last' => true,
),
),
);

// Make the call to integrate-manage_bans
call_integration_hook('integrate_manage_bans', array(&$subActions));

// Prepare some items for the template
$context['page_title'] = $txt['ban_title'];
$context['sub_action'] = $subAction;
],
],
]);

// Call the right function for this sub-action.
$action->dispatch($subAction);
Expand Down
22 changes: 8 additions & 14 deletions sources/ElkArte/AdminController/ManageBoards.php
Expand Up @@ -105,27 +105,21 @@ public function action_index()
'permission' => 'admin_forum'),
);

// Create the tabs for the template.
$context[$context['admin_menu_name']]['tab_data'] = array(
'title' => $txt['boards_and_cats'],
'help' => 'manage_boards',
'description' => $txt['boards_and_cats_desc'],
'tabs' => array(
'main' => array(),
'newcat' => array(),
'settings' => array(
'description' => $txt['mboards_settings_desc'],
),
),
);

// You way will end here if you don't have permission.
$action = new Action('manage_boards');

// Default to sub-action 'main' or 'settings' depending on permissions.
$subAction = $action->initialize($subActions, allowedTo('manage_boards') ? 'main' : 'settings');
$context['sub_action'] = $subAction;

// Create the tabs for the template.
$context[$context['admin_menu_name']]['object']->prepareTabData([
'title' => 'boards_and_cats',
'help' => 'manage_boards',
'description' => 'boards_and_cats_desc',
'prefix' => 'mboards',
]);

$action->dispatch($subAction);
}

Expand Down
18 changes: 9 additions & 9 deletions sources/ElkArte/AdminController/ManageCalendarModule.php
Expand Up @@ -82,18 +82,18 @@ public function action_index()
$action = new Action('manage_calendar');

// Set up the two tabs here...
$context[$context['admin_menu_name']]['tab_data'] = array(
'title' => $txt['manage_calendar'],
$context[$context['admin_menu_name']]['object']->prepareTabData([
'title' => 'manage_calendar',
'description' => 'calendar_settings_desc',
'help' => 'calendar',
'description' => $txt['calendar_settings_desc'],
'tabs' => array(
'holidays' => array(
'tabs' => [
'holidays' => [
'description' => $txt['manage_holidays_desc'],
),
'settings' => array(
],
'settings' => [
'description' => $txt['calendar_settings_desc'],
),
),
],
]]
);

// Set up the default subaction, call integrate_sa_manage_calendar
Expand Down

0 comments on commit 6d3b525

Please sign in to comment.