aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--phpBB/includes/acp/acp_extensions.php45
-rw-r--r--phpBB/phpbb/console/command/update/check.php2
-rw-r--r--phpBB/phpbb/extension/manager.php33
-rw-r--r--phpBB/phpbb/extension/metadata_manager.php85
4 files changed, 79 insertions, 86 deletions
diff --git a/phpBB/includes/acp/acp_extensions.php b/phpBB/includes/acp/acp_extensions.php
index e01d95167a..8ce910c242 100644
--- a/phpBB/includes/acp/acp_extensions.php
+++ b/phpBB/includes/acp/acp_extensions.php
@@ -307,23 +307,23 @@ class acp_extensions
case 'details':
// Output it to the template
- $md_manager->output_template_data($this->template);
-
$meta = $md_manager->get_metadata('all');
+ $this->output_metadata_to_template($meta);
+
if (isset($meta['extra']['version-check']))
{
try
{
$updates_available = $this->ext_manager->version_check($md_manager, $this->request->variable('versioncheck_force', false), $this->config['extension_force_unstable'] ? 'unstable' : null);
- $this->template->assign_vars(array(
+ $this->template->assign_vars(array(
'S_UP_TO_DATE' => empty($updates_available),
'UP_TO_DATE_MSG' => $this->user->lang(empty($updates_available) ? 'UP_TO_DATE' : 'NOT_UP_TO_DATE', $md_manager->get_metadata('display-name')),
));
foreach ($updates_available as $branch => $version_data)
{
- $this->template->assign_block_vars('updates_available', $version_data);
+ $this->template->assign_block_vars('updates_available', $version_data);
}
}
catch (exception_interface $e)
@@ -583,4 +583,41 @@ class acp_extensions
{
return strnatcasecmp($val1['META_DISPLAY_NAME'], $val2['META_DISPLAY_NAME']);
}
+
+ /**
+ * Outputs extension metadata into the template
+ *
+ * @param array $metadata Array with all metadata for the extension
+ * @return null
+ */
+ public function output_metadata_to_template($metadata)
+ {
+ $this->template->assign_vars(array(
+ 'META_NAME' => $metadata['name'],
+ 'META_TYPE' => $metadata['type'],
+ 'META_DESCRIPTION' => (isset($metadata['description'])) ? $metadata['description'] : '',
+ 'META_HOMEPAGE' => (isset($metadata['homepage'])) ? $metadata['homepage'] : '',
+ 'META_VERSION' => $metadata['version'],
+ 'META_TIME' => (isset($metadata['time'])) ? $metadata['time'] : '',
+ 'META_LICENSE' => $metadata['license'],
+
+ 'META_REQUIRE_PHP' => (isset($metadata['require']['php'])) ? $metadata['require']['php'] : '',
+ 'META_REQUIRE_PHP_FAIL' => (isset($metadata['require']['php'])) ? false : true,
+
+ 'META_REQUIRE_PHPBB' => (isset($metadata['extra']['soft-require']['phpbb/phpbb'])) ? $metadata['extra']['soft-require']['phpbb/phpbb'] : '',
+ 'META_REQUIRE_PHPBB_FAIL' => (isset($metadata['extra']['soft-require']['phpbb/phpbb'])) ? false : true,
+
+ 'META_DISPLAY_NAME' => (isset($metadata['extra']['display-name'])) ? $metadata['extra']['display-name'] : '',
+ ));
+
+ foreach ($metadata['authors'] as $author)
+ {
+ $this->template->assign_block_vars('meta_authors', array(
+ 'AUTHOR_NAME' => $author['name'],
+ 'AUTHOR_EMAIL' => (isset($author['email'])) ? $author['email'] : '',
+ 'AUTHOR_HOMEPAGE' => (isset($author['homepage'])) ? $author['homepage'] : '',
+ 'AUTHOR_ROLE' => (isset($author['role'])) ? $author['role'] : '',
+ ));
+ }
+ }
}
diff --git a/phpBB/phpbb/console/command/update/check.php b/phpBB/phpbb/console/command/update/check.php
index 1f1cfa25d2..ed8ad79eea 100644
--- a/phpBB/phpbb/console/command/update/check.php
+++ b/phpBB/phpbb/console/command/update/check.php
@@ -134,7 +134,7 @@ class check extends \phpbb\console\command\command
try
{
$ext_manager = $this->phpbb_container->get('ext.manager');
- $md_manager = $ext_manager->create_extension_metadata_manager($ext_name, null);
+ $md_manager = $ext_manager->create_extension_metadata_manager($ext_name);
$updates_available = $ext_manager->version_check($md_manager, $recheck, false, $stability);
$metadata = $md_manager->get_metadata('all');
diff --git a/phpBB/phpbb/extension/manager.php b/phpBB/phpbb/extension/manager.php
index 22522d0785..5cafd9319a 100644
--- a/phpBB/phpbb/extension/manager.php
+++ b/phpBB/phpbb/extension/manager.php
@@ -152,7 +152,12 @@ class manager
*/
public function create_extension_metadata_manager($name)
{
- return new \phpbb\extension\metadata_manager($name, $this->config, $this, $this->phpbb_root_path);
+ if (!isset($this->extensions[$name]['metadata']))
+ {
+ $metadata = new \phpbb\extension\metadata_manager($name, $this->get_extension_path($name, true));
+ $this->extensions[$name]['metadata'] = $metadata;
+ }
+ return $this->extensions[$name]['metadata'];
}
/**
@@ -168,7 +173,7 @@ class manager
public function enable_step($name)
{
// ignore extensions that are already enabled
- if (isset($this->extensions[$name]) && $this->extensions[$name]['ext_active'])
+ if ($this->is_enabled($name))
{
return false;
}
@@ -258,7 +263,7 @@ class manager
public function disable_step($name)
{
// ignore extensions that are already disabled
- if (!isset($this->extensions[$name]) || !$this->extensions[$name]['ext_active'])
+ if ($this->is_disabled($name))
{
return false;
}
@@ -336,8 +341,8 @@ class manager
*/
public function purge_step($name)
{
- // ignore extensions that do not exist
- if (!isset($this->extensions[$name]))
+ // ignore extensions that are not configured
+ if (!$this->is_configured($name))
{
return false;
}
@@ -458,8 +463,12 @@ class manager
$configured = array();
foreach ($this->extensions as $name => $data)
{
- $data['ext_path'] = ($phpbb_relative ? $this->phpbb_root_path : '') . $data['ext_path'];
- $configured[$name] = $data;
+ if ($this->is_configured($name))
+ {
+ unset($data['metadata']);
+ $data['ext_path'] = ($phpbb_relative ? $this->phpbb_root_path : '') . $data['ext_path'];
+ $configured[$name] = $data;
+ }
}
return $configured;
}
@@ -476,7 +485,7 @@ class manager
$enabled = array();
foreach ($this->extensions as $name => $data)
{
- if ($data['ext_active'])
+ if ($this->is_enabled($name))
{
$enabled[$name] = ($phpbb_relative ? $this->phpbb_root_path : '') . $data['ext_path'];
}
@@ -497,7 +506,7 @@ class manager
$disabled = array();
foreach ($this->extensions as $name => $data)
{
- if (!$data['ext_active'])
+ if ($this->is_disabled($name))
{
$disabled[$name] = ($phpbb_relative ? $this->phpbb_root_path : '') . $data['ext_path'];
}
@@ -532,7 +541,7 @@ class manager
*/
public function is_enabled($name)
{
- return isset($this->extensions[$name]) && $this->extensions[$name]['ext_active'];
+ return isset($this->extensions[$name]['ext_active']) && $this->extensions[$name]['ext_active'];
}
/**
@@ -543,7 +552,7 @@ class manager
*/
public function is_disabled($name)
{
- return isset($this->extensions[$name]) && !$this->extensions[$name]['ext_active'];
+ return isset($this->extensions[$name]['ext_active']) && !$this->extensions[$name]['ext_active'];
}
/**
@@ -557,7 +566,7 @@ class manager
*/
public function is_configured($name)
{
- return isset($this->extensions[$name]);
+ return isset($this->extensions[$name]['ext_active']);
}
/**
diff --git a/phpBB/phpbb/extension/metadata_manager.php b/phpBB/phpbb/extension/metadata_manager.php
index 089f9a7a32..2dec6944b7 100644
--- a/phpBB/phpbb/extension/metadata_manager.php
+++ b/phpBB/phpbb/extension/metadata_manager.php
@@ -19,24 +19,6 @@ namespace phpbb\extension;
class metadata_manager
{
/**
- * phpBB Config instance
- * @var \phpbb\config\config
- */
- protected $config;
-
- /**
- * phpBB Extension Manager
- * @var \phpbb\extension\manager
- */
- protected $extension_manager;
-
- /**
- * phpBB root path
- * @var string
- */
- protected $phpbb_root_path;
-
- /**
* Name (including vendor) of the extension
* @var string
*/
@@ -58,19 +40,13 @@ class metadata_manager
* Creates the metadata manager
*
* @param string $ext_name Name (including vendor) of the extension
- * @param \phpbb\config\config $config phpBB Config instance
- * @param \phpbb\extension\manager $extension_manager An instance of the phpBB extension manager
- * @param string $phpbb_root_path Path to the phpbb includes directory.
+ * @param string $ext_path Path to the extension directory including root path
*/
- public function __construct($ext_name, \phpbb\config\config $config, \phpbb\extension\manager $extension_manager, $phpbb_root_path)
+ public function __construct($ext_name, $ext_path)
{
- $this->config = $config;
- $this->extension_manager = $extension_manager;
- $this->phpbb_root_path = $phpbb_root_path;
-
$this->ext_name = $ext_name;
$this->metadata = array();
- $this->metadata_file = '';
+ $this->metadata_file = $ext_path . 'composer.json';
}
/**
@@ -119,15 +95,12 @@ class metadata_manager
}
/**
- * Sets the path of the metadata file, gets its contents and cleans loaded file
+ * Gets the metadata file contents and cleans loaded file
*
* @throws \phpbb\extension\exception
*/
private function fetch_metadata_from_file()
{
- $ext_filepath = $this->extension_manager->get_extension_path($this->ext_name);
- $this->metadata_file = $this->phpbb_root_path . $ext_filepath . 'composer.json';
-
if (!file_exists($this->metadata_file))
{
throw new \phpbb\extension\exception('FILE_NOT_FOUND', array($this->metadata_file));
@@ -182,9 +155,19 @@ class metadata_manager
case 'all':
$this->validate('display');
- if (!$this->validate_enable())
+ if (!$this->validate_dir())
{
- throw new \phpbb\extension\exception('META_FIELD_NOT_SET', array($name));
+ throw new \phpbb\extension\exception('EXTENSION_DIR_INVALID');
+ }
+
+ if (!$this->validate_require_phpbb())
+ {
+ throw new \phpbb\extension\exception('META_FIELD_NOT_SET', array('soft-require'));
+ }
+
+ if (!$this->validate_require_php())
+ {
+ throw new \phpbb\extension\exception('META_FIELD_NOT_SET', array('require php'));
}
break;
@@ -296,40 +279,4 @@ class metadata_manager
return true;
}
-
- /**
- * Outputs the metadata into the template
- *
- * @param \phpbb\template\template $template phpBB Template instance
- */
- public function output_template_data(\phpbb\template\template $template)
- {
- $template->assign_vars(array(
- 'META_NAME' => $this->metadata['name'],
- 'META_TYPE' => $this->metadata['type'],
- 'META_DESCRIPTION' => (isset($this->metadata['description'])) ? $this->metadata['description'] : '',
- 'META_HOMEPAGE' => (isset($this->metadata['homepage'])) ? $this->metadata['homepage'] : '',
- 'META_VERSION' => (isset($this->metadata['version'])) ? $this->metadata['version'] : '',
- 'META_TIME' => (isset($this->metadata['time'])) ? $this->metadata['time'] : '',
- 'META_LICENSE' => $this->metadata['license'],
-
- 'META_REQUIRE_PHP' => (isset($this->metadata['require']['php'])) ? $this->metadata['require']['php'] : '',
- 'META_REQUIRE_PHP_FAIL' => !$this->validate_require_php(),
-
- 'META_REQUIRE_PHPBB' => (isset($this->metadata['extra']['soft-require']['phpbb/phpbb'])) ? $this->metadata['extra']['soft-require']['phpbb/phpbb'] : '',
- 'META_REQUIRE_PHPBB_FAIL' => !$this->validate_require_phpbb(),
-
- 'META_DISPLAY_NAME' => (isset($this->metadata['extra']['display-name'])) ? $this->metadata['extra']['display-name'] : '',
- ));
-
- foreach ($this->metadata['authors'] as $author)
- {
- $template->assign_block_vars('meta_authors', array(
- 'AUTHOR_NAME' => $author['name'],
- 'AUTHOR_EMAIL' => (isset($author['email'])) ? $author['email'] : '',
- 'AUTHOR_HOMEPAGE' => (isset($author['homepage'])) ? $author['homepage'] : '',
- 'AUTHOR_ROLE' => (isset($author['role'])) ? $author['role'] : '',
- ));
- }
- }
}