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
2 changes: 1 addition & 1 deletion acp/wpn_acp_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ protected function get_styles(): array
FROM ' . STYLES_TABLE . '
WHERE style_active = 1
ORDER BY style_name';
$result = $this->db->sql_query($sql, 3600);
$result = $this->db->sql_query($sql);

$rows = $this->db->sql_fetchrowset($result);
$this->db->sql_freeresult($result);
Expand Down
4 changes: 2 additions & 2 deletions adm/style/wpn_acp_pwa.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ <h1>{{ lang('PWA_THEME_COLOURS') }}</h1>
<dt><label for="pwa_theme_color_{{ style.style_id }}">{{ style.style_name ~ lang('COLON') }}</label></dt>
<dd>
<span class="color-pickers">
<input type="text" id="pwa_theme_color_{{ style.style_id }}" name="pwa_theme_color_{{ style.style_id }}" size="8" value="{{ style.pwa_theme_color }}" placeholder="{{ constant('phpbb\\webpushnotifications\\ext::PWA_THEME_COLOR') }}">
<input type="text" id="pwa_theme_color_{{ style.style_id }}" name="pwa_theme_color_{{ style.style_id }}" size="8" value="{{ style.pwa_theme_color }}" placeholder="#000000">
<input type="color" id="pwa_theme_color_picker_{{ style.style_id }}" aria-label="{{ lang('PWA_THEME_COLOUR') }}" value="{{ style.pwa_theme_color|default(default_color) }}">
</span>
<span class="color-pickers">
<input type="text" id="pwa_bg_color_{{ style.style_id }}" name="pwa_bg_color_{{ style.style_id }}" size="8" value="{{ style.pwa_bg_color }}" placeholder="{{ constant('phpbb\\webpushnotifications\\ext::PWA_BG_COLOR') }}">
<input type="text" id="pwa_bg_color_{{ style.style_id }}" name="pwa_bg_color_{{ style.style_id }}" size="8" value="{{ style.pwa_bg_color }}" placeholder="#ffffff">
<input type="color" id="pwa_bg_color_picker_{{ style.style_id }}" aria-label="{{ lang('PWA_BACKGROUND_COLOUR') }}" value="{{ style.pwa_bg_color|default(default_color) }}">
</span>
</dd>
Expand Down
12 changes: 10 additions & 2 deletions controller/manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,18 @@ 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->user->style['pwa_theme_color']))
{
$manifest['theme_color'] = $this->user->style['pwa_theme_color'];
}

if (!empty($this->user->style['pwa_bg_color']))
{
$manifest['background_color'] = $this->user->style['pwa_bg_color'];
}

if (!empty($this->config['pwa_icon_small']) && !empty($this->config['pwa_icon_large']))
{
$manifest['icons'] = [
Expand Down
4 changes: 2 additions & 2 deletions event/listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ 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,
'PWA_THEME_COLOR' => $this->user->style['pwa_theme_color'] ?? '',
'PWA_BG_COLOR' => $this->user->style['pwa_bg_color'] ?? '',
'S_PWA_SHOW_BANNER' => !empty($this->config['pwa_show_install_banner']) && $this->is_mobile_phone(),
]);
}
Expand Down
6 changes: 0 additions & 6 deletions ext.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ 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.
*/
Expand Down
6 changes: 5 additions & 1 deletion styles/all/template/event/overall_header_head_append.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<!-- Android / Chrome PWA support -->
<meta name="mobile-web-app-capable" content="yes">
<meta name="background-color" content="{{ PWA_BG_COLOR }}">
{% if PWA_THEME_COLOR %}
<meta name="theme-color" content="{{ PWA_THEME_COLOR }}">
<style>:root { --pwa-theme-colour: {{ PWA_THEME_COLOR }}; }</style>
{% endif %}
{% if PWA_BG_COLOR %}
<meta name="background-color" content="{{ PWA_BG_COLOR }}">
{% endif %}
<!-- iOS PWA support -->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-title" content="{{ SHORT_SITE_NAME }}">
Expand Down
2 changes: 2 additions & 0 deletions tests/controller/controller_manifest_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ protected function setUp(): void
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
$language = new \phpbb\language\language($lang_loader);
$user = $this->user = new \phpbb\user($language, '\phpbb\datetime');
$this->user->style['pwa_theme_color'] = '#000000';
$this->user->style['pwa_bg_color'] = '#ffffff';

$this->manifest = new \phpbb\webpushnotifications\controller\manifest($this->config, $this->user);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/event/listener_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,8 @@ public function test_pwa_manifest()
'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',
'PWA_THEME_COLOR' => ext::PWA_THEME_COLOR,
'PWA_BG_COLOR' => ext::PWA_BG_COLOR,
'PWA_THEME_COLOR' => '',
'PWA_BG_COLOR' => '',
'S_PWA_SHOW_BANNER' => false,
]);

Expand Down
2 changes: 2 additions & 0 deletions tests/functional/functional_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ public function test_manifest()

$form_data = [
'config[pwa_short_name]' => $expected['short_name'],
'pwa_theme_color_1' => $expected['theme_color'],
'pwa_bg_color_1' => $expected['background_color'],
];
$form = $crawler->selectButton('submit')->form($form_data);
$crawler = self::submit($form);
Expand Down
Loading