diff options
author | Michael Cullum <unknownbliss@phpbbdevelopers.net> | 2012-04-28 18:13:28 +0100 |
---|---|---|
committer | Unknown Bliss <m@michaelcullum.com> | 2012-09-01 15:04:53 +0100 |
commit | 7a954d352ef1fe84256ad691135b6c6bf0d4bcc5 (patch) | |
tree | 29ced22db05656cc9d93d9a3453a0c23ffaeeb21 | |
parent | 3a5843959c754b99e595ca6d1ffa30ad67d31209 (diff) | |
download | forums-7a954d352ef1fe84256ad691135b6c6bf0d4bcc5.tar forums-7a954d352ef1fe84256ad691135b6c6bf0d4bcc5.tar.gz forums-7a954d352ef1fe84256ad691135b6c6bf0d4bcc5.tar.bz2 forums-7a954d352ef1fe84256ad691135b6c6bf0d4bcc5.tar.xz forums-7a954d352ef1fe84256ad691135b6c6bf0d4bcc5.zip |
[ticket/10631] Fixing some items mentioned in PR
PHPBB3-10631
-rw-r--r-- | phpBB/adm/style/acp_ext_delete.html | 4 | ||||
-rw-r--r-- | phpBB/adm/style/acp_ext_details.html | 6 | ||||
-rw-r--r-- | phpBB/adm/style/acp_ext_disable.html | 4 | ||||
-rw-r--r-- | phpBB/adm/style/acp_ext_enable.html | 4 | ||||
-rw-r--r-- | phpBB/adm/style/acp_ext_purge.html | 4 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_extensions.php | 111 | ||||
-rw-r--r-- | phpBB/includes/extension/manager.php | 64 | ||||
-rw-r--r-- | phpBB/language/en/acp/extensions.php | 2 |
8 files changed, 111 insertions, 88 deletions
diff --git a/phpBB/adm/style/acp_ext_delete.html b/phpBB/adm/style/acp_ext_delete.html index 1ce99b8905..f9a52861e5 100644 --- a/phpBB/adm/style/acp_ext_delete.html +++ b/phpBB/adm/style/acp_ext_delete.html @@ -18,10 +18,10 @@ </form>
<!-- ELSE IF -->
<div class="successbox">
- <p>{L_DELETE_SUCESS}</p>
+ <p>{L_DELETE_SUCCESS}</p>
<br />
<p><a href="{U_RETURN}">{L_RETURN}</a></p>
</div>
<!-- ENDIF -->
-<!-- INCLUDE overall_footer.html -->
\ No newline at end of file +<!-- INCLUDE overall_footer.html -->
diff --git a/phpBB/adm/style/acp_ext_details.html b/phpBB/adm/style/acp_ext_details.html index 397610d83b..bc5fda7cc2 100644 --- a/phpBB/adm/style/acp_ext_details.html +++ b/phpBB/adm/style/acp_ext_details.html @@ -69,10 +69,6 @@ <dt><label for="author_name">{L_AUTHOR_NAME}:</label></dt>
<dd><strong id="author_name">{authors.AUTHOR_NAME}</strong></dd>
</dl>
- <dl>
- <dt><label for="author_email">{L_AUTHOR_USERNAME}:</label></dt>
- <dd><strong id="author_email">{authors.AUTHOR_USERNAME}</strong></dd>
- </dl>
<!-- IF authors.AUTHOR_EMAIL -->
<dl>
<dt><label for="author_email">{L_AUTHOR_EMAIL}:</label></dt>
@@ -94,4 +90,4 @@ <!-- END authors -->
</fieldset>
-<!-- INCLUDE overall_footer.html -->
\ No newline at end of file +<!-- INCLUDE overall_footer.html -->
diff --git a/phpBB/adm/style/acp_ext_disable.html b/phpBB/adm/style/acp_ext_disable.html index 2198db09a1..c7de43a611 100644 --- a/phpBB/adm/style/acp_ext_disable.html +++ b/phpBB/adm/style/acp_ext_disable.html @@ -18,10 +18,10 @@ </form>
<!-- ELSE IF -->
<div class="successbox">
- <p>{L_DISABLE_SUCESS}</p>
+ <p>{L_DISABLE_SUCCESS}</p>
<br />
<p><a href="{U_RETURN}">{L_RETURN}</a></p>
</div>
<!-- ENDIF -->
-<!-- INCLUDE overall_footer.html -->
\ No newline at end of file +<!-- INCLUDE overall_footer.html -->
diff --git a/phpBB/adm/style/acp_ext_enable.html b/phpBB/adm/style/acp_ext_enable.html index 4c94ce7b2b..dd892d3477 100644 --- a/phpBB/adm/style/acp_ext_enable.html +++ b/phpBB/adm/style/acp_ext_enable.html @@ -18,10 +18,10 @@ </form>
<!-- ELSE IF -->
<div class="successbox">
- <p>{L_ENABLE_SUCESS}</p>
+ <p>{L_ENABLE_SUCCESS}</p>
<br />
<p><a href="{U_RETURN}">{L_RETURN}</a></p>
</div>
<!-- ENDIF -->
-<!-- INCLUDE overall_footer.html -->
\ No newline at end of file +<!-- INCLUDE overall_footer.html -->
diff --git a/phpBB/adm/style/acp_ext_purge.html b/phpBB/adm/style/acp_ext_purge.html index c73bbe6e00..55a648a3e3 100644 --- a/phpBB/adm/style/acp_ext_purge.html +++ b/phpBB/adm/style/acp_ext_purge.html @@ -18,10 +18,10 @@ </form>
<!-- ELSE IF -->
<div class="successbox">
- <p>{L_PURGE_SUCESS}</p>
+ <p>{L_PURGE_SUCCESS}</p>
<br />
<p><a href="{U_RETURN}">{L_RETURN}</a></p>
</div>
<!-- ENDIF -->
-<!-- INCLUDE overall_footer.html -->
\ No newline at end of file +<!-- INCLUDE overall_footer.html -->
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; } } diff --git a/phpBB/includes/extension/manager.php b/phpBB/includes/extension/manager.php index 86d8fab64b..2eebebf9b2 100644 --- a/phpBB/includes/extension/manager.php +++ b/phpBB/includes/extension/manager.php @@ -464,4 +464,68 @@ class phpbb_extension_manager { return new phpbb_extension_finder($this, $this->phpbb_root_path, $this->cache, $this->php_ext, $this->cache_name . '_finder'); } + + /** + * Gets and processes the contents of the composer.json file. + * + * TODO: Add authors, fix it + * + * @param string $name Extension name to check + * @return array All the existing metadata keys + */ + public function get_meta_data($name) + { + // Find out where the composer.json is + $ext_filepath = get_extension_path($name); + $md_filepath = $phpbb_root_path . $ext_filepath . '/composer.json'; + + // Read the composer.json and decode it + $metadatafile = file_get_contents($filepath); + $metadata = json_decode($metadatafile, true); + + // What keys are required + $required_md_keys = array( + $metadata['name'], + $metadata['type'], + $metadata['description'], + $metadata['version'], + $metadata['license'], + $medadata['require']['phpbb'], + $metadata['extra']['dispay-name'], + ); + + // Check for required keys and trigger and error if it doesn't exist + foreach ($required_md_keys as $md_key) + { + if (empty($md_key)) + { + trigger_error('Not all required items exist in the composer.json'); + } + else + { + $existing_required_keys += $md_key; + } + } + + // Which keys are optional + $optional_md_keys = array( + $metadata['require']['php'], + $metadata['time'], + $metadata['homepage'], + ); + + $existing_optional_keys = array(); + + foreach ($optional_md_keys as $md_key) + { + if (!empty($md_key)) + { + $existing_optional_keys += $md_key; + } + } + + $keys = array_merge($existing_optional_keys, $existing_required_keys); + + return $keys; + } } diff --git a/phpBB/language/en/acp/extensions.php b/phpBB/language/en/acp/extensions.php index 77d0b2f3cd..37cabe477b 100644 --- a/phpBB/language/en/acp/extensions.php +++ b/phpBB/language/en/acp/extensions.php @@ -38,7 +38,7 @@ $lang = array_merge($lang, array( 'EXTENSION' => 'Extension',
'EXTENSIONS' => 'Extensions',
'EXTENSIONS_ADMIN' => 'Extensions Admin',
- 'EXTENSIONS_EXPLAIN' => 'The Extensions Admin is a tool in your phpBB Board which allows you to manage all of your extensions. For more information about extensions please visit <a href="http://phpbb.com/mods/extensions/">this page</a> on phpBBs Offical Website.',
+ 'EXTENSIONS_EXPLAIN' => 'The Extensions Admin is a tool in your phpBB Board which allows you to manage all of your extensions. For more information about extensions please visit <a href="http://phpbb.com/mods/extensions/">this page</a> on phpBB's Offical Website.',
'DETAILS' => 'Details',
|