diff options
-rw-r--r-- | modules/gallery/controllers/albums.php | 4 | ||||
-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 | ||||
-rw-r--r-- | themes/default/views/login_page.html.php | 61 |
7 files changed, 190 insertions, 78 deletions
diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php index f37609e6..34fee917 100644 --- a/modules/gallery/controllers/albums.php +++ b/modules/gallery/controllers/albums.php @@ -26,7 +26,9 @@ class Albums_Controller extends Items_Controller { $page_size = module::get_var("gallery", "page_size", 9); if (!access::can("view", $album)) { if ($album->id == 1) { - print new Theme_View("login_page.html"); + $view = new Theme_View("page.html", "page"); + $view->content = user::get_login_form("login/auth_html"); + print $view; return; } else { access::forbidden(); 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> diff --git a/themes/default/views/login_page.html.php b/themes/default/views/login_page.html.php deleted file mode 100644 index c4880727..00000000 --- a/themes/default/views/login_page.html.php +++ /dev/null @@ -1,61 +0,0 @@ -<?php defined("SYSPATH") or die("No direct script access.") ?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Tranisitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> - <head> - <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> - <title> - <?= t("Please Login to Gallery") ?> - </title> - <link rel="shortcut icon" href="<?= $theme->url("images/favicon.ico") ?>" type="image/x-icon" /> - <link rel="stylesheet" type="text/css" href="<?= url::file("lib/yui/reset-fonts-grids.css") ?>" - media="screen,print,projection" /> - <link rel="stylesheet" type="text/css" href="<?= url::file("lib/superfish/css/superfish.css") ?>" - media="screen" /> - <link rel="stylesheet" type="text/css" href="<?= url::file("lib/themeroller/ui.base.css") ?>" - media="screen,print,projection" /> - <link rel="stylesheet" type="text/css" href="<?= $theme->url("css/screen.css") ?>" - media="screen,print,projection" /> - <!--[if lt IE 8]> - <link rel="stylesheet" type="text/css" href="<?= $theme->url("css/fix-ie.css") ?>" - media="screen,print,projection" /> - <![endif]--> - <script src="<?= url::file("lib/jquery.js") ?>" type="text/javascript"></script> - <script src="<?= url::file("lib/jquery.form.js") ?>" type="text/javascript"></script> - <script src="<?= url::file("lib/jquery-ui.js") ?>" type="text/javascript"></script> - <script src="<?= url::file("lib/gallery.common.js") ?>" type="text/javascript"></script> - <script src="<?= url::file("lib/gallery.dialog.js") ?>" type="text/javascript"></script> - <script src="<?= url::file("lib/gallery.form.js") ?>" type="text/javascript"></script> - <script src="<?= url::file("lib/superfish/js/superfish.js") ?>" type="text/javascript"></script> - <script src="<?= $theme->url("js/jquery.scrollTo.js") ?>" type="text/javascript"></script> - <script src="<?= $theme->url("js/jquery.localscroll.js") ?>" type="text/javascript"></script> - <script src="<?= $theme->url("js/ui.init.js") ?>" type="text/javascript"></script> - <?= $theme->head() ?> - </head> - - <body <?= $theme->main_element_attributes() ?>> - <?= $theme->page_top() ?> - <div id="doc4" class="yui-t5 gView"> - <?= $theme->site_status() ?> - <div id="gHeader"> - <?= $theme->display("header.html") ?> - </div> - <div id="bd"> - <div id="yui-main"> - <div class="yui-b"> - <div id="gContent" class="yui-g"> - <?= $theme->messages() ?> - <?= user::get_login_form("login/auth_html") ?> - </div> - </div> - </div> - <div id="gSidebar" class="yui-b"> - </div> - </div> - <div id="gFooter"> - <?= $theme->display("footer.html") ?> - </div> - </div> - <?= $theme->page_bottom() ?> - </body> -</html> |