summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAndy Staudacher <andy.st@gmail.com>2009-06-09 21:10:53 -0700
committerAndy Staudacher <andy.st@gmail.com>2009-06-09 21:10:53 -0700
commit03e9cefa17f1170c8414da672f5fbc3bba9ad56c (patch)
tree4e3201b21fb9291ed844756dd05aff7a382c89bf /modules
parent5f7dfc272e3188fbced26a72881176c98481cfb0 (diff)
parentf55686c7ef2ca5f3c2c78588e39ac717064c5e09 (diff)
Merge branch 'master' of git@github.com:gallery/gallery3
Diffstat (limited to 'modules')
-rw-r--r--modules/gallery/controllers/upgrader.php25
-rw-r--r--modules/gallery/helpers/module.php34
-rw-r--r--modules/gallery/views/upgrader.html.php135
3 files changed, 180 insertions, 14 deletions
diff --git a/modules/gallery/controllers/upgrader.php b/modules/gallery/controllers/upgrader.php
new file mode 100644
index 00000000..e8798de5
--- /dev/null
+++ b/modules/gallery/controllers/upgrader.php
@@ -0,0 +1,25 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2009 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 Upgrader_Controller extends Controller {
+ public function index() {
+ $view = new View("upgrader.html");
+ print $view;
+ }
+}
diff --git a/modules/gallery/helpers/module.php b/modules/gallery/helpers/module.php
index 2fd5be6c..58f9b20d 100644
--- a/modules/gallery/helpers/module.php
+++ b/modules/gallery/helpers/module.php
@@ -27,6 +27,7 @@ class module_Core {
public static $active = array();
public static $modules = array();
public static $var_cache = null;
+ public static $available = array();
/**
* Set the version of the corresponding Module_Model
@@ -74,22 +75,27 @@ class module_Core {
* Return the list of available modules, including uninstalled modules.
*/
static function available() {
- $modules = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS);
- foreach (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 = self::is_installed($module_name);
- $modules->$module_name->active = self::is_active($module_name);
- $modules->$module_name->version = self::get_version($module_name);
- $modules->$module_name->locked = false;
- }
+ if (empty(self::$available)) {
+ $modules = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS);
+ foreach (glob(MODPATH . "*/module.info") as $file) {
+ $module_name = basename(dirname($file));
+ $modules->$module_name = new ArrayObject(parse_ini_file($file), ArrayObject::ARRAY_AS_PROPS);
+ $m =& $modules->$module_name;
+ $m->installed = self::is_installed($module_name);
+ $m->active = self::is_active($module_name);
+ $m->code_version = $m->version;
+ $m->version = self::get_version($module_name);
+ $m->locked = false;
+ }
- // Lock certain modules
- $modules->gallery->locked = true;
- $modules->user->locked = true;
- $modules->ksort();
+ // Lock certain modules
+ $modules->gallery->locked = true;
+ $modules->user->locked = true;
+ $modules->ksort();
+ self::$available = $modules;
+ }
- return $modules;
+ return self::$available;
}
/**
diff --git a/modules/gallery/views/upgrader.html.php b/modules/gallery/views/upgrader.html.php
new file mode 100644
index 00000000..ecf2e265
--- /dev/null
+++ b/modules/gallery/views/upgrader.html.php
@@ -0,0 +1,135 @@
+<?php defined("SYSPATH") or die("No direct script access.") ?>
+<html>
+ <head>
+ <title><?= t("Gallery3 Upgrader") ?></title>
+ </head>
+ <style>
+ body {
+ background: #eee;
+ font-family: Trebuchet MS;
+ font-size: 1.1em;
+ }
+ div#outer {
+ width: 650px;
+ background: white;
+ border: 1px solid #999;
+ margin: 0 auto;
+ padding: -10px;
+ }
+ div#inner {
+ padding: 0 1em 0 1em;
+ margin: 0px;
+ }
+ div#footer {
+ border-top: 1px solid #ccc;
+ margin: 1em;
+ }
+ td.name {
+ text-align: left;
+ padding-left: 30px;
+ }
+ td {
+ text-align: center;
+ border-bottom: 1px solid #eee;
+ }
+ tr.current td {
+ color: #999;
+ font-style: italic;
+ }
+ tr.upgradeable td {
+ font-weight: bold;
+ }
+ table {
+ width: 600px;
+ margin-bottom: 10px;
+ }
+ p {
+ font-size: .9em;
+ }
+ ul {
+ font-size: .9em;
+ list-style: none;
+ }
+ li {
+ display: inline;
+ }
+ li:before {
+ content: "\00BB \0020";
+ }
+ div.button {
+ margin: 0 auto;
+ width: 120px;
+ text-align: center;
+ border: 1px solid #999;
+ background: #eee;
+ }
+ div.button:hover {
+ background: #ccc;
+ }
+ </style>
+ <body>
+ <div id="outer">
+ <img src="<?= url::file("modules/gallery/images/gallery.png") ?>" />
+ <div id="inner">
+ <p>
+ <?= t("Welcome to the Gallery upgrader. One click and you're done!") ?>
+ </p>
+ <table>
+ <tr>
+ <th> <?= t("Module name") ?> </th>
+ <th> <?= t("Installed version") ?> </th>
+ <th> <?= t("Available version") ?> </th>
+ </tr>
+
+ <? foreach (module::available() as $module): ?>
+ <? if ($module->active): ?>
+ <tr class="<?= $module->version == $module->code_version ? "current" : "upgradeable" ?>" >
+ <td class="name">
+ <?= $module->name ?>
+ </td>
+ <td>
+ <?= $module->version ?>
+ </td>
+ <td>
+ <?= $module->code_version ?>
+ </td>
+ </tr>
+ <? else: ?>
+ <? @$inactive++ ?>
+ <? endif ?>
+ <? endforeach ?>
+ </table>
+
+ <div class="button">
+ <a href="<?= url::site("upgrader/upgrade") ?>">
+ <?= t("Upgrade all") ?>
+ </a>
+ </div>
+
+ <? if (@$inactive): ?>
+ <p>
+ <?= t("The following modules are inactive and don't require an upgrade.") ?>
+ </p>
+ <ul>
+ <? foreach (module::available() as $module): ?>
+ <? if (!$module->active): ?>
+ <li>
+ <?= $module->name ?>
+ </li>
+ <? endif ?>
+ <? endforeach ?>
+ </p>
+ <? endif ?>
+ </div>
+ <div id="footer">
+ <p>
+ <i>
+ <?= t("Did something go wrong? Try the <a href=\"%faq_url\">FAQ</a> or ask in the <a href=\"%forums_url\">Gallery forums</a>.</i>",
+ array("faq_url" => "http://codex.gallery2.org/Gallery3:FAQ",
+ "forums_url" => "http://gallery.menalto.com/forum")) ?>
+ </i>
+ </p>
+ </div>
+ </div>
+ </body>
+</html>