Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions adm/style/wpn_acp_pwa.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ <h3>{{ lang('WARNING') }}</h3>
<form id="webpushnotifications_pwa_settings" method="post" action="{{ U_ACTION }}">
<fieldset>
<legend>{{ lang('GENERAL_SETTINGS') }}</legend>
<dl>
<dt><label>{{ lang('PWA_METADATA_ENABLED') ~ lang('COLON') }}</label><br><span>{{ lang('PWA_METADATA_ENABLED_EXPLAIN') }}</span></dt>
<dd><label><input type="radio" class="radio" name="config[pwa_metadata_enabled]" value="1"{% if S_PWA_METADATA_ENABLED %} checked="checked"{% endif %}> {{ lang('YES') }}</label>
<label><input type="radio" class="radio" name="config[pwa_metadata_enabled]" value="0"{% if not S_PWA_METADATA_ENABLED %} checked="checked"{% endif %}> {{ lang('NO') }}</label></dd>
</dl>
<dl>
<dt><label for="pwa_short_name">{{ lang('PWA_SHORT_NAME') ~ lang('COLON') }}</label><br><span>{{ lang('PWA_SHORT_NAME_EXPLAIN') }}</span></dt>
<dd><input id="pwa_short_name" type="text" size="40" maxlength="12" name="config[pwa_short_name]" value="{{ PWA_SHORT_NAME }}" placeholder="{{ PWA_SHORT_NAME_PLACEHOLDER|e('html_attr') }}"></dd>
Expand Down
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
"ext-gmp": "Optional but better for performance"
},
"config": {
"platform": {
"php": "7.3"
},
"allow-plugins": {
"composer/installers": true
}
Expand Down
51 changes: 27 additions & 24 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions controller/acp_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ protected function save_settings()
protected function display_pwa_settings()
{
$this->template->assign_vars([
'S_PWA_METADATA_ENABLED' => (bool) $this->config['pwa_metadata_enabled'],
'S_PWA_SHOW_INSTALL_BANNER' => (bool) $this->config['pwa_show_install_banner'],
'PWA_SHORT_NAME' => $this->config['pwa_short_name'],
'PWA_SHORT_NAME_PLACEHOLDER'=> utf8_substr(ext::decode_entities($this->config['sitename'], ENT_QUOTES), 0, 12),
Expand Down Expand Up @@ -307,6 +308,7 @@ protected function save_pwa_settings()
$config_array['pwa_short_name'] = utf8_encode_ucr($config_array['pwa_short_name']);

foreach ([
'pwa_metadata_enabled',
'pwa_short_name',
'pwa_icon_small',
'pwa_icon_large',
Expand Down
1 change: 1 addition & 0 deletions event/listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ public function compatibility_notice()
public function pwa_manifest()
{
$this->template->assign_vars([
'S_PWA_METADATA_ENABLED' => !empty($this->config['pwa_metadata_enabled']),
'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']),
Expand Down
2 changes: 2 additions & 0 deletions language/en/webpushnotifications_module_acp.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@

// PWA Settings
'ACP_PWA_SETTINGS_EXPLAIN' => 'Progressive Web Apps (PWAs) allow users to install your board on their mobile device and use it like an app. These settings control the app name, icons, colours, and install prompts shown to users.',
'PWA_METADATA_ENABLED' => 'Output PWA metadata',
'PWA_METADATA_ENABLED_EXPLAIN'=> 'Output the web app manifest link and related PWA metadata in the page header. Disable this if another extension or your style already provides the board’s PWA metadata. This does not disable Web Push or the app install banner.',
'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 <samp>Site name</samp> will be used.)',
'PWA_SHORT_NAME_INVALID' => '“Short site name” exceeds the 12 character limit.',
Expand Down
2 changes: 2 additions & 0 deletions language/ru/webpushnotifications_module_acp.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@

// PWA Settings
'ACP_PWA_SETTINGS_EXPLAIN' => 'Здесь вы можете настроить функции прогрессивного веб-приложения (PWA), включая метаданные приложения, значки, цвета темы и приглашения к установке.',
'PWA_METADATA_ENABLED' => 'Выводить метаданные PWA',
'PWA_METADATA_ENABLED_EXPLAIN'=> 'Вывод ссылки на манифест и метаданных прогрессивного веб-приложения (PWA) в коде заголовков страниц конференции. Отключите, если другое расширение или стиль уже выводят такие данные. При этом браузерные push-уведомления и баннер установки прогрессивного веб-приложения (PWA) не будут отключены.',
'PWA_SHORT_NAME' => 'Краткое название сайта',
'PWA_SHORT_NAME_EXPLAIN' => 'Название сайта длиной не более 12 символов, которое может использоваться как подпись к значку на главном экране мобильного устройства. (Если оставить это поле пустым, будут использованы первые 12 символов значения <samp>Название сайта</samp>.)',
'PWA_SHORT_NAME_INVALID' => 'Значение поля «Краткое название сайта» превышает ограничение в 12 символов.',
Expand Down
40 changes: 40 additions & 0 deletions migrations/add_pwa_metadata_toggle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/**
*
* phpBB Browser Push Notifications. An extension for the phpBB Forum Software package.
*
* @copyright (c) 2026, phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/

namespace phpbb\webpushnotifications\migrations;

use phpbb\db\migration\migration;

class add_pwa_metadata_toggle extends migration
{
public function effectively_installed(): bool
{
return $this->config->offsetExists('pwa_metadata_enabled');
}

public static function depends_on()
{
return ['\phpbb\webpushnotifications\migrations\add_pwa_enhancer_schema'];
}

public function update_data(): array
{
return [
['config.add', ['pwa_metadata_enabled', 1]],
];
}

public function revert_data(): array
{
return [
['config.remove', ['pwa_metadata_enabled']],
];
}
}
22 changes: 12 additions & 10 deletions styles/all/template/event/overall_header_head_append.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@

<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-title" content="{{ SHORT_SITE_NAME }}">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
{% if PWA_THEME_COLOR %}
<meta name="theme-color" content="{{ PWA_THEME_COLOR }}">
<style>:root { --pwa-theme-colour: {{ PWA_THEME_COLOR }}; }</style>
{% endif %}
{% if S_PWA_METADATA_ENABLED %}
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-title" content="{{ SHORT_SITE_NAME }}">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
{% if PWA_THEME_COLOR %}
<meta name="theme-color" content="{{ PWA_THEME_COLOR }}">
<style>:root { --pwa-theme-colour: {{ PWA_THEME_COLOR }}; }</style>
{% endif %}

<link rel="manifest" href="{{ U_MANIFEST_URL }}" crossorigin="use-credentials">
{% if U_TOUCH_ICON %}<link rel="apple-touch-icon" href="{{ ROOT_PATH ~ U_TOUCH_ICON }}">{% endif %}
<link rel="manifest" href="{{ U_MANIFEST_URL }}" crossorigin="use-credentials">
{% if U_TOUCH_ICON %}<link rel="apple-touch-icon" href="{{ ROOT_PATH ~ U_TOUCH_ICON }}">{% endif %}
{% endif %}

{% if NOTIFICATIONS_WEBPUSH_ENABLE %}
{% include '@phpbb_webpushnotifications/ucp_notifications_webpush.html' %}
Expand Down
6 changes: 6 additions & 0 deletions tests/controller/controller_acp_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ public function test_save_settings_ignores_unrelated_config(): void
public function pwa_save_data(): array
{
$valid = [
'pwa_metadata_enabled' => 0,
'pwa_short_name' => 'Forum',
'pwa_icon_small' => 'icon192.png',
'pwa_icon_large' => 'icon512.png',
Expand Down Expand Up @@ -413,6 +414,7 @@ public function pwa_save_data(): array
'ERROR_MSG' => '',
],
[
'pwa_metadata_enabled' => 0,
'pwa_short_name' => 'Forum',
'pwa_icon_small' => 'icon192.png',
'pwa_icon_large' => 'icon512.png',
Expand All @@ -430,6 +432,7 @@ public function pwa_save_data(): array
'ERROR_MSG' => '',
],
[
'pwa_metadata_enabled' => 0,
'pwa_short_name' => '',
'pwa_icon_small' => '',
'pwa_icon_large' => '',
Expand Down Expand Up @@ -460,6 +463,7 @@ public function pwa_save_data(): array
'ERROR_MSG' => '',
],
[
'pwa_metadata_enabled' => 0,
'pwa_short_name' => 'Forum',
'pwa_icon_small' => 'icon192.png',
'pwa_icon_large' => 'icon512.png',
Expand Down Expand Up @@ -770,6 +774,7 @@ protected function default_config(): array
'wpn_webpush_method_enabled' => 1,
'wpn_webpush_popup_prompt' => 1,
'pwa_show_install_banner' => 1,
'pwa_metadata_enabled' => 1,
'pwa_short_name' => 'Old',
'pwa_icon_small' => 'old-small.png',
'pwa_icon_large' => 'old-large.png',
Expand Down Expand Up @@ -811,6 +816,7 @@ protected function webpush_template_vars($u_action): array
protected function pwa_template_vars($u_action): array
{
return [
'S_PWA_METADATA_ENABLED' => true,
'S_PWA_SHOW_INSTALL_BANNER' => true,
'PWA_SHORT_NAME' => 'Old',
'PWA_SHORT_NAME_PLACEHOLDER' => 'Board & 😀 Fo',
Expand Down
4 changes: 4 additions & 0 deletions tests/event/listener_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ protected function setUp(): void
'sitename' => 'phpBB',
'cookie_name' => 'phpbb3',
'pwa_show_install_banner' => true,
'pwa_metadata_enabled' => true,
'pwa_icon_small' => '',
'pwa_icon_large' => '',
'pwa_short_name' => '',
Expand Down Expand Up @@ -387,6 +388,7 @@ public function test_pwa_manifest()
$this->template->expects(self::once())
->method('assign_vars')
->with([
'S_PWA_METADATA_ENABLED' => true,
'U_MANIFEST_URL' => $this->controller_helper->route('phpbb_webpushnotifications_manifest_controller'),
'U_TOUCH_ICON' => ext::PWA_ICON_DIR . '/icon-192x192.png',
'SHORT_SITE_NAME' => 'Test',
Expand All @@ -412,13 +414,15 @@ public function test_load_template_data_returns_when_notifications_unavailable()
public function test_pwa_manifest_builds_fallback_name_and_mobile_banner()
{
$this->config['sitename'] = 'Long &amp; Mobile Site';
$this->config['pwa_metadata_enabled'] = false;
$this->user->style = [
'pwa_theme_color' => '#112233',
'pwa_bg_color' => '#445566',
];
$this->request->method('server')->with('HTTP_USER_AGENT', '')->willReturn('Mozilla/5.0 iPhone Mobile');

$this->template->expects(self::once())->method('assign_vars')->with([
'S_PWA_METADATA_ENABLED' => false,
'U_MANIFEST_URL' => $this->controller_helper->route('phpbb_webpushnotifications_manifest_controller'),
'U_TOUCH_ICON' => null,
'SHORT_SITE_NAME' => 'Long &amp; Mobil',
Expand Down
Loading