1717use phpbb \log \log_interface ;
1818use phpbb \notification \method \messenger_base ;
1919use phpbb \notification \type \type_interface ;
20- use phpbb \path_helper ;
2120use phpbb \user ;
2221use phpbb \user_loader ;
2322use phpbb \webpushnotifications \form \form_helper ;
@@ -42,9 +41,6 @@ class webpush extends messenger_base implements extended_method_interface
4241 /** @var user */
4342 protected $ user ;
4443
45- /** @var path_helper */
46- protected $ path_helper ;
47-
4844 /** @var string Notification Web Push table */
4945 protected $ notification_webpush_table ;
5046
@@ -59,22 +55,20 @@ class webpush extends messenger_base implements extended_method_interface
5955 * @param log_interface $log
6056 * @param user_loader $user_loader
6157 * @param user $user
62- * @param path_helper $path_helper
6358 * @param string $phpbb_root_path
6459 * @param string $php_ext
6560 * @param string $notification_webpush_table
6661 * @param string $push_subscriptions_table
6762 */
68- public function __construct (config $ config , driver_interface $ db , log_interface $ log , user_loader $ user_loader , user $ user , path_helper $ path_helper ,
69- string $ phpbb_root_path , string $ php_ext , string $ notification_webpush_table , string $ push_subscriptions_table )
63+ public function __construct (config $ config , driver_interface $ db , log_interface $ log , user_loader $ user_loader , user $ user , string $ phpbb_root_path ,
64+ string $ php_ext , string $ notification_webpush_table , string $ push_subscriptions_table )
7065 {
7166 parent ::__construct ($ user_loader , $ phpbb_root_path , $ php_ext );
7267
7368 $ this ->config = $ config ;
7469 $ this ->db = $ db ;
7570 $ this ->log = $ log ;
7671 $ this ->user = $ user ;
77- $ this ->path_helper = $ path_helper ;
7872 $ this ->notification_webpush_table = $ notification_webpush_table ;
7973 $ this ->push_subscriptions_table = $ push_subscriptions_table ;
8074 }
@@ -436,16 +430,10 @@ protected function clean_expired_subscriptions(array $user_subscription_map, arr
436430 }
437431
438432 /**
439- * Takes an avatar string (usually in full html format already) and extracts the url.
440- * If the avatar url is a relative path, it's converted to an absolute path.
441- *
442- * Converts:
443- * <img class="avatar" src="./path/to/avatar=123456789.gif" width="123" height="123" alt="User avatar" />
444- * or <img class="avatar" src="./styles/prosilver/theme/images/no_avatar.gif" data-src="./path/to/avatar=123456789.gif" width="123" height="123" alt="User avatar" />
445- * into https://myboard.url/path/to/avatar=123456789.gif
433+ * Takes an avatar string (usually in full html format already) and extracts the src path.
446434 *
447435 * @param string $avatar
448- * @return string Absolute path to avatar image
436+ * @return array
449437 */
450438 protected function prepare_avatar ($ avatar )
451439 {
@@ -455,23 +443,6 @@ protected function prepare_avatar($avatar)
455443
456444 $ path = !empty ($ matches [1 ]) ? end ($ matches [1 ]) : $ avatar ;
457445
458- return preg_replace ('#^ ' . preg_quote ($ this ->path_helper ->get_web_root_path (), '# ' ) . '# ' , $ this ->get_board_url (), $ path , 1 );
459- }
460-
461- /**
462- * Returns the board url (and caches it in the function)
463- *
464- * @return string the generated board url
465- */
466- protected function get_board_url ()
467- {
468- static $ board_url ;
469-
470- if (empty ($ board_url ))
471- {
472- $ board_url = generate_board_url () . '/ ' ;
473- }
474-
475- return $ board_url ;
446+ return ['src ' => preg_replace ('#^\./# ' , '/ ' , $ path )];
476447 }
477448}
0 commit comments