diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2009-06-09 20:35:37 -0700 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-06-09 20:35:37 -0700 |
commit | 16ef912154f7adb1d623ac843f480c5f91f05774 (patch) | |
tree | 7e6737d27ad436dff4a48c4558ea9d4a97f48581 /modules | |
parent | ec0890e42bda0262a621b8c8d3e8a5e8000bbc55 (diff) | |
parent | f55686c7ef2ca5f3c2c78588e39ac717064c5e09 (diff) |
Merge branch 'master' of git://github.com/gallery/gallery3
Diffstat (limited to 'modules')
-rw-r--r-- | modules/gallery/controllers/upgrader.php | 25 | ||||
-rw-r--r-- | modules/gallery/helpers/l10n_client.php | 7 | ||||
-rw-r--r-- | modules/gallery/helpers/module.php | 34 | ||||
-rw-r--r-- | modules/gallery/views/admin_advanced_settings.html.php | 2 | ||||
-rw-r--r-- | modules/gallery/views/upgrader.html.php | 135 |
5 files changed, 187 insertions, 16 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/l10n_client.php b/modules/gallery/helpers/l10n_client.php index 33f23857..20f81ecc 100644 --- a/modules/gallery/helpers/l10n_client.php +++ b/modules/gallery/helpers/l10n_client.php @@ -123,7 +123,12 @@ class l10n_client_Core { $key = $message_data->key; $locale = $message_data->locale; $revision = $message_data->rev; - $translation = serialize(json_decode($message_data->translation)); + $translation = json_decode($message_data->translation); + if (!is_string($translation)) { + // Normalize stdclass to array + $translation = (array) $translation; + } + $translation = serialize($translation); // @todo Should we normalize the incoming_translations table into messages(id, key, message) // and incoming_translations(id, translation, locale, revision)? Or just allow 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/admin_advanced_settings.html.php b/modules/gallery/views/admin_advanced_settings.html.php index 34abadea..b4dedaef 100644 --- a/modules/gallery/views/admin_advanced_settings.html.php +++ b/modules/gallery/views/admin_advanced_settings.html.php @@ -6,7 +6,7 @@ </p> <ul id="gMessage"> <li class="gWarning"> - <b><?= t("Change these values at your own risk!</b>") ?> + <b><?= t("Change these values at your own risk!") ?> </li> </ul> 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> |