diff --git a/config/services.yml b/config/services.yml
index 5a3eb10..e21730d 100644
--- a/config/services.yml
+++ b/config/services.yml
@@ -33,7 +33,6 @@ services:
- '@log'
- '@user_loader'
- '@user'
- - '@path_helper'
- '%core.root_path%'
- '%core.php_ext%'
- '%tables.phpbb.wpn.notification_push%'
@@ -62,5 +61,4 @@ services:
class: phpbb\webpushnotifications\controller\manifest
arguments:
- '@config'
- - '@path_helper'
- '@user'
diff --git a/controller/manifest.php b/controller/manifest.php
index 634d880..0201769 100644
--- a/controller/manifest.php
+++ b/controller/manifest.php
@@ -11,7 +11,6 @@
namespace phpbb\webpushnotifications\controller;
use phpbb\config\config;
-use phpbb\path_helper;
use phpbb\user;
use phpbb\webpushnotifications\ext;
use Symfony\Component\HttpFoundation\JsonResponse;
@@ -21,9 +20,6 @@ class manifest
/** @var config */
protected $config;
- /** @var path_helper */
- protected $path_helper;
-
/** @var user */
protected $user;
@@ -31,13 +27,11 @@ class manifest
* Constructor for webpush controller
*
* @param config $config
- * @param path_helper $path_helper
* @param user $user
*/
- public function __construct(config $config, path_helper $path_helper, user $user)
+ public function __construct(config $config, user $user)
{
$this->config = $config;
- $this->path_helper = $path_helper;
$this->user = $user;
}
@@ -48,20 +42,25 @@ public function __construct(config $config, path_helper $path_helper, user $user
*/
public function handle(): JsonResponse
{
- $board_path = $this->config['force_server_vars'] ? $this->config['script_path'] : $this->path_helper->get_web_root_path();
+ // Get the board URL and extract the path component
$board_url = generate_board_url();
+ $board_path = $this->config['force_server_vars'] ? $this->config['script_path'] : (parse_url($board_url)['path'] ?? '');
+
+ // Ensure path ends with '/' for PWA scope
+ $scope = rtrim($board_path, '/\\') . '/';
+ $start_url = $scope;
// Emoji fixer-uppers
$sitename = ext::decode_entities($this->config['sitename'], ENT_QUOTES);
- $pwa_short_name = ext::decode_entities($this->config['pwa_short_name'], ENT_QUOTES);
+ $sitename_short = ext::decode_entities($this->config['pwa_short_name'], ENT_QUOTES);
$manifest = [
'name' => $sitename,
- 'short_name' => $pwa_short_name ?: utf8_substr($sitename, 0, 12),
+ 'short_name' => $sitename_short ?: utf8_substr($sitename, 0, 12),
'display' => 'standalone',
'orientation' => 'portrait',
- 'start_url' => $board_path,
- 'scope' => $board_path,
+ 'start_url' => $start_url,
+ 'scope' => $scope,
];
if (!empty($this->config['pwa_icon_small']) && !empty($this->config['pwa_icon_large']))
diff --git a/notification/method/webpush.php b/notification/method/webpush.php
index c1756c4..311eeb0 100644
--- a/notification/method/webpush.php
+++ b/notification/method/webpush.php
@@ -17,7 +17,6 @@
use phpbb\log\log_interface;
use phpbb\notification\method\base;
use phpbb\notification\type\type_interface;
-use phpbb\path_helper;
use phpbb\user;
use phpbb\user_loader;
use phpbb\webpushnotifications\form\form_helper;
@@ -44,9 +43,6 @@ class webpush extends base implements extended_method_interface
/** @var user */
protected $user;
- /** @var path_helper */
- protected $path_helper;
-
/** @var string */
protected $phpbb_root_path;
@@ -73,13 +69,12 @@ class webpush extends base implements extended_method_interface
* @param log_interface $log
* @param user_loader $user_loader
* @param user $user
- * @param path_helper $path_helper
* @param string $phpbb_root_path
* @param string $php_ext
* @param string $notification_webpush_table
* @param string $push_subscriptions_table
*/
- public function __construct(config $config, driver_interface $db, log_interface $log, user_loader $user_loader, user $user, path_helper $path_helper,
+ public function __construct(config $config, driver_interface $db, log_interface $log, user_loader $user_loader, user $user,
string $phpbb_root_path, string $php_ext, string $notification_webpush_table, string $push_subscriptions_table)
{
$this->config = $config;
@@ -87,7 +82,6 @@ public function __construct(config $config, driver_interface $db, log_interface
$this->log = $log;
$this->user_loader = $user_loader;
$this->user = $user;
- $this->path_helper = $path_helper;
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
$this->notification_webpush_table = $notification_webpush_table;
diff --git a/styles/all/template/event/overall_header_head_append.html b/styles/all/template/event/overall_header_head_append.html
index 00c8172..de18eab 100644
--- a/styles/all/template/event/overall_header_head_append.html
+++ b/styles/all/template/event/overall_header_head_append.html
@@ -1,5 +1,9 @@
+
+
+
+
diff --git a/tests/controller/controller_manifest_test.php b/tests/controller/controller_manifest_test.php
index be9d3ba..8dac316 100644
--- a/tests/controller/controller_manifest_test.php
+++ b/tests/controller/controller_manifest_test.php
@@ -15,14 +15,12 @@
class controller_manifest_test extends \phpbb_test_case
{
protected $config;
- protected $path_helper;
protected $user;
protected $manifest;
protected function setUp(): void
{
- global $phpbb_root_path, $phpEx;
- global $config, $user, $request, $symfony_request;
+ global $config, $user, $phpbb_root_path, $phpEx;
parent::setUp();
@@ -38,21 +36,14 @@ 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');
- $symfony_request = $this->createMock(\phpbb\symfony_request::class);
- $request = $this->request = $this->createMock(\phpbb\request\request_interface::class);
- $this->path_helper = new \phpbb\path_helper($symfony_request, new \phpbb\filesystem\filesystem(), $this->request, $phpbb_root_path, $phpEx);
-
- $this->manifest = new \phpbb\webpushnotifications\controller\manifest(
- $this->config,
- $this->path_helper,
- $this->user
- );
+
+ $this->manifest = new \phpbb\webpushnotifications\controller\manifest($this->config, $this->user);
}
public function manifest_data()
{
return [
- 'using web root path' => [
+ 'using board url root path' => [
[
'force_server_vars' => false,
'script_path' => '',
@@ -64,14 +55,14 @@ public function manifest_data()
'short_name' => 'yourdomain',
'display' => 'standalone',
'orientation' => 'portrait',
- 'start_url' => './phpBB/',
- 'scope' => './phpBB/',
+ 'start_url' => '/',
+ 'scope' => '/',
],
],
'using script path' => [
[
'force_server_vars' => true,
- 'script_path' => '/',
+ 'script_path' => '/foo/',
'sitename' => 'yourdomain.com',
'pwa_short_name' => 'yourdomain',
],
@@ -80,8 +71,8 @@ public function manifest_data()
'short_name' => 'yourdomain',
'display' => 'standalone',
'orientation' => 'portrait',
- 'start_url' => '/',
- 'scope' => '/',
+ 'start_url' => '/foo/',
+ 'scope' => '/foo/',
],
],
'with shortname' => [
@@ -94,8 +85,8 @@ public function manifest_data()
'short_name' => 'testdomain',
'display' => 'standalone',
'orientation' => 'portrait',
- 'start_url' => './phpBB/',
- 'scope' => './phpBB/',
+ 'start_url' => '/',
+ 'scope' => '/',
],
],
'without shortname' => [
@@ -108,8 +99,8 @@ public function manifest_data()
'short_name' => 'testdomain.c',
'display' => 'standalone',
'orientation' => 'portrait',
- 'start_url' => './phpBB/',
- 'scope' => './phpBB/',
+ 'start_url' => '/',
+ 'scope' => '/',
],
],
'with icons' => [
@@ -124,8 +115,8 @@ public function manifest_data()
'short_name' => '',
'display' => 'standalone',
'orientation' => 'portrait',
- 'start_url' => './phpBB/',
- 'scope' => './phpBB/',
+ 'start_url' => '/',
+ 'scope' => '/',
'icons' => [
[
'src' => 'http://images/site_icons/foo_sm.png',
diff --git a/tests/event/listener_test.php b/tests/event/listener_test.php
index b6de772..162fe4b 100644
--- a/tests/event/listener_test.php
+++ b/tests/event/listener_test.php
@@ -95,11 +95,6 @@ protected function setUp(): void
$this->user
);
- $path_helper = $this->getMockBuilder('\phpbb\path_helper')
- ->disableOriginalConstructor()
- ->setMethods(array())
- ->getMock();
-
$this->notifications = $this->getMockBuilder('\phpbb\notification\manager')
->disableOriginalConstructor()
->getMock();
@@ -113,7 +108,6 @@ protected function setUp(): void
new \phpbb\log\dummy(),
$user_loader,
$this->user,
- $path_helper,
$phpbb_root_path,
$phpEx,
'phpbb_wpn_notification_push',
diff --git a/tests/notification/notification_method_webpush_test.php b/tests/notification/notification_method_webpush_test.php
index d5b9450..3c472c2 100644
--- a/tests/notification/notification_method_webpush_test.php
+++ b/tests/notification/notification_method_webpush_test.php
@@ -128,19 +128,6 @@ protected function setUp(): void
$phpEx
);
- $request = new \phpbb_mock_request;
- $symfony_request = new \phpbb\symfony_request(
- $request
- );
- $filesystem = new \phpbb\filesystem\filesystem();
- $phpbb_path_helper = new \phpbb\path_helper(
- $symfony_request,
- $filesystem,
- $request,
- $phpbb_root_path,
- $phpEx
- );
-
$log_table = 'phpbb_log';
$this->log = new \phpbb\log\log($this->db, $user, $auth, $this->phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, $log_table);
@@ -158,7 +145,6 @@ protected function setUp(): void
$phpbb_container->set('log', $this->log);
$phpbb_container->set('text_formatter.utils', new \phpbb\textformatter\s9e\utils());
$phpbb_container->set('dispatcher', $this->phpbb_dispatcher);
- $phpbb_container->set('path_helper', $phpbb_path_helper);
$phpbb_container->setParameter('core.root_path', $phpbb_root_path);
$phpbb_container->setParameter('core.php_ext', $phpEx);
$phpbb_container->setParameter('tables.notifications', 'phpbb_notifications');
@@ -174,7 +160,6 @@ protected function setUp(): void
$phpbb_container->get('log'),
$phpbb_container->get('user_loader'),
$phpbb_container->get('user'),
- $phpbb_container->get('path_helper'),
$phpbb_root_path,
$phpEx,
$phpbb_container->getParameter('tables.phpbb.wpn.notification_push'),