aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--phpBB/config/default/container/services.yml1
-rw-r--r--phpBB/config/default/container/services_help.yml10
-rw-r--r--phpBB/config/default/routing/help.yml3
-rw-r--r--phpBB/config/default/routing/routing.yml4
-rw-r--r--phpBB/faq.php92
-rw-r--r--phpBB/includes/acp/acp_contact.php5
-rw-r--r--phpBB/includes/acp/acp_users.php5
-rw-r--r--phpBB/includes/functions.php4
-rw-r--r--phpBB/includes/ucp/ucp_pm_compose.php5
-rw-r--r--phpBB/includes/ucp/ucp_profile.php5
-rw-r--r--phpBB/phpbb/help/controller/help.php160
-rw-r--r--phpBB/posting.php4
-rw-r--r--phpBB/viewonline.php15
13 files changed, 217 insertions, 96 deletions
diff --git a/phpBB/config/default/container/services.yml b/phpBB/config/default/container/services.yml
index c376726b3b..36f22d72d6 100644
--- a/phpBB/config/default/container/services.yml
+++ b/phpBB/config/default/container/services.yml
@@ -8,6 +8,7 @@ imports:
- { resource: services_db.yml }
- { resource: services_event.yml }
- { resource: services_feed.yml }
+ - { resource: services_help.yml }
- { resource: services_mimetype_guesser.yml }
- { resource: services_notification.yml }
- { resource: services_password.yml }
diff --git a/phpBB/config/default/container/services_help.yml b/phpBB/config/default/container/services_help.yml
new file mode 100644
index 0000000000..ae3eafe7b0
--- /dev/null
+++ b/phpBB/config/default/container/services_help.yml
@@ -0,0 +1,10 @@
+services:
+ phpbb.help.controller:
+ class: phpbb\help\controller\help
+ arguments:
+ - @controller.helper
+ - @dispatcher
+ - @template
+ - @user
+ - %core.root_path%
+ - %core.php_ext%
diff --git a/phpBB/config/default/routing/help.yml b/phpBB/config/default/routing/help.yml
new file mode 100644
index 0000000000..957d6dab55
--- /dev/null
+++ b/phpBB/config/default/routing/help.yml
@@ -0,0 +1,3 @@
+phpbb_help_controller:
+ path: /{mode}
+ defaults: { _controller: phpbb.help.controller:handle }
diff --git a/phpBB/config/default/routing/routing.yml b/phpBB/config/default/routing/routing.yml
index 94146e1ec2..d6881f1959 100644
--- a/phpBB/config/default/routing/routing.yml
+++ b/phpBB/config/default/routing/routing.yml
@@ -7,3 +7,7 @@
# The above will be accessed via app.php?controller=foo and it will
# instantiate the "foo_service" service and call the "method" method.
#
+
+phpbb_help_routing:
+ resource: "help.yml"
+ prefix: /help
diff --git a/phpBB/faq.php b/phpBB/faq.php
index ddecd28b00..7420bc5a95 100644
--- a/phpBB/faq.php
+++ b/phpBB/faq.php
@@ -24,90 +24,12 @@ $user->session_begin();
$auth->acl($user->data);
$user->setup();
-$mode = $request->variable('mode', '');
+/** @var \phpbb\controller\helper $controller_helper */
+$controller_helper = $phpbb_container->get('controller.helper');
-// Load the appropriate faq file
-switch ($mode)
-{
- case 'bbcode':
- $l_title = $user->lang['BBCODE_GUIDE'];
- $user->add_lang('bbcode', false, true);
- break;
-
- default:
- $page_title = $user->lang['FAQ_EXPLAIN'];
- $ext_name = $lang_file = '';
-
- /**
- * You can use this event display a custom help page
- *
- * @event core.faq_mode_validation
- * @var string page_title Title of the page
- * @var string mode FAQ that is going to be displayed
- * @var string lang_file Language file containing the help data
- * @var string ext_name Vendor and extension name where the help
- * language file can be loaded from
- * @since 3.1.4-RC1
- */
- $vars = array(
- 'page_title',
- 'mode',
- 'lang_file',
- 'ext_name',
- );
- extract($phpbb_dispatcher->trigger_event('core.faq_mode_validation', compact($vars)));
-
- $l_title = $page_title;
- $user->add_lang(($lang_file) ? $lang_file : 'faq', false, true, $ext_name);
- break;
-}
-
-// Pull the array data from the lang pack
-$switch_column = $found_switch = false;
-$help_blocks = array();
-foreach ($user->help as $help_ary)
-{
- if ($help_ary[0] == '--')
- {
- if ($help_ary[1] == '--')
- {
- $switch_column = true;
- $found_switch = true;
- continue;
- }
-
- $template->assign_block_vars('faq_block', array(
- 'BLOCK_TITLE' => $help_ary[1],
- 'SWITCH_COLUMN' => $switch_column,
- ));
-
- if ($switch_column)
- {
- $switch_column = false;
- }
- continue;
- }
-
- $template->assign_block_vars('faq_block.faq_row', array(
- 'FAQ_QUESTION' => $help_ary[0],
- 'FAQ_ANSWER' => $help_ary[1])
- );
-}
-
-// Lets build a page ...
-$template->assign_vars(array(
- 'L_FAQ_TITLE' => $l_title,
- 'L_BACK_TO_TOP' => $user->lang['BACK_TO_TOP'],
-
- 'SWITCH_COLUMN_MANUALLY' => (!$found_switch) ? true : false,
- 'S_IN_FAQ' => true,
-));
-
-page_header($l_title);
-
-$template->set_filenames(array(
- 'body' => 'faq_body.html')
+$response = new \Symfony\Component\HttpFoundation\RedirectResponse(
+ $controller_helper->route('phpbb_help_controller', array(
+ 'mode' => $request->variable('mode', 'faq'),
+ ), 301)
);
-make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
-
-page_footer();
+$response->send();
diff --git a/phpBB/includes/acp/acp_contact.php b/phpBB/includes/acp/acp_contact.php
index 2aa6620835..945add66a4 100644
--- a/phpBB/includes/acp/acp_contact.php
+++ b/phpBB/includes/acp/acp_contact.php
@@ -105,6 +105,9 @@ class acp_contact
$contact_admin_edit = generate_text_for_edit($contact_admin_info, $contact_admin_info_uid, $contact_admin_info_flags);
+ /** @var \phpbb\controller\helper $controller_helper */
+ $controller_helper = $phpbb_container->get('controller.helper');
+
$template->assign_vars(array(
'ERRORS' => $error,
'CONTACT_ENABLED' => $config['contact_admin_form_enable'],
@@ -116,7 +119,7 @@ class acp_contact
'S_SMILIES_DISABLE_CHECKED' => !$contact_admin_edit['allow_smilies'],
'S_MAGIC_URL_DISABLE_CHECKED' => !$contact_admin_edit['allow_urls'],
- 'BBCODE_STATUS' => $user->lang('BBCODE_IS_ON', '<a href="' . append_sid("{$phpbb_root_path}faq.$phpEx", 'mode=bbcode') . '">', '</a>'),
+ 'BBCODE_STATUS' => $user->lang('BBCODE_IS_ON', '<a href="' . $controller_helper->route('phpbb_help_controller', array('mode' => 'bbcode')) . '">', '</a>'),
'SMILIES_STATUS' => $user->lang['SMILIES_ARE_ON'],
'IMG_STATUS' => $user->lang['IMAGES_ARE_ON'],
'FLASH_STATUS' => $user->lang['FLASH_IS_ON'],
diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php
index 4cefdc2b4f..976589bac1 100644
--- a/phpBB/includes/acp/acp_users.php
+++ b/phpBB/includes/acp/acp_users.php
@@ -2019,6 +2019,9 @@ class acp_users
$decoded_message = generate_text_for_edit($signature, $bbcode_uid, $bbcode_bitfield);
+ /** @var \phpbb\controller\helper $controller_helper */
+ $controller_helper = $phpbb_container->get('controller.helper');
+
$template->assign_vars(array(
'S_SIGNATURE' => true,
@@ -2029,7 +2032,7 @@ class acp_users
'S_SMILIES_CHECKED' => (!$enable_smilies) ? ' checked="checked"' : '',
'S_MAGIC_URL_CHECKED' => (!$enable_urls) ? ' checked="checked"' : '',
- 'BBCODE_STATUS' => ($config['allow_sig_bbcode']) ? sprintf($user->lang['BBCODE_IS_ON'], '<a href="' . append_sid("{$phpbb_root_path}faq.$phpEx", 'mode=bbcode') . '">', '</a>') : sprintf($user->lang['BBCODE_IS_OFF'], '<a href="' . append_sid("{$phpbb_root_path}faq.$phpEx", 'mode=bbcode') . '">', '</a>'),
+ 'BBCODE_STATUS' => $user->lang(($config['allow_sig_bbcode'] ? 'BBCODE_IS_ON' : 'BBCODE_IS_OFF'), '<a href="' . $controller_helper->route('phpbb_help_controller', array('mode' => 'bbcode')) . '">', '</a>'),
'SMILIES_STATUS' => ($config['allow_sig_smilies']) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'],
'IMG_STATUS' => ($config['allow_sig_img']) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'],
'FLASH_STATUS' => ($config['allow_sig_flash']) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'],
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index fcfba6f4ed..2514dd48d5 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -4862,6 +4862,8 @@ function page_header($page_title = '', $display_online_list = false, $item_id =
}
}
+ /** @var \phpbb\controller\helper $controller_helper */
+ $controller_helper = $phpbb_container->get('controller.helper');
$notification_mark_hash = generate_link_hash('mark_all_notifications_read');
// The following assigns all _common_ variables that may be used at any point in a template.
@@ -4915,7 +4917,7 @@ function page_header($page_title = '', $display_online_list = false, $item_id =
'U_PROFILE' => append_sid("{$phpbb_root_path}ucp.$phpEx"),
'U_USER_PROFILE' => get_username_string('profile', $user->data['user_id'], $user->data['username'], $user->data['user_colour']),
'U_MODCP' => append_sid("{$phpbb_root_path}mcp.$phpEx", false, true, $user->session_id),
- 'U_FAQ' => append_sid("{$phpbb_root_path}faq.$phpEx"),
+ 'U_FAQ' => $controller_helper->route('phpbb_help_controller', array('mode' => 'faq')),
'U_SEARCH_SELF' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=egosearch'),
'U_SEARCH_NEW' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=newposts'),
'U_SEARCH_UNANSWERED' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=unanswered'),
diff --git a/phpBB/includes/ucp/ucp_pm_compose.php b/phpBB/includes/ucp/ucp_pm_compose.php
index 0064fb89fc..fa28bd89a4 100644
--- a/phpBB/includes/ucp/ucp_pm_compose.php
+++ b/phpBB/includes/ucp/ucp_pm_compose.php
@@ -1120,6 +1120,9 @@ function compose_pm($id, $mode, $action, $user_folders = array())
$form_enctype = (@ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads')) == 'off' || !$config['allow_pm_attach'] || !$auth->acl_get('u_pm_attach')) ? '' : ' enctype="multipart/form-data"';
+ /** @var \phpbb\controller\helper $controller_helper */
+ $controller_helper = $phpbb_container->get('controller.helper');
+
// Start assigning vars for main posting page ...
$template->assign_vars(array(
'L_POST_A' => $page_title,
@@ -1128,7 +1131,7 @@ function compose_pm($id, $mode, $action, $user_folders = array())
'SUBJECT' => (isset($message_subject)) ? $message_subject : '',
'MESSAGE' => $message_text,
- 'BBCODE_STATUS' => ($bbcode_status) ? sprintf($user->lang['BBCODE_IS_ON'], '<a href="' . append_sid("{$phpbb_root_path}faq.$phpEx", 'mode=bbcode') . '">', '</a>') : sprintf($user->lang['BBCODE_IS_OFF'], '<a href="' . append_sid("{$phpbb_root_path}faq.$phpEx", 'mode=bbcode') . '">', '</a>'),
+ 'BBCODE_STATUS' => $user->lang(($bbcode_status ? 'BBCODE_IS_ON' : 'BBCODE_IS_OFF'), '<a href="' . $controller_helper->route('phpbb_help_controller', array('mode' => 'bbcode')) . '">', '</a>'),
'IMG_STATUS' => ($img_status) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'],
'FLASH_STATUS' => ($flash_status) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'],
'SMILIES_STATUS' => ($smilies_status) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'],
diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php
index cc1e58edac..8adb96b6ab 100644
--- a/phpBB/includes/ucp/ucp_profile.php
+++ b/phpBB/includes/ucp/ucp_profile.php
@@ -548,6 +548,9 @@ class ucp_profile
$decoded_message = generate_text_for_edit($signature, $bbcode_uid, $bbcode_bitfield);
+ /** @var \phpbb\controller\helper $controller_helper */
+ $controller_helper = $phpbb_container->get('controller.helper');
+
$template->assign_vars(array(
'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
'SIGNATURE' => $decoded_message['text'],
@@ -557,7 +560,7 @@ class ucp_profile
'S_SMILIES_CHECKED' => (!$enable_smilies) ? ' checked="checked"' : '',
'S_MAGIC_URL_CHECKED' => (!$enable_urls) ? ' checked="checked"' : '',
- 'BBCODE_STATUS' => ($config['allow_sig_bbcode']) ? sprintf($user->lang['BBCODE_IS_ON'], '<a href="' . append_sid("{$phpbb_root_path}faq.$phpEx", 'mode=bbcode') . '">', '</a>') : sprintf($user->lang['BBCODE_IS_OFF'], '<a href="' . append_sid("{$phpbb_root_path}faq.$phpEx", 'mode=bbcode') . '">', '</a>'),
+ 'BBCODE_STATUS' => $user->lang(($config['allow_sig_bbcode'] ? 'BBCODE_IS_ON' : 'BBCODE_IS_OFF'), '<a href="' . $controller_helper->route('phpbb_help_controller', array('mode' => 'bbcode')) . '">', '</a>'),
'SMILIES_STATUS' => ($config['allow_sig_smilies']) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'],
'IMG_STATUS' => ($config['allow_sig_img']) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'],
'FLASH_STATUS' => ($config['allow_sig_flash']) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'],
diff --git a/phpBB/phpbb/help/controller/help.php b/phpBB/phpbb/help/controller/help.php
new file mode 100644
index 0000000000..9cc3b0c8b4
--- /dev/null
+++ b/phpBB/phpbb/help/controller/help.php
@@ -0,0 +1,160 @@
+<?php
+/**
+ *
+ * This file is part of the phpBB Forum Software package.
+ *
+ * @copyright (c) phpBB Limited <https://www.phpbb.com>
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ * For full copyright and license information, please see
+ * the docs/CREDITS.txt file.
+ *
+ */
+
+namespace phpbb\help\controller;
+
+use phpbb\exception\http_exception;
+
+class help
+{
+ /** @var \phpbb\controller\helper */
+ protected $helper;
+
+ /** @var \phpbb\event\dispatcher_interface */
+ protected $dispatcher;
+
+ /** @var \phpbb\template\template */
+ protected $template;
+
+ /** @var \phpbb\user */
+ protected $user;
+
+ /** @var string */
+ protected $root_path;
+
+ /** @var string */
+ protected $php_ext;
+
+ /**
+ * Constructor
+ *
+ * @param \phpbb\controller\helper $helper
+ * @param \phpbb\event\dispatcher_interface $dispatcher
+ * @param \phpbb\template\template $template
+ * @param \phpbb\user $user
+ * @param string $root_path
+ * @param string $php_ext
+ */
+ public function __construct(\phpbb\controller\helper $helper, \phpbb\event\dispatcher_interface $dispatcher, \phpbb\template\template $template, \phpbb\user $user, $root_path, $php_ext)
+ {
+ $this->helper = $helper;
+ $this->dispatcher = $dispatcher;
+ $this->template = $template;
+ $this->user = $user;
+ $this->root_path = $root_path;
+ $this->php_ext = $php_ext;
+ }
+
+ /**
+ * Controller for /help/{mode} routes
+ *
+ * @param string $mode
+ * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object
+ * @throws http_exception when the $mode is not known by any extension
+ */
+ public function handle($mode)
+ {
+ switch ($mode)
+ {
+ case 'faq':
+ case 'bbcode':
+ $page_title = ($mode === 'faq') ? $this->user->lang['FAQ_EXPLAIN'] : $this->user->lang['BBCODE_GUIDE'];
+ $this->user->add_lang($mode, false, true);
+ break;
+
+ default:
+ $page_title = $this->user->lang['FAQ_EXPLAIN'];
+ $ext_name = $lang_file = '';
+
+ /**
+ * You can use this event display a custom help page
+ *
+ * @event core.faq_mode_validation
+ * @var string page_title Title of the page
+ * @var string mode FAQ that is going to be displayed
+ * @var string lang_file Language file containing the help data
+ * @var string ext_name Vendor and extension name where the help
+ * language file can be loaded from
+ * @since 3.1.4-RC1
+ */
+ $vars = array(
+ 'page_title',
+ 'mode',
+ 'lang_file',
+ 'ext_name',
+ );
+ extract($this->dispatcher->trigger_event('core.faq_mode_validation', compact($vars)));
+
+ if ($ext_name === '' || $lang_file === '')
+ {
+ throw new http_exception(404, 'Not Found');
+ }
+
+ $this->user->add_lang($lang_file, false, true, $ext_name);
+ break;
+
+ }
+
+ $this->template->assign_vars(array(
+ 'L_FAQ_TITLE' => $page_title,
+ 'S_IN_FAQ' => true,
+ ));
+
+ $this->assign_to_template($this->user->help);
+
+ make_jumpbox(append_sid("{$this->root_path}viewforum.{$this->php_ext}"));
+ return $this->helper->render('faq_body.html', $page_title);
+ }
+
+ /**
+ * Assigns the help data to the template blocks
+ *
+ * @param array $help_data
+ * @return null
+ */
+ protected function assign_to_template(array $help_data)
+ {
+ // Pull the array data from the lang pack
+ $switch_column = $found_switch = false;
+ foreach ($help_data as $help_ary)
+ {
+ if ($help_ary[0] == '--')
+ {
+ if ($help_ary[1] == '--')
+ {
+ $switch_column = true;
+ $found_switch = true;
+ continue;
+ }
+
+ $this->template->assign_block_vars('faq_block', array(
+ 'BLOCK_TITLE' => $help_ary[1],
+ 'SWITCH_COLUMN' => $switch_column,
+ ));
+
+ if ($switch_column)
+ {
+ $switch_column = false;
+ }
+ continue;
+ }
+
+ $this->template->assign_block_vars('faq_block.faq_row', array(
+ 'FAQ_QUESTION' => $help_ary[0],
+ 'FAQ_ANSWER' => $help_ary[1],
+ ));
+ }
+
+ $this->template->assign_var('SWITCH_COLUMN_MANUALLY', !$found_switch);
+ }
+}
diff --git a/phpBB/posting.php b/phpBB/posting.php
index ecd9e9f6c0..9768dc6ea7 100644
--- a/phpBB/posting.php
+++ b/phpBB/posting.php
@@ -1720,6 +1720,8 @@ if (isset($captcha) && $captcha->is_solved() !== false)
$form_enctype = (@ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads')) == 'off' || !$config['allow_attachments'] || !$auth->acl_get('u_attach') || !$auth->acl_get('f_attach', $forum_id)) ? '' : ' enctype="multipart/form-data"';
add_form_key('posting');
+/** @var \phpbb\controller\helper $controller_helper */
+$controller_helper = $phpbb_container->get('controller.helper');
// Build array of variables for main posting page
$page_data = array(
@@ -1734,7 +1736,7 @@ $page_data = array(
'USERNAME' => ((!$preview && $mode != 'quote') || $preview) ? $post_data['username'] : '',
'SUBJECT' => $post_data['post_subject'],
'MESSAGE' => $post_data['post_text'],
- 'BBCODE_STATUS' => ($bbcode_status) ? sprintf($user->lang['BBCODE_IS_ON'], '<a href="' . append_sid("{$phpbb_root_path}faq.$phpEx", 'mode=bbcode') . '">', '</a>') : sprintf($user->lang['BBCODE_IS_OFF'], '<a href="' . append_sid("{$phpbb_root_path}faq.$phpEx", 'mode=bbcode') . '">', '</a>'),
+ 'BBCODE_STATUS' => $user->lang(($bbcode_status ? 'BBCODE_IS_ON' : 'BBCODE_IS_OFF'), '<a href="' . $controller_helper->route('phpbb_help_controller', array('mode' => 'bbcode')) . '">', '</a>'),
'IMG_STATUS' => ($img_status) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'],
'FLASH_STATUS' => ($flash_status) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'],
'SMILIES_STATUS' => ($smilies_status) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'],
diff --git a/phpBB/viewonline.php b/phpBB/viewonline.php
index ccbdc8d57e..46f67b93fa 100644
--- a/phpBB/viewonline.php
+++ b/phpBB/viewonline.php
@@ -163,6 +163,9 @@ $result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary));
$prev_id = $prev_ip = $user_list = array();
$logged_visible_online = $logged_hidden_online = $counter = 0;
+/** @var \phpbb\controller\helper $controller_helper */
+$controller_helper = $phpbb_container->get('controller.helper');
+
while ($row = $db->sql_fetchrow($result))
{
if ($row['user_id'] != ANONYMOUS && !isset($prev_id[$row['user_id']]))
@@ -287,11 +290,6 @@ while ($row = $db->sql_fetchrow($result))
$location_url = append_sid("{$phpbb_root_path}search.$phpEx");
break;
- case 'faq':
- $location = $user->lang['VIEWING_FAQ'];
- $location_url = append_sid("{$phpbb_root_path}faq.$phpEx");
- break;
-
case 'viewonline':
$location = $user->lang['VIEWING_ONLINE'];
$location_url = append_sid("{$phpbb_root_path}viewonline.$phpEx");
@@ -357,6 +355,13 @@ while ($row = $db->sql_fetchrow($result))
default:
$location = $user->lang['INDEX'];
$location_url = append_sid("{$phpbb_root_path}index.$phpEx");
+
+ if ($row['session_page'] === 'app.' . $phpEx . '/help/faq' ||
+ $row['session_page'] === 'app.' . $phpEx . '/help/bbcode')
+ {
+ $location = $user->lang['VIEWING_FAQ'];
+ $location_url = $controller_helper->route('phpbb_help_controller', array('mode' => 'faq'));
+ }
break;
}