aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/acp/acp_extensions.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/acp/acp_extensions.php')
-rw-r--r--phpBB/includes/acp/acp_extensions.php111
1 files changed, 37 insertions, 74 deletions
diff --git a/phpBB/includes/acp/acp_extensions.php b/phpBB/includes/acp/acp_extensions.php
index 918ef3f813..130d00208d 100644
--- a/phpBB/includes/acp/acp_extensions.php
+++ b/phpBB/includes/acp/acp_extensions.php
@@ -25,28 +25,23 @@ class acp_extensions
function main()
{
// Start the page
- global $user, $template, $request;
+ global $user, $template, $request, $phpbb_extension_manager, $db;
- $user->add_lang(array('install', 'acp/customisations'));
+ $user->add_lang(array('install', 'acp/extensions'));
$this->page_title = 'ACP_EXTENSIONS';
- $action = $request->variable('action', '');
+ $action = $request->variable('action', 'list');
$ext_name = $request->variable('ext_name', '');
- // Set action to list if not set
- if (empty($action))
- {
- $action = 'list';
- }
-
// What are we doing?
switch ($action)
{
case 'list':
default:
- $this->list_enabled_exts();
- $this->list_disabled_exts();
+ $this->list_enabled_exts($db, $template);
+ $this->list_disabled_exts($db, $template);
+ $this->list_available_exts($phpbb_extension_manager, $template);
$this->tpl_name = 'acp_ext_list';
break;
@@ -55,13 +50,15 @@ class acp_extensions
$template->assign_vars(array(
'PRE' => true,
'U_ENABLE' => $this->u_action . '&action=enable&ext_name=' . $ext_name,
- )
- );
+ ));
break;
case 'enable':
- $this->enable_extension($ext_name);
+ $phpbb_extension_manager->enable($ext_name);
$this->tpl_name = 'acp_ext_enable';
+ $template->assign_vars(array(
+ 'U_RETURN' => $this->u_action . '&action=list',
+ ));
break;
case 'disable_pre':
@@ -69,13 +66,15 @@ class acp_extensions
$template->assign_vars(array(
'PRE' => true,
'U_DISABLE' => $this->u_action . '&action=disable&ext_name=' . $ext_name,
- )
- );
+ ));
break;
case 'disable':
- $this->disable_extension($ext_name);
+ $phpbb_extension_manager->disable($ext_name);
$this->tpl_name = 'acp_ext_disable';
+ $template->assign_vars(array(
+ 'U_RETURN' => $this->u_action . '&action=list',
+ ));
break;
case 'purge_pre':
@@ -83,13 +82,15 @@ class acp_extensions
$template->assign_vars(array(
'PRE' => true,
'U_PURGE' => $this->u_action . '&action=purge&ext_name=' . $ext_name,
- )
- );
+ ));
break;
case 'purge':
- $this->purge_extension($ext_name);
+ $phpbb_extension_manager->purge($ext_name);
$this->tpl_name = 'acp_ext_purge';
+ $template->assign_vars(array(
+ 'U_RETURN' => $this->u_action . '&action=list',
+ ));
break;
case 'delete_pre':
@@ -97,8 +98,7 @@ class acp_extensions
$template->assign_vars(array(
'PRE' => true,
'U_DELETE' => $this->u_action . '&action=delete&ext_name=' . $ext_name,
- )
- );
+ ));
break;
case 'delete':
@@ -108,49 +108,16 @@ class acp_extensions
case 'details':
$filepath = $phpbb_root_path . 'ext/' . $ext_name . '/extension.json';
$this->tpl_name = 'acp_ext_details';
- $this->get_meta_info($filepath);
+ $this->parse_meta_info($ext_name, $phpbb_extension_manager);
break;
}
}
-
- function enable_extension($ext_name)
- {
- global $phpbb_extension_manager, $template, $cache;
-
- $phpbb_extension_manager->enable($name);
- $template->assign_vars(array(
- 'U_RETURN' => $this->u_action . '&action=list',
- ));
- $cache->purge();
- }
-
- function disable_extension($ext_name)
- {
- global $phpbb_extension_manager, $template, $cache;
- $phpbb_extension_manager->disable($name);
- $template->assign_vars(array(
- 'U_RETURN' => $this->u_action . '&action=list',
- ));
- $cache->purge();
- }
- function purge_extension($ext_name)
+ private function list_enabled_exts($db, $template)
{
- global $phpbb_extension_manager, $template, $cache;
- $phpbb_extension_manager->purge($name);
- $template->assign_vars(array(
- 'U_RETURN' => $this->u_action . '&action=list',
- ));
- $cache->purge();
- }
-
- function list_enabled_exts()
- {
- global $db, $template;
-
$sql = 'SELECT ext_name
FROM ' . EXT_TABLE . '
- WHERE ext_active= 1
+ WHERE ext_active = 1
ORDER BY ext_name ASC';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
@@ -168,13 +135,11 @@ class acp_extensions
return;
}
- function list_disabled_exts()
+ private function list_disabled_exts($db, $template)
{
- global $db, $template;
-
$sql = 'SELECT ext_name
FROM ' . EXT_TABLE . '
- WHERE ext_active= 0
+ WHERE ext_active = 0
ORDER BY ext_name ASC';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
@@ -193,7 +158,7 @@ class acp_extensions
return;
}
- function list_available_exts()
+ function list_available_exts($phpbb_extension_manager, $template)
{
$phpbb_extension_manager->load_extensions();
$all_available = array_keys($phpbb_extension_manager->all_available());
@@ -214,12 +179,9 @@ class acp_extensions
return;
}
- function get_meta_info($filepath)
+ function parse_meta_info($ext_name, $phpbb_extension_manager)
{
- global $template;
-
- $metadatafile = file_get_contents($filepath);
- $metadata = json_decode($metadatafile,true);
+ $phpbb_extension_manager->get_meta_data($ext_name)
$template->assign_vars(array(
'NAME' => $metadata['name'],
@@ -235,15 +197,16 @@ class acp_extensions
)
);
- foreach ($metadata["authors"] as $author)
+ foreach ($metadata['authors'] as $author)
{
$template->assign_block_vars('authors', array(
- 'AUTHOR_NAME' => $author["name"],
- 'AUTHOR_USERNAME' => $author["username"],
- 'AUTHOR_EMAIL' => $author["email"],
- 'AUTHOR_HOMEPAGE' => $author["homepage"],
- 'AUTHOR_ROLE' => $author["role"],
+ 'AUTHOR_NAME' => $author['name'],
+ 'AUTHOR_EMAIL' => $author['email'],
+ 'AUTHOR_HOMEPAGE' => $author['homepage'],
+ 'AUTHOR_ROLE' => $author['role'],
));
}
+
+ return $metadata;
}
}