From e6b7defd3818771d27ab2b3aa0e7d9a8448fc4e7 Mon Sep 17 00:00:00 2001 From: kasimi Date: Fri, 28 Apr 2017 16:32:11 +0200 Subject: [ticket/15187] Add paths of newly enabled extensions to template When enabling an extension its paths aren't added immediately to the template which results in ACP events not being registered in the compiled template files. PHPBB3-15187 --- phpBB/phpbb/extension/manager.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'phpBB') diff --git a/phpBB/phpbb/extension/manager.php b/phpBB/phpbb/extension/manager.php index e7e5f83c23..7045624f28 100644 --- a/phpBB/phpbb/extension/manager.php +++ b/phpBB/phpbb/extension/manager.php @@ -227,6 +227,8 @@ class manager if ($active) { $this->config->increment('assets_version', 1); + + $this->update_template_paths($name, $this->container->get('template')); } return !$active; @@ -589,4 +591,38 @@ class manager } return $finder; } + + /** + * Make the template aware of ACP template events of a newly enabled extension + * + * @param string $name The extension's name + * @param \phpbb\template\base|null $template The template service + * @return null + */ + protected function update_template_paths($name, \phpbb\template\base $template = null) + { + if ($template instanceof \phpbb\template\base) + { + $possible_paths = array( + $this->phpbb_root_path . 'ext/' . $name . '/adm/style', + $this->phpbb_root_path . 'ext/' . $name . '/styles', + ); + + $paths = array_filter($possible_paths, 'is_dir'); + + if ($paths) + { + $names = array( + array( + 'name' => 'adm', + 'ext_path' => 'adm/style/', + ), + ); + + $paths[] = $this->phpbb_root_path . 'adm/style'; + + $template->set_custom_style($names, $paths); + } + } + } } -- cgit v1.2.1 From 90a80b7b31e94985e53ddccc8a13117c0c4e7fcf Mon Sep 17 00:00:00 2001 From: kasimi Date: Fri, 28 Apr 2017 16:58:08 +0200 Subject: [ticket/15187] Fail gracefully if template service is unavailable --- phpBB/phpbb/extension/manager.php | 43 ++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 21 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/extension/manager.php b/phpBB/phpbb/extension/manager.php index 7045624f28..81e6f57b79 100644 --- a/phpBB/phpbb/extension/manager.php +++ b/phpBB/phpbb/extension/manager.php @@ -228,7 +228,7 @@ class manager { $this->config->increment('assets_version', 1); - $this->update_template_paths($name, $this->container->get('template')); + $this->update_template_paths($name); } return !$active; @@ -595,34 +595,35 @@ class manager /** * Make the template aware of ACP template events of a newly enabled extension * - * @param string $name The extension's name - * @param \phpbb\template\base|null $template The template service + * @param string $name The extension's name * @return null */ - protected function update_template_paths($name, \phpbb\template\base $template = null) + protected function update_template_paths($name) { - if ($template instanceof \phpbb\template\base) + if (!$this->container->has('template')) { - $possible_paths = array( - $this->phpbb_root_path . 'ext/' . $name . '/adm/style', - $this->phpbb_root_path . 'ext/' . $name . '/styles', - ); + return; + } + + $possible_paths = array( + $this->phpbb_root_path . 'ext/' . $name . '/adm/style', + $this->phpbb_root_path . 'ext/' . $name . '/styles', + ); - $paths = array_filter($possible_paths, 'is_dir'); + $paths = array_filter($possible_paths, 'is_dir'); - if ($paths) - { - $names = array( - array( - 'name' => 'adm', - 'ext_path' => 'adm/style/', - ), - ); + if ($paths) + { + $names = array( + array( + 'name' => 'adm', + 'ext_path' => 'adm/style/', + ), + ); - $paths[] = $this->phpbb_root_path . 'adm/style'; + $paths[] = $this->phpbb_root_path . 'adm/style'; - $template->set_custom_style($names, $paths); - } + $this->container->get('template')->set_custom_style($names, $paths); } } } -- cgit v1.2.1 From 0082dd8039aa534ae0d6f4f17622a665e82c6942 Mon Sep 17 00:00:00 2001 From: kasimi Date: Fri, 28 Apr 2017 22:20:24 +0200 Subject: [ticket/15187] Reverted commits e6b7def & 90a80b7 PHPBB3-15187 --- phpBB/phpbb/extension/manager.php | 37 ------------------------------------- 1 file changed, 37 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/extension/manager.php b/phpBB/phpbb/extension/manager.php index 81e6f57b79..e7e5f83c23 100644 --- a/phpBB/phpbb/extension/manager.php +++ b/phpBB/phpbb/extension/manager.php @@ -227,8 +227,6 @@ class manager if ($active) { $this->config->increment('assets_version', 1); - - $this->update_template_paths($name); } return !$active; @@ -591,39 +589,4 @@ class manager } return $finder; } - - /** - * Make the template aware of ACP template events of a newly enabled extension - * - * @param string $name The extension's name - * @return null - */ - protected function update_template_paths($name) - { - if (!$this->container->has('template')) - { - return; - } - - $possible_paths = array( - $this->phpbb_root_path . 'ext/' . $name . '/adm/style', - $this->phpbb_root_path . 'ext/' . $name . '/styles', - ); - - $paths = array_filter($possible_paths, 'is_dir'); - - if ($paths) - { - $names = array( - array( - 'name' => 'adm', - 'ext_path' => 'adm/style/', - ), - ); - - $paths[] = $this->phpbb_root_path . 'adm/style'; - - $this->container->get('template')->set_custom_style($names, $paths); - } - } } -- cgit v1.2.1 From bc404a3701a4f746fbd161d3f550e2f32fda3a7c Mon Sep 17 00:00:00 2001 From: kasimi Date: Sat, 29 Apr 2017 11:01:55 +0200 Subject: [ticket/15187] Add ACP style after enabling an extension --- phpBB/includes/acp/acp_extensions.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'phpBB') diff --git a/phpBB/includes/acp/acp_extensions.php b/phpBB/includes/acp/acp_extensions.php index 9e72ab83f8..f2fb09b427 100644 --- a/phpBB/includes/acp/acp_extensions.php +++ b/phpBB/includes/acp/acp_extensions.php @@ -212,6 +212,15 @@ class acp_extensions meta_refresh(0, $this->u_action . '&action=enable&ext_name=' . urlencode($ext_name) . '&hash=' . generate_link_hash('enable.' . $ext_name)); } } + + // Update custom style for admin area + $template->set_custom_style(array( + array( + 'name' => 'adm', + 'ext_path' => 'adm/style/', + ), + ), array($phpbb_root_path . 'adm/style')); + $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_EXT_ENABLE', time(), array($ext_name)); } catch (\phpbb\db\migration\exception $e) -- cgit v1.2.1 From 5808c9fae1dad98a88a02e5b43c4c45f93e3b0b7 Mon Sep 17 00:00:00 2001 From: kasimi Date: Sat, 29 Apr 2017 13:45:20 +0200 Subject: [ticket/15187] Use $this->template property --- phpBB/includes/acp/acp_extensions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/includes/acp/acp_extensions.php b/phpBB/includes/acp/acp_extensions.php index f2fb09b427..f0348817c8 100644 --- a/phpBB/includes/acp/acp_extensions.php +++ b/phpBB/includes/acp/acp_extensions.php @@ -214,7 +214,7 @@ class acp_extensions } // Update custom style for admin area - $template->set_custom_style(array( + $this->template->set_custom_style(array( array( 'name' => 'adm', 'ext_path' => 'adm/style/', -- cgit v1.2.1