Skip to content

Commit 62b791e

Browse files
committed
Add FAQ to help users
Signed-off-by: Matt Friedman <maf675@gmail.com>
1 parent 8034231 commit 62b791e

2 files changed

Lines changed: 94 additions & 0 deletions

File tree

event/listener.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public static function getSubscribedEvents()
8686
'core.acp_main_notice' => 'compatibility_notice',
8787
'core.acp_board_config_edit_add' => 'acp_pwa_options',
8888
'core.validate_config_variable' => 'validate_pwa_options',
89+
'core.help_manager_add_block_before'=> 'wpn_faq',
8990
];
9091
}
9192

@@ -279,6 +280,45 @@ public function validate_pwa_options($event)
279280
}
280281
}
281282

283+
/**
284+
* Add Web Push info to the phpBB FAQ
285+
*
286+
* @param \phpbb\event\data $event The event object
287+
* @return void
288+
*/
289+
public function wpn_faq($event)
290+
{
291+
if ($event['block_name'] === 'HELP_FAQ_BLOCK_ATTACHMENTS')
292+
{
293+
$this->language->add_lang('webpushnotifications_faq', 'phpbb/webpushnotifications');
294+
295+
$this->template->assign_block_vars('faq_block', [
296+
'BLOCK_TITLE' => $this->language->lang('HELP_FAQ_WPN'),
297+
'SWITCH_COLUMN' => false,
298+
]);
299+
300+
$questions = [
301+
'HELP_FAQ_WPN_WHAT_QUESTION' => 'HELP_FAQ_WPN_WHAT_ANSWER',
302+
'HELP_FAQ_WPN_HOW_QUESTION' => 'HELP_FAQ_WPN_HOW_ANSWER',
303+
'HELP_FAQ_WPN_IOS_QUESTION' => 'HELP_FAQ_WPN_IOS_ANSWER',
304+
'HELP_FAQ_WPN_SESSION_QUESTION' => 'HELP_FAQ_WPN_SESSION_ANSWER',
305+
'HELP_FAQ_WPN_SUBBING_QUESTION' => 'HELP_FAQ_WPN_SUBBING_ANSWER',
306+
'HELP_FAQ_WPN_GENERAL_QUESTION' => 'HELP_FAQ_WPN_GENERAL_ANSWER',
307+
];
308+
309+
$faq_rows = [];
310+
foreach ($questions as $question => $answer)
311+
{
312+
$faq_rows[] = [
313+
'FAQ_QUESTION' => $this->language->lang($question),
314+
'FAQ_ANSWER' => $this->language->lang($answer),
315+
];
316+
}
317+
318+
$this->template->assign_block_vars_array('faq_block.faq_row', $faq_rows);
319+
}
320+
}
321+
282322
/**
283323
* Add errors to the error array
284324
*
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
/**
3+
*
4+
* phpBB Browser Push Notifications. An extension for the phpBB Forum Software package.
5+
*
6+
* @copyright (c) 2024, phpBB Limited <https://www.phpbb.com>
7+
* @license GNU General Public License, version 2 (GPL-2.0)
8+
*
9+
*/
10+
11+
/**
12+
* DO NOT CHANGE
13+
*/
14+
if (!defined('IN_PHPBB'))
15+
{
16+
exit;
17+
}
18+
19+
if (empty($lang) || !is_array($lang))
20+
{
21+
$lang = [];
22+
}
23+
24+
// DEVELOPERS PLEASE NOTE
25+
//
26+
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
27+
//
28+
// Placeholders can now contain order information, e.g. instead of
29+
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
30+
// translators to re-order the output of data while ensuring it remains correct
31+
//
32+
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
33+
// equally where a string contains only two placeholders which are used to wrap text
34+
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine
35+
//
36+
// Some characters you may want to copy&paste:
37+
// ’ » “ ” …
38+
//
39+
40+
$lang = array_merge($lang, [
41+
'HELP_FAQ_WPN' => 'Web Push Notifications for Browsers',
42+
'HELP_FAQ_WPN_WHAT_QUESTION' => 'What are web push notifications?',
43+
'HELP_FAQ_WPN_WHAT_ANSWER' => 'Web push notifications enhance phpBB’s notifications by enabling web browsers to push real-time system notifications directly to your desktop or mobile device, even when you are not actively browsing this site. These notifications appear like app alerts and can deliver real time updates for private messages, post interactions, moderation actions, etc.',
44+
'HELP_FAQ_WPN_HOW_QUESTION' => 'How can I get forum notification alerts on my computer or mobile device?',
45+
'HELP_FAQ_WPN_HOW_ANSWER' => 'Go to the ‘Notification options’ in the UCP and enable to ‘web push notifications’. Once enabled, your browser may prompt you to allow this forum to send push notifications to your device, which you should allow. Note: if you still are not receiving notifications, you may need to visit your device‘s system settings enable/allow notifications from your browser.',
46+
'HELP_FAQ_WPN_IOS_QUESTION' => 'How does it work on mobile devices (iOS/Android)?',
47+
'HELP_FAQ_WPN_IOS_ANSWER' => 'On some devices, like those running iOS or iPadOS, users need to add the forum’s site to their Home Screen for push notifications to work. This will make the site function like a stand-alone web application. Refer to your specific device’s OS for instructions on enabling web push notifications for <a href="https://izooto.com/blog/enable-safari-push-notifications-on-ios-step-by-step-guide" target="_blank">iOS / iPadOS</a> or <a href="https://support.google.com/chrome/answer/3220216?hl=en&co=GENIE.Platform%3DAndroid&oco=0" target="_blank">Android Help</a>.',
48+
'HELP_FAQ_WPN_SESSION_QUESTION' => 'Will I receive notifications if I am logged out?',
49+
'HELP_FAQ_WPN_SESSION_ANSWER' => 'Yes, notifications will continue to be sent even if you are logged out.',
50+
'HELP_FAQ_WPN_SUBBING_QUESTION' => 'Why are the “Enable Push Notifications” buttons disabled?',
51+
'HELP_FAQ_WPN_SUBBING_ANSWER' => 'If the “Enable Push Notifications” buttons are visible but cannot be clicked, it’s likely because the browser or device you’re using doesn’t support push notifications. To resolve this, try using a different browser or device that supports this feature.',
52+
'HELP_FAQ_WPN_GENERAL_QUESTION' => 'I am still having trouble getting notifications after enable/allowing them?',
53+
'HELP_FAQ_WPN_GENERAL_ANSWER' => 'Ensure that your computer or device is configured to receive notifications from your web browser or web application. Some browsers may deliver notifications even when closed, while others may only do so when the browser is open. <a href="https://github.com/phpbb-extensions/webpushnotifications?tab=readme-ov-file#browser-support" target="_blank">Here is a table of supported behavior among the most common browsers.</a>',
54+
]);

0 commit comments

Comments
 (0)