diff --git a/phpBB/config/default/container/services.yml b/phpBB/config/default/container/services.yml index 14c0d40263..253a70342a 100644 --- a/phpBB/config/default/container/services.yml +++ b/phpBB/config/default/container/services.yml @@ -157,6 +157,15 @@ services: - '%core.php_ext%' - '%tables.log%' + manifest.controller: + class: phpbb\manifest + arguments: + - '@config' + - '@language' + - '@path_helper' + - '@event_dispatcher' + - '@user' + path_helper: class: phpbb\path_helper arguments: diff --git a/phpBB/config/default/routing/routing.yml b/phpBB/config/default/routing/routing.yml index 7fff9204f0..46d20e4527 100644 --- a/phpBB/config/default/routing/routing.yml +++ b/phpBB/config/default/routing/routing.yml @@ -24,6 +24,10 @@ phpbb_help_routing: resource: help.yml prefix: /help +phpbb_manifest_controller: + path: /manifest + defaults: { _controller: manifest.controller:handle } + phpbb_mention_controller: path: /mention methods: [GET, POST] diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index d2076ce086..a632253c52 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -78,6 +78,7 @@ class acp_board 'site_home_url' => array('lang' => 'SITE_HOME_URL', 'validate' => 'url', 'type' => 'url:40:255', 'explain' => true), 'site_home_text' => array('lang' => 'SITE_HOME_TEXT', 'validate' => 'string', 'type' => 'text:40:255', 'explain' => true), 'board_index_text' => array('lang' => 'BOARD_INDEX_TEXT', 'validate' => 'string', 'type' => 'text:40:255', 'explain' => true), + 'sitename_short' => array('lang' => 'SITE_NAME_SHORT', 'validate' => 'string', 'type' => 'text:40:12', 'explain' => true), 'board_disable' => array('lang' => 'DISABLE_BOARD', 'validate' => 'bool', 'type' => 'custom', 'method' => 'board_disable', 'explain' => true), 'board_disable_msg' => false, 'board_disable_access' => array('lang' => 'DISABLE_BOARD_ACCESS', 'validate' => 'int', 'type' => 'select', 'method' => 'board_disable_access', 'explain' => true), @@ -593,6 +594,7 @@ class acp_board // Array of emoji-enabled configurations $config_name_ary = [ 'sitename', + 'sitename_short', 'site_desc', 'site_home_text', 'board_index_text', diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 0e52fb37d6..8cee5a6ba0 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3855,6 +3855,7 @@ function page_header($page_title = '', $display_online_list = false, $item_id = 'UA_PRIVACY' => addslashes(append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=privacy')), 'U_RESTORE_PERMISSIONS' => ($user->data['user_perm_from'] && $auth->acl_get('a_switchperm')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=restore_perm') : '', 'U_FEED' => $controller_helper->route('phpbb_feed_index'), + 'U_MANIFEST' => $controller_helper->route('phpbb_manifest_controller'), 'S_ALLOW_MENTIONS' => ($config['allow_mentions'] && $auth->acl_get('u_mention') && (empty($forum_id) || $auth->acl_get('f_mention', $forum_id))) ? true : false, 'S_MENTION_NAMES_LIMIT' => $config['mention_names_limit'], diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index ba8f654a90..40240213d3 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -284,6 +284,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('site_desc', '{L_CO INSERT INTO phpbb_config (config_name, config_value) VALUES ('site_home_text', ''); INSERT INTO phpbb_config (config_name, config_value) VALUES ('site_home_url', ''); INSERT INTO phpbb_config (config_name, config_value) VALUES ('sitename', '{L_CONFIG_SITENAME}'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('sitename_short', ''); INSERT INTO phpbb_config (config_name, config_value) VALUES ('smilies_path', 'images/smilies'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('smilies_per_page', '50'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('smtp_allow_self_signed', '0'); diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php index 3228db126b..def1b01c60 100644 --- a/phpBB/language/en/acp/board.php +++ b/phpBB/language/en/acp/board.php @@ -69,6 +69,8 @@ $lang = array_merge($lang, array( 'SITE_HOME_URL' => 'Main website URL', 'SITE_HOME_URL_EXPLAIN' => 'If specified, a link to this URL will be prepended to your board’s breadcrumbs and the board logo will link to this URL instead of the forum index. An absolute URL is required, e.g. http://www.phpbb.com.', 'SITE_NAME' => 'Site name', + 'SITE_NAME_SHORT' => 'Short site name', + 'SITE_NAME_SHORT_EXPLAIN' => 'Short name will be used if your site is added to a mobile device’s home screen. It can not exceed 12 characters (Emoji is supported).', 'SYSTEM_TIMEZONE' => 'Guest timezone', 'SYSTEM_TIMEZONE_EXPLAIN' => 'Timezone to use for displaying times to users who are not logged in (guests, bots). Logged in users set their timezone during registration and can change it in their user control panel.', 'WARNINGS_EXPIRE' => 'Warning duration', diff --git a/phpBB/phpbb/manifest.php b/phpBB/phpbb/manifest.php new file mode 100644 index 0000000000..1a7d0148e5 --- /dev/null +++ b/phpBB/phpbb/manifest.php @@ -0,0 +1,95 @@ + + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +namespace phpbb; + +use phpbb\config\config; +use phpbb\event\dispatcher_interface; +use phpbb\exception\http_exception; +use phpbb\language\language; +use Symfony\Component\HttpFoundation\JsonResponse; +use Symfony\Component\HttpFoundation\Response; + +class manifest +{ + /** @var config */ + protected $config; + + /** @var language */ + protected $language; + + /** @var path_helper */ + protected $path_helper; + + /** @var dispatcher_interface */ + protected $phpbb_dispatcher; + + /** @var user */ + protected $user; + + /** + * Constructor for manifest controller + * + * @param config $config + * @param language $language + * @param path_helper $path_helper + * @param dispatcher_interface $phpbb_dispatcher + * @param user $user + */ + public function __construct(config $config, language $language, path_helper $path_helper, dispatcher_interface $phpbb_dispatcher, user $user) + { + $this->config = $config; + $this->path_helper = $path_helper; + $this->phpbb_dispatcher = $phpbb_dispatcher; + $this->language = $language; + $this->user = $user; + } + + /** + * Handle creation of a manifest json file for progressive web-app support + * + * @return JsonResponse + */ + public function handle(): JsonResponse + { + if ($this->user->data['is_bot']) + { + throw new http_exception(Response::HTTP_FORBIDDEN, 'NO_AUTH_OPERATION'); + } + + $board_path = $this->config['force_server_vars'] ? $this->config['script_path'] : $this->path_helper->get_web_root_path(); + + $manifest = [ + 'name' => $this->config['sitename'], + 'short_name' => $this->config['sitename_short'] ?: substr($this->config['sitename'], 0, 12), + 'display' => 'standalone', + 'orientation' => 'portrait', + 'dir' => $this->language->lang('DIRECTION'), + 'start_url' => $board_path, + 'scope' => $board_path, + ]; + + /** + * Event to modify manifest data before it is outputted + * + * @event core.modify_manifest + * @var array manifest Array of manifest members + * @var string board_path Path to the board root + * @since 4.0.0-a1 + */ + $vars = array('manifest', 'board_path'); + extract($this->phpbb_dispatcher->trigger_event('core.modify_manifest', compact($vars))); + + return new JsonResponse($manifest); + } +} diff --git a/phpBB/styles/prosilver/template/overall_header.html b/phpBB/styles/prosilver/template/overall_header.html index 790f793d8f..49f2d3bff6 100644 --- a/phpBB/styles/prosilver/template/overall_header.html +++ b/phpBB/styles/prosilver/template/overall_header.html @@ -4,6 +4,9 @@ + + + {META}