+{% endif %}
+
+
+
+{% include 'overall_footer.html' %}
diff --git a/config/services.yml b/config/services.yml
index e21730d..bc3120c 100644
--- a/config/services.yml
+++ b/config/services.yml
@@ -14,13 +14,12 @@ services:
arguments:
- '@config'
- '@controller.helper'
- - '@upload_imagesize'
- '@phpbb.wpn.form_helper'
- '@language'
+ - '@request'
- '@template'
- '@user'
- '@notification_manager'
- - '%core.root_path%'
tags:
- { name: event.listener }
diff --git a/controller/manifest.php b/controller/manifest.php
index 968a84e..a1b71ba 100644
--- a/controller/manifest.php
+++ b/controller/manifest.php
@@ -61,6 +61,8 @@ public function handle(): JsonResponse
'orientation' => 'portrait',
'start_url' => $start_url,
'scope' => $scope,
+ 'theme_color' => !empty($this->user->style['pwa_theme_color']) ? $this->user->style['pwa_theme_color'] : ext::PWA_THEME_COLOR,
+ 'background_color' => !empty($this->user->style['pwa_bg_color']) ? $this->user->style['pwa_bg_color'] : ext::PWA_BG_COLOR,
];
if (!empty($this->config['pwa_icon_small']) && !empty($this->config['pwa_icon_large']))
@@ -80,6 +82,7 @@ public function handle(): JsonResponse
}
$response = new JsonResponse($manifest);
+ $response->headers->set('Content-Type', 'application/manifest+json');
$response->setPublic();
$response->setMaxAge(3600);
$response->headers->addCacheControlDirective('must-revalidate', true);
diff --git a/event/listener.php b/event/listener.php
index 462a9ff..4e5ae34 100644
--- a/event/listener.php
+++ b/event/listener.php
@@ -10,11 +10,11 @@
namespace phpbb\webpushnotifications\event;
-use FastImageSize\FastImageSize;
use phpbb\config\config;
use phpbb\controller\helper as controller_helper;
use phpbb\language\language;
use phpbb\notification\manager;
+use phpbb\request\request_interface;
use phpbb\template\template;
use phpbb\user;
use phpbb\webpushnotifications\ext;
@@ -35,12 +35,12 @@ class listener implements EventSubscriberInterface
/* @var form_helper */
protected $form_helper;
- /** @var FastImageSize */
- protected $imagesize;
-
/* @var language */
protected $language;
+ /** @var request_interface */
+ protected $request;
+
/* @var template */
protected $template;
@@ -50,33 +50,28 @@ class listener implements EventSubscriberInterface
/* @var manager */
protected $phpbb_notifications;
- /** @var string */
- protected $root_path;
-
/**
* Constructor
*
* @param config $config
* @param controller_helper $controller_helper Controller helper object
- * @param FastImageSize $imagesize
* @param form_helper $form_helper Form helper object
* @param language $language Language object
+ * @param request_interface $request
* @param template $template Template object
* @param user $user
* @param manager $phpbb_notifications Notifications manager object
- * @param string $root_path
*/
- public function __construct(config $config, controller_helper $controller_helper, FastImageSize $imagesize, form_helper $form_helper, language $language, template $template, user $user, manager $phpbb_notifications, $root_path)
+ public function __construct(config $config, controller_helper $controller_helper, form_helper $form_helper, language $language, request_interface $request, template $template, user $user, manager $phpbb_notifications)
{
$this->config = $config;
$this->controller_helper = $controller_helper;
- $this->imagesize = $imagesize;
$this->form_helper = $form_helper;
$this->language = $language;
+ $this->request = $request;
$this->template = $template;
$this->user = $user;
$this->phpbb_notifications = $phpbb_notifications;
- $this->root_path = $root_path;
}
public static function getSubscribedEvents()
@@ -86,9 +81,6 @@ public static function getSubscribedEvents()
'core.page_header_after' => [['load_template_data'], ['pwa_manifest']],
'core.ucp_display_module_before' => 'load_language',
'core.acp_main_notice' => 'compatibility_notice',
- 'core.acp_board_config_edit_add' => 'acp_pwa_options',
- 'core.acp_board_config_emoji_enabled' => 'acp_pwa_allow_emoji',
- 'core.validate_config_variable' => 'validate_pwa_options',
'core.help_manager_add_block_after' => 'wpn_faq',
];
}
@@ -163,155 +155,12 @@ public function pwa_manifest()
'U_MANIFEST_URL' => $this->controller_helper->route('phpbb_webpushnotifications_manifest_controller'),
'U_TOUCH_ICON' => $this->config['pwa_icon_small'] ? ext::PWA_ICON_DIR . '/' . $this->config['pwa_icon_small'] : null,
'SHORT_SITE_NAME' => $this->config['pwa_short_name'] ?: $this->trim_shortname($this->config['sitename']),
+ 'PWA_THEME_COLOR' => !empty($this->user->style['pwa_theme_color']) ? $this->user->style['pwa_theme_color'] : ext::PWA_THEME_COLOR,
+ 'PWA_BG_COLOR' => !empty($this->user->style['pwa_bg_color']) ? $this->user->style['pwa_bg_color'] : ext::PWA_BG_COLOR,
+ 'S_PWA_SHOW_BANNER' => !empty($this->config['pwa_show_install_banner']) && $this->is_mobile_phone(),
]);
}
- /**
- * Progressive web app options for the ACP
- *
- * @param \phpbb\event\data $event
- * @return void
- */
- public function acp_pwa_options($event)
- {
- if ($event['mode'] === 'settings' && array_key_exists('legend4', $event['display_vars']['vars']))
- {
- $this->language->add_lang('webpushnotifications_common_acp', 'phpbb/webpushnotifications');
-
- $my_config_vars = [
- 'legend_pwa_settings'=> 'PWA_SETTINGS',
- 'pwa_short_name' => ['lang' => 'PWA_SHORT_NAME', 'validate' => 'pwa_options:string', 'type' => 'custom', 'function' => [$this, 'pwa_short_sitename'], 'explain' => true],
- 'pwa_icon_small' => ['lang' => 'PWA_ICON_SMALL', 'validate' => 'pwa_options:icons', 'type' => 'custom', 'function' => [$this, 'pwa_icon_name'], 'explain' => true],
- 'pwa_icon_large' => ['lang' => 'PWA_ICON_LARGE', 'validate' => 'pwa_options:icons', 'type' => 'custom', 'function' => [$this, 'pwa_icon_name'], 'explain' => true],
- ];
-
- $event->update_subarray('display_vars', 'vars', phpbb_insert_config_array($event['display_vars']['vars'], $my_config_vars, ['before' => 'legend4']));
-
- $this->template->assign_var('S_PWA_OPTIONS', true);
- }
- }
-
- /**
- * Allow PWA short name ACP field to accept emoji characters
- *
- * @param \phpbb\event\data $event
- * @return void
- */
- public function acp_pwa_allow_emoji($event)
- {
- if (in_array('pwa_short_name', $event['config_name_ary'], true))
- {
- return;
- }
-
- $config_name_ary = $event['config_name_ary'];
- $config_name_ary[] = 'pwa_short_name';
- $event['config_name_ary'] = $config_name_ary;
- }
-
- /**
- * Return HTML for PWA icon name settings
- *
- * @param string $value Value of config
- * @param string $key Name of config
- * @return string
- */
- public function pwa_icon_name($value, $key)
- {
- return ext::PWA_ICON_DIR . '/';
- }
-
- /**
- * Return HTML for PWA short site name setting
- *
- * @param string $value Value of config
- * @param string $key Name of config
- * @return string
- */
- public function pwa_short_sitename($value, $key)
- {
- $placeholder = $this->trim_shortname($this->config['sitename']);
-
- return '';
- }
-
- /**
- * Validate PWA options
- *
- * @param \phpbb\event\data $event
- * @return void
- */
- public function validate_pwa_options($event)
- {
- $type = 0;
- $mode = 1;
-
- $validator = explode(':', $event['config_definition']['validate']);
-
- if ($validator[$type] !== 'pwa_options')
- {
- return;
- }
-
- switch ($validator[$mode])
- {
- case 'string':
- // Ignore validation if icon fields are empty
- if (empty($event['cfg_array']['pwa_short_name']))
- {
- return;
- }
-
- $short_name = ext::decode_entities($event['cfg_array']['pwa_short_name'], ENT_QUOTES);
-
- // Do not allow strings longer than 12 characters
- if (utf8_strlen($short_name) > 12)
- {
- $this->add_error($event, 'PWA_SHORT_NAME_INVALID');
- return;
- }
- break;
-
- case 'icons':
- // Ignore validation if icon fields are empty
- if (empty($event['cfg_array']['pwa_icon_small']) && empty($event['cfg_array']['pwa_icon_large']))
- {
- return;
- }
-
- $value = $event['cfg_array'][$event['config_name']];
-
- // Don't allow empty values, if one icon is set, both must be set.
- if (empty($value))
- {
- $this->add_error($event, 'PWA_ICON_NOT_PROVIDED', $this->language->lang(strtoupper($event['config_name'])));
- return;
- }
-
- // Check if image is valid
- $image = $this->root_path . ext::PWA_ICON_DIR . '/' . $value;
- $image_info = $this->imagesize->getImageSize($image);
- if ($image_info !== false)
- {
- if (($event['config_name'] === 'pwa_icon_small' && $image_info['width'] !== 192 && $image_info['height'] !== 192) ||
- ($event['config_name'] === 'pwa_icon_large' && $image_info['width'] !== 512 && $image_info['height'] !== 512))
- {
- $this->add_error($event, 'PWA_ICON_SIZE_INVALID', $value);
- }
-
- if ($image_info['type'] !== IMAGETYPE_PNG)
- {
- $this->add_error($event, 'PWA_ICON_MIME_INVALID', $value);
- }
- }
- else
- {
- $this->add_error($event, 'PWA_ICON_INVALID', $value);
- }
- break;
- }
- }
-
/**
* Add Web Push info to the phpBB FAQ
*
@@ -350,21 +199,6 @@ public function wpn_faq($event)
}
}
- /**
- * Add errors to the error array
- *
- * @param \phpbb\event\data $event
- * @param string $error_key
- * @param string $param
- * @return void
- */
- protected function add_error($event, $error_key, $param = null)
- {
- $error = $event['error'];
- $error[] = $this->language->lang($error_key, $param);
- $event['error'] = $error;
- }
-
/**
* Can notifications be used by the user?
*
@@ -389,4 +223,20 @@ protected function trim_shortname($name)
$trimmed = utf8_substr($decoded, 0, 12);
return utf8_htmlspecialchars($trimmed);
}
+
+ /**
+ * Lightweight phone detection for install-banner display
+ *
+ * @return bool
+ */
+ protected function is_mobile_phone()
+ {
+ $user_agent = (string) $this->request->server('HTTP_USER_AGENT', '');
+ if ($user_agent === '' || preg_match('/ipad|tablet|kindle|silk|playbook/i', $user_agent))
+ {
+ return false;
+ }
+
+ return (bool) preg_match('/mobile|iphone|ipod|android.*mobile|windows phone|blackberry|opera mini/i', $user_agent);
+ }
}
diff --git a/ext.php b/ext.php
index 56f2872..e58af68 100644
--- a/ext.php
+++ b/ext.php
@@ -20,6 +20,12 @@ class ext extends \phpbb\extension\base
*/
public const PWA_ICON_DIR = 'images/site_icons';
+ /** @var string PWA theme color */
+ public const PWA_THEME_COLOR = '#000000';
+
+ /** @var string PWA background color */
+ public const PWA_BG_COLOR = '#ffffff';
+
/**
* Require phpBB 3.3.12 due to new template and core events.
*/
diff --git a/language/en/common.php b/language/en/common.php
index 36a6e24..99704aa 100644
--- a/language/en/common.php
+++ b/language/en/common.php
@@ -38,5 +38,9 @@
//
$lang = array_merge($lang, [
+ 'PWA_INSTALL_BUTTON' => 'Install app',
+ 'PWA_INSTALL_DISMISS' => 'Close',
+ 'PWA_INSTALL_SUBTITLE' => 'Add to home screen',
+ 'PWA_INSTALL_SUBTITLE_IOS' => 'Tap Share and then “Add to Home Screen” to install this app.',
'WEBPUSH_INVALID_ENDPOINT' => 'The push notification endpoint is not from a recognised push service.',
]);
diff --git a/language/en/info_acp_webpushnotifications.php b/language/en/info_acp_webpushnotifications.php
index 7e01c05..dfecca9 100644
--- a/language/en/info_acp_webpushnotifications.php
+++ b/language/en/info_acp_webpushnotifications.php
@@ -39,6 +39,7 @@
$lang = array_merge($lang, [
'ACP_WEBPUSH_EXT_SETTINGS' => 'Web Push settings',
+ 'ACP_WEBPUSH_PWA_SETTINGS' => 'PWA settings',
'ACP_WEBPUSH_REMOVE_WARNING' => 'Web Push Notifications are now built into phpBB',
'ACP_WEBPUSH_REMOVE_NOTICE' => 'The extension “phpBB Browser Push Notifications” is no longer needed and should be uninstalled and removed. All settings and user preferences associated with the extension will be migrated into phpBB’s built-in push notifications when you uninstall the extension.',
'LOG_CONFIG_WEBPUSH' => 'Altered Web Push settings',
diff --git a/language/en/webpushnotifications_common_acp.php b/language/en/webpushnotifications_common_acp.php
deleted file mode 100644
index 7cfb060..0000000
--- a/language/en/webpushnotifications_common_acp.php
+++ /dev/null
@@ -1,53 +0,0 @@
-
- * @license GNU General Public License, version 2 (GPL-2.0)
- *
- */
-
-/**
- * DO NOT CHANGE
- */
-if (!defined('IN_PHPBB'))
-{
- exit;
-}
-
-if (empty($lang) || !is_array($lang))
-{
- $lang = [];
-}
-
-// DEVELOPERS PLEASE NOTE
-//
-// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
-//
-// Placeholders can now contain order information, e.g. instead of
-// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
-// translators to re-order the output of data while ensuring it remains correct
-//
-// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
-// equally where a string contains only two placeholders which are used to wrap text
-// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine
-//
-// Some characters you may want to copy&paste:
-// ’ » “ ” …
-//
-
-$lang = array_merge($lang, [
- 'PWA_SETTINGS' => 'Progressive web application options',
- 'PWA_SHORT_NAME' => 'Short site name',
- 'PWA_SHORT_NAME_EXPLAIN' => 'Your site name in 12 characters or fewer, which may be used as a label for an icon on a mobile device’s home screen. (If this field is left empty, the first 12 characters of the Site name will be used.)',
- 'PWA_SHORT_NAME_INVALID' => '“Short site name” exceeds the 12 character limit.',
- 'PWA_ICON_SMALL' => 'Small mobile device icon',
- 'PWA_ICON_SMALL_EXPLAIN' => 'File name of a 192px x 192px PNG image. This file must be uploaded to your board’s ' . \phpbb\webpushnotifications\ext::PWA_ICON_DIR . ' directory.',
- 'PWA_ICON_LARGE' => 'Large mobile device icon',
- 'PWA_ICON_LARGE_EXPLAIN' => 'File name of a 512px x 512px PNG image. This file must be uploaded to your board’s ' . \phpbb\webpushnotifications\ext::PWA_ICON_DIR . ' directory.',
- 'PWA_ICON_SIZE_INVALID' => '“%s” does not have the correct image dimensions.',
- 'PWA_ICON_MIME_INVALID' => '“%s” must be a PNG image file.',
- 'PWA_ICON_INVALID' => '“%s” is not a valid image file or is missing from the expected location. Verify the file name and location are correct.',
- 'PWA_ICON_NOT_PROVIDED' => '%s field must not be empty. All icon fields must contain an image.',
-]);
diff --git a/language/en/webpushnotifications_module_acp.php b/language/en/webpushnotifications_module_acp.php
index 9d83cd0..3929a27 100644
--- a/language/en/webpushnotifications_module_acp.php
+++ b/language/en/webpushnotifications_module_acp.php
@@ -38,7 +38,8 @@
//
$lang = array_merge($lang, [
- '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.
To enable push notifications on Apple mobile devices, your site needs to function as a Progressive Web Application (PWA). This requires users to add your site to their device’s home screen. For an improved user experience, you can find additional PWA settings under Board settings, where you can configure an optional app name and app icons for how your site will appear on users’ home screens.',
+ // Web push settings
+ '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.
To enable push notifications on Apple mobile devices, your site needs to function as a Progressive Web Application (PWA). This requires users to add your site to their device’s home screen. Configure app metadata and install behaviour under PWA settings.',
'WEBPUSH_ENABLE' => 'Enable Web Push',
'WEBPUSH_ENABLE_EXPLAIN' => 'Allow users to receive notifications in their browser or device via Web Push. To utilise Web Push, you must input or generate valid VAPID identification keys.',
'WEBPUSH_GENERATE_VAPID_KEYS' => 'Generate Identification keys',
@@ -53,4 +54,26 @@
'WEBPUSH_POPUP_PROMPT' => 'Show popup prompt for unsubscribed members',
'WEBPUSH_POPUP_PROMPT_EXPLAIN' => 'Display a popup message asking registered members if they want to receive push notifications. The popup will only appear to members who are not currently subscribed and have not previously denied.',
'WEBPUSH_INSECURE_SERVER_ERROR' => 'This board is not using a secure SSL/HTTPS protocol, which is required for enabling web push notifications. Alternatively, the server environment might be misconfigured. Ensure that the HTTPS and HEADER_CLIENT_PROTO server environment variables are correctly configured.',
+
+ // PWA Settings
+ 'ACP_PWA_SETTINGS_EXPLAIN' => 'Here you can configure Progressive Web App behaviour, including app manifest metadata and install banner display.',
+ 'PWA_SHORT_NAME' => 'Short site name',
+ 'PWA_SHORT_NAME_EXPLAIN' => 'Your site name in 12 characters or fewer, which may be used as a label for an icon on a mobile device’s home screen. (If this field is left empty, the first 12 characters of the Site name will be used.)',
+ 'PWA_SHORT_NAME_INVALID' => '“Short site name” exceeds the 12 character limit.',
+ 'PWA_ICON_SMALL' => 'Small mobile device icon',
+ 'PWA_ICON_SMALL_EXPLAIN' => 'File name of a 192px x 192px PNG image. This file must be uploaded to your board’s ' . \phpbb\webpushnotifications\ext::PWA_ICON_DIR . ' directory.',
+ 'PWA_ICON_LARGE' => 'Large mobile device icon',
+ 'PWA_ICON_LARGE_EXPLAIN' => 'File name of a 512px x 512px PNG image. This file must be uploaded to your board’s ' . \phpbb\webpushnotifications\ext::PWA_ICON_DIR . ' directory.',
+ 'PWA_ICON_SIZE_INVALID' => '“%s” does not have the correct image dimensions.',
+ 'PWA_ICON_MIME_INVALID' => '“%s” must be a PNG image file.',
+ 'PWA_ICON_INVALID' => '“%s” is not a valid image file or is missing from the expected location. Verify the file name and location are correct.',
+ 'PWA_ICON_NOT_PROVIDED' => '%s field must not be empty. All icon fields must contain an image.',
+ 'PWA_THEME_COLOURS' => 'Theme & background colours (optional)',
+ 'PWA_THEME_COLOURS_EXPLAIN' => 'Used to specify the default colour for your web application’s user interface. Theme colours may be applied to various browser UI elements, such as the toolbar, address bar, and status bar. Background colours appears in the application window before your application’s stylesheets have loaded.',
+ 'PWA_COLOURS' => 'Colours',
+ 'PWA_THEME_COLOUR' => 'Theme colour',
+ 'PWA_BACKGROUND_COLOUR' => 'Background colour',
+ 'PWA_INVALID_COLOUR' => 'The colour code “%s” is not a valid hex code.',
+ 'PWA_SHOW_INSTALL_BANNER' => 'Show install banner',
+ 'PWA_SHOW_INSTALL_BANNER_EXPLAIN' => 'Display a mobile install prompt when the browser reports that your board can be installed as an app.',
]);
diff --git a/language/ru/common.php b/language/ru/common.php
index 8ea5c41..50188d7 100644
--- a/language/ru/common.php
+++ b/language/ru/common.php
@@ -38,5 +38,9 @@
//
$lang = array_merge($lang, [
+ 'PWA_INSTALL_BUTTON' => 'Install app',
+ 'PWA_INSTALL_DISMISS' => 'Close',
+ 'PWA_INSTALL_SUBTITLE' => 'Add to home screen',
+ 'PWA_INSTALL_SUBTITLE_IOS' => 'Tap Share and then “Add to Home Screen” to install this app.',
'WEBPUSH_INVALID_ENDPOINT' => 'Конечная точка push-уведомления не принадлежит известному сервису push-уведомлений.',
]);
diff --git a/language/ru/info_acp_webpushnotifications.php b/language/ru/info_acp_webpushnotifications.php
index b1c1564..8355db6 100644
--- a/language/ru/info_acp_webpushnotifications.php
+++ b/language/ru/info_acp_webpushnotifications.php
@@ -39,6 +39,7 @@
$lang = array_merge($lang, [
'ACP_WEBPUSH_EXT_SETTINGS' => 'Браузерные уведомления',
+ 'ACP_WEBPUSH_PWA_SETTINGS' => 'PWA settings',
'ACP_WEBPUSH_REMOVE_WARNING' => 'Браузерные push—уведомления теперь встроены в phpBB',
'ACP_WEBPUSH_REMOVE_NOTICE' => 'Расширение «phpBB Browser Push Notifications» больше не требуется и должно быть удалено. Все системные и пользовательские настройки, связанные с данным расширением, будут перенесены в соответствующие настройки браузерных push—уведомлений конференции автоматически при удалении данного расширения.',
'LOG_CONFIG_WEBPUSH' => 'Изменены настройки браузерных push—уведомлений',
diff --git a/language/ru/webpushnotifications_common_acp.php b/language/ru/webpushnotifications_common_acp.php
deleted file mode 100644
index 7107b4f..0000000
--- a/language/ru/webpushnotifications_common_acp.php
+++ /dev/null
@@ -1,53 +0,0 @@
-
- * @license GNU General Public License, version 2 (GPL-2.0)
- *
- */
-
-/**
- * DO NOT CHANGE
- */
-if (!defined('IN_PHPBB'))
-{
- exit;
-}
-
-if (empty($lang) || !is_array($lang))
-{
- $lang = [];
-}
-
-// DEVELOPERS PLEASE NOTE
-//
-// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
-//
-// Placeholders can now contain order information, e.g. instead of
-// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
-// translators to re-order the output of data while ensuring it remains correct
-//
-// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
-// equally where a string contains only two placeholders which are used to wrap text
-// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine
-//
-// Some characters you may want to copy&paste:
-// ’ » “ ” …
-//
-
-$lang = array_merge($lang, [
- 'PWA_SETTINGS' => 'Настройки прогрессивного веб—приложения (PWA)',
- 'PWA_SHORT_NAME' => 'Краткое имя сайта',
- 'PWA_SHORT_NAME_EXPLAIN' => 'Краткое имя сайта длиной не более 12 символов, которое будет использовано в качестве подписи к значку на домашнем экране мобильного устройства. Если оставить пустым, будут использованы первые 12 символов значения настройки, заданной в поле Название конференции.',
- 'PWA_SHORT_NAME_INVALID' => 'Заданное значение в поле «Краткое имя сайта» превышает 12 символов.',
- 'PWA_ICON_SMALL' => 'Маленький значок для мобильного устройства',
- 'PWA_ICON_SMALL_EXPLAIN' => 'Имя файла изображения формата PNG размером 192 x 192 пикселя. Файл изображения должен быть загружен на сервер в папку ' . \phpbb\webpushnotifications\ext::PWA_ICON_DIR . '.',
- 'PWA_ICON_LARGE' => 'Большой значок для мобильного устройства',
- 'PWA_ICON_LARGE_EXPLAIN' => 'Имя файла изображения формата PNG размером 512 x 512 пикселей. Файл изображения должен быть загружен на сервер в папку ' . \phpbb\webpushnotifications\ext::PWA_ICON_DIR . '.',
- 'PWA_ICON_SIZE_INVALID' => 'Изображение «%s» имеет некорректные размеры.',
- 'PWA_ICON_MIME_INVALID' => 'Файл изображения «%s» должен иметь формат PNG.',
- 'PWA_ICON_INVALID' => 'Файл «%s» не является файлом изображения или отсутствует по указанному пути. Проверьте правильность имени файла и его расположения.',
- 'PWA_ICON_NOT_PROVIDED' => 'Настройка «%s» не может быть пустой. Необходимо задать все пути к файлам значков для мобильных устройств.',
-]);
diff --git a/language/ru/webpushnotifications_module_acp.php b/language/ru/webpushnotifications_module_acp.php
index 5232e58..3c5fece 100644
--- a/language/ru/webpushnotifications_module_acp.php
+++ b/language/ru/webpushnotifications_module_acp.php
@@ -38,7 +38,8 @@
//
$lang = array_merge($lang, [
- 'ACP_WEBPUSH_SETTINGS_EXPLAIN' => 'Здесь вы можете включить браузерные push—уведомления. Браузерные push—уведомления — это протокол мгновенной доставки пользователю сообщений о различных событиях. Они совместимы с большинством современных браузеров как на настольных, так и на мобильных устройствах. Пользователи могут включить их в своих браузерах и выбрать предпочтительные виды браузерных уведомлений в личном разделе. Для работы браузерных push—уведомлений необходимо ввести или сгенерировать ключи идентификации ниже.
Для того, чтобы браузерные push—уведомления стали доступны на мобильных устройствах Apple, конференция должна функционировать как прогрессивное веб—приложение (PWA). Параметры прогрессивного веб—приложения (краткое имя сайта и значки для его отображения на домашнем экране) можно задать в разделе Настройки конференции. После этого пользователи смогут добавлять сайт конференции на домашний экран своего мобильного устройства Apple и получать браузерные push—уведомления.',
+ // Web push settings
+ 'ACP_WEBPUSH_SETTINGS_EXPLAIN' => 'Здесь вы можете включить браузерные push—уведомления. Браузерные push—уведомления — это протокол мгновенной доставки пользователю сообщений о различных событиях. Они совместимы с большинством современных браузеров как на настольных, так и на мобильных устройствах. Пользователи могут включить их в своих браузерах и выбрать предпочтительные виды браузерных уведомлений в личном разделе. Для работы браузерных push—уведомлений необходимо ввести или сгенерировать ключи идентификации ниже.
Для того, чтобы браузерные push—уведомления стали доступны на мобильных устройствах Apple, конференция должна функционировать как прогрессивное веб—приложение (PWA). Параметры прогрессивного веб—приложения (краткое имя сайта и значки для его отображения на домашнем экране) можно задать в разделе PWA settings. После этого пользователи смогут добавлять сайт конференции на домашний экран своего мобильного устройства Apple и получать браузерные push—уведомления.',
'WEBPUSH_ENABLE' => 'Включить браузерные push—уведомления',
'WEBPUSH_ENABLE_EXPLAIN' => 'Включение возможности получения браузерных push—уведомлений для всех пользователей. Для использования браузерных push—уведомлений необходимо задать или сгенерировать корректные ключи идентификации VAPID.',
'WEBPUSH_GENERATE_VAPID_KEYS' => 'Сгенерировать ключи идентификации',
@@ -53,4 +54,26 @@
'WEBPUSH_POPUP_PROMPT' => 'Показывать всплывающее приглашение',
'WEBPUSH_POPUP_PROMPT_EXPLAIN' => 'Показывать всплывающее сообщение зарегистрированным пользователям с приглашением подписаться на браузерные уведомления данной конференции. Сообщение будет показано только тем зарегистрированным пользователям, которые не подписаны на браузерные уведомления и ранее не отклоняли такое приглашение.',
'WEBPUSH_INSECURE_SERVER_ERROR' => 'На данной конференции не применяется защищённый протокол SSL/HTTPS, без которого использование браузерных push—уведомлений невозможно, либо соответствующие переменные серверного окружения неверно сконфигурированы. Убедитесь, что значения переменных серверного окружения HTTPS и/или HEADER_CLIENT_PROTO заданы верно.',
+
+ // PWA Settings
+ 'ACP_PWA_SETTINGS_EXPLAIN' => 'Here you can configure Progressive Web App behaviour, including app manifest metadata and install banner display.',
+ 'PWA_SHORT_NAME' => 'Short site name',
+ 'PWA_SHORT_NAME_EXPLAIN' => 'Your site name in 12 characters or fewer, which may be used as a label for an icon on a mobile device’s home screen. (If this field is left empty, the first 12 characters of the Site name will be used.)',
+ 'PWA_SHORT_NAME_INVALID' => '“Short site name” exceeds the 12 character limit.',
+ 'PWA_ICON_SMALL' => 'Small mobile device icon',
+ 'PWA_ICON_SMALL_EXPLAIN' => 'File name of a 192px x 192px PNG image. This file must be uploaded to your board’s ' . \phpbb\webpushnotifications\ext::PWA_ICON_DIR . ' directory.',
+ 'PWA_ICON_LARGE' => 'Large mobile device icon',
+ 'PWA_ICON_LARGE_EXPLAIN' => 'File name of a 512px x 512px PNG image. This file must be uploaded to your board’s ' . \phpbb\webpushnotifications\ext::PWA_ICON_DIR . ' directory.',
+ 'PWA_ICON_SIZE_INVALID' => '“%s” does not have the correct image dimensions.',
+ 'PWA_ICON_MIME_INVALID' => '“%s” must be a PNG image file.',
+ 'PWA_ICON_INVALID' => '“%s” is not a valid image file or is missing from the expected location. Verify the file name and location are correct.',
+ 'PWA_ICON_NOT_PROVIDED' => '%s field must not be empty. All icon fields must contain an image.',
+ 'PWA_THEME_COLOURS' => 'Theme & background colours (optional)',
+ 'PWA_THEME_COLOURS_EXPLAIN' => 'Used to specify the default colour for your web application’s user interface. Theme colours may be applied to various browser UI elements, such as the toolbar, address bar, and status bar. Background colours appears in the application window before your application’s stylesheets have loaded.',
+ 'PWA_COLOURS' => 'Colours',
+ 'PWA_THEME_COLOUR' => 'Theme colour',
+ 'PWA_BACKGROUND_COLOUR' => 'Background colour',
+ 'PWA_INVALID_COLOUR' => 'The colour code “%s” is not a valid hex code.',
+ 'PWA_SHOW_INSTALL_BANNER' => 'Show install banner',
+ 'PWA_SHOW_INSTALL_BANNER_EXPLAIN' => 'Display a mobile install prompt when the browser reports that your board can be installed as an app.',
]);
diff --git a/migrations/add_pwa_enhancer_configs.php b/migrations/add_pwa_enhancer_configs.php
new file mode 100644
index 0000000..8e7d3c7
--- /dev/null
+++ b/migrations/add_pwa_enhancer_configs.php
@@ -0,0 +1,52 @@
+
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ */
+
+namespace phpbb\webpushnotifications\migrations;
+
+use phpbb\db\migration\migration;
+
+class add_pwa_enhancer_configs extends migration
+{
+ public function effectively_installed(): bool
+ {
+ return $this->config->offsetExists('pwa_show_install_banner');
+ }
+
+ public static function depends_on()
+ {
+ return ['\phpbb\webpushnotifications\migrations\add_acp_pwa_configs'];
+ }
+
+ public function update_data(): array
+ {
+ return [
+ ['config.add', ['pwa_show_install_banner', false]],
+ ['module.add', ['acp', 'ACP_CLIENT_COMMUNICATION', [
+ 'module_basename' => '\phpbb\webpushnotifications\acp\wpn_acp_module',
+ 'module_langname' => 'ACP_WEBPUSH_PWA_SETTINGS',
+ 'module_mode' => 'pwa',
+ 'module_auth' => 'ext_phpbb/webpushnotifications && acl_a_board',
+ 'after' => 'ACP_WEBPUSH_EXT_SETTINGS',
+ ]]],
+ ];
+ }
+
+ public function revert_data(): array
+ {
+ return [
+ ['config.remove', ['pwa_show_install_banner']],
+ ['module.remove', ['acp', 'ACP_CLIENT_COMMUNICATION', [
+ 'module_basename' => '\phpbb\webpushnotifications\acp\wpn_acp_module',
+ 'module_langname' => 'ACP_WEBPUSH_PWA_SETTINGS',
+ 'module_mode' => 'pwa',
+ ]]],
+ ];
+ }
+}
diff --git a/migrations/add_pwa_enhancer_schema.php b/migrations/add_pwa_enhancer_schema.php
new file mode 100644
index 0000000..dde8565
--- /dev/null
+++ b/migrations/add_pwa_enhancer_schema.php
@@ -0,0 +1,50 @@
+
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ */
+
+namespace phpbb\webpushnotifications\migrations;
+
+use phpbb\db\migration\migration;
+
+class add_pwa_enhancer_schema extends migration
+{
+ public static function depends_on()
+ {
+ return ['\phpbb\webpushnotifications\migrations\add_pwa_enhancer_configs'];
+ }
+
+ public function effectively_installed(): bool
+ {
+ return $this->db_tools->sql_column_exists($this->table_prefix . 'styles', 'pwa_bg_color');
+ }
+
+ public function update_schema(): array
+ {
+ return [
+ 'add_columns' => [
+ $this->table_prefix . 'styles' => [
+ 'pwa_bg_color' => ['VCHAR:8', ''],
+ 'pwa_theme_color' => ['VCHAR:8', ''],
+ ],
+ ],
+ ];
+ }
+
+ public function revert_schema(): array
+ {
+ return [
+ 'drop_columns' => [
+ $this->table_prefix . 'styles' => [
+ 'pwa_bg_color',
+ 'pwa_theme_color',
+ ],
+ ],
+ ];
+ }
+}
diff --git a/styles/all/template/event/overall_footer_body_after.html b/styles/all/template/event/overall_footer_body_after.html
index 36ac651..2c4e6c6 100644
--- a/styles/all/template/event/overall_footer_body_after.html
+++ b/styles/all/template/event/overall_footer_body_after.html
@@ -16,3 +16,24 @@
}
{% endif %}
+
+{% if S_PWA_SHOW_BANNER %}
+ {% INCLUDEJS '@phpbb_webpushnotifications/pwa_install_banner.js' %}
+ {% INCLUDECSS '@phpbb_webpushnotifications/phpbb_pwa.css' %}
+