diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/controllers/admin_modules.php | 27 | ||||
-rw-r--r-- | core/controllers/welcome.php | 3 | ||||
-rw-r--r-- | core/helpers/core_menu.php | 2 | ||||
-rw-r--r-- | core/helpers/module.php | 18 | ||||
-rw-r--r-- | core/module.info | 3 | ||||
-rw-r--r-- | core/views/admin_modules.html.php | 19 | ||||
-rw-r--r-- | core/views/welcome_syscheck.html.php | 21 |
7 files changed, 74 insertions, 19 deletions
diff --git a/core/controllers/admin_modules.php b/core/controllers/admin_modules.php new file mode 100644 index 00000000..12686f87 --- /dev/null +++ b/core/controllers/admin_modules.php @@ -0,0 +1,27 @@ +<?php defined("SYSPATH") or die("No direct script access."); +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2008 Bharat Mediratta + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. + */ +class Admin_Modules_Controller extends Admin_Controller { + public function index() { + $view = new View("admin_modules.html"); + $view->available = module::available(); + return $view; + } +} + diff --git a/core/controllers/welcome.php b/core/controllers/welcome.php index d6c40850..b253f13f 100644 --- a/core/controllers/welcome.php +++ b/core/controllers/welcome.php @@ -425,12 +425,13 @@ class Welcome_Controller extends Template_Controller { $modules = module::available(); try { foreach (module::installed() as $installed_module) { - $modules[$installed_module->name] = $installed_module->version; + $modules->$installed_module->version = $installed_module->version; } } catch (Exception $e) { // The database may not be installed } ksort($modules); + return $modules; } diff --git a/core/helpers/core_menu.php b/core/helpers/core_menu.php index 5ed88700..a30151c7 100644 --- a/core/helpers/core_menu.php +++ b/core/helpers/core_menu.php @@ -78,7 +78,7 @@ class core_menu_Core { ->append(Menu::factory("link") ->id("modules") ->label(_("Modules")) - ->url("#")) + ->url("admin/modules")) ->append(Menu::factory("submenu") ->id("content_menu") ->label(_("Content"))) diff --git a/core/helpers/module.php b/core/helpers/module.php index fed01921..bb6e8dad 100644 --- a/core/helpers/module.php +++ b/core/helpers/module.php @@ -74,7 +74,7 @@ class module_Core { * @param string $module_name */ public static function is_installed($module_name) { - return in_array($module_name, self::$module_names); + return !empty(self::$module_names[$module_name]); } /** @@ -88,11 +88,13 @@ class module_Core { * Return the list of available modules. */ public static function available() { - $modules = array(); - foreach (glob(MODPATH . "*/helpers/*_installer.php") as $file) { - if (empty($modules[basename(dirname(dirname($file)))])) { - $modules[basename(dirname(dirname($file)))] = 0; - } + $modules = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS); + foreach (array_merge(array("core/module.info"), glob(MODPATH . "*/module.info")) as $file) { + $module_name = basename(dirname($file)); + $modules->$module_name = new ArrayObject(parse_ini_file($file), ArrayObject::ARRAY_AS_PROPS); + $modules->$module_name->installed = + empty(self::$modules[$module_name]) ? + null : self::$modules[$module_name]->version; } return $modules; @@ -152,8 +154,8 @@ class module_Core { try { foreach ($modules as $module) { - self::$module_names[] = $module->name; - self::$modules[] = $module; + self::$module_names[$module->name] = $module->name; + self::$modules[$module->name] = $module; $kohana_modules[] = MODPATH . $module->name; } diff --git a/core/module.info b/core/module.info new file mode 100644 index 00000000..ff7da82d --- /dev/null +++ b/core/module.info @@ -0,0 +1,3 @@ +name = Gallery 3 +description = Gallery core application +version = 1 diff --git a/core/views/admin_modules.html.php b/core/views/admin_modules.html.php new file mode 100644 index 00000000..d0a0f613 --- /dev/null +++ b/core/views/admin_modules.html.php @@ -0,0 +1,19 @@ +<? defined("SYSPATH") or die("No direct script access."); ?> +<div id="gModules"> + <table> + <tr> + <th> <?= _("Installed") ?> </th> + <th> <?= _("Name") ?> </th> + <th> <?= _("Version") ?> </th> + <th> <?= _("Description") ?> </th> + </tr> + <? foreach ($available as $module_name => $module_info): ?> + <tr> + <td> <?= form::checkbox($module_name, '', module::is_installed($module_name)) ?> </td> + <td> <?= _($module_info["name"]) ?> </td> + <td> <?= module::get_version($module_name) ?> </td> + <td> <?= _($module_info["description"]) ?> </td> + </tr> + <? endforeach ?> + </table> +</div> diff --git a/core/views/welcome_syscheck.html.php b/core/views/welcome_syscheck.html.php index e46a179b..2908f8bd 100644 --- a/core/views/welcome_syscheck.html.php +++ b/core/views/welcome_syscheck.html.php @@ -18,7 +18,7 @@ <? if (empty($errors)): ?> <div class="block"> - <? if (empty($modules['core'])): ?> + <? if (!module::is_installed("core")): ?> <p class="success"> Your system is ready, but Gallery is not yet installed. </p> @@ -32,25 +32,28 @@ <table style="width: 400px"> <tr> <th align="left">Name</th> - <th align="left">Version</th> + <th align="left">Installed</th> + <th align="left">Available</th> <th align="left">Action</th> </tr> <tr class="core"> <td> <b> core </b> </td> - <td> <b> <?= $modules["core"] ?> </b> </td> + <td> <b> <?= module::get_version("core") ?> </b> </td> + <td> <b> <?= module::get_version("core") ?> </b> </td> <td> <b> <?= html::anchor("welcome/uninstall/core", "reset install") ?> </b> </td> </tr> - <? foreach ($modules as $module_name => $module_version): ?> + <? foreach ($modules as $module_name => $info): ?> <? if ($module_name == "core") continue; ?> <tr> <td><?= $module_name ?></td> - <td><?= empty($module_version) ? "" : $module_version ?></td> + <td><?= $info->installed ?></td> + <td><?= $info->version ?></td> <td> - <? if (empty($module_version)): ?> - <?= html::anchor("welcome/install/{$module_name}", "install") ?> + <? if ($info->installed): ?> + <?= html::anchor("welcome/uninstall/{$module_name}", "uninstall") ?> <? else: ?> - <?= html::anchor("welcome/uninstall/{$module_name}", "uninstall") ?> - <? endif; ?> + <?= html::anchor("welcome/install/{$module_name}", "install") ?> + <? endif ?> </td> </tr> <? endforeach; ?> |