From ff7e9dc91262aa43c6153831a33fda13d5324325 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 16 May 2015 18:49:32 +0200 Subject: [ticket/13844] Refactor bbcode help to the new system PHPBB3-13844 --- phpBB/phpbb/help/manager.php | 85 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 phpBB/phpbb/help/manager.php (limited to 'phpBB/phpbb/help/manager.php') diff --git a/phpBB/phpbb/help/manager.php b/phpBB/phpbb/help/manager.php new file mode 100644 index 0000000000..a7320563a8 --- /dev/null +++ b/phpBB/phpbb/help/manager.php @@ -0,0 +1,85 @@ + + * @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; + +/** + * Class help page manager + */ +class manager +{ + /** @var \phpbb\template\template */ + protected $template; + + /** @var \phpbb\language\language */ + protected $language; + + /** @var bool */ + protected $switched_column; + + /** + * Constructor + * + * @param \phpbb\template\template $template + * @param \phpbb\language\language $language + */ + public function __construct(\phpbb\template\template $template, \phpbb\language\language $language) + { + $this->template = $template; + $this->language = $language; + } + + /** + * Add a new faq block + * + * @param string $block_name Name or language key with the name of the block + * @param bool $switch_column Switch the column of the menu + */ + public function add_block($block_name, $switch_column = false, $questions = array()) + { + $this->template->assign_block_vars('faq_block', array( + 'BLOCK_TITLE' => $this->language->lang($block_name), + 'SWITCH_COLUMN' => !$this->switched_column && $switch_column, + )); + + foreach ($questions as $question => $answer) + { + $this->add_question($question, $answer); + } + + $this->switched_column = $this->switched_column || $switch_column; + } + + /** + * Add a new faq question + * + * @param string $question Question or language key with the question of the block + * @param string $answer Answer or language key with the answer of the block + */ + public function add_question($question, $answer) + { + $this->template->assign_block_vars('faq_block.faq_row', array( + 'FAQ_QUESTION' => $this->language->lang($question), + 'FAQ_ANSWER' => $this->language->lang($answer), + )); + } + + /** + * Returns whether the block titles switched side + * @return bool + */ + public function switched_column() + { + return $this->switched_column; + } +} -- cgit v1.2.1 From 077051fef56f0d9b504a2593dc84a3d05ef02e18 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 20 May 2015 00:23:42 +0200 Subject: [ticket/13844] Add events PHPBB3-13844 --- phpBB/phpbb/help/manager.php | 61 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 56 insertions(+), 5 deletions(-) (limited to 'phpBB/phpbb/help/manager.php') diff --git a/phpBB/phpbb/help/manager.php b/phpBB/phpbb/help/manager.php index a7320563a8..d6991c0733 100644 --- a/phpBB/phpbb/help/manager.php +++ b/phpBB/phpbb/help/manager.php @@ -18,25 +18,30 @@ namespace phpbb\help; */ class manager { - /** @var \phpbb\template\template */ - protected $template; + /** @var \phpbb\event\dispatcher */ + protected $dispatcher; /** @var \phpbb\language\language */ protected $language; + /** @var \phpbb\template\template */ + protected $template; + /** @var bool */ protected $switched_column; /** * Constructor * - * @param \phpbb\template\template $template + * @param \phpbb\event\dispatcher $dispatcher * @param \phpbb\language\language $language + * @param \phpbb\template\template $template */ - public function __construct(\phpbb\template\template $template, \phpbb\language\language $language) + public function __construct(\phpbb\event\dispatcher $dispatcher, \phpbb\language\language $language, \phpbb\template\template $template) { - $this->template = $template; + $this->dispatcher = $dispatcher; $this->language = $language; + $this->template = $template; } /** @@ -47,6 +52,18 @@ class manager */ public function add_block($block_name, $switch_column = false, $questions = array()) { + /** + * You can use this event to add a block before the current one. + * + * @event core.help_manager_add_block_before + * @var string block_name Language key of the block headline + * @var bool switch_column Should we switch the menu column before this headline + * @var array questions Array with questions + * @since 3.2.0-a1 + */ + $vars = array('block_name', 'switch_column', 'questions'); + extract($this->dispatcher->trigger_event('core.help_manager_add_block_before', compact($vars))); + $this->template->assign_block_vars('faq_block', array( 'BLOCK_TITLE' => $this->language->lang($block_name), 'SWITCH_COLUMN' => !$this->switched_column && $switch_column, @@ -58,6 +75,18 @@ class manager } $this->switched_column = $this->switched_column || $switch_column; + + /** + * You can use this event to add a block after the current one. + * + * @event core.help_manager_add_block_after + * @var string block_name Language key of the block headline + * @var bool switch_column Should we switch the menu column before this headline + * @var array questions Array with questions + * @since 3.2.0-a1 + */ + $vars = array('block_name', 'switch_column', 'questions'); + extract($this->dispatcher->trigger_event('core.help_manager_add_block_after', compact($vars))); } /** @@ -68,10 +97,32 @@ class manager */ public function add_question($question, $answer) { + /** + * You can use this event to add a question before the current one. + * + * @event core.help_manager_add_question_before + * @var string question Language key of the question + * @var string answer Language key of the answer + * @since 3.2.0-a1 + */ + $vars = array('question', 'answer'); + extract($this->dispatcher->trigger_event('core.help_manager_add_question_before', compact($vars))); + $this->template->assign_block_vars('faq_block.faq_row', array( 'FAQ_QUESTION' => $this->language->lang($question), 'FAQ_ANSWER' => $this->language->lang($answer), )); + + /** + * You can use this event to add a question after the current one. + * + * @event core.help_manager_add_question_after + * @var string question Language key of the question + * @var string answer Language key of the answer + * @since 3.2.0-a1 + */ + $vars = array('question', 'answer'); + extract($this->dispatcher->trigger_event('core.help_manager_add_question_after', compact($vars))); } /** -- cgit v1.2.1 From af7872473d41b4fd82a850e87f9e74a72a5b3230 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Thu, 16 Jul 2015 22:52:25 -0700 Subject: [ticket/14033] Fix errors in docblocks PHPBB3-14033 --- phpBB/phpbb/help/manager.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/phpbb/help/manager.php') diff --git a/phpBB/phpbb/help/manager.php b/phpBB/phpbb/help/manager.php index d6991c0733..39f52d343b 100644 --- a/phpBB/phpbb/help/manager.php +++ b/phpBB/phpbb/help/manager.php @@ -49,6 +49,7 @@ class manager * * @param string $block_name Name or language key with the name of the block * @param bool $switch_column Switch the column of the menu + * @param array $questions Array of frequently asked questions */ public function add_block($block_name, $switch_column = false, $questions = array()) { -- cgit v1.2.1 From ba5a2bcb73c8914a3c2a8f2dba11f1afd810aeb2 Mon Sep 17 00:00:00 2001 From: Agris Date: Tue, 20 Jun 2017 22:38:21 +0300 Subject: [ticket/15251] Use dispatcher_interface in help manager Allow TraceableEventDispatcher for webprofiler PHPBB3-15251 --- phpBB/phpbb/help/manager.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/help/manager.php') diff --git a/phpBB/phpbb/help/manager.php b/phpBB/phpbb/help/manager.php index 39f52d343b..1637c58a61 100644 --- a/phpBB/phpbb/help/manager.php +++ b/phpBB/phpbb/help/manager.php @@ -18,7 +18,7 @@ namespace phpbb\help; */ class manager { - /** @var \phpbb\event\dispatcher */ + /** @var \phpbb\event\dispatcher_interface */ protected $dispatcher; /** @var \phpbb\language\language */ @@ -33,11 +33,11 @@ class manager /** * Constructor * - * @param \phpbb\event\dispatcher $dispatcher + * @param \phpbb\event\dispatcher_interface $dispatcher * @param \phpbb\language\language $language * @param \phpbb\template\template $template */ - public function __construct(\phpbb\event\dispatcher $dispatcher, \phpbb\language\language $language, \phpbb\template\template $template) + public function __construct(\phpbb\event\dispatcher_interface $dispatcher, \phpbb\language\language $language, \phpbb\template\template $template) { $this->dispatcher = $dispatcher; $this->language = $language; -- cgit v1.2.1