diff options
author | Igor Wiedler <igor@wiedler.ch> | 2012-02-09 01:36:06 +0100 |
---|---|---|
committer | Igor Wiedler <igor@wiedler.ch> | 2012-02-09 01:36:06 +0100 |
commit | 36728d3414e513f0b4aede75d53316e208e5eceb (patch) | |
tree | 080a833defccf680d378f4af1ea73fa399197a5f /phpBB/develop | |
parent | fb83a5f6c07fe1d3755d868b93bb632802ab7fb7 (diff) | |
download | forums-36728d3414e513f0b4aede75d53316e208e5eceb.tar forums-36728d3414e513f0b4aede75d53316e208e5eceb.tar.gz forums-36728d3414e513f0b4aede75d53316e208e5eceb.tar.bz2 forums-36728d3414e513f0b4aede75d53316e208e5eceb.tar.xz forums-36728d3414e513f0b4aede75d53316e208e5eceb.zip |
[ticket/10614] Refactor list command to use manager API
PHPBB3-10614
Diffstat (limited to 'phpBB/develop')
-rw-r--r-- | phpBB/develop/extensions.php | 74 |
1 files changed, 22 insertions, 52 deletions
diff --git a/phpBB/develop/extensions.php b/phpBB/develop/extensions.php index 81bfecc45f..4a5b0c7643 100644 --- a/phpBB/develop/extensions.php +++ b/phpBB/develop/extensions.php @@ -20,11 +20,6 @@ function usage() echo "\n"; echo "list:\n"; echo " Lists all extensions in the database and the filesystem.\n"; - echo " Next to each extension name are two flags:\n"; - echo "\n"; - echo " * present|missing: whether the extension exists in the filesystem\n"; - echo " * active|inactive: whether the extension is activated in the database\n"; - echo " * state: the current persisted installation state\n"; echo "\n"; echo "enable NAME:\n"; echo " Enables the specified extension.\n"; @@ -39,76 +34,51 @@ function usage() function list_extensions() { - global $db, $cache, $phpbb_root_path; + global $phpbb_extension_manager; - $cache->destroy('_ext'); + $phpbb_extension_manager->load_extensions(); - $sql = "SELECT ext_name, ext_active, ext_state from " . EXT_TABLE; + echo "Enabled:\n"; + $enabled = array_keys($phpbb_extension_manager->all_enabled()); + print_extensions($enabled); + echo "\n"; - $result = $db->sql_query($sql); - $extensions = array(); - while ($row = $db->sql_fetchrow($result)) - { - $extensions[$row['ext_name']]['active'] = (bool) $row['ext_active']; - $extensions[$row['ext_name']]['state'] = (bool) $row['ext_state']; - if (file_exists($phpbb_root_path . 'ext/' . $row['ext_name'])) - { - $extensions[$row['ext_name']]['present'] = true; - } - else - { - $extensions[$row['ext_name']]['present'] = false; - } - } + echo "Disabled:\n"; + $disabled = array_keys($phpbb_extension_manager->all_disabled()); + print_extensions($disabled); + echo "\n"; - $iterator = new DirectoryIterator($phpbb_root_path . 'ext'); - foreach ($iterator as $file) - { - // ignore hidden files - // php refuses to subscript iterator objects - $file = "$file"; - if ($file[0] != '.') - { - if (!array_key_exists($file, $extensions)) - { - $extensions[$file] = array('active' => false, 'present' => true, 'state' => false); - } - } - } + echo "Not installed:\n"; + $all = array_keys($phpbb_extension_manager->all_available()); + $purged = array_diff($all, $enabled, $disabled); + print_extensions($purged); +} - ksort($extensions); - foreach ($extensions as $name => $ext) +function print_extensions($exts) +{ + foreach ($exts as $ext) { - $present = $ext['present'] ? 'present' : 'missing'; - $active = $ext['active'] ? 'active' : 'inactive'; - $state = json_encode(unserialize($ext['state'])); - printf("%-20s %-7s %-7s %-20s\n", $name, $present, $active, $state); + echo "- $ext\n"; } } function enable_extension($name) { - global $phpbb_extension_manager, $cache; - - $cache->destroy('_ext'); + global $phpbb_extension_manager; $phpbb_extension_manager->enable($name); } function disable_extension($name) { - global $phpbb_extension_manager, $cache; - - $cache->destroy('_ext'); + global $phpbb_extension_manager; $phpbb_extension_manager->disable($name); } function purge_extension($name) { - global $phpbb_extension_manager, $cache; - - $cache->destroy('_ext'); + global $phpbb_extension_manager; $phpbb_extension_manager->purge($name); } |