Skip to content

Commit 2fee530

Browse files
committed
Improve ACP
Signed-off-by: Matt Friedman <maf675@gmail.com>
1 parent c885959 commit 2fee530

4 files changed

Lines changed: 19 additions & 7 deletions

File tree

event/listener.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,26 @@ public function acp_pwa_options($event)
138138
$my_config_vars = [
139139
'legend_pwa_settings'=> 'PWA_SETTINGS',
140140
'pwa_short_name' => ['lang' => 'PWA_SHORT_NAME', 'validate' => 'string', 'type' => 'text:40:12', 'explain' => true],
141-
'pwa_icon_small' => ['lang' => 'PWA_ICON_SMALL', 'validate' => 'pwa_options', 'type' => 'text:40:255', 'explain' => true],
142-
'pwa_icon_large' => ['lang' => 'PWA_ICON_LARGE', 'validate' => 'pwa_options', 'type' => 'text:40:255', 'explain' => true],
141+
'pwa_icon_small' => ['lang' => 'PWA_ICON_SMALL', 'validate' => 'pwa_options', 'type' => 'custom', 'function' => [$this, 'pwa_icon_name'], 'explain' => true],
142+
'pwa_icon_large' => ['lang' => 'PWA_ICON_LARGE', 'validate' => 'pwa_options', 'type' => 'custom', 'function' => [$this, 'pwa_icon_name'], 'explain' => true],
143143
];
144144

145145
$event->update_subarray('display_vars', 'vars', phpbb_insert_config_array($event['display_vars']['vars'], $my_config_vars, ['before' => 'legend4']));
146146
}
147147
}
148148

149+
/**
150+
* Return HTML for PWA icon name settings
151+
*
152+
* @param string $value Value of config
153+
* @param string $key Name of config
154+
* @return string
155+
*/
156+
public function pwa_icon_name($value, $key)
157+
{
158+
return $this->config['icons_path'] . '/<input id="' . $key . '" type="text" size="40" maxlength="255" name="config[' . $key . ']" value="' . $value . '">';
159+
}
160+
149161
/**
150162
* Validate PWA options
151163
*

language/en/webpushnotifications_common_acp.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@
3838
//
3939

4040
$lang = array_merge($lang, [
41-
'PWA_SETTINGS' => 'Web application options',
41+
'PWA_SETTINGS' => 'Progressive web application options',
4242
'PWA_SHORT_NAME' => 'Short site name',
4343
'PWA_SHORT_NAME_EXPLAIN' => 'Your site name in 12 characters or less, which may be used as a label for an icon on a mobile device’s home screen.',
4444
'PWA_ICON_SMALL' => 'Small mobile device icon',
45-
'PWA_ICON_SMALL_EXPLAIN' => 'File name of a 192px x 192px PNG image. This file must be uploaded to your <samp>icons</samp> directory, e.g. <samp>./images/icons</samp>',
45+
'PWA_ICON_SMALL_EXPLAIN' => 'File name of a 192px x 192px PNG image. This file must be uploaded to your board’s <samp>icons</samp> directory.',
4646
'PWA_ICON_LARGE' => 'Large mobile device icon',
47-
'PWA_ICON_LARGE_EXPLAIN' => 'File name of a 512px x 512px PNG image. This file must be uploaded to your <samp>icons</samp> directory, e.g. <samp>./images/icons</samp>',
47+
'PWA_ICON_LARGE_EXPLAIN' => 'File name of a 512px x 512px PNG image. This file must be uploaded to your board’s <samp>icons</samp> directory.',
4848
'PWA_ICON_SIZE_INVALID' => '%s does not have the correct image dimensions.',
4949
'PWA_ICON_MIME_INVALID' => '%s must be a PNG image file.',
5050
'PWA_IMAGE_INVALID' => '%s does not appear to be a valid image file.',

language/en/webpushnotifications_module_acp.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
//
3939

4040
$lang = array_merge($lang, [
41-
'ACP_WEBPUSH_SETTINGS_EXPLAIN' => 'Here you can enable Web Push for board notifications. Web Push is a protocol for the real-time delivery of events to user agents, commonly referred to as push messages. It is compatible with the majority of modern browsers on both desktop and mobile devices. Users can opt to receive Web Push alerts in their browser by subscribing and enabling their preferred notifications in the UCP.',
41+
'ACP_WEBPUSH_SETTINGS_EXPLAIN' => 'Here you can enable Web Push for board notifications. Web Push is a protocol for the real-time delivery of events to user agents, commonly referred to as push messages. It is compatible with the majority of modern browsers on both desktop and mobile devices. Users can opt to receive Web Push alerts in their browser by subscribing and enabling their preferred notifications in the UCP.<br><br>To enable push notifications on Apple mobile devices, your site needs to operate as a Progressive Web Application (PWA) and be added to users’ home screens. This feature is now built into phpBB. For a better user experience, you can find additional PWA settings under <strong>Board settings</strong>, where you can configure an optional app name and app icons for your site.',
4242
'WEBPUSH_ENABLE' => 'Enable Web Push',
4343
'WEBPUSH_ENABLE_EXPLAIN' => 'Allow users to receive notifications in their browser or device via Web Push. To utilize Web Push, you must input or generate valid VAPID identification keys.',
4444
'WEBPUSH_GENERATE_VAPID_KEYS' => 'Generate Identification keys',

tests/functional/functional_test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function test_acp_module()
4141
$crawler = self::request('GET', 'adm/index.php?i=-phpbb-webpushnotifications-acp-wpn_acp_module&mode=webpush&sid=' . $this->sid);
4242

4343
$this->assertContainsLang('ACP_WEBPUSH_EXT_SETTINGS', $crawler->filter('div.main > h1')->text());
44-
$this->assertContainsLang('ACP_WEBPUSH_SETTINGS_EXPLAIN', $crawler->filter('div.main > p')->text());
44+
$this->assertContainsLang('ACP_WEBPUSH_SETTINGS_EXPLAIN', $crawler->filter('div.main > p')->html());
4545
$this->assertContainsLang('WEBPUSH_GENERATE_VAPID_KEYS', $crawler->filter('input[type="button"]')->attr('value'));
4646

4747
$form_data = [

0 commit comments

Comments
 (0)