diff options
Diffstat (limited to 'modules/gallery')
118 files changed, 3984 insertions, 1932 deletions
diff --git a/modules/gallery/config/upload.php b/modules/gallery/config/upload.php index 897ecacf..69ea7768 100644 --- a/modules/gallery/config/upload.php +++ b/modules/gallery/config/upload.php @@ -33,4 +33,4 @@ $config['create_directories'] = FALSE; /** * Remove spaces from uploaded filenames. */ -$config['remove_spaces'] = TRUE;
\ No newline at end of file +$config['remove_spaces'] = FALSE;
\ No newline at end of file diff --git a/modules/gallery/controllers/admin.php b/modules/gallery/controllers/admin.php index b92a32cd..98cac557 100644 --- a/modules/gallery/controllers/admin.php +++ b/modules/gallery/controllers/admin.php @@ -21,7 +21,7 @@ class Admin_Controller extends Controller { private $theme; public function __construct($theme=null) { - if (!(user::active()->admin)) { + if (!(identity::active_user()->admin)) { access::forbidden(); } diff --git a/modules/gallery/controllers/admin_dashboard.php b/modules/gallery/controllers/admin_dashboard.php index 3cb97b14..7e28f625 100644 --- a/modules/gallery/controllers/admin_dashboard.php +++ b/modules/gallery/controllers/admin_dashboard.php @@ -22,7 +22,7 @@ class Admin_Dashboard_Controller extends Admin_Controller { $view = new Admin_View("admin.html"); $view->content = new View("admin_dashboard.html"); $view->content->blocks = block_manager::get_html("dashboard_center"); - $view->sidebar = "<div id=\"gAdminDashboardSidebar\">" . + $view->sidebar = "<div id=\"g-admin-dashboard-sidebar\">" . block_manager::get_html("dashboard_sidebar") . "</div>"; print $view; @@ -34,7 +34,7 @@ class Admin_Dashboard_Controller extends Admin_Controller { $form = gallery_block::get_add_block_form(); if ($form->validate()) { list ($module_name, $id) = explode(":", $form->add_block->id->value); - $available = block_manager::get_available(); + $available = block_manager::get_available_admin_blocks(); if ($form->add_block->center->value) { block_manager::add("dashboard_center", $module_name, $id); @@ -66,7 +66,7 @@ class Admin_Dashboard_Controller extends Admin_Controller { } if (!empty($deleted)) { - $available = block_manager::get_available(); + $available = block_manager::get_available_admin_blocks(); $title = $available[join(":", $deleted)]; message::success(t("Removed <b>%title</b> block", array("title" => $title))); } diff --git a/modules/gallery/controllers/admin_identity.php b/modules/gallery/controllers/admin_identity.php new file mode 100644 index 00000000..acf71665 --- /dev/null +++ b/modules/gallery/controllers/admin_identity.php @@ -0,0 +1,76 @@ +<?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 Admin_Identity_Controller extends Admin_Controller { + public function index() { + $view = new Admin_View("admin.html"); + $view->content = new View("admin_identity.html"); + $view->content->available = identity::providers(); + $view->content->active = module::get_var("gallery", "identity_provider", "user"); + print $view; + } + + public function confirm() { + access::verify_csrf(); + + $v = new View("admin_identity_confirm.html"); + $v->new_provider = $this->input->post("provider"); + + print $v; + } + + public function change() { + access::verify_csrf(); + + $active_provider = module::get_var("gallery", "identity_provider", "user"); + $providers = identity::providers(); + $new_provider = $this->input->post("provider"); + + if ($new_provider != $active_provider) { + + module::deactivate($active_provider); + + // Switch authentication + identity::reset(); + module::set_var("gallery", "identity_provider", $new_provider); + + module::install($new_provider); + module::activate($new_provider); + + module::event("identity_provider_changed", $active_provider, $new_provider); + + module::uninstall($active_provider); + + message::success(t("Changed to %description", + array("description" => $providers->$new_provider))); + + try { + Session::instance()->destroy(); + } catch (Exception $e) { + // We don't care if there was a problem destroying the session. + } + url::redirect(item::root()->abs_url()); + } + + message::info(t("The selected provider \"%description\" is already active.", + array("description" => $providers->$new_provider))); + url::redirect("admin/identity"); + } +} + diff --git a/modules/gallery/controllers/admin_languages.php b/modules/gallery/controllers/admin_languages.php index d91e5205..27537c7f 100644 --- a/modules/gallery/controllers/admin_languages.php +++ b/modules/gallery/controllers/admin_languages.php @@ -24,7 +24,7 @@ class Admin_Languages_Controller extends Admin_Controller { $v->content->available_locales = locales::available(); $v->content->installed_locales = locales::installed(); $v->content->default_locale = module::get_var("gallery", "default_locale"); - + if (empty($share_translations_form)) { $share_translations_form = $this->_share_translations_form(); } @@ -35,21 +35,21 @@ class Admin_Languages_Controller extends Admin_Controller { public function save() { access::verify_csrf(); - - locales::update_installed($this->input->post("installed_locales")); - - $installed_locales = array_keys(locales::installed()); + + locales::update_installed($this->input->post("installed_locales")); + + $installed_locales = array_keys(locales::installed()); $new_default_locale = $this->input->post("default_locale"); - if (!in_array($new_default_locale, $installed_locales)) { - if (!empty($installed_locales)) { - $new_default_locale = $installed_locales[0]; - } else { - $new_default_locale = "en_US"; - } - } - module::set_var("gallery", "default_locale", $new_default_locale); - - print json_encode(array("result" => "success")); + if (!in_array($new_default_locale, $installed_locales)) { + if (!empty($installed_locales)) { + $new_default_locale = $installed_locales[0]; + } else { + $new_default_locale = "en_US"; + } + } + module::set_var("gallery", "default_locale", $new_default_locale); + + print json_encode(array("result" => "success")); } public function share() { @@ -88,6 +88,8 @@ class Admin_Languages_Controller extends Admin_Controller { message::success(t("Your API key has been changed.")); } else if (!$old_key && $new_key) { message::success(t("Your API key has been saved.")); + } else if ($old_key && $new_key && $old_key == $new_key) { + message::info(t("Your API key was not changed.")); } log::success(t("gallery"), t("l10n_client API key changed.")); @@ -103,16 +105,17 @@ class Admin_Languages_Controller extends Admin_Controller { } private function _share_translations_form() { - $form = new Forge("admin/languages/share", "", "post", array("id" => "gShareTranslationsForm")); + $form = new Forge("admin/languages/share", "", "post", array("id" => "g-share-translations-form")); $group = $form->group("sharing") ->label(t("Sharing your own translations with the Gallery community is easy. Please do!")); $api_key = l10n_client::api_key(); $server_link = l10n_client::server_api_key_url(); $group->input("api_key") ->label(empty($api_key) - ? t("This is a unique key that will allow you to send translations to the remote server. To get your API key go to %server-link.", + ? t("This is a unique key that will allow you to send translations to the remote + server. To get your API key go to %server-link.", array("server-link" => html::mark_clean(html::anchor($server_link)))) - : t("API Key")) + : t("API key")) ->value($api_key) ->error_messages("invalid", t("The API key you provided is invalid.")); $group->submit("save")->value(t("Save settings")); diff --git a/modules/gallery/controllers/admin_sidebar.php b/modules/gallery/controllers/admin_sidebar.php new file mode 100644 index 00000000..77e83bc2 --- /dev/null +++ b/modules/gallery/controllers/admin_sidebar.php @@ -0,0 +1,68 @@ +<?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 Admin_Sidebar_Controller extends Admin_Controller { + public function index() { + $view = new Admin_View("admin.html"); + $view->content = new View("admin_sidebar.html"); + $view->content->csrf = access::csrf_token(); + $view->content->available = new View("admin_sidebar_blocks.html"); + $view->content->active = new View("admin_sidebar_blocks.html"); + list($view->content->available->blocks, $view->content->active->blocks) = $this->_get_blocks(); + print $view; + } + + public function update() { + access::verify_csrf(); + + $available_blocks = block_manager::get_available_site_blocks(); + + $active_blocks = array(); + foreach ($this->input->get("block", array()) as $block_id) { + $active_blocks[md5($block_id)] = explode(":", (string) $block_id); + } + block_manager::set_active("site_sidebar", $active_blocks); + + $result = array("result" => "success"); + list($available, $active) = $this->_get_blocks(); + $v = new View("admin_sidebar_blocks.html"); + $v->blocks = $available; + $result["available"] = $v->render(); + $v = new View("admin_sidebar_blocks.html"); + $v->blocks = $active; + $result["active"] = $v->render(); + $message = t("Updated sidebar blocks"); + $result["message"] = (string) $message; + print json_encode($result); + } + + private function _get_blocks() { + $active_blocks = array(); + $available_blocks = block_manager::get_available_site_blocks(); + foreach (block_manager::get_active("site_sidebar") as $block) { + $id = "{$block[0]}:{$block[1]}"; + if (!empty($available_blocks[$id])) { + $active_blocks[$id] = $available_blocks[$id]; + unset($available_blocks[$id]); + } + } + return array($available_blocks, $active_blocks); + } +} + diff --git a/modules/gallery/controllers/admin_theme_options.php b/modules/gallery/controllers/admin_theme_options.php index 8970c3c9..27a67bdb 100644 --- a/modules/gallery/controllers/admin_theme_options.php +++ b/modules/gallery/controllers/admin_theme_options.php @@ -35,9 +35,9 @@ class Admin_Theme_Options_Controller extends Admin_Controller { $thumb_size = $form->edit_theme->thumb_size->value; $thumb_dirty = false; if (module::get_var("gallery", "thumb_size") != $thumb_size) { - graphics::remove_rule("gallery", "thumb", "resize"); + graphics::remove_rule("gallery", "thumb", "gallery_graphics::resize"); graphics::add_rule( - "gallery", "thumb", "resize", + "gallery", "thumb", "gallery_graphics::resize", array("width" => $thumb_size, "height" => $thumb_size, "master" => Image::AUTO), 100); module::set_var("gallery", "thumb_size", $thumb_size); @@ -46,9 +46,9 @@ class Admin_Theme_Options_Controller extends Admin_Controller { $resize_size = $form->edit_theme->resize_size->value; $resize_dirty = false; if (module::get_var("gallery", "resize_size") != $resize_size) { - graphics::remove_rule("gallery", "resize", "resize"); + graphics::remove_rule("gallery", "resize", "gallery_graphics::resize"); graphics::add_rule( - "gallery", "resize", "resize", + "gallery", "resize", "gallery_graphics::resize", array("width" => $resize_size, "height" => $resize_size, "master" => Image::AUTO), 100); module::set_var("gallery", "resize_size", $resize_size); diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php index 08a60132..4e37649c 100644 --- a/modules/gallery/controllers/albums.php +++ b/modules/gallery/controllers/albums.php @@ -28,7 +28,8 @@ class Albums_Controller extends Items_Controller { if ($album->id == 1) { $view = new Theme_View("page.html", "login"); $view->page_title = t("Log in to Gallery"); - $view->content = user::get_login_form("login/auth_html"); + $view->content = new View("login_ajax.html"); + $view->content->form = auth::get_login_form("login/auth_html"); print $view; return; } else { @@ -39,7 +40,8 @@ class Albums_Controller extends Items_Controller { $show = $this->input->get("show"); if ($show) { - $index = $album->get_position($show); + $child = ORM::factory("item", $show); + $index = $album->get_position($child); if ($index) { $page = ceil($index / $page_size); if ($page == 1) { @@ -63,6 +65,8 @@ class Albums_Controller extends Items_Controller { } $template = new Theme_View("page.html", "album"); + $template->set_global("page", $page); + $template->set_global("max_pages", $max_pages); $template->set_global("page_size", $page_size); $template->set_global("item", $album); $template->set_global("children", $album->viewable()->children($page_size, $offset)); @@ -109,7 +113,7 @@ class Albums_Controller extends Items_Controller { $this->input->post("name"), $this->input->post("title", $this->input->post("name")), $this->input->post("description"), - user::active()->id, + identity::active_user()->id, $this->input->post("slug")); log::success("content", "Created an album", @@ -144,7 +148,7 @@ class Albums_Controller extends Items_Controller { $_FILES["file"]["name"], $this->input->post("title", $this->input->post("name")), $this->input->post("description"), - user::active()->id); + identity::active_user()->id); log::success("content", "Added a photo", html::anchor("photos/$photo->id", "view photo")); message::success(t("Added photo %photo_title", @@ -198,6 +202,8 @@ class Albums_Controller extends Items_Controller { } if ($valid) { + $watching_album = $album->url() != ($location = parse_url(request::referrer(), PHP_URL_PATH)); + $album->title = $form->edit_item->title->value; $album->description = $form->edit_item->description->value; $album->sort_column = $form->edit_item->sort_order->column->value; @@ -214,7 +220,8 @@ class Albums_Controller extends Items_Controller { array("album_title" => html::purify($album->title)))); print json_encode( - array("result" => "success")); + array("result" => "success", + "location" => $watching_album ? $location : $album->url())); } else { print json_encode( array("result" => "error", diff --git a/modules/gallery/controllers/file_proxy.php b/modules/gallery/controllers/file_proxy.php index 8cb90c50..acfd6eb9 100644 --- a/modules/gallery/controllers/file_proxy.php +++ b/modules/gallery/controllers/file_proxy.php @@ -32,10 +32,6 @@ class File_Proxy_Controller extends Controller { $request_uri = $this->input->server("REQUEST_URI"); $request_uri = preg_replace("/\?.*/", "", $request_uri); - // Unescape %7E (~), %20 ( ) and %27 (') - // @todo: figure out why we have to do this and unescape everything appropriate - $request_uri = str_replace(array("%7E", "%20", "%27"), array("~", " ", "'"), $request_uri); - // var_uri: http://example.com/gallery3/var/ $var_uri = url::file("var/"); diff --git a/modules/gallery/controllers/l10n_client.php b/modules/gallery/controllers/l10n_client.php index 6e19310b..6db67d3b 100644 --- a/modules/gallery/controllers/l10n_client.php +++ b/modules/gallery/controllers/l10n_client.php @@ -20,7 +20,7 @@ class L10n_Client_Controller extends Controller { public function save() { access::verify_csrf(); - if (!user::active()->admin) { + if (!identity::active_user()->admin) { access::forbidden(); } @@ -85,7 +85,7 @@ class L10n_Client_Controller extends Controller { public function toggle_l10n_mode() { access::verify_csrf(); - if (!user::active()->admin) { + if (!identity::active_user()->admin) { access::forbidden(); } @@ -102,9 +102,9 @@ class L10n_Client_Controller extends Controller { } private static function _l10n_client_search_form() { - $form = new Forge("l10n_client/search", "", "post", array("id" => "gL10nSearchForm")); + $form = new Forge("l10n_client/search", "", "post", array("id" => "g-l10n-search-form")); $group = $form->group("l10n_search"); - $group->input("l10n-search")->id("gL10nSearch"); + $group->input("l10n-search")->id("g-l10n-search"); $group->submit("l10n-search-filter-clear")->value(t("X")); return $form; diff --git a/modules/gallery/controllers/login.php b/modules/gallery/controllers/login.php new file mode 100644 index 00000000..75ee6b9c --- /dev/null +++ b/modules/gallery/controllers/login.php @@ -0,0 +1,81 @@ +<?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 Login_Controller extends Controller { + + public function ajax() { + $view = new View("login_ajax.html"); + $view->form = auth::get_login_form("login/auth_ajax"); + print $view; + } + + public function auth_ajax() { + access::verify_csrf(); + + list ($valid, $form) = $this->_auth("login/auth_ajax"); + if ($valid) { + print json_encode( + array("result" => "success")); + } else { + print json_encode( + array("result" => "error", + "form" => $form->__toString())); + } + } + + public function html() { + print auth::get_login_form("login/auth_html"); + } + + public function auth_html() { + access::verify_csrf(); + + list ($valid, $form) = $this->_auth("login/auth_html"); + if ($valid) { + url::redirect(item::root()->abs_url()); + } else { + print $form; + } + } + + private function _auth($url) { + $form = auth::get_login_form($url); + $valid = $form->validate(); + if ($valid) { + $user = identity::lookup_user_by_name($form->login->inputs["name"]->value); + if (empty($user) || !identity::is_correct_password($user, $form->login->password->value)) { + log::warning( + "user", + t("Failed login for %name", + array("name" => $form->login->inputs["name"]->value))); + $form->login->inputs["name"]->add_error("invalid_login", 1); + $valid = false; + } + } + + if ($valid) { + auth::login($user); + } + + // Either way, regenerate the session id to avoid session trapping + Session::instance()->regenerate(); + + return array($valid, $form); + } +}
\ No newline at end of file diff --git a/modules/gallery/controllers/logout.php b/modules/gallery/controllers/logout.php new file mode 100644 index 00000000..2b93655d --- /dev/null +++ b/modules/gallery/controllers/logout.php @@ -0,0 +1,33 @@ +<?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 Logout_Controller extends Controller { + public function index() { + auth::logout(); + if ($continue_url = $this->input->get("continue")) { + $item = url::get_item_from_uri($continue_url); + if (access::can("view", $item)) { + // Don't use url::redirect() because it'll call url::site() and munge the continue url. + header("Location: $continue_url"); + } else { + url::redirect(item::root()->abs_url()); + } + } + } +}
\ No newline at end of file diff --git a/modules/gallery/controllers/movies.php b/modules/gallery/controllers/movies.php index 04e15315..5e78376b 100644 --- a/modules/gallery/controllers/movies.php +++ b/modules/gallery/controllers/movies.php @@ -22,42 +22,33 @@ class Movies_Controller extends Items_Controller { /** * @see REST_Controller::_show($resource) */ - public function _show($photo) { - access::required("view", $photo); + public function _show($movie) { + access::required("view", $movie); - // We sort by id ascending so for now, find sibling info by doing id based queries. - $next_item = ORM::factory("item") - ->viewable() - ->where("parent_id", $photo->parent_id) - ->where("id >", $photo->id) - ->orderby("id", "ASC") - ->find(); - $previous_item = ORM::factory("item") - ->viewable() - ->where("parent_id", $photo->parent_id) - ->where("id <", $photo->id) - ->orderby("id", "DESC") - ->find(); - $position = ORM::factory("item") - ->viewable() - ->where("parent_id", $photo->parent_id) - ->where("id <=", $photo->id) - ->count_all(); + $where = array("type != " => "album"); + $position = $movie->parent()->get_position($movie, $where); + if ($position > 1) { + list ($previous_item, $ignore, $next_item) = + $movie->parent()->children(3, $position - 2, $where); + } else { + $previous_item = null; + list ($next_item) = $movie->parent()->viewable()->children(1, $position, $where); + } $template = new Theme_View("page.html", "movie"); - $template->set_global("item", $photo); + $template->set_global("item", $movie); $template->set_global("children", array()); - $template->set_global("children_count", $photo->children_count()); - $template->set_global("parents", $photo->parents()); - $template->set_global("next_item", $next_item->loaded ? $next_item : null); - $template->set_global("previous_item", $previous_item->loaded ? $previous_item : null); - $template->set_global("sibling_count", $photo->parent()->children_count()); + $template->set_global("children_count", 0); + $template->set_global("parents", $movie->parents()); + $template->set_global("next_item", $next_item); + $template->set_global("previous_item", $previous_item); + $template->set_global("sibling_count", $movie->parent()->viewable()->children_count($where)); $template->set_global("position", $position); $template->content = new View("movie.html"); - $photo->view_count++; - $photo->save(); + $movie->view_count++; + $movie->save(); print $template; } @@ -65,21 +56,32 @@ class Movies_Controller extends Items_Controller { /** * @see REST_Controller::_update($resource) */ - public function _update($photo) { + public function _update($movie) { access::verify_csrf(); - access::required("view", $photo); - access::required("edit", $photo); + access::required("view", $movie); + access::required("edit", $movie); + + $form = movie::get_edit_form($movie); + $valid = $form->validate(); + + if ($valid) { + $new_ext = pathinfo($form->edit_item->filename->value, PATHINFO_EXTENSION); + $old_ext = pathinfo($movie->name, PATHINFO_EXTENSION); + if (strcasecmp($new_ext, $old_ext)) { + $form->edit_item->filename->add_error("illegal_extension", 1); + $valid = false; + } + } - $form = photo::get_edit_form($photo); - if ($valid = $form->validate()) { - if ($form->edit_item->filename->value != $photo->name || - $form->edit_item->slug->value != $photo->slug) { + if ($valid) { + if ($form->edit_item->filename->value != $movie->name || + $form->edit_item->slug->value != $movie->slug) { // Make sure that there's not a name or slug conflict if ($row = Database::instance() ->select(array("name", "slug")) ->from("items") - ->where("parent_id", $photo->parent_id) - ->where("id <>", $photo->id) + ->where("parent_id", $movie->parent_id) + ->where("id <>", $movie->id) ->open_paren() ->where("name", $form->edit_item->filename->value) ->orwhere("slug", $form->edit_item->slug->value) @@ -98,16 +100,16 @@ class Movies_Controller extends Items_Controller { } if ($valid) { - $photo->title = $form->edit_item->title->value; - $photo->description = $form->edit_item->description->value; - $photo->slug = $form->edit_item->slug->value; - $photo->rename($form->edit_item->filename->value); - $photo->save(); - module::event("item_edit_form_completed", $photo, $form); + $movie->title = $form->edit_item->title->value; + $movie->description = $form->edit_item->description->value; + $movie->slug = $form->edit_item->slug->value; + $movie->rename($form->edit_item->filename->value); + $movie->save(); + module::event("item_edit_form_completed", $movie, $form); - log::success("content", "Updated movie", "<a href=\"{$photo->url()}\">view</a>"); + log::success("content", "Updated movie", "<a href=\"{$movie->url()}\">view</a>"); message::success( - t("Saved movie %movie_title", array("movie_title" => $photo->title))); + t("Saved movie %movie_title", array("movie_title" => $movie->title))); print json_encode( array("result" => "success")); @@ -121,9 +123,9 @@ class Movies_Controller extends Items_Controller { /** * @see REST_Controller::_form_edit($resource) */ - public function _form_edit($photo) { - access::required("view", $photo); - access::required("edit", $photo); - print photo::get_edit_form($photo); + public function _form_edit($movie) { + access::required("view", $movie); + access::required("edit", $movie); + print movie::get_edit_form($movie); } } diff --git a/modules/gallery/controllers/packager.php b/modules/gallery/controllers/packager.php index ae87d74b..82c3c938 100644 --- a/modules/gallery/controllers/packager.php +++ b/modules/gallery/controllers/packager.php @@ -62,6 +62,7 @@ class Packager_Controller extends Controller { srand(0); gallery_installer::install(true); + module::load_modules(); foreach (array("user", "comment", "organize", "info", "rss", @@ -75,18 +76,18 @@ class Packager_Controller extends Controller { // We now have a clean install with just the packages that we want. Make sure that the // database is clean too. $i = 1; - foreach (array("blocks_dashboard_sidebar", "blocks_dashboard_center") as $key) { + foreach (array("dashboard_sidebar", "dashboard_center", "site_sidebar") as $key) { $blocks = array(); - foreach (unserialize(module::get_var("gallery", $key)) as $rnd => $value) { + foreach (unserialize(module::get_var("gallery", "blocks_{$key}")) as $rnd => $value) { $blocks[++$i] = $value; } - module::set_var("gallery", $key, serialize($blocks)); + module::set_var("gallery", "blocks_{$key}", serialize($blocks)); } $db = Database::instance(); $db->query("TRUNCATE {sessions}"); $db->query("TRUNCATE {logs}"); - $db->query("DELETE FROM {vars} WHERE `module_name` = 'core' AND `name` = '_cache'"); + $db->query("DELETE FROM {vars} WHERE `module_name` = 'gallery' AND `name` = '_cache'"); $db->update("users", array("password" => ""), array("id" => 1)); $db->update("users", array("password" => ""), array("id" => 2)); diff --git a/modules/gallery/controllers/permissions.php b/modules/gallery/controllers/permissions.php index 8d75862e..99943fbb 100644 --- a/modules/gallery/controllers/permissions.php +++ b/modules/gallery/controllers/permissions.php @@ -51,13 +51,13 @@ class Permissions_Controller extends Controller { function change($command, $group_id, $perm_id, $item_id) { access::verify_csrf(); - $group = ORM::factory("group", $group_id); + $group = identity::lookup_group($group_id); $perm = ORM::factory("permission", $perm_id); $item = ORM::factory("item", $item_id); access::required("view", $item); access::required("edit", $item); - if ($group->loaded && $perm->loaded && $item->loaded) { + if (!empty($group) && $perm->loaded && $item->loaded) { switch($command) { case "allow": access::allow($group, $perm->name, $item); @@ -74,7 +74,7 @@ class Permissions_Controller extends Controller { // If the active user just took away their own edit permissions, give it back. if ($perm->name == "edit") { - if (!access::user_can(user::active(), "edit", $item)) { + if (!access::user_can(identity::active_user(), "edit", $item)) { access::allow($group, $perm->name, $item); } } @@ -84,7 +84,7 @@ class Permissions_Controller extends Controller { private function _get_form($item) { $view = new View("permissions_form.html"); $view->item = $item; - $view->groups = ORM::factory("group")->find_all(); + $view->groups = identity::groups(); $view->permissions = ORM::factory("permission")->find_all(); return $view; } diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php index 79ad674a..b9adfd90 100644 --- a/modules/gallery/controllers/photos.php +++ b/modules/gallery/controllers/photos.php @@ -25,23 +25,24 @@ class Photos_Controller extends Items_Controller { public function _show($photo) { access::required("view", $photo); - $position = $photo->parent()->get_position($photo->id); + $where = array("type != " => "album"); + $position = $photo->parent()->get_position($photo, $where); if ($position > 1) { list ($previous_item, $ignore, $next_item) = - $photo->parent()->children(3, $position - 2); + $photo->parent()->children(3, $position - 2, $where); } else { $previous_item = null; - list ($next_item) = $photo->parent()->children(1, $position); + list ($next_item) = $photo->parent()->viewable()->children(1, $position, $where); } $template = new Theme_View("page.html", "photo"); $template->set_global("item", $photo); $template->set_global("children", array()); - $template->set_global("children_count", $photo->children_count()); + $template->set_global("children_count", 0); $template->set_global("parents", $photo->parents()); $template->set_global("next_item", $next_item); $template->set_global("previous_item", $previous_item); - $template->set_global("sibling_count", $photo->parent()->children_count()); + $template->set_global("sibling_count", $photo->parent()->viewable()->children_count($where)); $template->set_global("position", $position); $template->content = new View("photo.html"); @@ -63,7 +64,17 @@ class Photos_Controller extends Items_Controller { $form = photo::get_edit_form($photo); $valid = $form->validate(); - if ($valid = $form->validate()) { + + if ($valid) { + $new_ext = pathinfo($form->edit_item->filename->value, PATHINFO_EXTENSION); + $old_ext = pathinfo($photo->name, PATHINFO_EXTENSION); + if (strcasecmp($new_ext, $old_ext)) { + $form->edit_item->filename->add_error("illegal_extension", 1); + $valid = false; + } + } + + if ($valid) { if ($form->edit_item->filename->value != $photo->name || $form->edit_item->slug->value != $photo->slug) { // Make sure that there's not a name or slug conflict @@ -90,6 +101,8 @@ class Photos_Controller extends Items_Controller { } if ($valid) { + $watching_album = $photo->url() != ($location = parse_url(request::referrer(), PHP_URL_PATH)); + $photo->title = $form->edit_item->title->value; $photo->description = $form->edit_item->description->value; $photo->slug = $form->edit_item->slug->value; @@ -103,7 +116,8 @@ class Photos_Controller extends Items_Controller { array("photo_title" => html::purify($photo->title)))); print json_encode( - array("result" => "success")); + array("result" => "success", + "location" => $watching_album ? $location : $photo->url())); } else { print json_encode( array("result" => "error", diff --git a/modules/gallery/controllers/quick.php b/modules/gallery/controllers/quick.php index 2ac54754..a1e7dcc3 100644 --- a/modules/gallery/controllers/quick.php +++ b/modules/gallery/controllers/quick.php @@ -36,7 +36,8 @@ class Quick_Controller extends Controller { } if ($degrees) { - graphics::rotate($item->file_path(), $item->file_path(), array("degrees" => $degrees)); + gallery_graphics::rotate($item->file_path(), $item->file_path(), + array("degrees" => $degrees)); list($item->width, $item->height) = getimagesize($item->file_path()); $item->resize_dirty= 1; diff --git a/modules/gallery/controllers/simple_uploader.php b/modules/gallery/controllers/simple_uploader.php index bc508319..d43d2f9d 100644 --- a/modules/gallery/controllers/simple_uploader.php +++ b/modules/gallery/controllers/simple_uploader.php @@ -79,7 +79,7 @@ class Simple_Uploader_Controller extends Controller { print "FILEID: $item->id"; } else { header("HTTP/1.1 400 Bad Request"); - print "ERROR: Invalid Upload"; + print "ERROR: " . t("Invalid Upload"); } } diff --git a/modules/gallery/controllers/upgrader.php b/modules/gallery/controllers/upgrader.php index 0f6cbc2c..48769bce 100644 --- a/modules/gallery/controllers/upgrader.php +++ b/modules/gallery/controllers/upgrader.php @@ -40,10 +40,10 @@ class Upgrader_Controller extends Controller { } $view = new View("upgrader.html"); - $view->can_upgrade = user::active()->admin || $session->get("can_upgrade"); + $view->can_upgrade = identity::active_user()->admin || $session->get("can_upgrade"); $view->upgrade_token = $upgrade_token; $view->available = module::available(); - $view->done = ($available_upgrades == 0); + $view->done = $available_upgrades == 0; print $view; } @@ -52,13 +52,17 @@ class Upgrader_Controller extends Controller { // @todo this may screw up some module installers, but we don't have a better answer at // this time. $_SERVER["HTTP_HOST"] = "example.com"; - } else if (!user::active()->admin && !Session::instance()->get("can_upgrade", false)) { + } else if (!identity::active_user()->admin && !Session::instance()->get("can_upgrade", false)) { access::forbidden(); } - // Upgrade gallery and user first - module::upgrade("gallery"); - module::upgrade("user"); + $available = module::available(); + // Upgrade gallery first + $gallery = $available["gallery"]; + if ($gallery->code_version != $gallery->version) { + module::upgrade("gallery"); + module::activate("gallery"); + } // Then upgrade the rest foreach (module::available() as $id => $module) { diff --git a/modules/gallery/controllers/welcome_message.php b/modules/gallery/controllers/welcome_message.php index 8fd1e0a0..af0d6997 100644 --- a/modules/gallery/controllers/welcome_message.php +++ b/modules/gallery/controllers/welcome_message.php @@ -19,12 +19,12 @@ */ class Welcome_Message_Controller extends Controller { public function index() { - if (!user::active()->admin) { + if (!identity::active_user()->admin) { url::redirect(item::root()->abs_url()); } $v = new View("welcome_message.html"); - $v->user = user::active(); + $v->user = identity::active_user(); print $v; } } diff --git a/modules/gallery/css/debug.css b/modules/gallery/css/debug.css index fe5665ad..6808da09 100644 --- a/modules/gallery/css/debug.css +++ b/modules/gallery/css/debug.css @@ -1,4 +1,4 @@ -.gAnnotatedThemeBlock { +.g-annotated-theme-block { border: 1px solid #C00; clear: both; margin: 1em; @@ -6,15 +6,15 @@ position: relative; } -.gAnnotatedThemeBlock_album_top { +.g-annotated-theme-block_album_top { float: right; } -.gAnnotatedThemeBlock_header_bottom { +.g-annotated-theme-block_header_bottom { float: right; } -.gAnnotatedThemeBlock div.title { +.g-annotated-theme-block div.title { background: #C00; border: 1px solid black; color: white; diff --git a/modules/gallery/css/gallery.css b/modules/gallery/css/gallery.css new file mode 100644 index 00000000..113f0e09 --- /dev/null +++ b/modules/gallery/css/gallery.css @@ -0,0 +1,89 @@ +/** + * Gallery 3 core module styles + * + * Sheet organization: + * 1) End-user + * 2) Admin + */ + +/** ******************************************************************* + * 1) End-user + **********************************************************************/ + +/* Permissions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#g-edit-permissions-form { + clear: both; +} + +#g-edit-permissions-form td { + background-image: none; +} + +#g-edit-permissions-form fieldset { + border: 1px solid #ccc; +} + +#g-permissions .g-denied, +#g-permissions .g-allowed { + text-align: center; + vertical-align: middle; +} + +#g-permissions .g-denied { + background-color: #fcc; +} + +#g-permissions .g-allowed { + background-color: #cfc; +} + +/* Move items ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#g-move ul { + padding-left: 1em; +} + +#g-move .selected { + background: #999; +} + +/* In-place edit ~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#g-in-place-edit-form ul { + margin: 0; +} + +/** ******************************************************************* + * 2) Admin + **********************************************************************/ + +.g-task-log { + border: 1px solid #000; + height: 400px; + margin: .6em 0; + overflow: auto; + padding: .4em +} + +#g-languages-form table { + width: 40%; + margin: 0 3em 1em 0; +} + +#g-languages-form input { + clear: both; +} + +#g-translations ol { + margin: 0 0 1em 2em; +} +#g-translations ol li { + list-style-type: decimal; + line-height: 150%; +} + +#g-translations .g-button { + padding: .5em; + margin-bottom: 1em; +} diff --git a/modules/gallery/css/l10n_client.css b/modules/gallery/css/l10n_client.css index 9c1b12d0..542da8e6 100644 --- a/modules/gallery/css/l10n_client.css +++ b/modules/gallery/css/l10n_client.css @@ -1,6 +1,8 @@ -// TODO(andy_st): Add original copyright notice from Drupal l10_client. -// TODO(andy_st): Add G3 copyright notice. -// TODO(andy_st): clean up formatting to match our other CSS files. +/** + * TODO(andy_st): Add original copyright notice from Drupal l10_client. + * TODO(andy_st): Add G3 copyright notice. + * TODO(andy_st): clean up formatting to match our other CSS files. + */ /* $Id: l10n_client.css,v 1.6 2008/09/09 10:48:20 goba Exp $ */ @@ -50,7 +52,7 @@ font-size: 1em; padding: .5em; } -#l10n-client-toggler #gMinimizeL10n { +#l10n-client-toggler #g-minimize-l10n { border-right: 1px solid #ffffff; } @@ -126,31 +128,31 @@ #l10n-client .string-list li.active { font-weight:bold;} -#l10n-client #gL10nSearchForm { +#l10n-client #g-l10n-search-form { background:#eee; text-align:center; height:2em; line-height:2em; margin:0em; padding:.5em .5em; } -#l10n-client #gL10nSearchForm .form-item, -#l10n-client #gL10nSearchForm input.form-text, -#l10n-client #gL10nSearchForm #search-filter-go, -#l10n-client #gL10nSearchForm #search-filter-clear { +#l10n-client #g-l10n-search-form .form-item, +#l10n-client #g-l10n-search-form input.form-text, +#l10n-client #g-l10n-search-form #search-filter-go, +#l10n-client #g-l10n-search-form #search-filter-clear { display:inline; vertical-align:middle; } -#l10n-client #gL10nSearchForm .form-item { +#l10n-client #g-l10n-search-form .form-item { margin:0em; padding:0em; } -#l10n-client #gL10nSearchForm input.form-text { +#l10n-client #g-l10n-search-form input.form-text { width:80%; } -#l10n-client #gL10nSearchForm #search-filter-clear { +#l10n-client #g-l10n-search-form #search-filter-clear { width:10%; margin:0em; } @@ -178,7 +180,7 @@ overflow:hidden; width:49%; float:right;} -#gL10nClientSaveForm { +#g-l10n-client-save-form { padding:0em;} #l10n-client form ul, diff --git a/modules/gallery/css/upgrader.css b/modules/gallery/css/upgrader.css index 7c377817..73da0ff4 100644 --- a/modules/gallery/css/upgrader.css +++ b/modules/gallery/css/upgrader.css @@ -1,6 +1,6 @@ body { background: #eee; - font-family: Trebuchet MS; + font-family: 'Trebuchet MS'; font-size: 1.1em; } @@ -37,7 +37,7 @@ td { } tr.current td { - color: #999; + opacity: 0.5; font-style: italic; } @@ -87,11 +87,13 @@ div.button a { text-decoration: none; } -div.button:hover { +div.button-active:hover { background: #ccc; } -div#confirmation { +div#dialog { + width: 340px; + height: 200px; position: absolute; background: blue; z-index: 1000; @@ -99,21 +101,23 @@ div#confirmation { text-align: center; } -div#confirmation a.close { +div#dialog a.close { float: right; padding: 10px; text-decoration: none; } -div#confirmation div { +div#dialog div { + width: 292px; + height: 152px; margin: 2px; padding: 20px; border: 2px solid #999; background: #eee; } -.gray_on_done { - opacity: <?= $done ? "0.5" : "1" ?>; +.muted { + opacity: 0.5; } pre { diff --git a/modules/gallery/helpers/access.php b/modules/gallery/helpers/access.php index 949aea84..c1c1f9d1 100644 --- a/modules/gallery/helpers/access.php +++ b/modules/gallery/helpers/access.php @@ -79,7 +79,7 @@ class access_Core { * @return boolean */ static function can($perm_name, $item) { - return self::user_can(user::active(), $perm_name, $item); + return self::user_can(identity::active_user(), $perm_name, $item); } /** @@ -197,8 +197,8 @@ class access_Core { * @param Item_Model $item * @param boolean $value */ - private static function _set(Group_Model $group, $perm_name, $album, $value) { - if (get_class($group) != "Group_Model") { + private static function _set(Group_Definition $group, $perm_name, $album, $value) { + if (!($group instanceof Group_Definition)) { throw new Exception("@todo PERMISSIONS_ONLY_WORK_ON_GROUPS"); } if (!$album->loaded) { @@ -419,10 +419,10 @@ class access_Core { * @return ORM_Iterator */ private static function _get_all_groups() { - // When we build the gallery package, it's possible that the user module is not installed yet. + // When we build the gallery package, it's possible that there is no identity provider installed yet. // This is ok at packaging time, so work around it. - if (module::is_active("user")) { - return ORM::factory("group")->find_all(); + if (module::is_active(module::get_var("gallery", "identity_provider", "user"))) { + return identity::groups(); } else { return array(); } diff --git a/modules/gallery/helpers/album.php b/modules/gallery/helpers/album.php index 9cd746d7..72a79a75 100644 --- a/modules/gallery/helpers/album.php +++ b/modules/gallery/helpers/album.php @@ -92,7 +92,7 @@ class album_Core { } static function get_add_form($parent) { - $form = new Forge("albums/{$parent->id}", "", "post", array("id" => "gAddAlbumForm")); + $form = new Forge("albums/{$parent->id}", "", "post", array("id" => "g-add-album-form")); $group = $form->group("add_album") ->label(t("Add an album to %album_title", array("album_title" => $parent->title))); $group->input("title")->label(t("Title")); @@ -114,7 +114,7 @@ class album_Core { } static function get_edit_form($parent) { - $form = new Forge("albums/{$parent->id}", "", "post", array("id" => "gEditAlbumForm")); + $form = new Forge("albums/{$parent->id}", "", "post", array("id" => "g-edit-album-form")); $form->hidden("_method")->value("put"); $group = $form->group("edit_item")->label(t("Edit Album")); @@ -123,14 +123,15 @@ class album_Core { if ($parent->id != 1) { $group->input("dirname")->label(t("Directory Name"))->value($parent->name) ->rules("required") - ->error_messages("name_conflict", t("There is already a photo or album with this name")) + ->error_messages( + "name_conflict", t("There is already a movie, photo or album with this name")) ->callback("item::validate_no_slashes") ->error_messages("no_slashes", t("The directory name can't contain a \"/\"")) ->callback("item::validate_no_trailing_period") ->error_messages("no_trailing_period", t("The directory name can't end in \".\"")); $group->input("slug")->label(t("Internet Address"))->value($parent->slug) ->error_messages( - "slug_conflict", t("There is already a photo or album with this internet address")) + "slug_conflict", t("There is already a movie, photo or album with this internet address")) ->callback("item::validate_url_safe") ->error_messages( "not_url_safe", @@ -140,14 +141,14 @@ class album_Core { $group->hidden("slug")->value($parent->slug); } - $sort_order = $group->group("sort_order", array("id" => "gAlbumSortOrder")) + $sort_order = $group->group("sort_order", array("id" => "g-album-sort-order")) ->label(t("Sort Order")); - $sort_order->dropdown("column", array("id" => "gAlbumSortColumn")) + $sort_order->dropdown("column", array("id" => "g-album-sort-column")) ->label(t("Sort by")) ->options(album::get_sort_order_options()) ->selected($parent->sort_column); - $sort_order->dropdown("direction", array("id" => "gAlbumSortDirection")) + $sort_order->dropdown("direction", array("id" => "g-album-sort-direction")) ->label(t("Order")) ->options(array("ASC" => t("Ascending"), "DESC" => t("Descending"))) diff --git a/modules/gallery/helpers/auth.php b/modules/gallery/helpers/auth.php new file mode 100644 index 00000000..9c69cecd --- /dev/null +++ b/modules/gallery/helpers/auth.php @@ -0,0 +1,56 @@ +<?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 auth_Core { + static function get_login_form($url) { + $form = new Forge($url, "", "post", array("id" => "g-login-form")); + $form->set_attr('class', "g-narrow"); + $group = $form->group("login")->label(t("Login")); + $group->input("name")->label(t("Username"))->id("g-username")->class(null); + $group->password("password")->label(t("Password"))->id("g-password")->class(null); + $group->inputs["name"]->error_messages("invalid_login", t("Invalid name or password")); + $group->submit("")->value(t("Login")); + return $form; + } + + static function login($user) { + if (identity::is_writable()) { + $user->login_count += 1; + $user->last_login = time(); + $user->save(); + } + identity::set_active_user($user); + log::info("user", t("User %name logged in", array("name" => $user->name))); + module::event("user_login", $user); + } + + static function logout() { + $user = identity::active_user(); + if (!$user->guest) { + try { + Session::instance()->destroy(); + } catch (Exception $e) { + Kohana::log("error", $e); + } + module::event("user_logout", $user); + } + log::info("user", t("User %name logged out", array("name" => $user->name)), + html::anchor("user/$user->id", html::clean($user->name))); + } +}
\ No newline at end of file diff --git a/modules/gallery/helpers/block_manager.php b/modules/gallery/helpers/block_manager.php index 20b641d4..b003f1d8 100644 --- a/modules/gallery/helpers/block_manager.php +++ b/modules/gallery/helpers/block_manager.php @@ -29,22 +29,68 @@ class block_manager_Core { static function add($location, $module_name, $block_id) { $blocks = self::get_active($location); $blocks[rand()] = array($module_name, $block_id); + self::set_active($location, $blocks); } + static function activate_blocks($module_name) { + $block_class = "{$module_name}_block"; + if (method_exists($block_class, "get_site_list")) { + $blocks = call_user_func(array($block_class, "get_site_list")); + foreach (array_keys($blocks) as $block_id) { + self::add("site_sidebar", $module_name, $block_id); + } + } + } + static function remove($location, $block_id) { $blocks = self::get_active($location); unset($blocks[$block_id]); self::set_active($location, $blocks); } - static function get_available() { + static function remove_blocks_for_module($location, $module_name) { + $blocks = self::get_active($location); + foreach ($blocks as $key => $block) { + if ($block[0] == $module_name) { + unset($blocks[$key]); + } + } + self::set_active($location, $blocks); + } + + static function deactivate_blocks($module_name) { + $block_class = "{$module_name}_block"; + if (method_exists($block_class, "get_site_list")) { + $blocks = call_user_func(array($block_class, "get_site_list")); + foreach (array_keys($blocks) as $block_id) { + self::remove_blocks_for_module("site_sidebar", $module_name); + } + } + + if (method_exists($block_class, "get_admin_list")) { + $blocks = call_user_func(array($block_class, "get_admin_list")); + foreach (array("dashboard_sidebar", "dashboard_center") as $location) { + self::remove_blocks_for_module($location, $module_name); + } + } + } + + static function get_available_admin_blocks() { + return self::_get_blocks("get_admin_list"); + } + + static function get_available_site_blocks() { + return self::_get_blocks("get_site_list"); + } + + private static function _get_blocks($function) { $blocks = array(); foreach (module::active() as $module) { $class_name = "{$module->name}_block"; - if (method_exists($class_name, "get_list")) { - foreach (call_user_func(array($class_name, "get_list")) as $id => $title) { + if (method_exists($class_name, $function)) { + foreach (call_user_func(array($class_name, $function)) as $id => $title) { $blocks["{$module->name}:$id"] = $title; } } @@ -52,14 +98,16 @@ class block_manager_Core { return $blocks; } - static function get_html($location) { + static function get_html($location, $theme=null) { $active = self::get_active($location); $result = ""; foreach ($active as $id => $desc) { if (method_exists("$desc[0]_block", "get")) { - $block = call_user_func(array("$desc[0]_block", "get"), $desc[1]); - $block->id = $id; - $result .= $block; + $block = call_user_func(array("$desc[0]_block", "get"), $desc[1], $theme); + if (!empty($block)) { + $block->id = $id; + $result .= $block; + } } } return $result; diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php index 80ae65bd..84f8a7fb 100644 --- a/modules/gallery/helpers/gallery.php +++ b/modules/gallery/helpers/gallery.php @@ -27,7 +27,7 @@ class gallery_Core { static function maintenance_mode() { $maintenance_mode = Kohana::config("core.maintenance_mode", false, false); - if (Router::$controller != "login" && !empty($maintenance_mode) && !user::active()->admin) { + if (Router::$controller != "login" && !empty($maintenance_mode) && !identity::active_user()->admin) { Router::$controller = "maintenance"; Router::$controller_path = MODPATH . "gallery/controllers/maintenance.php"; Router::$method = "index"; @@ -79,238 +79,39 @@ class gallery_Core { return date(module::get_var("gallery", "time_format", "H:i:s"), $timestamp); } - static function site_menu($menu, $theme) { - if ($theme->page_type != "login") { - $menu->append(Menu::factory("link") - ->id("home") - ->label(t("Home")) - ->url(item::root()->url())); - - $item = $theme->item(); - - $can_edit = $item && access::can("edit", $item); - $can_add = $item && access::can("add", $item); - - if ($can_add) { - $menu->append($add_menu = Menu::factory("submenu") - ->id("add_menu") - ->label(t("Add"))); - $is_album_writable = - is_writable($item->is_album() ? $item->file_path() : $item->parent()->file_path()); - if ($is_album_writable) { - $add_menu->append(Menu::factory("dialog") - ->id("add_photos_item") - ->label(t("Add photos")) - ->url(url::site("simple_uploader/app/$item->id"))); - if ($item->is_album()) { - $add_menu->append(Menu::factory("dialog") - ->id("add_album_item") - ->label(t("Add an album")) - ->url(url::site("form/add/albums/$item->id?type=album"))); - } - } else { - message::warning(t("The album '%album_name' is not writable.", - array("album_name" => $item->title))); - } - } - - $menu->append($options_menu = Menu::factory("submenu") - ->id("options_menu") - ->label(t("Photo options"))); - if ($item && ($can_edit || $can_add)) { - if ($can_edit) { - $options_menu->append(Menu::factory("dialog") - ->id("edit_item") - ->label($item->is_album() ? t("Edit album") : t("Edit photo")) - ->url(url::site("form/edit/{$item->type}s/$item->id"))); - } - - if ($item->is_album()) { - $options_menu->label(t("Album options")); - if ($can_edit) { - $options_menu->append(Menu::factory("dialog") - ->id("edit_permissions") - ->label(t("Edit permissions")) - ->url(url::site("permissions/browse/$item->id"))); - } - } - } - - if (user::active()->admin) { - $menu->append($admin_menu = Menu::factory("submenu") - ->id("admin_menu") - ->label(t("Admin"))); - gallery::admin_menu($admin_menu, $theme); - module::event("admin_menu", $admin_menu, $theme); + /** + * Provide a wrapper function for Kohana::find_file that first strips the extension and + * then calls the Kohana::find_file and supplies the extension as the type. + * @param string directory to search in + * @param string filename to look for + * @param boolean file required (optional: default false) + * @return array if the extension is config, i18n or l10n + * @return string if the file is found (relative to the DOCROOT) + * @return false if the file is not found + */ + static function find_file($directory, $file, $required=false) { + $file_name = substr($file, 0, -strlen($ext = strrchr($file, '.'))); + $file_name = Kohana::find_file($directory, $file_name, $required, substr($ext, 1)); + if (!$file_name) { + if (file_exists(DOCROOT . "lib/$directory/$file")) { + return "lib/$directory/$file"; + } else if (file_exists(DOCROOT . "lib/$file")) { + return "lib/$file"; } - - module::event("site_menu", $menu, $theme); } - } - - static function admin_menu($menu, $theme) { - $menu - ->append(Menu::factory("link") - ->id("dashboard") - ->label(t("Dashboard")) - ->url(url::site("admin"))) - ->append(Menu::factory("submenu") - ->id("settings_menu") - ->label(t("Settings")) - ->append(Menu::factory("link") - ->id("graphics_toolkits") - ->label(t("Graphics")) - ->url(url::site("admin/graphics"))) - ->append(Menu::factory("link") - ->id("languages") - ->label(t("Languages")) - ->url(url::site("admin/languages"))) - ->append(Menu::factory("link") - ->id("advanced") - ->label(t("Advanced")) - ->url(url::site("admin/advanced_settings")))) - ->append(Menu::factory("link") - ->id("modules") - ->label(t("Modules")) - ->url(url::site("admin/modules"))) - ->append(Menu::factory("submenu") - ->id("content_menu") - ->label(t("Content"))) - ->append(Menu::factory("submenu") - ->id("appearance_menu") - ->label(t("Appearance")) - ->append(Menu::factory("link") - ->id("themes") - ->label(t("Theme Choice")) - ->url(url::site("admin/themes"))) - ->append(Menu::factory("link") - ->id("theme_options") - ->label(t("Theme Options")) - ->url(url::site("admin/theme_options")))) - ->append(Menu::factory("submenu") - ->id("statistics_menu") - ->label(t("Statistics"))) - ->append(Menu::factory("link") - ->id("maintenance") - ->label(t("Maintenance")) - ->url(url::site("admin/maintenance"))); - return $menu; - } - static function context_menu($menu, $theme, $item, $thumb_css_selector) { - $menu->append($options_menu = Menu::factory("submenu") - ->id("options_menu") - ->label(t("Options")) - ->css_class("ui-icon-carat-1-n")); - - if (access::can("edit", $item)) { - $page_type = $theme->page_type(); - switch ($item->type) { - case "movie": - $edit_title = t("Edit this movie"); - $delete_title = t("Delete this movie"); - break; - - case "album": - $edit_title = t("Edit this album"); - $delete_title = t("Delete this album"); - break; - - default: - $edit_title = t("Edit this photo"); - $delete_title = t("Delete this photo"); - break; - } - $cover_title = t("Choose as the album cover"); - $move_title = t("Move to another album"); - - $csrf = access::csrf_token(); - - $options_menu->append(Menu::factory("dialog") - ->id("edit") - ->label($edit_title) - ->css_class("ui-icon-pencil") - ->url(url::site("quick/form_edit/$item->id?page_type=$page_type"))); - - - if ($item->is_photo() && graphics::can("rotate")) { - $options_menu - ->append( - Menu::factory("ajax_link") - ->id("rotate_ccw") - ->label(t("Rotate 90° counter clockwise")) - ->css_class("ui-icon-rotate-ccw") - ->ajax_handler("function(data) { " . - "\$.gallery_replace_image(data, \$('$thumb_css_selector')) }") - ->url(url::site("quick/rotate/$item->id/ccw?csrf=$csrf&page_type=$page_type"))) - ->append( - Menu::factory("ajax_link") - ->id("rotate_cw") - ->label(t("Rotate 90° clockwise")) - ->css_class("ui-icon-rotate-cw") - ->ajax_handler("function(data) { " . - "\$.gallery_replace_image(data, \$('$thumb_css_selector')) }") - ->url(url::site("quick/rotate/$item->id/cw?csrf=$csrf&page_type=$page_type"))); - } - - // Don't move photos from the photo page; we don't yet have a good way of redirecting after - // move - if ($page_type == "album") { - $options_menu - ->append(Menu::factory("dialog") - ->id("move") - ->label($move_title) - ->css_class("ui-icon-folder-open") - ->url(url::site("move/browse/$item->id"))); - } - - $parent = $item->parent(); - if (access::can("edit", $parent)) { - // We can't make this item the highlight if it's an album with no album cover, or if it's - // already the album cover. - if (($item->type == "album" && empty($item->album_cover_item_id)) || - ($item->type == "album" && $parent->album_cover_item_id == $item->album_cover_item_id) || - $parent->album_cover_item_id == $item->id) { - $disabledState = " ui-state-disabled"; - } else { - $disabledState = " "; + if (is_string($file_name)) { + // make relative to DOCROOT + $parts = explode("/", $file_name); + foreach ($parts as $idx => $part) { + if (in_array($part, array("application", "modules", "themes", "lib"))) { + break; } - if ($item->parent()->id != 1) { - $options_menu - ->append(Menu::factory("ajax_link") - ->id("make_album_cover") - ->label($cover_title) - ->css_class("ui-icon-star") - ->ajax_handler("function(data) { window.location.reload() }") - ->url(url::site("quick/make_album_cover/$item->id?csrf=$csrf"))); - } - $options_menu - ->append(Menu::factory("dialog") - ->id("delete") - ->label($delete_title) - ->css_class("ui-icon-trash") - ->css_id("gQuickDelete") - ->url(url::site("quick/form_delete/$item->id?csrf=$csrf&page_type=$page_type"))); - } - - if ($item->is_album()) { - $options_menu - ->append(Menu::factory("dialog") - ->id("add_item") - ->label(t("Add a photo")) - ->css_class("ui-icon-plus") - ->url(url::site("simple_uploader/app/$item->id"))) - ->append(Menu::factory("dialog") - ->id("add_album") - ->label(t("Add an album")) - ->css_class("ui-icon-note") - ->url(url::site("form/add/albums/$item->id?type=album"))) - ->append(Menu::factory("dialog") - ->id("edit_permissions") - ->label(t("Edit permissions")) - ->css_class("ui-icon-key") - ->url(url::site("permissions/browse/$item->id"))); + unset($parts[$idx]); } + $file_name = implode("/", $parts); } + return $file_name; } + }
\ No newline at end of file diff --git a/modules/gallery/helpers/gallery_block.php b/modules/gallery/helpers/gallery_block.php index b7816954..b5c32ad2 100644 --- a/modules/gallery/helpers/gallery_block.php +++ b/modules/gallery/helpers/gallery_block.php @@ -18,44 +18,48 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class gallery_block_Core { - static function get_list() { + static function get_admin_list() { return array( "welcome" => t("Welcome to Gallery 3!"), - "photo_stream" => t("Photo Stream"), - "log_entries" => t("Log Entries"), - "stats" => t("Gallery Stats"), - "platform_info" => t("Platform Information"), - "project_news" => t("Gallery Project News")); + "photo_stream" => t("Photo stream"), + "log_entries" => t("Log entries"), + "stats" => t("Gallery stats"), + "platform_info" => t("Platform information"), + "project_news" => t("Gallery project news")); + } + + static function get_site_list() { + return array("language" => t("Language preference")); } static function get($block_id) { $block = new Block(); switch($block_id) { case "welcome": - $block->css_id = "gWelcome"; + $block->css_id = "g-welcome"; $block->title = t("Welcome to Gallery 3"); $block->content = new View("admin_block_welcome.html"); break; case "photo_stream": - $block->css_id = "gPhotoStream"; - $block->title = t("Photo Stream"); + $block->css_id = "g-photo-stream"; + $block->title = t("Photo stream"); $block->content = new View("admin_block_photo_stream.html"); $block->content->photos = ORM::factory("item")->where("type", "photo")->orderby("created", "DESC")->find_all(10); break; case "log_entries": - $block->css_id = "gLogEntries"; - $block->title = t("Log Entries"); + $block->css_id = "g-log-entries"; + $block->title = t("Log entries"); $block->content = new View("admin_block_log_entries.html"); $block->content->entries = ORM::factory("log") ->orderby(array("timestamp" => "DESC", "id" => "DESC"))->find_all(5); break; case "stats": - $block->css_id = "gStats"; - $block->title = t("Gallery Stats"); + $block->css_id = "g-stats"; + $block->title = t("Gallery stats"); $block->content = new View("admin_block_stats.html"); $block->content->album_count = ORM::factory("item")->where("type", "album")->where("id <>", 1)->count_all(); @@ -63,38 +67,57 @@ class gallery_block_Core { break; case "platform_info": - $block->css_id = "gPlatform"; - $block->title = t("Platform Information"); + $block->css_id = "g-platform"; + $block->title = t("Platform information"); $block->content = new View("admin_block_platform.html"); if (is_readable("/proc/loadavg")) { $block->content->load_average = - join(" ", array_slice(split(" ", array_shift(file("/proc/loadavg"))), 0, 3)); + join(" ", array_slice(explode(" ", array_shift(file("/proc/loadavg"))), 0, 3)); } else { $block->content->load_average = t("Unavailable"); } break; case "project_news": - $block->css_id = "gProjectNews"; - $block->title = t("Gallery Project News"); + $block->css_id = "g-project-news"; + $block->title = t("Gallery project news"); $block->content = new View("admin_block_news.html"); $block->content->feed = feed::parse("http://gallery.menalto.com/node/feed", 3); break; case "block_adder": - $block->css_id = "gBlockAdder"; - $block->title = t("Dashboard Content"); + $block->css_id = "g-block-adder"; + $block->title = t("Dashboard content"); $block->content = self::get_add_block_form(); - } + break; + case "language": + $locales = locales::installed(); + if (count($locales)) { + foreach ($locales as $locale => $display_name) { + $locales[$locale] = SafeString::of_safe_html($display_name); + } + $block = new Block(); + $block->css_id = "g-user-language-block"; + $block->title = t("Language preference"); + $block->content = new View("user_languages_block.html"); + $block->content->installed_locales = + array_merge(array("" => t("« none »")), $locales); + $block->content->selected = (string) locales::cookie_locale(); + } else { + $block = ""; + } + break; + } return $block; } static function get_add_block_form() { $form = new Forge("admin/dashboard/add_block", "", "post", - array("id" => "gAddDashboardBlockForm")); + array("id" => "g-add-dashboard-block-form")); $group = $form->group("add_block")->label(t("Add Block")); - $group->dropdown("id")->label(t("Available Blocks"))->options(block_manager::get_available()); + $group->dropdown("id")->label(t("Available Blocks")) + ->options(block_manager::get_available_admin_blocks()); $group->submit("center")->value(t("Add to center")); $group->submit("sidebar")->value(t("Add to sidebar")); return $form; diff --git a/modules/gallery/helpers/gallery_error.php b/modules/gallery/helpers/gallery_error.php new file mode 100644 index 00000000..551f8c63 --- /dev/null +++ b/modules/gallery/helpers/gallery_error.php @@ -0,0 +1,30 @@ +<?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 gallery_error_Core { + static function error_handler($severity, $message, $filename, $lineno) { + if (error_reporting() == 0) { + return; + } + + if (error_reporting() & $severity) { + throw new ErrorException($message, 0, $severity, $filename, $lineno); + } + } +}
\ No newline at end of file diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index 64f2a9ff..cd72d01e 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -19,6 +19,49 @@ */ class gallery_event_Core { + /** + * Initialization. + */ + static function gallery_ready() { + identity::load_user(); + theme::load_themes(); + locales::set_request_locale(); + } + + static function user_deleted($user) { + $admin = identity::admin_user(); + $db = Database::instance(); + $db->from("tasks") + ->set(array("owner_id" => $admin->id)) + ->where(array("owner_id" => $user->id)) + ->update(); + $db->from("items") + ->set(array("owner_id" => $admin->id)) + ->where(array("owner_id" => $user->id)) + ->update(); + $db->from("logs") + ->set(array("user_id" => $admin->id)) + ->where(array("user_id" => $user->id)) + ->update(); + } + + static function identity_provider_changed($old_provider, $new_provider) { + $admin = identity::admin_user(); + $db = Database::instance(); + $db->from("tasks") + ->set(array("owner_id" => $admin->id)) + ->where("1 = 1") + ->update(); + $db->from("items") + ->set(array("owner_id" => $admin->id)) + ->where("1 = 1") + ->update(); + $db->from("logs") + ->set(array("user_id" => $admin->id)) + ->where("1 = 1") + ->update(); + } + static function group_created($group) { access::add_group($group); } @@ -53,4 +96,287 @@ class gallery_event_Core { $data[] = $item->name; $data[] = $item->title; } + + static function user_menu($menu, $theme) { + if ($theme->page_type != "login") { + $user = identity::active_user(); + if ($user->guest) { + $menu->append(Menu::factory("dialog") + ->id("user_menu_login") + ->css_id("g-login-link") + ->url(url::site("login/ajax")) + ->label(t("Login"))); + } else { + $csrf = access::csrf_token(); + $menu->append(Menu::factory("dialog") + ->id("user_menu_edit_profile") + ->css_id("g-user-profile-link") + ->view("login_current_user.html") + ->url(url::site("form/edit/users/{$user->id}")) + ->label($user->display_name())); + $menu->append(Menu::factory("link") + ->id("user_menu_logout") + ->css_id("g-logout-link") + ->url(url::site("logout?csrf=$csrf&continue=" . + urlencode(url::current(true)))) + ->label(t("Logout"))); + } + } + } + + static function site_menu($menu, $theme) { + if ($theme->page_type != "login") { + $menu->append(Menu::factory("link") + ->id("home") + ->label(t("Home")) + ->url(item::root()->url())); + + + $item = $theme->item(); + + if (!empty($item)) { + $can_edit = $item && access::can("edit", $item); + $can_add = $item && access::can("add", $item); + + if ($can_add) { + $menu->append($add_menu = Menu::factory("submenu") + ->id("add_menu") + ->label(t("Add"))); + $is_album_writable = + is_writable($item->is_album() ? $item->file_path() : $item->parent()->file_path()); + if ($is_album_writable) { + $add_menu->append(Menu::factory("dialog") + ->id("add_photos_item") + ->label(t("Add photos")) + ->url(url::site("simple_uploader/app/$item->id"))); + if ($item->is_album()) { + $add_menu->append(Menu::factory("dialog") + ->id("add_album_item") + ->label(t("Add an album")) + ->url(url::site("form/add/albums/$item->id?type=album"))); + } + } else { + message::warning(t("The album '%album_name' is not writable.", + array("album_name" => $item->title))); + } + } + + switch ($item->type) { + case "album": + $option_text = t("Album options"); + $edit_text = t("Edit album"); + break; + case "movie": + $option_text = t("Movie options"); + $edit_text = t("Edit movie"); + break; + default: + $option_text = t("Photo options"); + $edit_text = t("Edit photo"); + } + + $menu->append($options_menu = Menu::factory("submenu") + ->id("options_menu") + ->label($option_text)); + if ($item && ($can_edit || $can_add)) { + if ($can_edit) { + $options_menu->append(Menu::factory("dialog") + ->id("edit_item") + ->label($edit_text) + ->url(url::site("form/edit/{$item->type}s/$item->id"))); + } + + if ($item->is_album()) { + if ($can_edit) { + $options_menu->append(Menu::factory("dialog") + ->id("edit_permissions") + ->label(t("Edit permissions")) + ->url(url::site("permissions/browse/$item->id"))); + } + } + } + } + + if (identity::active_user()->admin) { + $menu->append($admin_menu = Menu::factory("submenu") + ->id("admin_menu") + ->label(t("Admin"))); + module::event("admin_menu", $admin_menu, $theme); + } + } + } + + static function admin_menu($menu, $theme) { + $menu + ->append(Menu::factory("link") + ->id("dashboard") + ->label(t("Dashboard")) + ->url(url::site("admin"))) + ->append(Menu::factory("submenu") + ->id("settings_menu") + ->label(t("Settings")) + ->append(Menu::factory("link") + ->id("graphics_toolkits") + ->label(t("Graphics")) + ->url(url::site("admin/graphics"))) + ->append(Menu::factory("link") + ->id("languages") + ->label(t("Languages")) + ->url(url::site("admin/languages"))) + ->append(Menu::factory("link") + ->id("advanced") + ->label(t("Advanced")) + ->url(url::site("admin/advanced_settings"))) + ->append(Menu::factory("link") + ->id("identity_drivers") + ->label(t("Identity drivers")) + ->url(url::site("admin/identity")))) + ->append(Menu::factory("link") + ->id("modules") + ->label(t("Modules")) + ->url(url::site("admin/modules"))) + ->append(Menu::factory("submenu") + ->id("content_menu") + ->label(t("Content"))) + ->append(Menu::factory("submenu") + ->id("appearance_menu") + ->label(t("Appearance")) + ->append(Menu::factory("link") + ->id("themes") + ->label(t("Theme choice")) + ->url(url::site("admin/themes"))) + ->append(Menu::factory("link") + ->id("theme_options") + ->label(t("Theme options")) + ->url(url::site("admin/theme_options"))) + ->append(Menu::factory("link") + ->id("sidebar") + ->label(t("Manage sidebar")) + ->url(url::site("admin/sidebar")))) + ->append(Menu::factory("submenu") + ->id("statistics_menu") + ->label(t("Statistics"))) + ->append(Menu::factory("link") + ->id("maintenance") + ->label(t("Maintenance")) + ->url(url::site("admin/maintenance"))); + return $menu; + } + + static function context_menu($menu, $theme, $item, $thumb_css_selector) { + $menu->append($options_menu = Menu::factory("submenu") + ->id("options_menu") + ->label(t("Options")) + ->css_class("ui-icon-carat-1-n")); + + if (access::can("edit", $item)) { + $page_type = $theme->page_type(); + switch ($item->type) { + case "movie": + $edit_title = t("Edit this movie"); + $delete_title = t("Delete this movie"); + break; + + case "album": + $edit_title = t("Edit this album"); + $delete_title = t("Delete this album"); + break; + + default: + $edit_title = t("Edit this photo"); + $delete_title = t("Delete this photo"); + break; + } + $cover_title = t("Choose as the album cover"); + $move_title = t("Move to another album"); + + $csrf = access::csrf_token(); + + $options_menu->append(Menu::factory("dialog") + ->id("edit") + ->label($edit_title) + ->css_class("ui-icon-pencil") + ->url(url::site("quick/form_edit/$item->id?page_type=$page_type"))); + + + if ($item->is_photo() && graphics::can("rotate")) { + $options_menu + ->append( + Menu::factory("ajax_link") + ->id("rotate_ccw") + ->label(t("Rotate 90° counter clockwise")) + ->css_class("ui-icon-rotate-ccw") + ->ajax_handler("function(data) { " . + "\$.gallery_replace_image(data, \$('$thumb_css_selector')) }") + ->url(url::site("quick/rotate/$item->id/ccw?csrf=$csrf&page_type=$page_type"))) + ->append( + Menu::factory("ajax_link") + ->id("rotate_cw") + ->label(t("Rotate 90° clockwise")) + ->css_class("ui-icon-rotate-cw") + ->ajax_handler("function(data) { " . + "\$.gallery_replace_image(data, \$('$thumb_css_selector')) }") + ->url(url::site("quick/rotate/$item->id/cw?csrf=$csrf&page_type=$page_type"))); + } + + // @todo Don't move photos from the photo page; we don't yet have a good way of redirecting after + // move + if ($page_type == "album") { + $options_menu + ->append(Menu::factory("dialog") + ->id("move") + ->label($move_title) + ->css_class("ui-icon-folder-open") + ->url(url::site("move/browse/$item->id"))); + } + + $parent = $item->parent(); + if (access::can("edit", $parent)) { + // We can't make this item the highlight if it's an album with no album cover, or if it's + // already the album cover. + if (($item->type == "album" && empty($item->album_cover_item_id)) || + ($item->type == "album" && $parent->album_cover_item_id == $item->album_cover_item_id) || + $parent->album_cover_item_id == $item->id) { + $disabledState = " ui-state-disabled"; + } else { + $disabledState = " "; + } + if ($item->parent()->id != 1) { + $options_menu + ->append(Menu::factory("ajax_link") + ->id("make_album_cover") + ->label($cover_title) + ->css_class("ui-icon-star") + ->ajax_handler("function(data) { window.location.reload() }") + ->url(url::site("quick/make_album_cover/$item->id?csrf=$csrf"))); + } + $options_menu + ->append(Menu::factory("dialog") + ->id("delete") + ->label($delete_title) + ->css_class("ui-icon-trash") + ->css_id("g-quick-delete") + ->url(url::site("quick/form_delete/$item->id?csrf=$csrf&page_type=$page_type"))); + } + + if ($item->is_album()) { + $options_menu + ->append(Menu::factory("dialog") + ->id("add_item") + ->label(t("Add a photo")) + ->css_class("ui-icon-plus") + ->url(url::site("simple_uploader/app/$item->id"))) + ->append(Menu::factory("dialog") + ->id("add_album") + ->label(t("Add an album")) + ->css_class("ui-icon-note") + ->url(url::site("form/add/albums/$item->id?type=album"))) + ->append(Menu::factory("dialog") + ->id("edit_permissions") + ->label(t("Edit permissions")) + ->css_class("ui-icon-key") + ->url(url::site("permissions/browse/$item->id"))); + } + } + } } diff --git a/modules/gallery/helpers/gallery_graphics.php b/modules/gallery/helpers/gallery_graphics.php new file mode 100644 index 00000000..c24d2bde --- /dev/null +++ b/modules/gallery/helpers/gallery_graphics.php @@ -0,0 +1,129 @@ +<?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 gallery_graphics_Core { + /** + * Rotate an image. Valid options are degrees + * + * @param string $input_file + * @param string $output_file + * @param array $options + */ + static function rotate($input_file, $output_file, $options) { + graphics::init_toolkit(); + + module::event("graphics_rotate", $input_file, $output_file, $options); + + Image::factory($input_file) + ->quality(module::get_var("gallery", "image_quality")) + ->rotate($options["degrees"]) + ->save($output_file); + + module::event("graphics_rotate_completed", $input_file, $output_file, $options); + } + + /** + * Resize an image. Valid options are width, height and master. Master is one of the Image + * master dimension constants. + * + * @param string $input_file + * @param string $output_file + * @param array $options + */ + static function resize($input_file, $output_file, $options) { + graphics::init_toolkit(); + + module::event("graphics_resize", $input_file, $output_file, $options); + + if (@filesize($input_file) == 0) { + throw new Exception("@todo EMPTY_INPUT_FILE"); + } + + $dims = getimagesize($input_file); + if (max($dims[0], $dims[1]) < min($options["width"], $options["height"])) { + // Image would get upscaled; do nothing + copy($input_file, $output_file); + } else { + $image = Image::factory($input_file) + ->resize($options["width"], $options["height"], $options["master"]) + ->quality(module::get_var("gallery", "image_quality")); + if (graphics::can("sharpen")) { + $image->sharpen(module::get_var("gallery", "image_sharpen")); + } + $image->save($output_file); + } + + module::event("graphics_resize_completed", $input_file, $output_file, $options); + } + + /** + * Overlay an image on top of the input file. + * + * Valid options are: file, mime_type, position, transparency_percent, padding + * + * Valid positions: northwest, north, northeast, + * west, center, east, + * southwest, south, southeast + * + * padding is in pixels + * + * @param string $input_file + * @param string $output_file + * @param array $options + */ + static function composite($input_file, $output_file, $options) { + try { + graphics::init_toolkit(); + + module::event("graphics_composite", $input_file, $output_file, $options); + + list ($width, $height) = getimagesize($input_file); + list ($w_width, $w_height) = getimagesize($options["file"]); + + $pad = isset($options["padding"]) ? $options["padding"] : 10; + $top = $pad; + $left = $pad; + $y_center = max($height / 2 - $w_height / 2, $pad); + $x_center = max($width / 2 - $w_width / 2, $pad); + $bottom = max($height - $w_height - $pad, $pad); + $right = max($width - $w_width - $pad, $pad); + + switch ($options["position"]) { + case "northwest": $x = $left; $y = $top; break; + case "north": $x = $x_center; $y = $top; break; + case "northeast": $x = $right; $y = $top; break; + case "west": $x = $left; $y = $y_center; break; + case "center": $x = $x_center; $y = $y_center; break; + case "east": $x = $right; $y = $y_center; break; + case "southwest": $x = $left; $y = $bottom; break; + case "south": $x = $x_center; $y = $bottom; break; + case "southeast": $x = $right; $y = $bottom; break; + } + + Image::factory($input_file) + ->composite($options["file"], $x, $y, $options["transparency"]) + ->quality(module::get_var("gallery", "image_quality")) + ->save($output_file); + + module::event("graphics_composite_completed", $input_file, $output_file, $options); + } catch (ErrorException $e) { + Kohana::log("error", $e->get_message()); + } + } +} diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index 6500482b..57a5ee9f 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -199,12 +199,12 @@ class gallery_installer { } access::register_permission("view", "View"); - access::register_permission("view_full", "View Full Size"); + access::register_permission("view_full", "View full size"); access::register_permission("edit", "Edit"); access::register_permission("add", "Add"); // Mark for translation (must be the same strings as used above) - t("View Full Size"); + t("View full size"); t("View"); t("Edit"); t("Add"); @@ -224,8 +224,8 @@ class gallery_installer { $root->save(); access::add_item($root); - module::set_var("gallery", "active_site_theme", "default"); - module::set_var("gallery", "active_admin_theme", "admin_default"); + module::set_var("gallery", "active_site_theme", "wind"); + module::set_var("gallery", "active_admin_theme", "admin_wind"); module::set_var("gallery", "page_size", 9); module::set_var("gallery", "thumb_size", 200); module::set_var("gallery", "resize_size", 640); @@ -235,16 +235,16 @@ class gallery_installer { // Add rules for generating our thumbnails and resizes graphics::add_rule( - "gallery", "thumb", "resize", + "gallery", "thumb", "gallery_graphics::resize", array("width" => 200, "height" => 200, "master" => Image::AUTO), 100); graphics::add_rule( - "gallery", "resize", "resize", + "gallery", "resize", "gallery_graphics::resize", array("width" => 640, "height" => 480, "master" => Image::AUTO), 100); // Instantiate default themes (site and admin) - foreach (array("default", "admin_default") as $theme_name) { + foreach (array("wind", "admin_wind") as $theme_name) { $theme_info = new ArrayObject(parse_ini_file(THEMEPATH . $theme_name . "/theme.info"), ArrayObject::ARRAY_AS_PROPS); $theme = ORM::factory("theme"); @@ -268,7 +268,7 @@ class gallery_installer { module::set_var("gallery", "show_credits", 1); // @todo this string needs to be picked up by l10n_scanner module::set_var("gallery", "credits", "Powered by <a href=\"%url\">Gallery %version</a>"); - module::set_version("gallery", 12); + module::set_version("gallery", 19); } static function upgrade($version) { @@ -317,7 +317,7 @@ class gallery_installer { } if ($version == 7) { - $groups = ORM::factory("group")->find_all(); + $groups = identity::groups(); $permissions = ORM::factory("permission")->find_all(); foreach($groups as $group) { foreach($permissions as $permission) { @@ -364,6 +364,74 @@ class gallery_installer { $db->query("UPDATE {items} SET `relative_url_cache` = NULL, `relative_path_cache` = NULL"); module::set_version("gallery", $version = 12); } + + if ($version == 12) { + if (module::get_var("gallery", "active_site_theme") == "default") { + module::set_var("gallery", "active_site_theme", "wind"); + } + if (module::get_var("gallery", "active_admin_theme") == "admin_default") { + module::set_var("gallery", "active_admin_theme", "admin_wind"); + } + module::set_version("gallery", $version = 13); + } + + if ($version == 13) { + // Add rules for generating our thumbnails and resizes + Database::instance()->query( + "UPDATE {graphics_rules} SET `operation` = CONCAT('gallery_graphics::', `operation`);"); + module::set_version("gallery", $version = 14); + } + + if ($version == 14) { + $sidebar_blocks = block_manager::get_active("site_sidebar"); + if (empty($sidebar_blocks)) { + $available_blocks = block_manager::get_available_site_blocks(); + foreach (array_keys(block_manager::get_available_site_blocks()) as $id) { + $sidebar_blocks[] = explode(":", $id); + } + block_manager::set_active("site_sidebar", $sidebar_blocks); + } + module::set_version("gallery", $version = 15); + } + + if ($version == 15) { + module::set_var("gallery", "identity_provider", "user"); + module::set_version("gallery", $version = 16); + } + + // Convert block keys to an md5 hash of the module and block name + if ($version == 16) { + foreach (array("dashboard_sidebar", "dashboard_center", "site_sidebar") as $location) { + $blocks = block_manager::get_active($location); + $new_blocks = array(); + foreach ($blocks as $block) { + $new_blocks[md5("{$block[0]}:{$block[1]}")] = $block; + } + block_manager::set_active($location, $new_blocks); + } + module::set_version("gallery", $version = 17); + } + + // We didn't like md5 hashes so convert block keys back to random keys to allow duplicates. + if ($version == 17) { + foreach (array("dashboard_sidebar", "dashboard_center", "site_sidebar") as $location) { + $blocks = block_manager::get_active($location); + $new_blocks = array(); + foreach ($blocks as $block) { + $new_blocks[rand()] = $block; + } + block_manager::set_active($location, $new_blocks); + } + module::set_version("gallery", $version = 18); + } + + // Rename blocks_site.sidebar to blocks_site_sidebar + if ($version == 18) { + $blocks = block_manager::get_active("site.sidebar"); + block_manager::set_active("site_sidebar", $blocks); + module::clear_var("gallery", "blocks_site.sidebar"); + module::set_version("gallery", $version = 19); + } } static function uninstall() { diff --git a/modules/gallery/helpers/gallery_rss.php b/modules/gallery/helpers/gallery_rss.php index feeab88a..155edfb5 100644 --- a/modules/gallery/helpers/gallery_rss.php +++ b/modules/gallery/helpers/gallery_rss.php @@ -39,8 +39,8 @@ class gallery_rss_Core { ->orderby("created", "DESC"); $feed->max_pages = ceil($all_children->find_all()->count() / $limit); - $feed->title = t("Recent Updates"); - $feed->description = t("Recent Updates"); + $feed->title = t("Recent updates"); + $feed->description = t("Recent updates"); return $feed; case "album": diff --git a/modules/gallery/helpers/gallery_task.php b/modules/gallery/helpers/gallery_task.php index 1b56ab97..95216cf0 100644 --- a/modules/gallery/helpers/gallery_task.php +++ b/modules/gallery/helpers/gallery_task.php @@ -48,9 +48,16 @@ class gallery_task_Core { $errors = array(); try { $result = graphics::find_dirty_images_query(); + $total_count = $task->get("total_count", $result->count()); + $mode = $task->get("mode", "init"); + if ($mode == "init") { + $task->set("total_count", $total_count); + $task->set("mode", "process"); + batch::start(); + } + $completed = $task->get("completed", 0); $ignored = $task->get("ignored", array()); - $remaining = $result->count() - count($ignored); $i = 0; foreach ($result as $row) { @@ -62,19 +69,18 @@ class gallery_task_Core { if ($item->loaded) { try { graphics::generate($item); - $ignored[$item->id] = 1; + $completed++; + $errors[] = t("Successfully rebuilt images for '%title'", array("title" => html::purify($item->title))); } catch (Exception $e) { $errors[] = t("Unable to rebuild images for '%title'", array("title" => html::purify($item->title))); $errors[] = $e->__toString(); + $ignored[$item->id] = 1; } } - $completed++; - $remaining--; - if (++$i == 2) { break; } @@ -83,19 +89,20 @@ class gallery_task_Core { $task->status = t2("Updated: 1 image. Total: %total_count.", "Updated: %count images. Total: %total_count.", $completed, - array("total_count" => ($remaining + $completed))); + array("total_count" => $total_count)); - if ($completed + $remaining > 0) { - $task->percent_complete = (int)(100 * $completed / ($completed + $remaining)); + if ($completed < $total_count) { + $task->percent_complete = (int)(100 * ($completed + count($ignored)) / $total_count); } else { $task->percent_complete = 100; } $task->set("completed", $completed); $task->set("ignored", $ignored); - if ($remaining == 0) { + if ($task->percent_complete == 100) { $task->done = true; $task->state = "success"; + batch::stop(); site_status::clear("graphics_dirty"); } } catch (Exception $e) { diff --git a/modules/gallery/helpers/gallery_theme.php b/modules/gallery/helpers/gallery_theme.php index 20dfeb04..0018fd9a 100644 --- a/modules/gallery/helpers/gallery_theme.php +++ b/modules/gallery/helpers/gallery_theme.php @@ -21,6 +21,7 @@ class gallery_theme_Core { static function head($theme) { $session = Session::instance(); $buf = ""; + $theme->css("gallery.css"); if ($session->get("debug")) { $theme->css("debug.css"); } @@ -37,16 +38,23 @@ class gallery_theme_Core { } } + if (count(locales::installed())) { + // Needed by the languages block + $theme->script("jquery.cookie.js"); + } + if ($session->get("l10n_mode", false)) { $theme->css("l10n_client.css"); $theme->script("jquery.cookie.js"); $theme->script("l10n_client.js"); } + $theme->css("uploadify/uploadify.css"); return $buf; } static function admin_head($theme) { + $theme->css("gallery.css"); $theme->script("gallery.panel.js"); $session = Session::instance(); if ($session->get("debug")) { @@ -88,7 +96,7 @@ class gallery_theme_Core { } static function credits() { - return "<li class=\"first\">" . + return "<li class=\"g-first\">" . t(module::get_var("gallery", "credits"), array("url" => "http://gallery.menalto.com", "version" => gallery::VERSION)) . "</li>"; diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php index 78812794..d6a2f00c 100644 --- a/modules/gallery/helpers/graphics.php +++ b/modules/gallery/helpers/graphics.php @@ -19,6 +19,7 @@ */ class graphics_Core { private static $init; + private static $_rules_cache = array(); /** * Add a new graphics rule. @@ -26,7 +27,7 @@ class graphics_Core { * Rules are applied to targets (thumbnails and resizes) in priority order. Rules are functions * in the graphics class. So for example, the following rule: * - * graphics::add_rule("gallery", "thumb", "resize", + * graphics::add_rule("gallery", "thumb", "gallery_graphics::resize", * array("width" => 200, "height" => 200, "master" => Image::AUTO), 100); * * Specifies that "gallery" is adding a rule to resize thumbnails down to a max of 200px on @@ -35,7 +36,7 @@ class graphics_Core { * * @param string $module_name the module that added the rule * @param string $target the target for this operation ("thumb" or "resize") - * @param string $operation the name of the operation + * @param string $operation the name of the operation (<defining class>::method) * @param array $args arguments to the operation * @param integer $priority the priority for this rule (lower priorities are run first) */ @@ -56,7 +57,7 @@ class graphics_Core { * Remove any matching graphics rules * @param string $module_name the module that added the rule * @param string $target the target for this operation ("thumb" or "resize") - * @param string $operation the name of the operation + * @param string $operation the name of the operation(<defining class>::method) */ static function remove_rule($module_name, $target, $operation) { ORM::factory("graphics_rule") @@ -146,13 +147,9 @@ class graphics_Core { $working_file = $input_file; } - foreach (ORM::factory("graphics_rule") - ->where("target", $target) - ->where("active", true) - ->orderby("priority", "asc") - ->find_all() as $rule) { + foreach (self::_get_rules($target) as $rule) { $args = array($working_file, $output_file, unserialize($rule->args)); - call_user_func_array(array("graphics", $rule->operation), $args); + call_user_func_array($rule->operation, $args); $working_file = $output_file; } } @@ -180,116 +177,19 @@ class graphics_Core { } } - /** - * Resize an image. Valid options are width, height and master. Master is one of the Image - * master dimension constants. - * - * @param string $input_file - * @param string $output_file - * @param array $options - */ - static function resize($input_file, $output_file, $options) { - if (!self::$init) { - self::init_toolkit(); - } - - module::event("graphics_resize", $input_file, $output_file, $options); - - if (@filesize($input_file) == 0) { - throw new Exception("@todo EMPTY_INPUT_FILE"); - } - - $dims = getimagesize($input_file); - if (max($dims[0], $dims[1]) < min($options["width"], $options["height"])) { - // Image would get upscaled; do nothing - copy($input_file, $output_file); - } else { - $image = Image::factory($input_file) - ->resize($options["width"], $options["height"], $options["master"]) - ->quality(module::get_var("gallery", "image_quality")); - if (graphics::can("sharpen")) { - $image->sharpen(module::get_var("gallery", "image_sharpen")); + private static function _get_rules($target) { + if (empty(self::$_rules_cache[$target])) { + $rules = array(); + foreach (ORM::factory("graphics_rule") + ->where("target", $target) + ->where("active", true) + ->orderby("priority", "asc") + ->find_all() as $rule) { + $rules[] = (object)$rule->as_array(); } - $image->save($output_file); - } - - module::event("graphics_resize_completed", $input_file, $output_file, $options); - } - - /** - * Rotate an image. Valid options are degrees - * - * @param string $input_file - * @param string $output_file - * @param array $options - */ - static function rotate($input_file, $output_file, $options) { - if (!self::$init) { - self::init_toolkit(); - } - - module::event("graphics_rotate", $input_file, $output_file, $options); - - Image::factory($input_file) - ->quality(module::get_var("gallery", "image_quality")) - ->rotate($options["degrees"]) - ->save($output_file); - - module::event("graphics_rotate_completed", $input_file, $output_file, $options); - } - - /** - * Overlay an image on top of the input file. - * - * Valid options are: file, mime_type, position, transparency_percent, padding - * - * Valid positions: northwest, north, northeast, - * west, center, east, - * southwest, south, southeast - * - * padding is in pixels - * - * @param string $input_file - * @param string $output_file - * @param array $options - */ - static function composite($input_file, $output_file, $options) { - if (!self::$init) { - self::init_toolkit(); - } - - module::event("graphics_composite", $input_file, $output_file, $options); - - list ($width, $height) = getimagesize($input_file); - list ($w_width, $w_height) = getimagesize($options["file"]); - - $pad = isset($options["padding"]) ? $options["padding"] : 10; - $top = $pad; - $left = $pad; - $y_center = max($height / 2 - $w_height / 2, $pad); - $x_center = max($width / 2 - $w_width / 2, $pad); - $bottom = max($height - $w_height - $pad, $pad); - $right = max($width - $w_width - $pad, $pad); - - switch ($options["position"]) { - case "northwest": $x = $left; $y = $top; break; - case "north": $x = $x_center; $y = $top; break; - case "northeast": $x = $right; $y = $top; break; - case "west": $x = $left; $y = $y_center; break; - case "center": $x = $x_center; $y = $y_center; break; - case "east": $x = $right; $y = $y_center; break; - case "southwest": $x = $left; $y = $bottom; break; - case "south": $x = $x_center; $y = $bottom; break; - case "southeast": $x = $right; $y = $bottom; break; + self::$_rules_cache[$target] = $rules; } - - Image::factory($input_file) - ->composite($options["file"], $x, $y, $options["transparency"]) - ->quality(module::get_var("gallery", "image_quality")) - ->save($output_file); - - - module::event("graphics_composite_completed", $input_file, $output_file, $options); + return self::$_rules_cache[$target]; } /** @@ -327,7 +227,7 @@ class graphics_Core { "%count of your photos are out of date. <a %attrs>Click here to fix them</a>", $count, array("attrs" => html::mark_clean(sprintf( - 'href="%s" class="gDialogLink"', + 'href="%s" class="g-dialog-link"', url::site("admin/maintenance/start/gallery_task::rebuild_dirty_images?csrf=__CSRF__"))))), "graphics_dirty"); } @@ -378,7 +278,10 @@ class graphics_Core { $toolkits->graphicsmagick->installed = false; $toolkits->graphicsmagick->error = t("GraphicsMagick requires the <b>exec</b> function"); } else { - putenv("PATH=" . getenv("PATH") . ":/usr/local/bin:/opt/local/bin:/opt/bin"); + $graphics_path = module::get_var("gallery", "graphics_toolkit_path", null); + + putenv("PATH=" . getenv("PATH") . (empty($graphics_path) ? "" : ":$graphics_path") . + ":/usr/local/bin:/opt/local/bin:/opt/bin"); // @todo: consider refactoring the two segments below into a loop since they are so // similar. @@ -463,6 +366,9 @@ class graphics_Core { * Choose which driver the Kohana Image library uses. */ static function init_toolkit() { + if (self::$init) { + return; + } switch(module::get_var("gallery", "graphics_toolkit")) { case "gd": Kohana::config_set("image.driver", "GD"); diff --git a/modules/gallery/helpers/identity.php b/modules/gallery/helpers/identity.php new file mode 100644 index 00000000..72e3312d --- /dev/null +++ b/modules/gallery/helpers/identity.php @@ -0,0 +1,244 @@ +<?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 identity_Core { + protected static $available; + + /** + * Return a list of installed Identity Drivers. + * + * @return boolean true if the driver supports updates; false if read only + */ + static function providers() { + if (empty(self::$available)) { + $drivers = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS); + foreach (module::available() as $module_name => $module) { + if (file_exists(MODPATH . "{$module_name}/config/identity.php")) { + $drivers->$module_name = $module->description; + } + } + self::$available = $drivers; + } + return self::$available; + } + + /** + * Frees the current instance of the identity provider so the next call to instance will reload + * + * @param string configuration + * @return Identity_Core + */ + static function reset() { + IdentityProvider::reset(); + } + + /** + * Make sure that we have a session and group_ids cached in the session. + */ + static function load_user() { + try { + // Call IdentityProvider::instance() now to force the load of the user interface classes. + // We are about to load the active user from the session and which needs the user definition + // class, which can't be reached by Kohana's heiracrchical lookup. + IdentityProvider::instance(); + + $session = Session::instance(); + if (!($user = $session->get("user"))) { + self::set_active_user($user = self::guest()); + } + + // The installer cannot set a user into the session, so it just sets an id which we should + // upconvert into a user. + // @todo set the user name into the session instead of 2 and then use it to get the user object + if ($user === 2) { + $user = IdentityProvider::instance()->admin_user(); + self::set_active_user($user); + $session->set("user", $user); + } + + if (!$session->get("group_ids")) { + $ids = array(); + foreach ($user->groups as $group) { + $ids[] = $group->id; + } + $session->set("group_ids", $ids); + } + } catch (Exception $e) { + // Log it, so we at least have so notification that we swallowed the exception. + Kohana::log("error", "Load_user Exception: " . $e->__toString()); + try { + Session::instance()->destroy(); + } catch (Exception $e) { + // We don't care if there was a problem destroying the session. + } + url::redirect(item::root()->abs_url()); + } + } + + /** + * Return the array of group ids this user belongs to + * + * @return array + */ + static function group_ids_for_active_user() { + return Session::instance()->get("group_ids", array(1)); + } + + /** + * Return the active user. If there's no active user, return the guest user. + * + * @return User_Definition + */ + static function active_user() { + // @todo (maybe) cache this object so we're not always doing session lookups. + $user = Session::instance()->get("user", null); + if (!isset($user)) { + // Don't do this as a fallback in the Session::get() call because it can trigger unnecessary + // work. + $user = identity::guest(); + } + return $user; + } + + /** + * Change the active user. + * @param User_Definition $user + */ + static function set_active_user($user) { + $session = Session::instance(); + $session->set("user", $user); + $session->delete("group_ids"); + self::load_user(); + } + + /** + * Determine if if the current driver supports updates. + * + * @return boolean true if the driver supports updates; false if read only + */ + static function is_writable() { + return IdentityProvider::instance()->is_writable(); + } + + /** + * @see IdentityProvider_Driver::guest. + */ + static function guest() { + return IdentityProvider::instance()->guest(); + } + + /** + * @see IdentityProvider_Driver::admin_user. + */ + static function admin_user() { + return IdentityProvider::instance()->admin_user(); + } + + /** + * @see IdentityProvider_Driver::create_user. + */ + static function create_user($name, $full_name, $password) { + return IdentityProvider::instance()->create_user($name, $full_name, $password); + } + + /** + * @see IdentityProvider_Driver::is_correct_password. + */ + static function is_correct_password($user, $password) { + return IdentityProvider::instance()->is_correct_password($user, $password); + } + + /** + * @see IdentityProvider_Driver::lookup_user. + */ + static function lookup_user($id) { + return IdentityProvider::instance()->lookup_user($id); + } + + /** + * @see IdentityProvider_Driver::lookup_user_by_name. + */ + static function lookup_user_by_name($name) { + return IdentityProvider::instance()->lookup_user_by_name($name); + } + + /** + * @see IdentityProvider_Driver::create_group. + */ + static function create_group($name) { + return IdentityProvider::instance()->create_group($name); + } + + /** + * @see IdentityProvider_Driver::everybody. + */ + static function everybody() { + return IdentityProvider::instance()->everybody(); + } + + /** + * @see IdentityProvider_Driver::registered_users. + */ + static function registered_users() { + return IdentityProvider::instance()->registered_users(); + } + + /** + * @see IdentityProvider_Driver::lookup_group. + */ + static function lookup_group($id) { + return IdentityProvider::instance()->lookup_group($id); + } + + /** + * @see IdentityProvider_Driver::lookup_group_by_name. + */ + static function lookup_group_by_name($name) { + return IdentityProvider::instance()->lookup_group_by_name($name); + } + + /** + * @see IdentityProvider_Driver::get_user_list. + */ + static function get_user_list($ids) { + return IdentityProvider::instance()->get_user_list($ids); + } + + /** + * @see IdentityProvider_Driver::groups. + */ + static function groups() { + return IdentityProvider::instance()->groups(); + } + + /** + * @see IdentityProvider_Driver::add_user_to_group. + */ + static function add_user_to_group($user, $group_id) { + return IdentityProvider::instance()->add_user_to_group($user, $group_id); + } + + /** + * @see IdentityProvider_Driver::remove_user_to_group. + */ + static function remove_user_from_group($user, $group_id) { + return IdentityProvider::instance()->remove_user_from_group($user, $group_id); + } +}
\ No newline at end of file diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php index 588c08d4..b3b6d0bb 100644 --- a/modules/gallery/helpers/item.php +++ b/modules/gallery/helpers/item.php @@ -130,7 +130,7 @@ class item_Core { $page_type = "photo"; } $form = new Forge( - "quick/delete/$item->id?page_type=$page_type", "", "post", array("id" => "gConfirmDelete")); + "quick/delete/$item->id?page_type=$page_type", "", "post", array("id" => "g-confirm-delete")); $form->hidden("_method")->value("put"); $group = $form->group("confirm_delete")->label(t("Confirm Deletion")); $group->submit("")->value(t("Delete")); @@ -158,8 +158,8 @@ class item_Core { */ static function viewable($model) { $view_restrictions = array(); - if (!user::active()->admin) { - foreach (user::group_ids() as $id) { + if (!identity::active_user()->admin) { + foreach (identity::group_ids_for_active_user() as $id) { // Separate the first restriction from the rest to make it easier for us to formulate // our where clause below if (empty($view_restrictions)) { diff --git a/modules/gallery/helpers/locales.php b/modules/gallery/helpers/locales.php index ab7f7526..2de029ff 100644 --- a/modules/gallery/helpers/locales.php +++ b/modules/gallery/helpers/locales.php @@ -219,4 +219,36 @@ class locales_Core { } return array(null, 0); } -}
\ No newline at end of file + + static function set_request_locale() { + // 1. Check the session specific preference (cookie) + $locale = self::cookie_locale(); + // 2. Check the user's preference + if (!$locale) { + $locale = identity::active_user()->locale; + } + // 3. Check the browser's / OS' preference + if (!$locale) { + $locale = self::locale_from_http_request(); + } + // If we have any preference, override the site's default locale + if ($locale) { + I18n::instance()->locale($locale); + } + } + + static function cookie_locale() { + $cookie_data = Input::instance()->cookie("g_locale"); + $locale = null; + if ($cookie_data) { + if (preg_match("/^([a-z]{2,3}(?:_[A-Z]{2})?)$/", trim($cookie_data), $matches)) { + $requested_locale = $matches[1]; + $installed_locales = locales::installed(); + if (isset($installed_locales[$requested_locale])) { + $locale = $requested_locale; + } + } + } + return $locale; + } +} diff --git a/modules/gallery/helpers/log.php b/modules/gallery/helpers/log.php index 451f985a..184b0b97 100644 --- a/modules/gallery/helpers/log.php +++ b/modules/gallery/helpers/log.php @@ -80,7 +80,7 @@ class log_Core { $log->url = substr(url::abs_current(true), 0, 255); $log->referer = request::referrer(null); $log->timestamp = time(); - $log->user_id = user::active()->id; + $log->user_id = identity::active_user()->id; $log->save(); } @@ -93,16 +93,16 @@ class log_Core { static function severity_class($severity) { switch($severity) { case self::SUCCESS: - return "gSuccess"; + return "g-success"; case self::INFO: - return "gInfo"; + return "g-info"; case self::WARNING: - return "gWarning"; + return "g-warning"; case self::ERROR: - return "gError"; + return "g-error"; } } } diff --git a/modules/gallery/helpers/message.php b/modules/gallery/helpers/message.php index af3b96cc..02680655 100644 --- a/modules/gallery/helpers/message.php +++ b/modules/gallery/helpers/message.php @@ -81,7 +81,7 @@ class message_Core { $buf[] = "<li class=\"" . self::severity_class($msg[1]) . "\">$msg[0]</li>"; } if ($buf) { - return "<ul id=\"gMessage\">" . implode("", $buf) . "</ul>"; + return "<ul id=\"g-action-status\" class=\"g-message-block\">" . implode("", $buf) . "</ul>"; } } @@ -93,16 +93,16 @@ class message_Core { static function severity_class($severity) { switch($severity) { case self::SUCCESS: - return "gSuccess"; + return "g-success"; case self::INFO: - return "gInfo"; + return "g-info"; case self::WARNING: - return "gWarning"; + return "g-warning"; case self::ERROR: - return "gError"; + return "g-error"; } } } diff --git a/modules/gallery/helpers/module.php b/modules/gallery/helpers/module.php index a3088c38..e6c196ce 100644 --- a/modules/gallery/helpers/module.php +++ b/modules/gallery/helpers/module.php @@ -50,8 +50,20 @@ class module_Core { * @param string $module_name */ static function get($module_name) { - // @todo can't easily use model_cache here because it throw an exception on missing models. - return ORM::factory("module", array("name" => $module_name)); + if (empty(self::$modules[$module_name])) { + return ORM::factory("module", array("name" => $module_name)); + } + return self::$modules[$module_name]; + } + + /** + * Get the information about a module + * @returns ArrayObject containing the module information from the module.info file or false if + * not found + */ + static function info($module_name) { + $module_list = self::available(); + return isset($module_list->$module_name) ? $module_list->$module_name : false; } /** @@ -79,18 +91,20 @@ class module_Core { $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 = + 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; + $m->locked = !empty($m->no_module_admin); } // Lock certain modules $modules->gallery->locked = true; - $modules->user->locked = true; + $identity_module = self::get_var("gallery", "identity_provider", "user"); + $modules->$identity_module->locked = true; $modules->ksort(); self::$available = $modules; } @@ -116,6 +130,8 @@ class module_Core { array_unshift($kohana_modules, MODPATH . $module_name); Kohana::config_set("core.modules", $kohana_modules); + // Rebuild the include path so the module installer can benefit from auto loading + Kohana::include_paths(true); $installer_class = "{$module_name}_installer"; if (method_exists($installer_class, "install")) { call_user_func_array(array($installer_class, "install"), array()); @@ -139,10 +155,6 @@ class module_Core { * @param string $module_name */ static function upgrade($module_name) { - $kohana_modules = Kohana::config("core.modules"); - array_unshift($kohana_modules, MODPATH . $module_name); - Kohana::config_set("core.modules", $kohana_modules); - $version_before = module::get_version($module_name); $installer_class = "{$module_name}_installer"; if (method_exists($installer_class, "upgrade")) { @@ -155,11 +167,14 @@ class module_Core { throw new Exception("@todo UNKNOWN_MODULE"); } } - module::load_modules(); - // Now the module is upgraded but inactive, so don't leave it in the active path - array_shift($kohana_modules); - Kohana::config_set("core.modules", $kohana_modules); + // Now the module is upgraded so deactivate it, but we can'it deactivae gallery or the + // current identity provider. + $identity_provider = module::get_var("gallery", "identity_provider", "user"); + if (!in_array($module_name, array("gallery", $identity_provider)) ) { + self::deactivate($module_name); + } + module::load_modules(); $version_after = module::get_version($module_name); if ($version_before != $version_after) { @@ -195,6 +210,9 @@ class module_Core { module::load_modules(); graphics::activate_rules($module_name); + + block_manager::activate_blocks($module_name); + log::success( "module", t("Activated module %module_name", array("module_name" => $module_name))); } @@ -219,6 +237,9 @@ class module_Core { module::load_modules(); graphics::deactivate_rules($module_name); + + block_manager::deactivate_blocks($module_name); + log::success( "module", t("Deactivated module %module_name", array("module_name" => $module_name))); } @@ -234,7 +255,7 @@ class module_Core { call_user_func(array($installer_class, "uninstall")); } - graphics::remove_rule($module_name); + graphics::remove_rules($module_name); $module = self::get($module_name); if ($module->loaded) { $module->delete(); @@ -283,9 +304,32 @@ class module_Core { array_shift($args); $function = str_replace(".", "_", $name); - // @todo: consider calling gallery_event first, since for things menus we need it to do some - // setup + if (method_exists("gallery_event", $function)) { + switch (count($args)) { + case 0: + gallery_event::$function(); + break; + case 1: + gallery_event::$function($args[0]); + break; + case 2: + gallery_event::$function($args[0], $args[1]); + break; + case 3: + gallery_event::$function($args[0], $args[1], $args[2]); + break; + case 4: // Context menu events have 4 arguments so lets optimize them + gallery_event::$function($args[0], $args[1], $args[2], $args[3]); + break; + default: + call_user_func_array(array("gallery_event", $function), $args); + } + } + foreach (self::$active as $module) { + if ($module->name == "gallery") { + continue; + } $class = "{$module->name}_event"; if (method_exists($class, $function)) { call_user_func_array(array($class, $function), $args); diff --git a/modules/gallery/helpers/movie.php b/modules/gallery/helpers/movie.php index 59bf5c19..e84e8ea6 100644 --- a/modules/gallery/helpers/movie.php +++ b/modules/gallery/helpers/movie.php @@ -77,7 +77,7 @@ class movie_Core { $movie->title = $title; $movie->description = $description; $movie->name = $name; - $movie->owner_id = $owner_id ? $owner_id : user::active(); + $movie->owner_id = $owner_id ? $owner_id : identity::active_user()->id; $movie->width = $movie_info[0]; $movie->height = $movie_info[1]; $movie->mime_type = strtolower($pi["extension"]) == "mp4" ? "video/mp4" : "video/x-flv"; @@ -128,6 +128,38 @@ class movie_Core { return $movie; } + static function get_edit_form($movie) { + $form = new Forge("movies/$movie->id", "", "post", array("id" => "g-edit-movie-form")); + $form->hidden("_method")->value("put"); + $group = $form->group("edit_item")->label(t("Edit Movie")); + $group->input("title")->label(t("Title"))->value($movie->title); + $group->textarea("description")->label(t("Description"))->value($movie->description); + $group->input("filename")->label(t("Filename"))->value($movie->name) + ->rules("required") + ->error_messages( + "name_conflict", t("There is already a movie, photo or album with this name")) + ->callback("item::validate_no_slashes") + ->error_messages("no_slashes", t("The movie name can't contain a \"/\"")) + ->callback("item::validate_no_trailing_period") + ->error_messages("no_trailing_period", t("The movie name can't end in \".\"")) + ->error_messages("illegal_extension", t("You cannot change the filename extension")); + $group->input("slug")->label(t("Internet Address"))->value($movie->slug) + ->callback("item::validate_url_safe") + ->error_messages( + "slug_conflict", t("There is already a movie, photo or album with this internet address")) + ->error_messages( + "not_url_safe", + t("The internet address should contain only letters, numbers, hyphens and underscores")); + + module::event("item_edit_form", $movie, $form); + + $group = $form->group("buttons")->label(""); + $group->submit("")->value(t("Modify")); + $form->add_rules_from(ORM::factory("item")); + return $form; + } + + static function getmoviesize($filename) { $ffmpeg = self::find_ffmpeg(); if (empty($ffmpeg)) { @@ -158,7 +190,10 @@ class movie_Core { static function find_ffmpeg() { if (!$ffmpeg_path = module::get_var("gallery", "ffmpeg_path")) { - putenv("PATH=" . getenv("PATH") . ":/usr/local/bin:/opt/local/bin:/opt/bin"); + $graphics_path = module::get_var("gallery", "graphics_toolkit_path", null); + + putenv("PATH=" . getenv("PATH") . (empty($graphics_path) ? "" : ":$graphics_path") . + ":/usr/local/bin:/opt/local/bin:/opt/bin"); if (function_exists("exec")) { $ffmpeg_path = exec("which ffmpeg"); } diff --git a/modules/gallery/helpers/photo.php b/modules/gallery/helpers/photo.php index 3d9fbe69..01cf5278 100644 --- a/modules/gallery/helpers/photo.php +++ b/modules/gallery/helpers/photo.php @@ -26,7 +26,7 @@ class photo_Core { /** * Create a new photo. - * @param integer $parent_id id of parent album + * @param integer $parent parent album * @param string $filename path to the photo file on disk * @param string $name the filename to use for this photo in the album * @param integer $title the title of the new photo @@ -76,7 +76,7 @@ class photo_Core { $photo->title = $title; $photo->description = $description; $photo->name = $name; - $photo->owner_id = $owner_id ? $owner_id : user::active(); + $photo->owner_id = $owner_id ? $owner_id : identity::active_user()->id; $photo->width = $image_info[0]; $photo->height = $image_info[1]; $photo->mime_type = empty($image_info['mime']) ? "application/unknown" : $image_info['mime']; @@ -138,7 +138,7 @@ class photo_Core { } static function get_add_form($parent) { - $form = new Forge("albums/{$parent->id}", "", "post", array("id" => "gAddPhotoForm")); + $form = new Forge("albums/{$parent->id}", "", "post", array("id" => "g-add-photo-form")); $group = $form->group("add_photo")->label( t("Add Photo to %album_title", array("album_title" => $parent->title))); $group->input("title")->label(t("Title")); @@ -157,21 +157,24 @@ class photo_Core { } static function get_edit_form($photo) { - $form = new Forge("photos/$photo->id", "", "post", array("id" => "gEditPhotoForm")); + $form = new Forge("photos/$photo->id", "", "post", array("id" => "g-edit-photo-form")); $form->hidden("_method")->value("put"); $group = $form->group("edit_item")->label(t("Edit Photo")); $group->input("title")->label(t("Title"))->value($photo->title); $group->textarea("description")->label(t("Description"))->value($photo->description); $group->input("filename")->label(t("Filename"))->value($photo->name) - ->error_messages("name_conflict", t("There is already a photo or album with this name")) + ->rules("required") + ->error_messages( + "name_conflict", t("There is already a movie, photo or album with this name")) ->callback("item::validate_no_slashes") ->error_messages("no_slashes", t("The photo name can't contain a \"/\"")) ->callback("item::validate_no_trailing_period") - ->error_messages("no_trailing_period", t("The photo name can't end in \".\"")); + ->error_messages("no_trailing_period", t("The photo name can't end in \".\"")) + ->error_messages("illegal_extension", t("You cannot change the filename extension")); $group->input("slug")->label(t("Internet Address"))->value($photo->slug) ->callback("item::validate_url_safe") ->error_messages( - "slug_conflict", t("There is already a photo or album with this internet address")) + "slug_conflict", t("There is already a movie, photo or album with this internet address")) ->error_messages( "not_url_safe", t("The internet address should contain only letters, numbers, hyphens and underscores")); diff --git a/modules/gallery/helpers/site_status.php b/modules/gallery/helpers/site_status.php index 6d47e565..2b090776 100644 --- a/modules/gallery/helpers/site_status.php +++ b/modules/gallery/helpers/site_status.php @@ -95,7 +95,7 @@ class site_status_Core { * @return html text */ static function get() { - if (!user::active()->admin) { + if (!identity::active_user()->admin) { return; } $buf = array(); @@ -105,7 +105,7 @@ class site_status_Core { } if ($buf) { - return "<ul id=\"gSiteStatus\">" . implode("", $buf) . "</ul>"; + return "<ul id=\"g-site-status\">" . implode("", $buf) . "</ul>"; } } @@ -117,16 +117,16 @@ class site_status_Core { static function severity_class($severity) { switch($severity) { case self::SUCCESS: - return "gSuccess"; + return "g-success"; case self::INFO: - return "gInfo"; + return "g-info"; case self::WARNING: - return "gWarning"; + return "g-warning"; case self::ERROR: - return "gError"; + return "g-error"; } } } diff --git a/modules/gallery/helpers/task.php b/modules/gallery/helpers/task.php index 9fa04305..dac5f9d3 100644 --- a/modules/gallery/helpers/task.php +++ b/modules/gallery/helpers/task.php @@ -42,7 +42,7 @@ class task_Core { $task->percent_complete = 0; $task->status = ""; $task->state = "started"; - $task->owner_id = user::active()->id; + $task->owner_id = identity::active_user()->id; $task->context = serialize($context); $task->save(); diff --git a/modules/gallery/helpers/theme.php b/modules/gallery/helpers/theme.php index b46a2c14..da57a37e 100644 --- a/modules/gallery/helpers/theme.php +++ b/modules/gallery/helpers/theme.php @@ -29,33 +29,39 @@ class theme_Core { * active for any given request. */ static function load_themes() { - $modules = Kohana::config("core.modules"); - if (Router::$controller == "admin") { - array_unshift($modules, THEMEPATH . module::get_var("gallery", "active_admin_theme")); - } else { - array_unshift($modules, THEMEPATH . module::get_var("gallery", "active_site_theme")); + $path = Input::instance()->server("PATH_INFO"); + $input = Input::instance(); + if (empty($path)) { + $path = "/" . $input->get("kohana_uri"); } + if (!(identity::active_user()->admin && $theme_name = $input->get("theme"))) { + $theme_name = module::get_var( + "gallery", + !strncmp($path, "/admin", 6) ? "active_admin_theme" : "active_site_theme"); + } + $modules = Kohana::config("core.modules"); + array_unshift($modules, THEMEPATH . $theme_name); Kohana::config_set("core.modules", $modules); } static function get_edit_form_admin() { - $form = new Forge("admin/theme_options/save/", "", null, array("id" =>"gThemeOptionsForm")); + $form = new Forge("admin/theme_options/save/", "", null, array("id" =>"g-theme-options-form")); $group = $form->group("edit_theme"); - $group->input("page_size")->label(t("Items per page"))->id("gPageSize") + $group->input("page_size")->label(t("Items per page"))->id("g-page-size") ->rules("required|valid_digit") ->value(module::get_var("gallery", "page_size")); - $group->input("thumb_size")->label(t("Thumbnail size (in pixels)"))->id("gThumbSize") + $group->input("thumb_size")->label(t("Thumbnail size (in pixels)"))->id("g-thumb-size") ->rules("required|valid_digit") ->value(module::get_var("gallery", "thumb_size")); - $group->input("resize_size")->label(t("Resized image size (in pixels)"))->id("gResizeSize") + $group->input("resize_size")->label(t("Resized image size (in pixels)"))->id("g-resize-size") ->rules("required|valid_digit") ->value(module::get_var("gallery", "resize_size")); - $group->textarea("header_text")->label(t("Header text"))->id("gHeaderText") + $group->textarea("header_text")->label(t("Header text"))->id("g-header-text") ->value(module::get_var("gallery", "header_text")); - $group->textarea("footer_text")->label(t("Footer text"))->id("gFooterText") + $group->textarea("footer_text")->label(t("Footer text"))->id("g-footer-text") ->value(module::get_var("gallery", "footer_text")); - $group->checkbox("show_credits")->label(t("Show site credits"))->id("gFooterText") + $group->checkbox("show_credits")->label(t("Show site credits"))->id("g-footer-text") ->checked(module::get_var("gallery", "show_credits")); $group->submit("")->value(t("Save")); return $form; diff --git a/modules/gallery/hooks/init_gallery.php b/modules/gallery/hooks/init_gallery.php index 5735e7dc..b2d9c4de 100644 --- a/modules/gallery/hooks/init_gallery.php +++ b/modules/gallery/hooks/init_gallery.php @@ -27,11 +27,13 @@ if (!file_exists(VARPATH . "database.php")) { Event::add("system.ready", array("I18n", "instance")); Event::add("system.ready", array("module", "load_modules")); Event::add("system.ready", array("gallery", "ready")); -Event::add("system.post_routing", array("theme", "load_themes")); Event::add("system.post_routing", array("url", "parse_url")); Event::add("system.post_routing", array("gallery", "maintenance_mode")); Event::add("system.shutdown", array("gallery", "shutdown")); +// @todo once we convert to Kohana 2.4 this doesn't have to be here +set_error_handler(array("gallery_error", "error_handler")); + // Override the cookie if we have a session id in the URL. // @todo This should probably be an event callback $input = Input::instance(); diff --git a/modules/gallery/js/albums_form_add.js b/modules/gallery/js/albums_form_add.js index 43166f27..a568f35d 100644 --- a/modules/gallery/js/albums_form_add.js +++ b/modules/gallery/js/albums_form_add.js @@ -1,22 +1,22 @@ -$("#gAddAlbumForm input[name=title]").change( +$("#g-add-album-form input[name=title]").change( function() { - $("#gAddAlbumForm input[name=name]").attr( - "value", $("#gAddAlbumForm input[name=title]").attr("value") + $("#g-add-album-form input[name=name]").attr( + "value", $("#g-add-album-form input[name=title]").attr("value") .replace(/[\s\/]+/g, "-").replace(/\.+$/, "")); - $("#gAddAlbumForm input[name=slug]").attr( - "value", $("#gAddAlbumForm input[name=title]").attr("value") + $("#g-add-album-form input[name=slug]").attr( + "value", $("#g-add-album-form input[name=title]").attr("value") .replace(/[^A-Za-z0-9-_]+/g, "-") .replace(/^-+/, "") .replace(/-+$/, "")); }); -$("#gAddAlbumForm input[name=title]").keyup( +$("#g-add-album-form input[name=title]").keyup( function() { - $("#gAddAlbumForm input[name=name]").attr( - "value", $("#gAddAlbumForm input[name=title]").attr("value") + $("#g-add-album-form input[name=name]").attr( + "value", $("#g-add-album-form input[name=title]").attr("value") .replace(/[\s\/]+/g, "-") .replace(/\.+$/, "")); - $("#gAddAlbumForm input[name=slug]").attr( - "value", $("#gAddAlbumForm input[name=title]").attr("value") + $("#g-add-album-form input[name=slug]").attr( + "value", $("#g-add-album-form input[name=title]").attr("value") .replace(/[^A-Za-z0-9-_]+/g, "-") .replace(/^-+/, "") .replace(/-+$/, "")); diff --git a/modules/gallery/js/l10n_client.js b/modules/gallery/js/l10n_client.js index 35986e5a..9acb6ca8 100644 --- a/modules/gallery/js/l10n_client.js +++ b/modules/gallery/js/l10n_client.js @@ -35,12 +35,12 @@ jQuery.extend(Gallery, { if(userSelection.length > 0) { Gallery.l10nClient.filter(userSelection); Gallery.l10nClient.toggle(1); - $('#l10n-client #gL10nSearch').focus(); + $('#l10n-client #g-l10n-search').focus(); } else { if($('#l10n-client').is('.hidden')) { Gallery.l10nClient.toggle(1); if(!$.browser.safari) { - $('#l10n-client #gL10nSearch').focus(); + $('#l10n-client #g-l10n-search').focus(); } } else { Gallery.l10nClient.toggle(0); @@ -59,7 +59,7 @@ jQuery.extend(Gallery, { $('#l10n-client-string-select, #l10n-client-string-editor, #l10n-client .labels .label').show(); $('#l10n-client').height('22em').removeClass('hidden'); //$('#l10n-client').slideUp(); - $('#gMinimizeL10n').text("_"); + $('#g-minimize-l10n').text("_"); /* * This CSS clashes with Gallery's CSS, probably due to * YUI's grid / floats. @@ -73,7 +73,7 @@ jQuery.extend(Gallery, { $('#l10n-client-string-select, #l10n-client-string-editor, #l10n-client .labels .label').hide(); $('#l10n-client').height('2em').addClass('hidden'); // TODO: Localize this message - $('#gMinimizeL10n').text(MSG_TRANSLATE_TEXT); + $('#g-minimize-l10n').text(MSG_TRANSLATE_TEXT); /* if(!$.browser.msie) { $('body').css('border-bottom', '0px'); @@ -131,13 +131,13 @@ jQuery.extend(Gallery, { if(search == false || search == '') { $('#l10n-client #l10n-search-filter-clear').focus(); $('#l10n-client-string-select li').show(); - $('#l10n-client #gL10nSearch').val(''); - $('#l10n-client #gL10nSearch').focus(); + $('#l10n-client #g-l10n-search').val(''); + $('#l10n-client #g-l10n-search').focus(); } else { if(search.length > 0) { $('#l10n-client-string-select li').hide(); $('#l10n-client-string-select li:contains('+search+')').show(); - $('#l10n-client #gL10nSearch').val(search); + $('#l10n-client #g-l10n-search').val(search); } } } @@ -193,12 +193,12 @@ Gallery.behaviors.l10nClient = function(context) { var is_plural = Gallery.l10nClient.isPluralMessage(source); Gallery.l10nClient.showSourceMessage(source, is_plural); Gallery.l10nClient.updateTranslationForm(Gallery.l10nClient.getString(index, 'translation'), is_plural); - $("#gL10nClientSaveForm input[name='l10n-message-key']").val(key); + $("#g-l10n-client-save-form input[name='l10n-message-key']").val(key); Gallery.l10nClient.selected = index; }); // When l10n_client window is clicked, toggle based on current state. - $('#gMinimizeL10n').click(function() { + $('#g-minimize-l10n').click(function() { if($('#l10n-client').is('.hidden')) { Gallery.l10nClient.toggle(1); } else { @@ -207,7 +207,7 @@ Gallery.behaviors.l10nClient = function(context) { }); // Close the l10n client using an AJAX call and refreshing the page - $('#gCloseL10n').click(function(event) { + $('#g-close-l10n').click(function(event) { $.ajax({ type: "GET", url: toggle_l10n_mode_url, @@ -223,12 +223,12 @@ Gallery.behaviors.l10nClient = function(context) { // TODO: Either remove hotkeys code or add query.hotkeys.js. if($.hotkeys) { $.hotkeys.add(Gallery.l10nClient.keys['toggle'], function(){Gallery.l10nClient.key('toggle')}); - $.hotkeys.add(Gallery.l10nClient.keys['clear'], {target:'#l10n-client #gL10nSearch', type:'keyup'}, function(){Gallery.l10nClient.key('clear')}); + $.hotkeys.add(Gallery.l10nClient.keys['clear'], {target:'#l10n-client #g-l10n-search', type:'keyup'}, function(){Gallery.l10nClient.key('clear')}); } // Custom listener for l10n_client livesearch - $('#l10n-client #gL10nSearch').keyup(function(key) { - Gallery.l10nClient.filter($('#l10n-client #gL10nSearch').val()); + $('#l10n-client #g-l10n-search').keyup(function(key) { + Gallery.l10nClient.filter($('#l10n-client #g-l10n-search').val()); }); // Clear search @@ -238,7 +238,7 @@ Gallery.behaviors.l10nClient = function(context) { }); // Send AJAX POST data on form submit. - $('#gL10nClientSaveForm').ajaxForm({ + $('#g-l10n-client-save-form').ajaxForm({ dataType: "json", success: function(data) { var source = Gallery.l10nClient.getString(Gallery.l10nClient.selected, 'source'); @@ -250,7 +250,7 @@ Gallery.behaviors.l10nClient = function(context) { var translation = {}; for (var i = 0; i < num_plural_forms; i++) { var form = plural_forms[i]; - translation[form] = $('#gL10nClientSaveForm #l10n-edit-plural-translation-' + form).attr('value'); + translation[form] = $('#g-l10n-client-save-form #l10n-edit-plural-translation-' + form).attr('value'); } } else { translation = $('#l10n-edit-translation').attr('value'); @@ -262,13 +262,13 @@ Gallery.behaviors.l10nClient = function(context) { // Clear the translation form fields Gallery.l10nClient.showSourceMessage('', false); - $('#gL10nClientSaveForm #l10n-edit-translation').val(''); + $('#g-l10n-client-save-form #l10n-edit-translation').val(''); for (var i = 0; i < num_plural_forms; i++) { var form = plural_forms[i]; - $('#gL10nClientSaveForm #l10n-edit-plural-translation-' + form).val(''); + $('#g-l10n-client-save-form #l10n-edit-plural-translation-' + form).val(''); } - $("#gL10nClientSaveForm input[name='l10n-message-key']").val(''); + $("#g-l10n-client-save-form input[name='l10n-message-key']").val(''); }, error: function(xmlhttp) { // TODO: Localize this message @@ -283,12 +283,12 @@ Gallery.behaviors.l10nClient = function(context) { // TODO: Handle plurals in copy button // Copy source text to translation field on button click. - $('#gL10nClientSaveForm #l10n-edit-copy').click(function() { - $('#gL10nClientSaveForm #l10n-edit-target').val($('#l10n-client-string-editor .source-text').text()); + $('#g-l10n-client-save-form #l10n-edit-copy').click(function() { + $('#g-l10n-client-save-form #l10n-edit-target').val($('#l10n-client-string-editor .source-text').text()); }); // Clear translation field on button click. - $('#gL10nClientSaveForm #l10n-edit-clear').click(function() { - $('#gL10nClientSaveForm #l10n-edit-target').val(''); + $('#g-l10n-client-save-form #l10n-edit-clear').click(function() { + $('#g-l10n-client-save-form #l10n-edit-target').val(''); }); }; diff --git a/modules/gallery/libraries/Admin_View.php b/modules/gallery/libraries/Admin_View.php index 21b70df6..cbb781a1 100644 --- a/modules/gallery/libraries/Admin_View.php +++ b/modules/gallery/libraries/Admin_View.php @@ -27,29 +27,27 @@ class Admin_View_Core extends Gallery_View { * @return void */ public function __construct($name) { - $theme_name = module::get_var("gallery", "active_site_theme"); - if (!file_exists("themes/$theme_name")) { - module::set_var("gallery", "active_site_theme", "admin_default"); + $theme_name = module::get_var("gallery", "active_admin_theme"); + if (!file_exists(THEMEPATH . $theme_name)) { + module::set_var("gallery", "active_admin_theme", "admin_wind"); theme::load_themes(); Kohana::log("error", "Unable to locate theme '$theme_name', switching to default theme."); } parent::__construct($name); $this->theme_name = module::get_var("gallery", "active_admin_theme"); - if (user::active()->admin) { + if (identity::active_user()->admin) { $this->theme_name = Input::instance()->get("theme", $this->theme_name); } $this->sidebar = ""; $this->set_global("theme", $this); - $this->set_global("user", user::active()); + $this->set_global("user", identity::active_user()); } public function admin_menu() { $menu = Menu::factory("root"); - gallery::admin_menu($menu, $this); module::event("admin_menu", $menu, $this); - $menu->compact(); - return $menu; + return $menu->render(); } /** @@ -97,7 +95,7 @@ class Admin_View_Core extends Gallery_View { if (Session::instance()->get("debug")) { if ($function != "admin_head") { array_unshift( - $blocks, "<div class=\"gAnnotatedThemeBlock gAnnotatedThemeBlock_$function\">" . + $blocks, "<div class=\"g-annotated-theme-block g-annotated-theme-block_$function\">" . "<div class=\"title\">$function</div>"); $blocks[] = "</div>"; } diff --git a/modules/gallery/libraries/Gallery_View.php b/modules/gallery/libraries/Gallery_View.php index 219cc883..bdfd2fc9 100644 --- a/modules/gallery/libraries/Gallery_View.php +++ b/modules/gallery/libraries/Gallery_View.php @@ -24,12 +24,12 @@ class Gallery_View_Core extends View { /** * Add a script to the combined scripts list. - * @param $file the relative path to a script from the gallery3 directory + * @param $file the file name or path of the script to include. If a path is specified then + * it needs to be relative to DOCROOT. Just specifying a file name will result + * in searching Kohana's cascading file system. */ public function script($file) { - $base_file = str_replace(".js", "", $file); - if (($path = Kohana::find_file("js", $base_file, false, "js")) || - file_exists($path = DOCROOT . "lib/$file")) { + if (($path = gallery::find_file("js", $file, false))) { $this->scripts[$path] = 1; } else { Kohana::log("error", "Can't find script file: $file"); @@ -47,12 +47,12 @@ class Gallery_View_Core extends View { /** * Add a css file to the combined css list. - * @param $file the relative path to a script from the gallery3 directory + * @param $file the file name or path of the script to include. If a path is specified then + * it needs to be relative to DOCROOT. Just specifying a file name will result + * in searching Kohana's cascading file system. */ public function css($file) { - $base_file = str_replace(".css", "", $file); - if (($path = Kohana::find_file("css", $base_file, false, "css")) || - file_exists($path = DOCROOT . "lib/$file")) { + if (($path = gallery::find_file("css", $file, false))) { $this->css[$path] = 1; } else { Kohana::log("error", "Can't find css file: $file"); @@ -85,13 +85,11 @@ class Gallery_View_Core extends View { if (empty($contents)) { $contents = ""; - $docroot_len = strlen(DOCROOT); foreach (array_keys($paths) as $path) { - $relative = substr($path, $docroot_len); if ($type == "css") { - $contents .= "/* $relative */\n" . $this->process_css($path) . "\n"; + $contents .= "/* $path */\n" . $this->process_css($path) . "\n"; } else { - $contents .= "/* $relative */\n" . file_get_contents($path) . "\n"; + $contents .= "/* $path */\n" . file_get_contents($path) . "\n"; } } diff --git a/modules/gallery/libraries/IdentityProvider.php b/modules/gallery/libraries/IdentityProvider.php new file mode 100644 index 00000000..e213ae97 --- /dev/null +++ b/modules/gallery/libraries/IdentityProvider.php @@ -0,0 +1,209 @@ +<?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. + */ + +/** + * Provides a driver-based interface for managing users and groups. + */ +class IdentityProvider_Core { + protected static $instance; + + // Configuration + protected $config; + + // Driver object + protected $driver; + + /** + * Returns a singleton instance of Identity. + * There can only be one Identity driver configured at a given point + * + * @param string configuration + * @return Identity_Core + */ + static function &instance() { + if (empty(self::$instance)) { + // Create a new instance + self::$instance = new IdentityProvider(); + } + + return self::$instance; + } + + /** + * Frees the current instance of the identity provider so the next call to instance will reload + * + * @param string configuration + * @return Identity_Core + */ + static function reset() { + self::$instance = null; + Kohana::config_clear("identity"); + } + + /** + * Loads the configured driver and validates it. + * + * @return void + */ + public function __construct($config=null) { + if (empty($config)) { + $config = module::get_var("gallery", "identity_provider", "user"); + } + + // Test the config group name + if (($this->config = Kohana::config("identity." . $config)) === NULL) { + throw new Exception("@todo NO_USER_LIBRARY_CONFIGURATION_FOR: $config"); + } + + // Set driver name + $driver = "IdentityProvider_" . ucfirst($this->config["driver"]) ."_Driver"; + + // Load the driver + if ( ! Kohana::auto_load($driver)) { + throw new Kohana_Exception("core.driver_not_found", $this->config["driver"], + get_class($this)); + } + + // Initialize the driver + $this->driver = new $driver($this->config["params"]); + + // Validate the driver + if ( !($this->driver instanceof IdentityProvider_Driver)) { + throw new Kohana_Exception("core.driver_implements", $this->config["driver"], + get_class($this), "IdentityProvider_Driver"); + } + + Kohana::log("debug", "Identity Library initialized"); + } + + /** + * Determine if if the current driver supports updates. + * + * @return boolean true if the driver supports updates; false if read only + */ + public function is_writable() { + return !empty($this->config["allow_updates"]); + } + + /** + * @see IdentityProvider_Driver::guest. + */ + public function guest() { + return $this->driver->guest(); + } + + /** + * @see IdentityProvider_Driver::admin_user. + */ + public function admin_user() { + return $this->driver->admin_user(); + } + + /** + * @see IdentityProvider_Driver::create_user. + */ + public function create_user($name, $full_name, $password) { + return $this->driver->create_user($name, $full_name, $password); + } + + /** + * @see IdentityProvider_Driver::is_correct_password. + */ + public function is_correct_password($user, $password) { + return $this->driver->is_correct_password($user, $password); + } + + /** + * @see IdentityProvider_Driver::lookup_user. + */ + public function lookup_user($id) { + return $this->driver->lookup_user($id); + } + + /** + * @see IdentityProvider_Driver::lookup_user_by_name. + */ + public function lookup_user_by_name($name) { + return $this->driver->lookup_user_by_name($name); + } + + /** + * @see IdentityProvider_Driver::create_group. + */ + public function create_group($name) { + return $this->driver->create_group($name); + } + + /** + * @see IdentityProvider_Driver::everybody. + */ + public function everybody() { + return $this->driver->everybody(); + } + + /** + * @see IdentityProvider_Driver::registered_users. + */ + public function registered_users() { + return $this->driver->registered_users(); + } + + /** + * @see IdentityProvider_Driver::lookup_group. + */ + public function lookup_group($id) { + return $this->driver->lookup_group($id); + } + + /** + * @see IdentityProvider_Driver::lookup_group_by_name. + */ + public function lookup_group_by_name($name) { + return $this->driver->lookup_group_by_name($name); + } + + /** + * @see IdentityProvider_Driver::get_user_list. + */ + public function get_user_list($ids) { + return $this->driver->get_user_list($ids); + } + + /** + * @see IdentityProvider_Driver::groups. + */ + public function groups() { + return $this->driver->groups(); + } + + /** + * @see IdentityProvider_Driver::add_user_to_group. + */ + public function add_user_to_group($user, $group_id) { + return $this->driver->add_user_to_group($user, $group_id); + } + + /** + * @see IdentityProvider_Driver::remove_user_to_group. + */ + public function remove_user_from_group($user, $group_id) { + return $this->driver->remove_user_from_group($user, $group_id); + } +} // End Identity diff --git a/modules/gallery/libraries/InPlaceEdit.php b/modules/gallery/libraries/InPlaceEdit.php new file mode 100644 index 00000000..67ab3805 --- /dev/null +++ b/modules/gallery/libraries/InPlaceEdit.php @@ -0,0 +1,88 @@ +<?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 InPlaceEdit_Core { + private $rules = array(); + private $messages = array(); + private $callback = array(); + private $initial_value; + private $action = ""; + private $errors; + private $form; + + static function factory($initial_value) { + $instance = new InPlaceEdit(); + $instance->initial_value = $initial_value; + $instance->form = array("input" => $initial_value); + $instance->errors = array("input" => ""); + + return $instance; + } + + public function action($action) { + $this->action = $action; + return $this; + } + + public function rules($rules) { + $this->rules += $rules; + return $this; + } + + public function messages($messages) { + $this->messages += $messages; + return $this; + } + + public function callback($callback) { + $this->callback = $callback; + return $this; + } + + public function validate() { + $post = Validation::factory($_POST) + ->add_callbacks("input", $this->callback); + foreach ($this->rules as $rule) { + $post->add_rules("input", $rule); + } + + $valid = $post->validate(); + $this->form = array_merge($this->form, $post->as_array()); + $this->errors = array_merge($this->errors, $post->errors()); + return $valid; + } + + public function render() { + $v = new View("in_place_edit.html"); + $v->hidden = array("csrf" => access::csrf_token()); + $v->action = url::site($this->action); + $v->form = $this->form; + $v->errors = $this->errors; + foreach ($v->errors as $key => $error) { + if (!empty($error)) { + $v->errors[$key] = $this->messages[$error]; + } + } + return $v->render(); + } + + public function value() { + return $this->form["input"]; + } +}
\ No newline at end of file diff --git a/modules/gallery/libraries/Menu.php b/modules/gallery/libraries/Menu.php index 07b2b2b8..e2b68d1a 100644 --- a/modules/gallery/libraries/Menu.php +++ b/modules/gallery/libraries/Menu.php @@ -43,6 +43,11 @@ class Menu_Element { * @chainable */ public function label($label) { + // Guard against developers who forget to internationalize label strings + if (!($label instanceof SafeString)) { + $label = new SafeString($label); + } + $this->label = $label; return $this; } @@ -74,25 +79,25 @@ class Menu_Element { return $this; } + /** + * Specifiy a view for this menu item + * @chainable + */ + public function view($view) { + $this->view = $view; + return $this; + } + } /** * Menu element that provides a link to a new page. */ class Menu_Element_Link extends Menu_Element { - public function __toString() { - if (isset($this->css_id) && !empty($this->css_id)) { - $css_id = " id=\"$this->css_id\""; - } else { - $css_id = ""; - } - if (isset($this->css_class) && !empty($this->css_class)) { - $css_class = " $this->css_class"; - } else { - $css_class = ""; - } - return "<li><a$css_id class=\"gMenuLink $css_class\" href=\"$this->url\" " . - "title=\"$this->label\">$this->label</a></li>"; + public function render() { + $view = new View(isset($this->view) ? $this->view : "menu_link.html"); + $view->menu = $this; + return $view; } } @@ -111,19 +116,10 @@ class Menu_Element_Ajax_Link extends Menu_Element { return $this; } - public function __toString() { - if (isset($this->css_id) && !empty($this->css_id)) { - $css_id = " id=\"$this->css_id\""; - } else { - $css_id = ""; - } - if (isset($this->css_class) && !empty($this->css_class)) { - $css_class = " $this->css_class"; - } else { - $css_class = ""; - } - return "<li><a$css_id class=\"gAjaxLink $css_class\" href=\"$this->url\" " . - "title=\"$this->label\" ajax_handler=\"$this->ajax_handler\">$this->label</a></li>"; + public function render() { + $view = new View(isset($this->view) ? $this->view : "menu_ajax_link.html"); + $view->menu = $this; + return $view; } } @@ -131,19 +127,10 @@ class Menu_Element_Ajax_Link extends Menu_Element { * Menu element that provides a pop-up dialog */ class Menu_Element_Dialog extends Menu_Element { - public function __toString() { - if (isset($this->css_id) && !empty($this->css_id)) { - $css_id = " id=\"$this->css_id\""; - } else { - $css_id = ""; - } - if (isset($this->css_class) && !empty($this->css_class)) { - $css_class = " $this->css_class"; - } else { - $css_class = ""; - } - return "<li><a$css_id class=\"gDialogLink $css_class\" href=\"$this->url\" " . - "title=\"$this->label\">$this->label</a></li>"; + public function render() { + $view = new View(isset($this->view) ? $this->view : "menu_dialog.html"); + $view->menu = $this; + return $view; } } @@ -171,7 +158,7 @@ class Menu_Core extends Menu_Element { case "root": $menu = new Menu("root"); - $menu->css_class("gMenu"); + $menu->css_class("g-menu"); return $menu; case "submenu": @@ -182,19 +169,6 @@ class Menu_Core extends Menu_Element { } } - public function compact() { - foreach ($this->elements as $target_id => $element) { - if ($element->type == "submenu") { - if (empty($element->elements)) { - $this->remove($target_id); - } else { - $element->compact(); - } - } - } - return $this; - } - public function __construct($type) { parent::__construct($type); $this->elements = array(); @@ -242,11 +216,9 @@ class Menu_Core extends Menu_Element { return null; } - public function __toString() { - $html = $this->is_root ? "<ul class=\"$this->css_class\">" : - "<li title=\"$this->label\"><a href=\"#\">$this->label</a><ul>"; - $html .= implode("\n", $this->elements); - $html .= $this->is_root ? "</ul>" : "</ul></li>"; - return $html; + public function render() { + $view = new View(isset($this->view) ? $this->view : "menu.html"); + $view->menu = $this; + return $view; } } diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php index 130e2dce..e98914c4 100644 --- a/modules/gallery/libraries/Theme_View.php +++ b/modules/gallery/libraries/Theme_View.php @@ -29,21 +29,21 @@ class Theme_View_Core extends Gallery_View { */ public function __construct($name, $page_type) { $theme_name = module::get_var("gallery", "active_site_theme"); - if (!file_exists("themes/$theme_name")) { - module::set_var("gallery", "active_site_theme", "default"); + if (!file_exists(THEMEPATH . $theme_name)) { + module::set_var("gallery", "active_site_theme", "wind"); theme::load_themes(); Kohana::log("error", "Unable to locate theme '$theme_name', switching to default theme."); } parent::__construct($name); $this->theme_name = module::get_var("gallery", "active_site_theme"); - if (user::active()->admin) { + if (identity::active_user()->admin) { $this->theme_name = Input::instance()->get("theme", $this->theme_name); } $this->item = null; $this->tag = null; $this->set_global("theme", $this); - $this->set_global("user", user::active()); + $this->set_global("user", identity::active_user()); $this->set_global("page_type", $page_type); $this->set_global("page_title", null); if ($page_type == "album") { @@ -78,23 +78,30 @@ class Theme_View_Core extends Gallery_View { return $this->page_type; } + public function user_menu() { + $menu = Menu::factory("root") + ->css_id("g-login-menu") + ->css_class("g-inline ui-helper-clear-fix"); + module::event("user_menu", $menu, $this); + return $menu->render(); + } + public function site_menu() { $menu = Menu::factory("root"); - gallery::site_menu($menu, $this); module::event("site_menu", $menu, $this); - return $menu->compact(); + return $menu->render(); } public function album_menu() { $menu = Menu::factory("root"); module::event("album_menu", $menu, $this); - return $menu->compact(); + return $menu->render(); } public function tag_menu() { $menu = Menu::factory("root"); module::event("tag_menu", $menu, $this); - return $menu->compact(); + return $menu->render(); } public function photo_menu() { @@ -104,17 +111,17 @@ class Theme_View_Core extends Gallery_View { ->id("fullsize") ->label(t("View full size")) ->url($this->item()->file_url()) - ->css_class("gFullSizeLink")); + ->css_class("g-fullsize-link")); } module::event("photo_menu", $menu, $this); - return $menu->compact(); + return $menu->render(); } public function movie_menu() { $menu = Menu::factory("root"); module::event("movie_menu", $menu, $this); - return $menu->compact(); + return $menu->render(); } public function context_menu($item, $thumbnail_css_selector) { @@ -122,23 +129,55 @@ class Theme_View_Core extends Gallery_View { ->append(Menu::factory("submenu") ->id("context_menu") ->label(t("Options"))) - ->css_class("gContextMenu"); + ->css_class("g-context-menu"); - gallery::context_menu($menu, $this, $item, $thumbnail_css_selector); module::event("context_menu", $menu, $this, $item, $thumbnail_css_selector); - return $menu->compact(); - } - - public function pager() { - if ($this->children_count) { - $this->pagination = new Pagination(); - $this->pagination->initialize( - array("query_string" => "page", - "total_items" => $this->children_count, - "items_per_page" => $this->page_size, - "style" => "classic")); - return $this->pagination->render(); + return $menu->render(); + } + + /** + * Set up the data and render a pager. + * + * See themes/wind/views/pager.html for documentation on the variables generated here. + */ + public function paginator() { + $v = new View("paginator.html"); + $v->page_type = $this->page_type; + $v->first_page_url = null; + $v->previous_page_url = null; + $v->next_page_url = null; + $v->last_page_url = null; + + if ($this->page_type == "album" || $this->page_type == "tag") { + $v->page = $this->page; + $v->max_pages = $this->max_pages; + $v->total = $this->children_count; + + if ($this->page != 1) { + $v->first_page_url = url::site(url::merge(array("page" => 1))); + $v->previous_page_url = url::site(url::merge(array("page" => $this->page - 1))); + } + + if ($this->page != $this->max_pages) { + $v->next_page_url = url::site(url::merge(array("page" => $this->page + 1))); + $v->last_page_url = url::site(url::merge(array("page" => $this->max_pages))); + } + + $v->first_visible_position = ($this->page - 1) * $this->page_size + 1; + $v->last_visible_position = $this->page * $this->page_size; + } else { + $v->position = $this->position; + $v->total = $this->sibling_count; + if ($this->previous_item) { + $v->previous_page_url = $this->previous_item->url(); + } + + if ($this->next_item) { + $v->next_page_url = $this->next_item->url(); + } } + + return $v; } /** @@ -156,6 +195,17 @@ class Theme_View_Core extends Gallery_View { } /** + * Print out the sidebar. + */ + public function sidebar_blocks() { + $sidebar = block_manager::get_html("site_sidebar", $this); + if (empty($sidebar) && identity::active_user()->admin) { + $sidebar = new View("no_sidebar.html"); + } + return $sidebar; + } + + /** * Handle all theme functions that insert module content. */ public function __call($function, $args) { @@ -178,7 +228,6 @@ class Theme_View_Core extends Gallery_View { case "photo_top": case "resize_bottom": case "resize_top": - case "sidebar_blocks": case "sidebar_bottom": case "sidebar_top": case "thumb_bottom": @@ -223,7 +272,7 @@ class Theme_View_Core extends Gallery_View { if (Session::instance()->get("debug")) { if ($function != "head") { array_unshift( - $blocks, "<div class=\"gAnnotatedThemeBlock gAnnotatedThemeBlock_$function gClearFix\">" . + $blocks, "<div class=\"g-annotated-theme-block g-annotated-theme-block_$function g-clear-fix\">" . "<div class=\"title\">$function</div>"); $blocks[] = "</div>"; } diff --git a/modules/gallery/libraries/drivers/IdentityProvider.php b/modules/gallery/libraries/drivers/IdentityProvider.php new file mode 100644 index 00000000..a808c7e8 --- /dev/null +++ b/modules/gallery/libraries/drivers/IdentityProvider.php @@ -0,0 +1,133 @@ +<?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. + */ +interface IdentityProvider_Driver { + /** + * Return the guest user. + * + * @return User_Definition the user object + */ + public function guest(); + + /** + * Return the admins user. + * + * @return User_Definition the user object + */ + public function admin_user(); + + /** + * Create a new user. + * + * @param string $name + * @param string $full_name + * @param string $password + * @return User_Definition the user object + */ + public function create_user($name, $full_name, $password); + + /** + * Is the password provided correct? + * + * @param user User_Definition the user object + * @param string $password a plaintext password + * @return boolean true if the password is correct + */ + public function is_correct_password($user, $password); + + /** + * Look up a user by id. + * @param integer $id + * @return User_Definition the user object, or null if the name was invalid. + */ + public function lookup_user($id); + + /** + * Look up a user by name. + * @param string $name + * @return User_Definition the user object, or null if the name was invalid. + */ + public function lookup_user_by_name($name); + + /** + * Create a new group. + * + * @param string $name + * @return Group_Definition the group object + */ + public function create_group($name); + + /** + * The group of all possible visitors. This includes the guest user. + * + * @return Group_Definition the group object + */ + public function everybody(); + + /** + * The group of all logged-in visitors. This does not include guest users. + * + * @return Group_Definition the group object + */ + public function registered_users(); + + /** + * List the users + * @param array $ids array of ids to return the user objects for + * @return array the user list. + */ + public function get_user_list($ids); + + /** + * Look up a group by id. + * @param integer $id id + * @return Group_Definition the user object, or null if the name was invalid. + */ + public function lookup_group($id); + + /** + * Look up the group by name. + * @param string $name the name of the group to locate + * @return Group_Definition + */ + public function lookup_group_by_name($name); + + /** + * List the groups defined in the Identity Provider + */ + public function groups(); + + /** + * Add the user to the specified group + * @param User_Definition the user to add to the group + * @param int the group_id + */ + static function add_user_to_group($user, $group_id); + + /** + * Remove the user to the specified group + * @param User_Definition the user to add to the group + * @param int the group id + */ + static function remove_user_from_group($user, $group_id); +} // End Identity Driver Definition + +interface Group_Definition {} + +interface User_Definition {} diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index a87997c6..d27e331b 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -24,7 +24,8 @@ class Item_Model extends ORM_MPTT { var $rules = array( "name" => "required|length[0,255]", "title" => "required|length[0,255]", - "description" => "length[0,65535]" + "description" => "length[0,65535]", + "slug" => "required|length[0,255]" ); /** @@ -98,6 +99,10 @@ class Item_Model extends ORM_MPTT { throw new Exception("@todo INVALID_MOVE_TYPE $target->type"); } + if (file_exists($target_file = "{$target->file_path()}/$this->name")) { + throw new Exception("@todo INVALID_MOVE_TARGET_EXISTS: $target_file"); + } + if ($this->id == 1) { throw new Exception("@todo INVALID_SOURCE root album"); } @@ -146,6 +151,10 @@ class Item_Model extends ORM_MPTT { $old_relative_path = urldecode($this->relative_path()); $new_relative_path = dirname($old_relative_path) . "/" . $new_name; + if (file_exists(VARPATH . "albums/$new_relative_path")) { + throw new Exception("@todo INVALID_RENAME_FILE_EXISTS: $new_relative_path"); + } + @rename(VARPATH . "albums/$old_relative_path", VARPATH . "albums/$new_relative_path"); @rename(VARPATH . "resizes/$old_relative_path", VARPATH . "resizes/$new_relative_path"); @rename(VARPATH . "thumbs/$old_relative_path", VARPATH . "thumbs/$new_relative_path"); @@ -284,6 +293,7 @@ class Item_Model extends ORM_MPTT { ->where("id <>", 1) ->orderby("left_ptr", "ASC") ->get() as $row) { + // Don't encode the names segment $names[] = rawurlencode($row->name); $slugs[] = rawurlencode($row->slug); } @@ -332,7 +342,7 @@ class Item_Model extends ORM_MPTT { // This relationship depends on an outside module, which may not be present so handle // failures gracefully. try { - return model_cache::get("user", $this->owner_id); + return identity::lookup_user($this->owner_id); } catch (Exception $e) { return null; } @@ -412,39 +422,76 @@ class Item_Model extends ORM_MPTT { * Find the position of the given child id in this album. The resulting value is 1-indexed, so * the first child in the album is at position 1. */ - public function get_position($child_id) { + public function get_position($child, $where=array()) { if ($this->sort_order == "DESC") { $comp = ">"; } else { $comp = "<"; } - $db = Database::instance(); - $position = $db->query(" - SELECT COUNT(*) AS position FROM {items} - WHERE `parent_id` = {$this->id} - AND `{$this->sort_column}` $comp (SELECT `{$this->sort_column}` - FROM {items} WHERE `id` = $child_id)") - ->current()->position; - - // We stopped short of our target value in the sort (notice that we're using a < comparator - // above) because it's possible that we have duplicate values in the sort column. An - // equality check would just arbitrarily pick one of those multiple possible equivalent - // columns, which would mean that if you choose a sort order that has duplicates, it'd pick - // any one of them as the child's "position". - // - // Fix this by doing a 2nd query where we iterate over the equivalent columns and add them to - // our base value. - $result = $db->query(" - SELECT id FROM {items} - WHERE `parent_id` = {$this->id} - AND `{$this->sort_column}` = (SELECT `{$this->sort_column}` - FROM {items} WHERE `id` = $child_id) - ORDER BY `id` ASC"); - foreach ($result as $row) { - $position++; - if ($row->id == $child_id) { - break; + + // If the comparison column has NULLs in it, we can't use comparators on it and will have to + // deal with it the hard way. + $count = $db->from("items") + ->where("parent_id", $this->id) + ->where($this->sort_column, NULL) + ->where($where) + ->count_records(); + + if (empty($count)) { + // There are no NULLs in the sort column, so we can just use it directly. + $sort_column = $this->sort_column; + + $position = $db->from("items") + ->where("parent_id", $this->id) + ->where("$sort_column $comp ", $child->$sort_column) + ->where($where) + ->count_records(); + + // We stopped short of our target value in the sort (notice that we're using a < comparator + // above) because it's possible that we have duplicate values in the sort column. An + // equality check would just arbitrarily pick one of those multiple possible equivalent + // columns, which would mean that if you choose a sort order that has duplicates, it'd pick + // any one of them as the child's "position". + // + // Fix this by doing a 2nd query where we iterate over the equivalent columns and add them to + // our base value. + foreach ($db->from("items") + ->where("parent_id", $this->id) + ->where($sort_column, $child->$sort_column) + ->where($where) + ->orderby(array("id" => "ASC")) + ->get() as $row) { + $position++; + if ($row->id == $child->id) { + break; + } + } + } else { + // There are NULLs in the sort column, so we can't use MySQL comparators. Fall back to + // iterating over every child row to get to the current one. This can be wildly inefficient + // for really large albums, but it should be a rare case that the user is sorting an album + // with null values in the sort column. + // + // Reproduce the children() functionality here using Database directly to avoid loading the + // whole ORM for each row. + $orderby = array($this->sort_column => $this->sort_order); + // Use id as a tie breaker + if ($this->sort_column != "id") { + $orderby["id"] = "ASC"; + } + + $position = 0; + foreach ($db->select("id") + ->from("items") + ->where("parent_id", $this->id) + ->where($where) + ->orderby($orderby) + ->get() as $row) { + $position++; + if ($row->id == $child->id) { + break; + } } } @@ -532,7 +579,7 @@ class Item_Model extends ORM_MPTT { $v->attrs = array_merge($extra_attrs, array("style" => "display:block;width:{$this->width}px;height:{$this->height}px")); if (empty($v->attrs["id"])) { - $v->attrs["id"] = "gMovieId-{$this->id}"; + $v->attrs["id"] = "g-movie-id-{$this->id}"; } return $v; } @@ -551,6 +598,10 @@ class Item_Model extends ORM_MPTT { function children($limit=null, $offset=0, $where=array(), $orderby=null) { if (empty($orderby)) { $orderby = array($this->sort_column => $this->sort_order); + // Use id as a tie breaker + if ($this->sort_column != "id") { + $orderby["id"] = "ASC"; + } } return parent::children($limit, $offset, $where, $orderby); } @@ -569,6 +620,10 @@ class Item_Model extends ORM_MPTT { function descendants($limit=null, $offset=0, $where=array(), $orderby=null) { if (empty($orderby)) { $orderby = array($this->sort_column => $this->sort_order); + // Use id as a tie breaker + if ($this->sort_column != "id") { + $orderby["id"] = "ASC"; + } } return parent::descendants($limit, $offset, $where, $orderby); } diff --git a/modules/gallery/models/log.php b/modules/gallery/models/log.php index 6734afb8..c816a4a7 100644 --- a/modules/gallery/models/log.php +++ b/modules/gallery/models/log.php @@ -18,5 +18,21 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class Log_Model extends ORM { - protected $has_one = array("user"); + /** + * @see ORM::__get() + */ + public function __get($column) { + if ($column == "user") { + // This relationship depends on an outside module, which may not be present so handle + // failures gracefully. + try { + return identity::lookup_user($this->user_id); + } catch (Exception $e) { + Kohana::log("alert", "Unable to load user with id $this->user_id"); + return null; + } + } else { + return parent::__get($column); + } + } } diff --git a/modules/gallery/models/task.php b/modules/gallery/models/task.php index b7e255a2..f40be492 100644 --- a/modules/gallery/models/task.php +++ b/modules/gallery/models/task.php @@ -46,7 +46,7 @@ class Task_Model extends ORM { } public function owner() { - return user::lookup($this->owner_id); + return identity::lookup_user($this->owner_id); } /** diff --git a/modules/gallery/module.info b/modules/gallery/module.info index 70bd91e2..2dc62ecd 100644 --- a/modules/gallery/module.info +++ b/modules/gallery/module.info @@ -1,3 +1,3 @@ name = "Gallery 3" description = "Gallery core application" -version = 12 +version = 19 diff --git a/modules/gallery/tests/Access_Helper_Test.php b/modules/gallery/tests/Access_Helper_Test.php index 59cec453..e9e5cb26 100644 --- a/modules/gallery/tests/Access_Helper_Test.php +++ b/modules/gallery/tests/Access_Helper_Test.php @@ -22,8 +22,8 @@ class Access_Helper_Test extends Unit_Test_Case { public function teardown() { try { - $group = ORM::factory("group")->where("name", "access_test")->find(); - if ($group->loaded) { + $group = identity::lookup_group_by_name("access_test"); + if (!empty($group)) { $group->delete(); } } catch (Exception $e) { } @@ -33,24 +33,24 @@ class Access_Helper_Test extends Unit_Test_Case { } catch (Exception $e) { } try { - $user = ORM::factory("user")->where("name", "access_test")->find(); - if ($user->loaded) { + $user = identity::lookup_user_by_name("access_test"); + if (!empty($user)) { $user->delete(); } } catch (Exception $e) { } // Reset some permissions that we mangle below $root = ORM::factory("item", 1); - access::allow(group::everybody(), "view", $root); + access::allow(identity::everybody(), "view", $root); } public function setup() { - user::set_active(user::guest()); + identity::set_active_user(identity::guest()); } public function groups_and_permissions_are_bound_to_columns_test() { access::register_permission("access_test", "Access Test"); - $group = group::create("access_test"); + $group = identity::create_group("access_test"); // We have a new column for this perm / group combo $fields = Database::instance()->list_fields("access_caches"); @@ -65,17 +65,17 @@ class Access_Helper_Test extends Unit_Test_Case { } public function user_can_access_test() { - $access_test = group::create("access_test"); + $access_test = identity::create_group("access_test"); $root = ORM::factory("item", 1); access::allow($access_test, "view", $root); $item = album::create($root, rand(), "test album"); - access::deny(group::everybody(), "view", $item); - access::deny(group::registered_users(), "view", $item); + access::deny(identity::everybody(), "view", $item); + access::deny(identity::registered_users(), "view", $item); - $user = user::create("access_test", "Access Test", ""); + $user = identity::create_user("access_test", "Access Test", ""); foreach ($user->groups as $group) { $user->remove($group); } @@ -89,10 +89,10 @@ class Access_Helper_Test extends Unit_Test_Case { $root = ORM::factory("item", 1); $item = album::create($root, rand(), "test album"); - access::deny(group::everybody(), "view", $item); - access::deny(group::registered_users(), "view", $item); + access::deny(identity::everybody(), "view", $item); + access::deny(identity::registered_users(), "view", $item); - $user = user::create("access_test", "Access Test", ""); + $user = identity::create_user("access_test", "Access Test", ""); foreach ($user->groups as $group) { $user->remove($group); } @@ -121,14 +121,11 @@ class Access_Helper_Test extends Unit_Test_Case { $root = ORM::factory("item", 1); $album = album::create($root, rand(), "test album"); - access::allow(group::everybody(), "view", $album); + access::allow(identity::everybody(), "view", $album); - $photo = ORM::factory("item"); - $photo->type = "photo"; - $photo->add_to_parent($album); - access::add_item($photo); + $photo = photo::create($album, MODPATH . "gallery/images/gallery.png", "", ""); - $this->assert_true($photo->__get("view_" . group::everybody()->id)); + $this->assert_true($photo->__get("view_" . identity::everybody()->id)); } public function can_allow_deny_and_reset_intent_test() { @@ -137,23 +134,23 @@ class Access_Helper_Test extends Unit_Test_Case { $intent = ORM::factory("access_intent")->where("item_id", $album)->find(); // Allow - access::allow(group::everybody(), "view", $album); + access::allow(identity::everybody(), "view", $album); $this->assert_same(access::ALLOW, $intent->reload()->view_1); // Deny - access::deny(group::everybody(), "view", $album); + access::deny(identity::everybody(), "view", $album); $this->assert_same( access::DENY, ORM::factory("access_intent")->where("item_id", $album)->find()->view_1); // Allow again. If the initial value was allow, then the first Allow clause above may not // have actually changed any values. - access::allow(group::everybody(), "view", $album); + access::allow(identity::everybody(), "view", $album); $this->assert_same( access::ALLOW, ORM::factory("access_intent")->where("item_id", $album)->find()->view_1); - access::reset(group::everybody(), "view", $album); + access::reset(identity::everybody(), "view", $album); $this->assert_same( null, ORM::factory("access_intent")->where("item_id", $album)->find()->view_1); @@ -161,7 +158,7 @@ class Access_Helper_Test extends Unit_Test_Case { public function cant_reset_root_item_test() { try { - access::reset(group::everybody(), "view", ORM::factory("item", 1)); + access::reset(identity::everybody(), "view", ORM::factory("item", 1)); } catch (Exception $e) { return; } @@ -170,17 +167,17 @@ class Access_Helper_Test extends Unit_Test_Case { public function can_view_item_test() { $root = ORM::factory("item", 1); - access::allow(group::everybody(), "view", $root); - $this->assert_true(access::group_can(group::everybody(), "view", $root)); + access::allow(identity::everybody(), "view", $root); + $this->assert_true(access::group_can(identity::everybody(), "view", $root)); } public function can_always_fails_on_unloaded_items_test() { $root = ORM::factory("item", 1); - access::allow(group::everybody(), "view", $root); - $this->assert_true(access::group_can(group::everybody(), "view", $root)); + access::allow(identity::everybody(), "view", $root); + $this->assert_true(access::group_can(identity::everybody(), "view", $root)); $bogus = ORM::factory("item", -1); - $this->assert_false(access::group_can(group::everybody(), "view", $bogus)); + $this->assert_false(access::group_can(identity::everybody(), "view", $bogus)); } public function cant_view_child_of_hidden_parent_test() { @@ -188,21 +185,21 @@ class Access_Helper_Test extends Unit_Test_Case { $album = album::create($root, rand(), "test album"); $root->reload(); - access::deny(group::everybody(), "view", $root); - access::reset(group::everybody(), "view", $album); + access::deny(identity::everybody(), "view", $root); + access::reset(identity::everybody(), "view", $album); $album->reload(); - $this->assert_false(access::group_can(group::everybody(), "view", $album)); + $this->assert_false(access::group_can(identity::everybody(), "view", $album)); } public function view_permissions_propagate_down_test() { $root = ORM::factory("item", 1); $album = album::create($root, rand(), "test album"); - access::allow(group::everybody(), "view", $root); - access::reset(group::everybody(), "view", $album); + access::allow(identity::everybody(), "view", $root); + access::reset(identity::everybody(), "view", $album); $album->reload(); - $this->assert_true(access::group_can(group::everybody(), "view", $album)); + $this->assert_true(access::group_can(identity::everybody(), "view", $album)); } public function can_toggle_view_permissions_propagate_down_test() { @@ -217,18 +214,18 @@ class Access_Helper_Test extends Unit_Test_Case { $album3->reload(); $album4->reload(); - access::allow(group::everybody(), "view", $root); - access::deny(group::everybody(), "view", $album1); - access::reset(group::everybody(), "view", $album2); - access::reset(group::everybody(), "view", $album3); - access::reset(group::everybody(), "view", $album4); + access::allow(identity::everybody(), "view", $root); + access::deny(identity::everybody(), "view", $album1); + access::reset(identity::everybody(), "view", $album2); + access::reset(identity::everybody(), "view", $album3); + access::reset(identity::everybody(), "view", $album4); $album4->reload(); - $this->assert_false(access::group_can(group::everybody(), "view", $album4)); + $this->assert_false(access::group_can(identity::everybody(), "view", $album4)); - access::allow(group::everybody(), "view", $album1); + access::allow(identity::everybody(), "view", $album1); $album4->reload(); - $this->assert_true(access::group_can(group::everybody(), "view", $album4)); + $this->assert_true(access::group_can(identity::everybody(), "view", $album4)); } public function revoked_view_permissions_cant_be_allowed_lower_down_test() { @@ -237,29 +234,29 @@ class Access_Helper_Test extends Unit_Test_Case { $album2 = album::create($album1, rand(), "test album"); $root->reload(); - access::deny(group::everybody(), "view", $root); - access::allow(group::everybody(), "view", $album2); + access::deny(identity::everybody(), "view", $root); + access::allow(identity::everybody(), "view", $album2); $album1->reload(); - $this->assert_false(access::group_can(group::everybody(), "view", $album1)); + $this->assert_false(access::group_can(identity::everybody(), "view", $album1)); $album2->reload(); - $this->assert_false(access::group_can(group::everybody(), "view", $album2)); + $this->assert_false(access::group_can(identity::everybody(), "view", $album2)); } public function can_edit_item_test() { $root = ORM::factory("item", 1); - access::allow(group::everybody(), "edit", $root); - $this->assert_true(access::group_can(group::everybody(), "edit", $root)); + access::allow(identity::everybody(), "edit", $root); + $this->assert_true(access::group_can(identity::everybody(), "edit", $root)); } public function non_view_permissions_propagate_down_test() { $root = ORM::factory("item", 1); $album = album::create($root, rand(), "test album"); - access::allow(group::everybody(), "edit", $root); - access::reset(group::everybody(), "edit", $album); - $this->assert_true(access::group_can(group::everybody(), "edit", $album)); + access::allow(identity::everybody(), "edit", $root); + access::reset(identity::everybody(), "edit", $album); + $this->assert_true(access::group_can(identity::everybody(), "edit", $album)); } public function non_view_permissions_can_be_revoked_lower_down_test() { @@ -279,36 +276,36 @@ class Access_Helper_Test extends Unit_Test_Case { $outer->reload(); $inner->reload(); - access::allow(group::everybody(), "edit", $root); - access::deny(group::everybody(), "edit", $outer); - access::allow(group::everybody(), "edit", $inner); + access::allow(identity::everybody(), "edit", $root); + access::deny(identity::everybody(), "edit", $outer); + access::allow(identity::everybody(), "edit", $inner); // Outer album is not editable, inner one is. - $this->assert_false(access::group_can(group::everybody(), "edit", $outer_photo)); - $this->assert_true(access::group_can(group::everybody(), "edit", $inner_photo)); + $this->assert_false(access::group_can(identity::everybody(), "edit", $outer_photo)); + $this->assert_true(access::group_can(identity::everybody(), "edit", $inner_photo)); } public function i_can_edit_test() { // Create a new user that belongs to no groups - $user = user::create("access_test", "Access Test", ""); + $user = identity::create_user("access_test", "Access Test", ""); foreach ($user->groups as $group) { $user->remove($group); } $user->save(); - user::set_active($user); + identity::set_active_user($user); // This user can't edit anything $root = ORM::factory("item", 1); $this->assert_false(access::can("edit", $root)); // Now add them to a group that has edit permission - $group = group::create("access_test"); + $group = identity::create_group("access_test"); $group->add($user); $group->save(); access::allow($group, "edit", $root); - $user = ORM::factory("user", $user->id); // reload() does not flush related columns - user::set_active($user); + $user = identity::lookup_user($user->id); // reload() does not flush related columns + identity::set_active_user($user); // And verify that the user can edit. $this->assert_true(access::can("edit", $root)); @@ -320,16 +317,16 @@ class Access_Helper_Test extends Unit_Test_Case { $this->assert_false(file_exists($album->file_path() . "/.htaccess")); - access::deny(group::everybody(), "view", $album); + access::deny(identity::everybody(), "view", $album); $this->assert_true(file_exists($album->file_path() . "/.htaccess")); - access::allow(group::everybody(), "view", $album); + access::allow(identity::everybody(), "view", $album); $this->assert_false(file_exists($album->file_path() . "/.htaccess")); - access::deny(group::everybody(), "view", $album); + access::deny(identity::everybody(), "view", $album); $this->assert_true(file_exists($album->file_path() . "/.htaccess")); - access::reset(group::everybody(), "view", $album); + access::reset(identity::everybody(), "view", $album); $this->assert_false(file_exists($album->file_path() . "/.htaccess")); } @@ -341,44 +338,44 @@ class Access_Helper_Test extends Unit_Test_Case { $this->assert_false(file_exists($album->resize_path() . "/.htaccess")); $this->assert_false(file_exists($album->thumb_path() . "/.htaccess")); - access::deny(group::everybody(), "view_full", $album); + access::deny(identity::everybody(), "view_full", $album); $this->assert_true(file_exists($album->file_path() . "/.htaccess")); $this->assert_false(file_exists($album->resize_path() . "/.htaccess")); $this->assert_false(file_exists($album->thumb_path() . "/.htaccess")); - access::allow(group::everybody(), "view_full", $album); + access::allow(identity::everybody(), "view_full", $album); $this->assert_false(file_exists($album->file_path() . "/.htaccess")); $this->assert_false(file_exists($album->resize_path() . "/.htaccess")); $this->assert_false(file_exists($album->thumb_path() . "/.htaccess")); - access::deny(group::everybody(), "view_full", $album); + access::deny(identity::everybody(), "view_full", $album); $this->assert_true(file_exists($album->file_path() . "/.htaccess")); $this->assert_false(file_exists($album->resize_path() . "/.htaccess")); $this->assert_false(file_exists($album->thumb_path() . "/.htaccess")); - access::reset(group::everybody(), "view_full", $album); + access::reset(identity::everybody(), "view_full", $album); $this->assert_false(file_exists($album->file_path() . "/.htaccess")); $this->assert_false(file_exists($album->resize_path() . "/.htaccess")); $this->assert_false(file_exists($album->thumb_path() . "/.htaccess")); } public function moved_items_inherit_new_permissions_test() { - user::set_active(user::lookup_by_name("admin")); + identity::set_active_user(identity::lookup_user_by_name("admin")); $root = ORM::factory("item", 1); $public_album = album::create($root, rand(), "public album"); $public_photo = photo::create($public_album, MODPATH . "gallery/images/gallery.png", "", ""); - access::allow(group::everybody(), "view", $public_album); + access::allow(identity::everybody(), "view", $public_album); $root->reload(); // Account for MPTT changes $private_album = album::create($root, rand(), "private album"); - access::deny(group::everybody(), "view", $private_album); + access::deny(identity::everybody(), "view", $private_album); $private_photo = photo::create($private_album, MODPATH . "gallery/images/gallery.png", "", ""); // Make sure that we now have a public photo and private photo. - $this->assert_true(access::group_can(group::everybody(), "view", $public_photo)); - $this->assert_false(access::group_can(group::everybody(), "view", $private_photo)); + $this->assert_true(access::group_can(identity::everybody(), "view", $public_photo)); + $this->assert_false(access::group_can(identity::everybody(), "view", $private_photo)); // Swap the photos item::move($public_photo, $private_album); @@ -394,7 +391,7 @@ class Access_Helper_Test extends Unit_Test_Case { $public_photo->reload(); // Make sure that the public_photo is now private, and the private_photo is now public. - $this->assert_false(access::group_can(group::everybody(), "view", $public_photo)); - $this->assert_true(access::group_can(group::everybody(), "view", $private_photo)); + $this->assert_false(access::group_can(identity::everybody(), "view", $public_photo)); + $this->assert_true(access::group_can(identity::everybody(), "view", $private_photo)); } } diff --git a/modules/gallery/tests/Albums_Controller_Test.php b/modules/gallery/tests/Albums_Controller_Test.php index d65946c7..8562355c 100644 --- a/modules/gallery/tests/Albums_Controller_Test.php +++ b/modules/gallery/tests/Albums_Controller_Test.php @@ -19,13 +19,13 @@ */ class Albums_Controller_Test extends Unit_Test_Case { public function setup() { - $this->_post = $_POST; - $this->_album = null; + $this->_save = array($_POST, $_SERVER); + $_SERVER["HTTP_REFERER"] = "HTTP_REFERER"; } public function teardown() { - $_POST = $this->_post; - if ($this->_album) { + list($_POST, $_SERVER) = $this->_save; + if (isset($this->_album)) { $this->_album->delete(); } } @@ -43,8 +43,9 @@ class Albums_Controller_Test extends Unit_Test_Case { $_POST["column"] = "weight"; $_POST["direction"] = "ASC"; $_POST["csrf"] = access::csrf_token(); + $_POST["slug"] = "new-name"; $_POST["_method"] = "put"; - access::allow(group::everybody(), "edit", $root); + access::allow(identity::everybody(), "edit", $root); ob_start(); $controller->_update($this->_album); @@ -52,7 +53,7 @@ class Albums_Controller_Test extends Unit_Test_Case { ob_end_clean(); $this->assert_equal( - json_encode(array("result" => "success")), + json_encode(array("result" => "success", "location" => "HTTP_REFERER")), $results); $this->assert_equal("new title", $this->_album->title); $this->assert_equal("new description", $this->_album->description); @@ -68,7 +69,7 @@ class Albums_Controller_Test extends Unit_Test_Case { $_POST["name"] = "new name"; $_POST["title"] = "new title"; $_POST["description"] = "new description"; - access::allow(group::everybody(), "edit", $root); + access::allow(identity::everybody(), "edit", $root); try { $controller->_update($this->_album); diff --git a/modules/gallery/tests/Controller_Auth_Test.php b/modules/gallery/tests/Controller_Auth_Test.php index caf6d8f2..0a7076c6 100644 --- a/modules/gallery/tests/Controller_Auth_Test.php +++ b/modules/gallery/tests/Controller_Auth_Test.php @@ -25,13 +25,18 @@ class Controller_Auth_Test extends Unit_Test_Case { public function find_missing_auth_test() { $found = array(); - $controllers = glob("*/*/controllers/*.php"); - $feeds = glob("*/*/helpers/*_rss.php"); + $controllers = explode("\n", `git ls-files '*/*/controllers/*.php'`); + $feeds = explode("\n", `git ls-files '*/*/helpers/*_rss.php'`); foreach (array_merge($controllers, $feeds) as $controller) { if (preg_match("{modules/(gallery_)?unit_test/}", $controller)) { continue; } + if (!$controller) { + // The last entry in each list from git ls-files appears to be an empty line + continue; + } + // List of all tokens without whitespace, simplifying parsing. $tokens = array(); foreach (token_get_all(file_get_contents($controller)) as $token) { @@ -118,7 +123,7 @@ class Controller_Auth_Test extends Unit_Test_Case { if ($token[1] == "access" && self::_token_matches(array(T_DOUBLE_COLON, "::"), $tokens, $token_number + 1) && self::_token_matches(array(T_STRING), $tokens, $token_number + 2) && - in_array($tokens[$token_number + 2][1], array("forbidden", "required")) && + in_array($tokens[$token_number + 2][1], array("forbidden", "required")) && self::_token_matches("(", $tokens, $token_number + 3)) { $token_number += 3; $function->checks_authorization(true); @@ -149,7 +154,7 @@ class Controller_Auth_Test extends Unit_Test_Case { } } } - } + } } // Generate the report diff --git a/modules/gallery/tests/Database_Test.php b/modules/gallery/tests/Database_Test.php index d83212ad..ad2bbba1 100644 --- a/modules/gallery/tests/Database_Test.php +++ b/modules/gallery/tests/Database_Test.php @@ -99,7 +99,7 @@ class Database_Test extends Unit_Test_Case { UNIQUE KEY(`name`)) ENGINE=InnoDB DEFAULT CHARSET=utf8"; $this->assert_same($expected, $converted); - + $sql = "UPDATE {test_tables} SET `name` = '{test string}' " . "WHERE `item_id` IN " . " (SELECT `id` FROM {items} " . @@ -116,12 +116,16 @@ class Database_Test extends Unit_Test_Case { $this->assert_same($expected, $sql); } - public function setup() { - } + function prefix_no_replacement_test() { + $update = Database_For_Test::instance()->from("test_tables") + ->where("1 = 1") + ->set(array("name" => "Test Name")) + ->update(); - public function teardown() { - } + $expected = "UPDATE `g3test_test_tables` SET `name` = 'Test Name' WHERE 1 = 1"; + $this->assert_same($expected, $update); + } } class Database_For_Test extends Database { @@ -131,4 +135,12 @@ class Database_For_Test extends Database { $db->config["table_prefix"] = "g3test_"; return $db; } + + public function query($sql = '') { + if (!empty($sql)) { + print " query($sql)\n"; + $sql = $this->add_table_prefixes($sql); + } + return $sql; + } } diff --git a/modules/gallery/tests/DrawForm_Test.php b/modules/gallery/tests/DrawForm_Test.php index dde54257..7ee80ca2 100644 --- a/modules/gallery/tests/DrawForm_Test.php +++ b/modules/gallery/tests/DrawForm_Test.php @@ -19,14 +19,14 @@ */ class DrawForm_Test extends Unit_Test_Case { function no_group_test() { - $form = new Forge("test/controller", "", "post", array("id" => "gTestGroupForm")); + $form = new Forge("test/controller", "", "post", array("id" => "g-test-group-form")); $form->input("title")->label(t("Title")); $form->textarea("description")->label(t("Text Area")); $form->submit("")->value(t("Submit")); $rendered = $form->__toString(); $expected = "<form action=\"http://./index.php/test/controller\" method=\"post\" " . - "id=\"gTestGroupForm\">\n" . + "id=\"g-test-group-form\">\n" . "<input type=\"hidden\" name=\"csrf\" value=\"" . access::csrf_token() . "\" />\n" . " <ul>\n" . " <li>\n" . @@ -48,7 +48,7 @@ class DrawForm_Test extends Unit_Test_Case { } function group_test() { - $form = new Forge("test/controller", "", "post", array("id" => "gTestGroupForm")); + $form = new Forge("test/controller", "", "post", array("id" => "g-test-group-form")); $group = $form->group("test_group")->label(t("Test Group")); $group->input("title")->label(t("Title")); $group->textarea("description")->label(t("Text Area")); @@ -56,7 +56,7 @@ class DrawForm_Test extends Unit_Test_Case { $rendered = $form->__toString(); $expected = "<form action=\"http://./index.php/test/controller\" method=\"post\" " . - "id=\"gTestGroupForm\">\n" . + "id=\"g-test-group-form\">\n" . "<input type=\"hidden\" name=\"csrf\" value=\"" . access::csrf_token() . "\" />\n" . " <fieldset>\n" . " <legend>Test Group</legend>\n" . @@ -81,7 +81,7 @@ class DrawForm_Test extends Unit_Test_Case { } function form_script_test() { - $form = new Forge("test/controller", "", "post", array("id" => "gTestGroupForm")); + $form = new Forge("test/controller", "", "post", array("id" => "g-test-group-form")); $group = $form->group("test_group")->label(t("Test Group")); $group->input("title")->label(t("Title")); $group->textarea("description")->label(t("Text Area")); @@ -92,7 +92,7 @@ class DrawForm_Test extends Unit_Test_Case { $rendered = $form->__toString(); $expected = "<form action=\"http://./index.php/test/controller\" method=\"post\" " . - "id=\"gTestGroupForm\">\n" . + "id=\"g-test-group-form\">\n" . "<input type=\"hidden\" name=\"csrf\" value=\"" . access::csrf_token() . "\" />\n" . " <fieldset>\n" . " <legend>Test Group</legend>\n" . diff --git a/modules/gallery/tests/File_Structure_Test.php b/modules/gallery/tests/File_Structure_Test.php index 9018f4c6..36342fda 100644 --- a/modules/gallery/tests/File_Structure_Test.php +++ b/modules/gallery/tests/File_Structure_Test.php @@ -17,6 +17,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ +require_once(MODPATH . "gallery/tests/Gallery_Filters.php"); + class File_Structure_Test extends Unit_Test_Case { public function no_trailing_closing_php_tag_test() { $dir = new GalleryCodeFilterIterator( @@ -233,7 +235,9 @@ class File_Structure_Test extends Unit_Test_Case { foreach ($info_files as $file) { foreach (file($file) as $line) { $parts = explode("=", $line, 2); - $values[trim($parts[0])] = trim($parts[1]); + if (isset($parts[1])) { + $values[trim($parts[0])] = trim($parts[1]); + } } $module = dirname($file); @@ -261,33 +265,3 @@ class File_Structure_Test extends Unit_Test_Case { } } } - -class PhpCodeFilterIterator extends FilterIterator { - public function accept() { - $path_name = $this->getInnerIterator()->getPathName(); - return substr($path_name, -4) == ".php"; - } -} - -class GalleryCodeFilterIterator extends FilterIterator { - public function accept() { - // Skip anything that we didn"t write - $path_name = $this->getInnerIterator()->getPathName(); - return !( - strpos($path_name, ".svn") || - strpos($path_name, DOCROOT . "test") !== false || - strpos($path_name, DOCROOT . "var") !== false || - strpos($path_name, MODPATH . "forge") !== false || - strpos($path_name, MODPATH . "gallery/views/kohana_error_page.php") !== false || - strpos($path_name, MODPATH . "gallery/views/kohana_profiler.php") !== false || - strpos($path_name, MODPATH . "gallery_unit_test/views/kohana_error_page.php") !== false || - strpos($path_name, MODPATH . "gallery_unit_test/views/kohana_unit_test_cli.php") !== false || - strpos($path_name, MODPATH . "unit_test") !== false || - strpos($path_name, MODPATH . "exif/lib") !== false || - strpos($path_name, MODPATH . "user/lib/PasswordHash") !== false || - strpos($path_name, DOCROOT . "lib/swfupload") !== false || - strpos($path_name, SYSPATH) !== false || - strpos($path_name, MODPATH . "gallery/libraries/HTMLPurifier") !== false || - substr($path_name, -1, 1) == "~"); - } -} diff --git a/modules/gallery/tests/Gallery_Filters.php b/modules/gallery/tests/Gallery_Filters.php new file mode 100644 index 00000000..d1bc2cfa --- /dev/null +++ b/modules/gallery/tests/Gallery_Filters.php @@ -0,0 +1,48 @@ +<?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 PhpCodeFilterIterator extends FilterIterator { + public function accept() { + $path_name = $this->getInnerIterator()->getPathName(); + return substr($path_name, -4) == ".php"; + } +} + +class GalleryCodeFilterIterator extends FilterIterator { + public function accept() { + // Skip anything that we didn"t write + $path_name = $this->getInnerIterator()->getPathName(); + return !( + strpos($path_name, ".svn") || + strpos($path_name, DOCROOT . "test") !== false || + strpos($path_name, DOCROOT . "var") !== false || + strpos($path_name, MODPATH . "forge") !== false || + strpos($path_name, MODPATH . "gallery/views/kohana_error_page.php") !== false || + strpos($path_name, MODPATH . "gallery/views/kohana_profiler.php") !== false || + strpos($path_name, MODPATH . "gallery_unit_test/views/kohana_error_page.php") !== false || + strpos($path_name, MODPATH . "gallery_unit_test/views/kohana_unit_test_cli.php") !== false || + strpos($path_name, MODPATH . "unit_test") !== false || + strpos($path_name, MODPATH . "exif/lib") !== false || + strpos($path_name, MODPATH . "user/lib/PasswordHash") !== false || + strpos($path_name, DOCROOT . "lib/swfupload") !== false || + strpos($path_name, SYSPATH) !== false || + strpos($path_name, MODPATH . "gallery/libraries/HTMLPurifier") !== false || + substr($path_name, -1, 1) == "~"); + } +} diff --git a/modules/gallery/tests/Item_Helper_Test.php b/modules/gallery/tests/Item_Helper_Test.php index 33fcdb73..a364423a 100644 --- a/modules/gallery/tests/Item_Helper_Test.php +++ b/modules/gallery/tests/Item_Helper_Test.php @@ -23,16 +23,16 @@ class Item_Helper_Test extends Unit_Test_Case { $root = ORM::factory("item", 1); $album = album::create($root, rand(), rand(), rand()); $item = self::_create_random_item($album); - user::set_active(user::guest()); + identity::set_active_user(identity::guest()); // We can see the item when permissions are granted - access::allow(group::everybody(), "view", $album); + access::allow(identity::everybody(), "view", $album); $this->assert_equal( 1, ORM::factory("item")->viewable()->where("id", $item->id)->count_all()); // We can't see the item when permissions are denied - access::deny(group::everybody(), "view", $album); + access::deny(identity::everybody(), "view", $album); $this->assert_equal( 0, ORM::factory("item")->viewable()->where("id", $item->id)->count_all()); diff --git a/modules/gallery/tests/Item_Model_Test.php b/modules/gallery/tests/Item_Model_Test.php index 84210e4c..e7dce893 100644 --- a/modules/gallery/tests/Item_Model_Test.php +++ b/modules/gallery/tests/Item_Model_Test.php @@ -24,12 +24,11 @@ class Item_Model_Test extends Unit_Test_Case { $this->assert_true(!empty($item->updated)); } - private static function _create_random_item() { - $item = ORM::factory("item"); - /* Set all required fields (values are irrelevant) */ - $item->name = rand(); - $item->type = "photo"; - return $item->add_to_parent(ORM::factory("item", 1)); + private static function _create_random_item($root=null, $rand=null) { + $root = $root ? $root : ORM::factory("item", 1); + $rand = $rand ? $rand : rand(); + $item = photo::create($root, MODPATH . "gallery/tests/test.jpg", "$rand.jpg", $rand, $rand); + return $item; } public function updating_doesnt_change_created_date_test() { @@ -62,7 +61,7 @@ class Item_Model_Test extends Unit_Test_Case { $this->assert_true(empty($item->updated)); } - public function move_photo_test() { + public function rename_photo_test() { // Create a test photo $item = self::_create_random_item(); @@ -86,14 +85,11 @@ class Item_Model_Test extends Unit_Test_Case { $this->assert_equal("file", file_get_contents($item->file_path())); } - public function move_album_test() { + public function rename_album_test() { // Create an album with a photo in it $root = ORM::factory("item", 1); $album = album::create($root, rand(), rand(), rand()); - $photo = ORM::factory("item"); - $photo->name = rand(); - $photo->type = "photo"; - $photo->add_to_parent($album); + $photo = self::_create_random_item($album); file_put_contents($photo->thumb_path(), "thumb"); file_put_contents($photo->resize_path(), "resize"); @@ -141,6 +137,24 @@ class Item_Model_Test extends Unit_Test_Case { $this->assert_false(true, "Item_Model::rename should not accept / characters"); } + public function item_rename_fails_with_existing_name_test() { + // Create a test photo + $item = self::_create_random_item(); + $item2 = self::_create_random_item(); + + $new_name = $item2->name; + + try { + $item->rename($new_name)->save(); + } catch (Exception $e) { + // pass + $this->assert_true(strpos($e->getMessage(), "INVALID_RENAME_FILE_EXISTS") !== false, + "incorrect exception."); + return; + } + $this->assert_false(true, "Item_Model::rename should fail."); + } + public function save_original_values_test() { $item = self::_create_random_item(); $item->title = "ORIGINAL_VALUE"; @@ -160,4 +174,102 @@ class Item_Model_Test extends Unit_Test_Case { $this->assert_equal("foo%20bar", $item->relative_url()); $this->assert_equal("foo%20bar.jpg", $item->relative_path()); } + + public function move_album_test() { + // Create an album with a photo in it + $root = ORM::factory("item", 1); + $album2 = album::create($root, rand(), rand(), rand()); + $album = album::create($album2, rand(), rand(), rand()); + $photo = self::_create_random_item($album); + + file_put_contents($photo->thumb_path(), "thumb"); + file_put_contents($photo->resize_path(), "resize"); + file_put_contents($photo->file_path(), "file"); + + // Now move the album + $album->move_to($root); + $photo->reload(); + + // Expected: + // * the album dirs are all moved + // * the photo's paths are all inside the albums paths + // * the photo files are all still intact and accessible + + $this->assert_same(0, strpos($photo->file_path(), $album->file_path())); + $this->assert_same(0, strpos($photo->thumb_path(), dirname($album->thumb_path()))); + $this->assert_same(0, strpos($photo->resize_path(), dirname($album->resize_path()))); + + $this->assert_equal("thumb", file_get_contents($photo->thumb_path())); + $this->assert_equal("resize", file_get_contents($photo->resize_path())); + $this->assert_equal("file", file_get_contents($photo->file_path())); + } + + public function move_photo_test() { + // Create an album with a photo in it + $root = ORM::factory("item", 1); + $album2 = album::create($root, rand(), rand(), rand()); + $album = album::create($album2, rand(), rand(), rand()); + $photo = self::_create_random_item($album); + + file_put_contents($photo->thumb_path(), "thumb"); + file_put_contents($photo->resize_path(), "resize"); + file_put_contents($photo->file_path(), "file"); + + // Now move the album + $photo->move_to($album2); + $photo->reload(); + + // Expected: + // * the album dirs are all moved + // * the photo's paths are all inside the albums paths + // * the photo files are all still intact and accessible + + $this->assert_same(0, strpos($photo->file_path(), $album->file_path())); + $this->assert_same(0, strpos($photo->thumb_path(), dirname($album->thumb_path()))); + $this->assert_same(0, strpos($photo->resize_path(), dirname($album->resize_path()))); + + $this->assert_equal("thumb", file_get_contents($photo->thumb_path())); + $this->assert_equal("resize", file_get_contents($photo->resize_path())); + $this->assert_equal("file", file_get_contents($photo->file_path())); + } + + public function move_album_fails_invalid_target_test() { + // Create an album with a photo in it + $root = ORM::factory("item", 1); + $name = rand(); + $album = album::create($root, $name, $name, $name); + $source = album::create($album, $name, $name, $name); + + try { + $source->move_to($root); + } catch (Exception $e) { + // pass + $this->assert_true(strpos($e->getMessage(), "INVALID_MOVE_TARGET_EXISTS") !== false, + "incorrect exception."); + return; + } + + $this->assert_false(true, "Item_Model::rename should not accept / characters"); + } + + public function move_photo_fails_invalid_target_test() { + // Create an album with a photo in it + $root = ORM::factory("item", 1); + $photo_name = rand(); + $photo1 = self::_create_random_item($root, $photo_name); + $name = rand(); + $album = album::create($root, $name, $name, $name); + $photo2 = self::_create_random_item($album, $photo_name); + + try { + $photo2->move_to($root); + } catch (Exception $e) { + // pass + $this->assert_true(strpos($e->getMessage(), "INVALID_MOVE_TARGET_EXISTS") !== false, + "incorrect exception."); + return; + } + + $this->assert_false(true, "Item_Model::rename should not accept / characters"); + } } diff --git a/modules/gallery/tests/Photos_Controller_Test.php b/modules/gallery/tests/Photos_Controller_Test.php index 0159b420..624e6878 100644 --- a/modules/gallery/tests/Photos_Controller_Test.php +++ b/modules/gallery/tests/Photos_Controller_Test.php @@ -19,11 +19,12 @@ */ class Photos_Controller_Test extends Unit_Test_Case { public function setup() { - $this->_post = $_POST; + $this->_save = array($_POST, $_SERVER); + $_SERVER["HTTP_REFERER"] = "HTTP_REFERER"; } public function teardown() { - $_POST = $this->_post; + list($_POST, $_SERVER) = $this->_save; } public function change_photo_test() { @@ -31,7 +32,7 @@ class Photos_Controller_Test extends Unit_Test_Case { $root = ORM::factory("item", 1); $photo = photo::create( $root, MODPATH . "gallery/tests/test.jpg", "test.jpeg", - "test", "test", user::active(), "slug"); + "test", "test", identity::active_user()->id, "slug"); $orig_name = $photo->name; $_POST["filename"] = "test.jpeg"; @@ -40,14 +41,15 @@ class Photos_Controller_Test extends Unit_Test_Case { $_POST["description"] = "new description"; $_POST["slug"] = "new-slug"; $_POST["csrf"] = access::csrf_token(); - access::allow(group::everybody(), "edit", $root); + access::allow(identity::everybody(), "edit", $root); ob_start(); $controller->_update($photo); $results = ob_get_contents(); ob_end_clean(); - $this->assert_equal(json_encode(array("result" => "success")), $results); + $this->assert_equal( + json_encode(array("result" => "success", "location" => "HTTP_REFERER")), $results); $this->assert_equal("new-slug", $photo->slug); $this->assert_equal("new title", $photo->title); $this->assert_equal("new description", $photo->description); @@ -64,7 +66,7 @@ class Photos_Controller_Test extends Unit_Test_Case { $_POST["name"] = "new name"; $_POST["title"] = "new title"; $_POST["description"] = "new description"; - access::allow(group::everybody(), "edit", $root); + access::allow(identity::everybody(), "edit", $root); try { $controller->_update($photo); diff --git a/modules/gallery/tests/Xss_Security_Test.php b/modules/gallery/tests/Xss_Security_Test.php index 16541017..b296d97c 100644 --- a/modules/gallery/tests/Xss_Security_Test.php +++ b/modules/gallery/tests/Xss_Security_Test.php @@ -248,7 +248,7 @@ class Xss_Security_Test extends Unit_Test_Case { $frame->is_safe_attr(true); } } - } + } } else if ($frame && $token[0] == T_OBJECT_OPERATOR) { $frame->expr_append($token[1]); @@ -349,7 +349,7 @@ class Xss_Security_Test extends Unit_Test_Case { $canonical = MODPATH . "gallery/tests/xss_data.txt"; exec("diff $canonical $new", $output, $return_value); $this->assert_false( - $return_value, "XSS golden file mismatch. Output:\n" . implode("\n", $output) ); + $return_value, "XSS golden file mismatch. Output:\n" . implode("\n", $output) ); } private static function _create_frame($token, $in_script_block, diff --git a/modules/gallery/tests/controller_auth_data.txt b/modules/gallery/tests/controller_auth_data.txt index fdf00c5e..30102538 100644 --- a/modules/gallery/tests/controller_auth_data.txt +++ b/modules/gallery/tests/controller_auth_data.txt @@ -9,6 +9,11 @@ modules/gallery/controllers/albums.php _form_add modules/gallery/controllers/combined.php javascript DIRTY_AUTH modules/gallery/controllers/combined.php css DIRTY_AUTH modules/gallery/controllers/file_proxy.php __call DIRTY_CSRF|DIRTY_AUTH +modules/gallery/controllers/login.php ajax DIRTY_AUTH +modules/gallery/controllers/login.php auth_ajax DIRTY_AUTH +modules/gallery/controllers/login.php html DIRTY_AUTH +modules/gallery/controllers/login.php auth_html DIRTY_AUTH +modules/gallery/controllers/logout.php index DIRTY_CSRF|DIRTY_AUTH modules/gallery/controllers/maintenance.php index DIRTY_AUTH modules/gallery/controllers/rest.php __construct DIRTY_AUTH modules/gallery/controllers/rest.php __call DIRTY_AUTH @@ -31,10 +36,5 @@ modules/server_add/controllers/admin_server_add.php autocomplete modules/server_add/controllers/server_add.php children DIRTY_CSRF modules/tag/controllers/admin_tags.php index DIRTY_CSRF modules/tag/controllers/tags.php _show DIRTY_CSRF|DIRTY_AUTH -modules/user/controllers/login.php ajax DIRTY_AUTH -modules/user/controllers/login.php auth_ajax DIRTY_AUTH -modules/user/controllers/login.php html DIRTY_AUTH -modules/user/controllers/login.php auth_html DIRTY_AUTH -modules/user/controllers/logout.php index DIRTY_CSRF|DIRTY_AUTH modules/user/controllers/password.php reset DIRTY_AUTH modules/user/controllers/password.php do_reset DIRTY_CSRF|DIRTY_AUTH diff --git a/modules/gallery/tests/selenium/Add_Comment.html b/modules/gallery/tests/selenium/Add_Comment.html index b4b96ed2..054e7597 100644 --- a/modules/gallery/tests/selenium/Add_Comment.html +++ b/modules/gallery/tests/selenium/Add_Comment.html @@ -18,22 +18,22 @@ </tr> <tr> <td>clickAndWait</td> - <td>gPhotoId-2</td> + <td>g-photo-id-2</td> <td></td> </tr> <tr> <td>type</td> - <td>gAuthor</td> + <td>g-author</td> <td>Test</td> </tr> <tr> <td>type</td> - <td>gEmail</td> + <td>g-email</td> <td>test@gmail.com</td> </tr> <tr> <td>type</td> - <td>gText</td> + <td>g-text</td> <td>This is a selenium test comment.</td> </tr> <tr> diff --git a/modules/gallery/tests/selenium/Login.html b/modules/gallery/tests/selenium/Login.html index 5e17a3c7..d2e45c63 100644 --- a/modules/gallery/tests/selenium/Login.html +++ b/modules/gallery/tests/selenium/Login.html @@ -18,17 +18,17 @@ </tr> <tr> <td>click</td> - <td>gLoginLink</td> + <td>g-login-link</td> <td></td> </tr> <tr> <td>type</td> - <td>gName</td> + <td>g-name</td> <td>admin</td> </tr> <tr> <td>type</td> - <td>gPassword</td> + <td>g-password</td> <td>admin</td> </tr> <tr> @@ -38,7 +38,7 @@ </tr> <tr> <td>clickAndWait</td> - <td>gUserProfileLink</td> + <td>g-user-profile-link</td> <td></td> </tr> diff --git a/modules/gallery/tests/xss_data.txt b/modules/gallery/tests/xss_data.txt index ff4a78a5..9146ddb2 100644 --- a/modules/gallery/tests/xss_data.txt +++ b/modules/gallery/tests/xss_data.txt @@ -1,24 +1,24 @@ modules/akismet/views/admin_akismet.html.php 16 DIRTY $form modules/akismet/views/admin_akismet_stats.html.php 9 DIRTY_ATTR $api_key modules/akismet/views/admin_akismet_stats.html.php 9 DIRTY_ATTR urlencode($blog_url) -modules/comment/views/admin_block_recent_comments.html.php 4 DIRTY_ATTR ($i%2==0)?"gEvenRow":"gOddRow" +modules/comment/views/admin_block_recent_comments.html.php 4 DIRTY_ATTR text::alternate("g-even","g-odd") modules/comment/views/admin_block_recent_comments.html.php 5 DIRTY_ATTR $comment->author()->avatar_url(32,$theme->url(,true)) modules/comment/views/admin_block_recent_comments.html.php 10 DIRTY gallery::date_time($comment->created) -modules/comment/views/admin_comments.html.php 42 DIRTY $menu -modules/comment/views/admin_comments.html.php 106 DIRTY_ATTR $comment->id -modules/comment/views/admin_comments.html.php 106 DIRTY_ATTR ($i%2==0)?"gOddRow":"gEvenRow" -modules/comment/views/admin_comments.html.php 109 DIRTY_ATTR $comment->author()->avatar_url(40,$theme->url(,true)) -modules/comment/views/admin_comments.html.php 122 DIRTY_JS $item->url() -modules/comment/views/admin_comments.html.php 124 DIRTY_ATTR $item->thumb_url() -modules/comment/views/admin_comments.html.php 126 DIRTY photo::img_dimensions($item->thumb_width,$item->thumb_height,75) -modules/comment/views/admin_comments.html.php 134 DIRTY gallery::date($comment->created) -modules/comment/views/admin_comments.html.php 141 DIRTY_JS $comment->id -modules/comment/views/admin_comments.html.php 150 DIRTY_JS $comment->id -modules/comment/views/admin_comments.html.php 159 DIRTY_JS $comment->id -modules/comment/views/admin_comments.html.php 168 DIRTY_JS $comment->id -modules/comment/views/admin_comments.html.php 175 DIRTY_JS $comment->id -modules/comment/views/admin_comments.html.php 183 DIRTY_JS $comment->id -modules/comment/views/admin_comments.html.php 196 DIRTY $pager +modules/comment/views/admin_comments.html.php 43 DIRTY $menu->render() +modules/comment/views/admin_comments.html.php 107 DIRTY_ATTR $comment->id +modules/comment/views/admin_comments.html.php 107 DIRTY_ATTR text::alternate("g-odd","g-even") +modules/comment/views/admin_comments.html.php 110 DIRTY_ATTR $comment->author()->avatar_url(40,$theme->url(,true)) +modules/comment/views/admin_comments.html.php 123 DIRTY_JS $item->url() +modules/comment/views/admin_comments.html.php 125 DIRTY_ATTR $item->thumb_url() +modules/comment/views/admin_comments.html.php 127 DIRTY photo::img_dimensions($item->thumb_width,$item->thumb_height,75) +modules/comment/views/admin_comments.html.php 135 DIRTY gallery::date($comment->created) +modules/comment/views/admin_comments.html.php 142 DIRTY_JS $comment->id +modules/comment/views/admin_comments.html.php 151 DIRTY_JS $comment->id +modules/comment/views/admin_comments.html.php 160 DIRTY_JS $comment->id +modules/comment/views/admin_comments.html.php 169 DIRTY_JS $comment->id +modules/comment/views/admin_comments.html.php 176 DIRTY_JS $comment->id +modules/comment/views/admin_comments.html.php 184 DIRTY_JS $comment->id +modules/comment/views/admin_comments.html.php 197 DIRTY $pager modules/comment/views/comment.html.php 2 DIRTY_ATTR $comment->id; modules/comment/views/comment.html.php 5 DIRTY_ATTR $comment->author()->avatar_url(40,$theme->url(,true)) modules/comment/views/comment.mrss.php 10 DIRTY $feed->uri @@ -39,7 +39,8 @@ modules/digibug/views/digibug_form.html.php 5 DIRTY form:: modules/digibug/views/digibug_form.html.php 6 DIRTY form::close() modules/exif/views/exif_dialog.html.php 14 DIRTY $details[$i]["caption"] modules/exif/views/exif_dialog.html.php 21 DIRTY $details[$i]["caption"] -modules/g2_import/views/admin_g2_import.html.php 28 DIRTY $form +modules/g2_import/views/admin_g2_import.html.php 29 DIRTY $form +modules/gallery/views/admin_advanced_settings.html.php 21 DIRTY_ATTR text::alternate("g-odd","g-even") modules/gallery/views/admin_advanced_settings.html.php 22 DIRTY $var->module_name modules/gallery/views/admin_block_log_entries.html.php 4 DIRTY_ATTR log::severity_class($entry->severity) modules/gallery/views/admin_block_log_entries.html.php 6 DIRTY gallery::date_time($entry->timestamp) @@ -53,61 +54,74 @@ modules/gallery/views/admin_block_photo_stream.html.php 6 DIRTY photo: modules/gallery/views/admin_block_photo_stream.html.php 7 DIRTY_ATTR $photo->thumb_url() modules/gallery/views/admin_dashboard.html.php 5 DIRTY_JS $csrf modules/gallery/views/admin_dashboard.html.php 35 DIRTY $blocks -modules/gallery/views/admin_graphics.html.php 22 DIRTY newView("admin_graphics_none.html") -modules/gallery/views/admin_graphics.html.php 24 DIRTY newView("admin_graphics_$active.html",array("tk"=>$tk->$active,"is_active"=>true)) -modules/gallery/views/admin_graphics.html.php 31 DIRTY newView("admin_graphics_$id.html",array("tk"=>$tk->$id,"is_active"=>false)) -modules/gallery/views/admin_graphics_gd.html.php 2 DIRTY_ATTR $is_active?" gSelected":"" -modules/gallery/views/admin_graphics_gd.html.php 2 DIRTY_ATTR $tk->installed?" gInstalledToolkit":" gUnavailable" +modules/gallery/views/admin_graphics.html.php 24 DIRTY newView("admin_graphics_none.html") +modules/gallery/views/admin_graphics.html.php 26 DIRTY newView("admin_graphics_$active.html",array("tk"=>$tk->$active,"is_active"=>true)) +modules/gallery/views/admin_graphics.html.php 33 DIRTY newView("admin_graphics_$id.html",array("tk"=>$tk->$id,"is_active"=>false)) +modules/gallery/views/admin_graphics_gd.html.php 2 DIRTY_ATTR $is_active?" g-selected":"" +modules/gallery/views/admin_graphics_gd.html.php 2 DIRTY_ATTR $tk->installed?" g-installed-toolkit":" g-unavailable" modules/gallery/views/admin_graphics_gd.html.php 19 DIRTY $tk->error -modules/gallery/views/admin_graphics_graphicsmagick.html.php 2 DIRTY_ATTR $is_active?" gSelected":"" -modules/gallery/views/admin_graphics_graphicsmagick.html.php 2 DIRTY_ATTR $tk->installed?" gInstalledToolkit":" gUnavailable" +modules/gallery/views/admin_graphics_graphicsmagick.html.php 2 DIRTY_ATTR $is_active?" g-selected":"" +modules/gallery/views/admin_graphics_graphicsmagick.html.php 2 DIRTY_ATTR $tk->installed?" g-installed-toolkit":" g-unavailable" modules/gallery/views/admin_graphics_graphicsmagick.html.php 18 DIRTY $tk->error -modules/gallery/views/admin_graphics_imagemagick.html.php 2 DIRTY_ATTR $is_active?" gSelected":"" -modules/gallery/views/admin_graphics_imagemagick.html.php 2 DIRTY_ATTR $tk->installed?" gInstalledToolkit":" gUnavailable" +modules/gallery/views/admin_graphics_imagemagick.html.php 2 DIRTY_ATTR $is_active?" g-selected":"" +modules/gallery/views/admin_graphics_imagemagick.html.php 2 DIRTY_ATTR $tk->installed?" g-installed-toolkit":" g-unavailable" modules/gallery/views/admin_graphics_imagemagick.html.php 18 DIRTY $tk->error -modules/gallery/views/admin_languages.html.php 9 DIRTY access::csrf_form_field() -modules/gallery/views/admin_languages.html.php 27 DIRTY_ATTR (isset($installed_locales[$code]))?"installed":"" -modules/gallery/views/admin_languages.html.php 27 DIRTY_ATTR ($default_locale==$code)?" default":"" -modules/gallery/views/admin_languages.html.php 28 DIRTY form::checkbox("installed_locales[]",$code,isset($installed_locales[$code])) -modules/gallery/views/admin_languages.html.php 29 DIRTY $display_name -modules/gallery/views/admin_languages.html.php 31 DIRTY form::radio("default_locale",$code,($default_locale==$code),((isset($installed_locales[$code]))?'':'disabled="disabled"')) -modules/gallery/views/admin_languages.html.php 102 DIRTY $share_translations_form -modules/gallery/views/admin_maintenance.html.php 24 DIRTY_ATTR ($i%2==0)?"gOddRow":"gEvenRow" +modules/gallery/views/admin_identity.html.php 43 DIRTY access::csrf_form_field() +modules/gallery/views/admin_identity.html.php 50 DIRTY_ATTR text::alternate("g-odd","g-even") +modules/gallery/views/admin_identity.html.php 52 DIRTY form::radio($data,$module_name,$module_name==$active) +modules/gallery/views/admin_identity_confirm.html.php 3 DIRTY access::csrf_form_field() +modules/gallery/views/admin_identity_confirm.html.php 4 DIRTY form::hidden("provider",$new_provider) +modules/gallery/views/admin_languages.html.php 43 DIRTY access::csrf_form_field() +modules/gallery/views/admin_languages.html.php 60 DIRTY_ATTR (isset($installed_locales[$code]))?"g-available":"" +modules/gallery/views/admin_languages.html.php 60 DIRTY_ATTR ($default_locale==$code)?" g-selected":"" +modules/gallery/views/admin_languages.html.php 61 DIRTY form::checkbox("installed_locales[]",$code,isset($installed_locales[$code])) +modules/gallery/views/admin_languages.html.php 62 DIRTY $display_name +modules/gallery/views/admin_languages.html.php 64 DIRTY form::radio("default_locale",$code,($default_locale==$code),((isset($installed_locales[$code]))?'':'disabled="disabled"')) +modules/gallery/views/admin_languages.html.php 109 DIRTY $share_translations_form +modules/gallery/views/admin_maintenance.html.php 24 DIRTY_ATTR text::alternate("g-odd","g-even") modules/gallery/views/admin_maintenance.html.php 24 DIRTY_ATTR log::severity_class($task->severity) modules/gallery/views/admin_maintenance.html.php 25 DIRTY_ATTR log::severity_class($task->severity) modules/gallery/views/admin_maintenance.html.php 26 DIRTY $task->name modules/gallery/views/admin_maintenance.html.php 29 DIRTY $task->description -modules/gallery/views/admin_maintenance.html.php 72 DIRTY_ATTR ($i%2==0)?"gOddRow":"gEvenRow" -modules/gallery/views/admin_maintenance.html.php 72 DIRTY_ATTR $task->state=="stalled"?"gWarning":"" -modules/gallery/views/admin_maintenance.html.php 73 DIRTY_ATTR $task->state=="stalled"?"gWarning":"" -modules/gallery/views/admin_maintenance.html.php 74 DIRTY gallery::date_time($task->updated) -modules/gallery/views/admin_maintenance.html.php 77 DIRTY $task->name -modules/gallery/views/admin_maintenance.html.php 92 DIRTY $task->status -modules/gallery/views/admin_maintenance.html.php 145 DIRTY_ATTR ($i%2==0)?"gOddRow":"gEvenRow" -modules/gallery/views/admin_maintenance.html.php 145 DIRTY_ATTR $task->state=="success"?"gSuccess":"gError" -modules/gallery/views/admin_maintenance.html.php 146 DIRTY_ATTR $task->state=="success"?"gSuccess":"gError" -modules/gallery/views/admin_maintenance.html.php 147 DIRTY gallery::date_time($task->updated) -modules/gallery/views/admin_maintenance.html.php 150 DIRTY $task->name -modules/gallery/views/admin_maintenance.html.php 162 DIRTY $task->status +modules/gallery/views/admin_maintenance.html.php 70 DIRTY_ATTR text::alternate("g-odd","g-even") +modules/gallery/views/admin_maintenance.html.php 70 DIRTY_ATTR $task->state=="stalled"?"g-warning":"" +modules/gallery/views/admin_maintenance.html.php 71 DIRTY_ATTR $task->state=="stalled"?"g-warning":"" +modules/gallery/views/admin_maintenance.html.php 72 DIRTY gallery::date_time($task->updated) +modules/gallery/views/admin_maintenance.html.php 75 DIRTY $task->name +modules/gallery/views/admin_maintenance.html.php 90 DIRTY $task->status +modules/gallery/views/admin_maintenance.html.php 141 DIRTY_ATTR text::alternate("g-odd","g-even") +modules/gallery/views/admin_maintenance.html.php 141 DIRTY_ATTR $task->state=="success"?"g-success":"g-error" +modules/gallery/views/admin_maintenance.html.php 142 DIRTY_ATTR $task->state=="success"?"g-success":"g-error" +modules/gallery/views/admin_maintenance.html.php 143 DIRTY gallery::date_time($task->updated) +modules/gallery/views/admin_maintenance.html.php 146 DIRTY $task->name +modules/gallery/views/admin_maintenance.html.php 158 DIRTY $task->status modules/gallery/views/admin_maintenance_show_log.html.php 8 DIRTY_JS url::site("admin/maintenance/save_log/$task->id?csrf=$csrf") modules/gallery/views/admin_maintenance_show_log.html.php 13 DIRTY $task->name modules/gallery/views/admin_maintenance_task.html.php 55 DIRTY $task->name -modules/gallery/views/admin_modules.html.php 9 DIRTY access::csrf_form_field() -modules/gallery/views/admin_modules.html.php 19 DIRTY_ATTR ($i%2==0)?"gOddRow":"gEvenRow" +modules/gallery/views/admin_modules.html.php 10 DIRTY access::csrf_form_field() +modules/gallery/views/admin_modules.html.php 19 DIRTY_ATTR text::alternate("g-odd","g-even") modules/gallery/views/admin_modules.html.php 22 DIRTY form::checkbox($data,'1',module::is_active($module_name)) modules/gallery/views/admin_modules.html.php 24 DIRTY $module_info->version -modules/gallery/views/admin_theme_options.html.php 5 DIRTY $form +modules/gallery/views/admin_sidebar.html.php 50 DIRTY $available +modules/gallery/views/admin_sidebar.html.php 58 DIRTY $active +modules/gallery/views/admin_sidebar_blocks.html.php 4 DIRTY_ATTR $ref +modules/gallery/views/admin_sidebar_blocks.html.php 4 DIRTY $text +modules/gallery/views/admin_theme_options.html.php 6 DIRTY $form modules/gallery/views/admin_themes.html.php 3 DIRTY_JS url::site("admin/themes/choose") modules/gallery/views/admin_themes.html.php 5 DIRTY_JS $csrf -modules/gallery/views/admin_themes.html.php 20 DIRTY $themes[$site]->name -modules/gallery/views/admin_themes.html.php 22 DIRTY $themes[$site]->description -modules/gallery/views/admin_themes.html.php 36 DIRTY $info->name -modules/gallery/views/admin_themes.html.php 38 DIRTY $info->description -modules/gallery/views/admin_themes.html.php 58 DIRTY $themes[$admin]->name -modules/gallery/views/admin_themes.html.php 60 DIRTY $themes[$admin]->description -modules/gallery/views/admin_themes.html.php 74 DIRTY $info->name -modules/gallery/views/admin_themes.html.php 76 DIRTY $info->description +modules/gallery/views/admin_themes.html.php 22 DIRTY $themes[$site]->name +modules/gallery/views/admin_themes.html.php 24 DIRTY $themes[$site]->description +modules/gallery/views/admin_themes.html.php 38 DIRTY $info->name +modules/gallery/views/admin_themes.html.php 40 DIRTY $info->description +modules/gallery/views/admin_themes.html.php 60 DIRTY $themes[$admin]->name +modules/gallery/views/admin_themes.html.php 62 DIRTY $themes[$admin]->description +modules/gallery/views/admin_themes.html.php 76 DIRTY $info->name +modules/gallery/views/admin_themes.html.php 78 DIRTY $info->description modules/gallery/views/admin_themes_preview.html.php 7 DIRTY_ATTR $url +modules/gallery/views/in_place_edit.html.php 2 DIRTY form::open($action,array("method"=>"post","id"=>"g-in-place-edit-form","class"=>"g-short-form"),$hidden) +modules/gallery/views/in_place_edit.html.php 5 DIRTY form::input("input",$form["input"]," class='textbox'") +modules/gallery/views/in_place_edit.html.php 12 DIRTY form::close() +modules/gallery/views/in_place_edit.html.php 14 DIRTY $errors["input"] modules/gallery/views/kohana_error_page.php 102 DIRTY $message modules/gallery/views/kohana_error_page.php 116 DIRTY $trace modules/gallery/views/kohana_profiler.php 32 DIRTY $profile->render(); @@ -125,7 +139,23 @@ modules/gallery/views/l10n_client.html.php 54 DIRTY form:: modules/gallery/views/l10n_client.html.php 58 DIRTY form::textarea("l10n-edit-plural-translation-few","",' rows="2"') modules/gallery/views/l10n_client.html.php 62 DIRTY form::textarea("l10n-edit-plural-translation-many","",' rows="2"') modules/gallery/views/l10n_client.html.php 67 DIRTY form::textarea("l10n-edit-plural-translation-other","",' rows="2"') -modules/gallery/views/maintenance.html.php 46 DIRTY user::get_login_form("login/auth_html") +modules/gallery/views/login_ajax.html.php 6 DIRTY_JS url::site("password/reset") +modules/gallery/views/login_ajax.html.php 37 DIRTY $form +modules/gallery/views/maintenance.html.php 46 DIRTY auth::get_login_form("login/auth_html") +modules/gallery/views/menu.html.php 4 DIRTY isset($menu->css_id)?"id='$menu->css_id'":"" +modules/gallery/views/menu.html.php 4 DIRTY_ATTR $menu->css_class +modules/gallery/views/menu.html.php 6 DIRTY $element->render() +modules/gallery/views/menu.html.php 18 DIRTY $element->render() +modules/gallery/views/menu_ajax_link.html.php 3 DIRTY_ATTR $menu->css_id +modules/gallery/views/menu_ajax_link.html.php 4 DIRTY_ATTR $menu->css_class +modules/gallery/views/menu_ajax_link.html.php 5 DIRTY_JS $menu->url +modules/gallery/views/menu_ajax_link.html.php 7 DIRTY $menu->ajax_handler +modules/gallery/views/menu_dialog.html.php 3 DIRTY_ATTR $menu->css_id +modules/gallery/views/menu_dialog.html.php 4 DIRTY_ATTR $menu->css_class +modules/gallery/views/menu_dialog.html.php 5 DIRTY_JS $menu->url +modules/gallery/views/menu_link.html.php 3 DIRTY_ATTR $menu->css_id +modules/gallery/views/menu_link.html.php 4 DIRTY_ATTR $menu->css_class +modules/gallery/views/menu_link.html.php 5 DIRTY_JS $menu->url modules/gallery/views/move_browse.html.php 4 DIRTY_JS url::site("move/show_sub_tree/{$source->id}/__TARGETID__") modules/gallery/views/move_browse.html.php 39 DIRTY $tree modules/gallery/views/move_browse.html.php 43 DIRTY access::csrf_form_field() @@ -143,42 +173,51 @@ modules/gallery/views/movieplayer.html.php 7 DIRTY_JS url::a modules/gallery/views/movieplayer.html.php 13 DIRTY_JS url::abs_file("lib/flowplayer.h264streaming.swf") modules/gallery/views/permissions_browse.html.php 3 DIRTY_JS url::site("permissions/form/__ITEM__") modules/gallery/views/permissions_browse.html.php 16 DIRTY_JS url::site("permissions/change/__CMD__/__GROUP__/__PERM__/__ITEM__?csrf=$csrf") -modules/gallery/views/permissions_browse.html.php 42 DIRTY_ATTR $parent->id -modules/gallery/views/permissions_browse.html.php 44 DIRTY_JS $parent->id +modules/gallery/views/permissions_browse.html.php 43 DIRTY_ATTR $parent->id +modules/gallery/views/permissions_browse.html.php 45 DIRTY_JS $parent->id modules/gallery/views/permissions_browse.html.php 52 DIRTY_ATTR $item->id modules/gallery/views/permissions_browse.html.php 53 DIRTY_JS $item->id modules/gallery/views/permissions_browse.html.php 60 DIRTY $form -modules/gallery/views/permissions_form.html.php 24 DIRTY_JS $lock->id -modules/gallery/views/permissions_form.html.php 32 DIRTY_JS $group->id -modules/gallery/views/permissions_form.html.php 32 DIRTY_JS $permission->id -modules/gallery/views/permissions_form.html.php 32 DIRTY_JS $item->id -modules/gallery/views/permissions_form.html.php 36 DIRTY_JS $group->id -modules/gallery/views/permissions_form.html.php 36 DIRTY_JS $permission->id -modules/gallery/views/permissions_form.html.php 36 DIRTY_JS $item->id -modules/gallery/views/permissions_form.html.php 43 DIRTY_JS $group->id -modules/gallery/views/permissions_form.html.php 43 DIRTY_JS $permission->id -modules/gallery/views/permissions_form.html.php 43 DIRTY_JS $item->id -modules/gallery/views/permissions_form.html.php 47 DIRTY_JS $group->id -modules/gallery/views/permissions_form.html.php 47 DIRTY_JS $permission->id -modules/gallery/views/permissions_form.html.php 47 DIRTY_JS $item->id -modules/gallery/views/permissions_form.html.php 56 DIRTY_JS $group->id -modules/gallery/views/permissions_form.html.php 56 DIRTY_JS $permission->id -modules/gallery/views/permissions_form.html.php 56 DIRTY_JS $item->id -modules/gallery/views/permissions_form.html.php 63 DIRTY_JS $group->id -modules/gallery/views/permissions_form.html.php 63 DIRTY_JS $permission->id -modules/gallery/views/permissions_form.html.php 63 DIRTY_JS $item->id -modules/gallery/views/permissions_form.html.php 74 DIRTY_JS $group->id -modules/gallery/views/permissions_form.html.php 74 DIRTY_JS $permission->id -modules/gallery/views/permissions_form.html.php 74 DIRTY_JS $item->id -modules/gallery/views/permissions_form.html.php 79 DIRTY_JS $group->id -modules/gallery/views/permissions_form.html.php 79 DIRTY_JS $permission->id -modules/gallery/views/permissions_form.html.php 79 DIRTY_JS $item->id -modules/gallery/views/upgrader.html.php 44 DIRTY_ATTR $module->version==$module->code_version?"current":"upgradeable" -modules/gallery/views/upgrader.html.php 45 DIRTY_ATTR $id -modules/gallery/views/upgrader.html.php 49 DIRTY $module->version -modules/gallery/views/upgrader.html.php 52 DIRTY $module->code_version +modules/gallery/views/permissions_form.html.php 26 DIRTY_JS $lock->id +modules/gallery/views/permissions_form.html.php 34 DIRTY_JS $group->id +modules/gallery/views/permissions_form.html.php 34 DIRTY_JS $permission->id +modules/gallery/views/permissions_form.html.php 34 DIRTY_JS $item->id +modules/gallery/views/permissions_form.html.php 37 DIRTY_JS $group->id +modules/gallery/views/permissions_form.html.php 37 DIRTY_JS $permission->id +modules/gallery/views/permissions_form.html.php 37 DIRTY_JS $item->id +modules/gallery/views/permissions_form.html.php 44 DIRTY_JS $group->id +modules/gallery/views/permissions_form.html.php 44 DIRTY_JS $permission->id +modules/gallery/views/permissions_form.html.php 44 DIRTY_JS $item->id +modules/gallery/views/permissions_form.html.php 48 DIRTY_JS $group->id +modules/gallery/views/permissions_form.html.php 48 DIRTY_JS $permission->id +modules/gallery/views/permissions_form.html.php 48 DIRTY_JS $item->id +modules/gallery/views/permissions_form.html.php 57 DIRTY_JS $group->id +modules/gallery/views/permissions_form.html.php 57 DIRTY_JS $permission->id +modules/gallery/views/permissions_form.html.php 57 DIRTY_JS $item->id +modules/gallery/views/permissions_form.html.php 64 DIRTY_JS $group->id +modules/gallery/views/permissions_form.html.php 64 DIRTY_JS $permission->id +modules/gallery/views/permissions_form.html.php 64 DIRTY_JS $item->id +modules/gallery/views/permissions_form.html.php 75 DIRTY_JS $group->id +modules/gallery/views/permissions_form.html.php 75 DIRTY_JS $permission->id +modules/gallery/views/permissions_form.html.php 75 DIRTY_JS $item->id +modules/gallery/views/permissions_form.html.php 80 DIRTY_JS $group->id +modules/gallery/views/permissions_form.html.php 80 DIRTY_JS $permission->id +modules/gallery/views/permissions_form.html.php 80 DIRTY_JS $item->id +modules/gallery/views/simple_uploader.html.php 7 DIRTY_JS url::file("lib/uploadify/uploadify.swf") +modules/gallery/views/simple_uploader.html.php 8 DIRTY_JS url::site("simple_uploader/add_photo/{$item->id}") +modules/gallery/views/simple_uploader.html.php 15 DIRTY_JS url::file("lib/uploadify/cancel.png") +modules/gallery/views/simple_uploader.html.php 43 DIRTY_JS t("Completed") +modules/gallery/views/upgrader.html.php 57 DIRTY_ATTR $done?"muted":"" +modules/gallery/views/upgrader.html.php 61 DIRTY_ATTR $done?"muted":"" +modules/gallery/views/upgrader.html.php 69 DIRTY_ATTR $module->version==$module->code_version?"current":"upgradeable" +modules/gallery/views/upgrader.html.php 70 DIRTY_ATTR $id +modules/gallery/views/upgrader.html.php 74 DIRTY $module->version +modules/gallery/views/upgrader.html.php 77 DIRTY $module->code_version +modules/gallery/views/upgrader.html.php 99 DIRTY_ATTR $done?"muted":"" +modules/gallery/views/upgrader.html.php 102 DIRTY_ATTR $done?"muted":"" +modules/gallery/views/user_languages_block.html.php 2 DIRTY form::dropdown("g-select-session-locale",$installed_locales,$selected) modules/image_block/views/image_block_block.html.php 3 DIRTY_JS $item->url() -modules/image_block/views/image_block_block.html.php 4 DIRTY $item->thumb_img(array("class"=>"gThumbnail")) +modules/image_block/views/image_block_block.html.php 4 DIRTY $item->thumb_img(array("class"=>"g-thumbnail")) modules/info/views/info_block.html.php 22 DIRTY date("M j, Y H:i:s",$item->captured) modules/info/views/info_block.html.php 29 DIRTY_JS $item->owner->url modules/notification/views/comment_published.html.php 28 DIRTY_JS $comment->item()->abs_url() @@ -193,24 +232,24 @@ modules/organize/views/organize_dialog.html.php 3 DIRTY_JS url::s modules/organize/views/organize_dialog.html.php 4 DIRTY_JS url::site("organize/rearrange/__TARGET_ID__/__BEFORE__?csrf=$csrf") modules/organize/views/organize_dialog.html.php 5 DIRTY_JS url::site("organize/sort_order/__ALBUM_ID__/__COL__/__DIR__?csrf=$csrf") modules/organize/views/organize_dialog.html.php 6 DIRTY_JS url::site("organize/tree/__ALBUM_ID__") -modules/organize/views/organize_dialog.html.php 22 DIRTY $album_tree -modules/organize/views/organize_dialog.html.php 29 DIRTY $micro_thumb_grid -modules/organize/views/organize_dialog.html.php 37 DIRTY form::dropdown(array("id"=>"gOrganizeSortColumn"),album::get_sort_order_options(),$album->sort_column) -modules/organize/views/organize_dialog.html.php 38 DIRTY form::dropdown(array("id"=>"gOrganizeSortOrder"),array("ASC"=>"Ascending","DESC"=>"Descending"),$album->sort_order) +modules/organize/views/organize_dialog.html.php 20 DIRTY $album_tree +modules/organize/views/organize_dialog.html.php 27 DIRTY $micro_thumb_grid +modules/organize/views/organize_dialog.html.php 35 DIRTY form::dropdown(array("id"=>"g-organize-sort-column"),album::get_sort_order_options(),$album->sort_column) +modules/organize/views/organize_dialog.html.php 36 DIRTY form::dropdown(array("id"=>"g-organize-sort-order"),array("ASC"=>"Ascending","DESC"=>"Descending"),$album->sort_order) modules/organize/views/organize_thumb_grid.html.php 3 DIRTY_ATTR $child->id modules/organize/views/organize_thumb_grid.html.php 4 DIRTY_ATTR $child->id -modules/organize/views/organize_thumb_grid.html.php 5 DIRTY_ATTR $child->is_album()?"gAlbum":"gPhoto" -modules/organize/views/organize_thumb_grid.html.php 6 DIRTY $child->thumb_img(array("class"=>"gThumbnail","ref"=>$child->id),90,true) +modules/organize/views/organize_thumb_grid.html.php 5 DIRTY_ATTR $child->is_album()?"g-album":"g-photo" +modules/organize/views/organize_thumb_grid.html.php 6 DIRTY $child->thumb_img(array("class"=>"g-thumbnail","ref"=>$child->id),90,true) modules/organize/views/organize_thumb_grid.html.php 14 DIRTY_JS url::site("organize/album/$album->id/".($offset+25)) -modules/organize/views/organize_tree.html.php 2 DIRTY_ATTR access::can("edit",$album)?"":"gViewOnly" +modules/organize/views/organize_tree.html.php 2 DIRTY_ATTR access::can("edit",$album)?"":"g-view-only" modules/organize/views/organize_tree.html.php 3 DIRTY_ATTR $album->id modules/organize/views/organize_tree.html.php 6 DIRTY_ATTR $selected&&$album->id==$selected->id?"selected":"" modules/organize/views/organize_tree.html.php 7 DIRTY_ATTR $album->id modules/organize/views/organize_tree.html.php 13 DIRTY View::factory("organize_tree.html",array("selected"=>$selected,"album"=>$child)); -modules/organize/views/organize_tree.html.php 15 DIRTY_ATTR access::can("edit",$child)?"":"gViewOnly" +modules/organize/views/organize_tree.html.php 15 DIRTY_ATTR access::can("edit",$child)?"":"g-view-only" modules/organize/views/organize_tree.html.php 16 DIRTY_ATTR $child->id modules/organize/views/organize_tree.html.php 19 DIRTY_ATTR $child->id -modules/recaptcha/views/admin_recaptcha.html.php 10 DIRTY $form +modules/recaptcha/views/admin_recaptcha.html.php 11 DIRTY $form modules/recaptcha/views/admin_recaptcha.html.php 23 DIRTY_JS $public_key modules/recaptcha/views/form_recaptcha.html.php 7 DIRTY_JS $public_key modules/rss/views/feed.mrss.php 10 DIRTY $feed->uri @@ -220,14 +259,13 @@ modules/rss/views/feed.mrss.php 19 DIRTY_JS $feed- modules/rss/views/feed.mrss.php 21 DIRTY $pub_date modules/rss/views/feed.mrss.php 22 DIRTY $pub_date modules/rss/views/feed.mrss.php 28 DIRTY date("D, d M Y H:i:s T",$child->created); -modules/rss/views/feed.mrss.php 34 DIRTY_ATTR $child->resize_url(true) -modules/rss/views/feed.mrss.php 36 DIRTY_ATTR $child->resize_height -modules/rss/views/feed.mrss.php 36 DIRTY_ATTR $child->resize_width -modules/rss/views/feed.mrss.php 39 DIRTY_ATTR $child->thumb_url(true) -modules/rss/views/feed.mrss.php 41 DIRTY_ATTR $child->thumb_height -modules/rss/views/feed.mrss.php 41 DIRTY_ATTR $child->thumb_width -modules/rss/views/feed.mrss.php 47 DIRTY_ATTR $child->thumb_url(true) -modules/rss/views/feed.mrss.php 48 DIRTY_ATTR @filesize($child->thumb_path()) +modules/rss/views/feed.mrss.php 35 DIRTY_ATTR $child->resize_url(true) +modules/rss/views/feed.mrss.php 37 DIRTY_ATTR $child->resize_height +modules/rss/views/feed.mrss.php 37 DIRTY_ATTR $child->resize_width +modules/rss/views/feed.mrss.php 40 DIRTY_ATTR $child->thumb_url(true) +modules/rss/views/feed.mrss.php 42 DIRTY_ATTR $child->thumb_height +modules/rss/views/feed.mrss.php 42 DIRTY_ATTR $child->thumb_width +modules/rss/views/feed.mrss.php 48 DIRTY_ATTR $child->thumb_url(true) modules/rss/views/feed.mrss.php 49 DIRTY_ATTR $child->thumb_height modules/rss/views/feed.mrss.php 50 DIRTY_ATTR $child->thumb_width modules/rss/views/feed.mrss.php 54 DIRTY_ATTR $child->resize_url(true) @@ -249,99 +287,98 @@ modules/rss/views/rss_block.html.php 6 DIRTY_JS rss::u modules/search/views/search.html.php 30 DIRTY_ATTR $item_class modules/search/views/search.html.php 31 DIRTY_JS $item->url() modules/search/views/search.html.php 32 DIRTY $item->thumb_img() +modules/search/views/search.html.php 43 DIRTY $theme->paginator() +modules/server_add/views/admin_server_add.html.php 5 DIRTY $form modules/server_add/views/admin_server_add.html.php 15 DIRTY_ATTR $id -modules/server_add/views/admin_server_add.html.php 24 DIRTY $form modules/server_add/views/server_add_tree.html.php 20 DIRTY_ATTR is_dir($file)?"ui-icon-folder-collapsed":"ui-icon-document" -modules/server_add/views/server_add_tree.html.php 21 DIRTY_ATTR is_dir($file)?"gDirectory":"gFile" +modules/server_add/views/server_add_tree.html.php 21 DIRTY_ATTR is_dir($file)?"g-directory":"g-file" modules/server_add/views/server_add_tree_dialog.html.php 3 DIRTY_JS url::site("server_add/children?path=__PATH__") modules/server_add/views/server_add_tree_dialog.html.php 4 DIRTY_JS url::site("server_add/start?item_id={$item->id}&csrf=$csrf") -modules/server_add/views/server_add_tree_dialog.html.php 23 DIRTY $tree -modules/tag/views/admin_tags.html.php 13 DIRTY_JS $csrf -modules/tag/views/admin_tags.html.php 50 DIRTY_ATTR $tag->id -modules/tag/views/admin_tags.html.php 51 DIRTY $tag->count -modules/tag/views/tag_block.html.php 15 DIRTY $cloud -modules/tag/views/tag_block.html.php 17 DIRTY $form +modules/server_add/views/server_add_tree_dialog.html.php 21 DIRTY $tree +modules/tag/views/admin_tags.html.php 45 DIRTY_ATTR $tag->id +modules/tag/views/admin_tags.html.php 46 DIRTY $tag->count +modules/tag/views/tag_block.html.php 27 DIRTY $cloud +modules/tag/views/tag_block.html.php 29 DIRTY $form modules/tag/views/tag_cloud.html.php 4 DIRTY_ATTR (int)(($tag->count/$max_count)*7) modules/tag/views/tag_cloud.html.php 5 DIRTY $tag->count +modules/tag/views/tag_cloud.html.php 6 DIRTY_JS $tag->url() modules/user/views/admin_users.html.php 3 DIRTY_JS url::site("admin/users/add_user_to_group/__USERID__/__GROUPID__?csrf=$csrf") modules/user/views/admin_users.html.php 26 DIRTY_JS url::site("admin/users/group/__GROUPID__") modules/user/views/admin_users.html.php 36 DIRTY_JS url::site("admin/users/remove_user_from_group/__USERID__/__GROUPID__?csrf=$csrf") -modules/user/views/admin_users.html.php 67 DIRTY_ATTR $user->id -modules/user/views/admin_users.html.php 67 DIRTY_ATTR text::alternate("gOddRow","gEvenRow") -modules/user/views/admin_users.html.php 67 DIRTY_ATTR $user->admin?"admin":"" -modules/user/views/admin_users.html.php 68 DIRTY_ATTR $user->id -modules/user/views/admin_users.html.php 69 DIRTY_ATTR $user->avatar_url(20,$theme->url(,true)) -modules/user/views/admin_users.html.php 83 DIRTY ($user->last_login==0)?"":gallery::date($user->last_login) -modules/user/views/admin_users.html.php 121 DIRTY_ATTR $group->id -modules/user/views/admin_users.html.php 121 DIRTY_ATTR ($group->special?"gDefaultGroup":"") -modules/user/views/admin_users.html.php 123 DIRTY $v +modules/user/views/admin_users.html.php 71 DIRTY_ATTR $user->id +modules/user/views/admin_users.html.php 71 DIRTY_ATTR text::alternate("g-odd","g-even") +modules/user/views/admin_users.html.php 71 DIRTY_ATTR $user->admin?"g-admin":"" +modules/user/views/admin_users.html.php 72 DIRTY_ATTR $user->id +modules/user/views/admin_users.html.php 73 DIRTY_ATTR $user->avatar_url(20,$theme->url(,true)) +modules/user/views/admin_users.html.php 87 DIRTY ($user->last_login==0)?"":gallery::date($user->last_login) +modules/user/views/admin_users.html.php 123 DIRTY_ATTR $group->id +modules/user/views/admin_users.html.php 123 DIRTY_ATTR ($group->special?"g-default-group":"") +modules/user/views/admin_users.html.php 125 DIRTY $v modules/user/views/admin_users_group.html.php 22 DIRTY_JS $user->id modules/user/views/admin_users_group.html.php 22 DIRTY_JS $group->id -modules/user/views/login_ajax.html.php 6 DIRTY_JS url::site("password/reset") -modules/user/views/login_ajax.html.php 37 DIRTY $form -modules/user/views/user_languages_block.html.php 2 DIRTY form::dropdown("gSelectSessionLocale",$installed_locales,$selected) -modules/watermark/views/admin_watermarks.html.php 19 DIRTY_ATTR $width -modules/watermark/views/admin_watermarks.html.php 19 DIRTY_ATTR $height -modules/watermark/views/admin_watermarks.html.php 19 DIRTY_ATTR $url -themes/admin_default/views/admin.html.php 15 DIRTY_JS $theme->url() -themes/admin_default/views/admin.html.php 32 DIRTY $theme->admin_head() -themes/admin_default/views/admin.html.php 36 DIRTY $theme->admin_page_top() -themes/admin_default/views/admin.html.php 44 DIRTY $theme->admin_header_top() -themes/admin_default/views/admin.html.php 49 DIRTY_JS item::root()->url() -themes/admin_default/views/admin.html.php 53 DIRTY $theme->admin_menu() -themes/admin_default/views/admin.html.php 55 DIRTY $theme->admin_header_bottom() -themes/admin_default/views/admin.html.php 62 DIRTY $content -themes/admin_default/views/admin.html.php 68 DIRTY $sidebar -themes/admin_default/views/admin.html.php 73 DIRTY $theme->admin_footer() -themes/admin_default/views/admin.html.php 75 DIRTY $theme->admin_credits() -themes/admin_default/views/admin.html.php 79 DIRTY $theme->admin_page_bottom() -themes/admin_default/views/block.html.php 3 DIRTY_ATTR $anchor -themes/admin_default/views/block.html.php 5 DIRTY $id -themes/admin_default/views/block.html.php 5 DIRTY_ATTR $css_id -themes/admin_default/views/block.html.php 13 DIRTY $title -themes/admin_default/views/block.html.php 16 DIRTY $content -themes/admin_default/views/pager.html.php 13 DIRTY_JS str_replace('{page}',1,$url) -themes/admin_default/views/pager.html.php 20 DIRTY_JS str_replace('{page}',$previous_page,$url) -themes/admin_default/views/pager.html.php 27 DIRTY $from_to_msg -themes/admin_default/views/pager.html.php 30 DIRTY_JS str_replace('{page}',$next_page,$url) -themes/admin_default/views/pager.html.php 37 DIRTY_JS str_replace('{page}',$last_page,$url) -themes/default/views/album.html.php 16 DIRTY_ATTR $child->id -themes/default/views/album.html.php 16 DIRTY_ATTR $item_class -themes/default/views/album.html.php 18 DIRTY_JS $child->url() -themes/default/views/album.html.php 19 DIRTY $child->thumb_img(array("class"=>"gThumbnail")) -themes/default/views/album.html.php 23 DIRTY_JS $child->url() -themes/default/views/block.html.php 3 DIRTY_ATTR $anchor -themes/default/views/block.html.php 5 DIRTY_ATTR $css_id -themes/default/views/block.html.php 6 DIRTY $title -themes/default/views/block.html.php 8 DIRTY $content -themes/default/views/dynamic.html.php 11 DIRTY_ATTR $child->is_album()?"gAlbum":"" -themes/default/views/dynamic.html.php 13 DIRTY_JS $child->url() -themes/default/views/dynamic.html.php 14 DIRTY_ATTR $child->id -themes/default/views/dynamic.html.php 15 DIRTY_ATTR $child->thumb_url() -themes/default/views/dynamic.html.php 16 DIRTY_ATTR $child->thumb_width -themes/default/views/dynamic.html.php 17 DIRTY_ATTR $child->thumb_height -themes/default/views/movie.html.php 8 DIRTY_JS $previous_item->url() -themes/default/views/movie.html.php 18 DIRTY_JS $next_item->url() -themes/default/views/movie.html.php 28 DIRTY $item->movie_img(array("class"=>"gMovie","id"=>"gMovieId-{$item->id}")) -themes/default/views/page.html.php 9 DIRTY $page_title -themes/default/views/page.html.php 32 DIRTY_JS $theme->url() -themes/default/views/page.html.php 41 DIRTY $new_width -themes/default/views/page.html.php 42 DIRTY $new_height -themes/default/views/page.html.php 43 DIRTY $thumb_proportion -themes/default/views/page.html.php 82 DIRTY $header_text -themes/default/views/page.html.php 84 DIRTY_JS item::root()->url() -themes/default/views/page.html.php 102 DIRTY_JS $parent->url($parent==$theme->item()->parent()?"show={$theme->item()->id}":null) -themes/default/views/page.html.php 117 DIRTY $content -themes/default/views/page.html.php 123 DIRTY newView("sidebar.html") -themes/default/views/page.html.php 130 DIRTY $footer_text -themes/default/views/pager.html.php 13 DIRTY_JS str_replace('{page}',1,$url) -themes/default/views/pager.html.php 20 DIRTY_JS str_replace('{page}',$previous_page,$url) -themes/default/views/pager.html.php 27 DIRTY $from_to_msg -themes/default/views/pager.html.php 30 DIRTY_JS str_replace('{page}',$next_page,$url) -themes/default/views/pager.html.php 37 DIRTY_JS str_replace('{page}',$last_page,$url) -themes/default/views/photo.html.php 8 DIRTY_JS $theme->item()->width -themes/default/views/photo.html.php 8 DIRTY_JS $theme->item()->height -themes/default/views/photo.html.php 21 DIRTY_JS $previous_item->url() -themes/default/views/photo.html.php 31 DIRTY_JS $next_item->url() -themes/default/views/photo.html.php 43 DIRTY_JS $item->file_url() -themes/default/views/photo.html.php 45 DIRTY $item->resize_img(array("id"=>"gPhotoId-{$item->id}","class"=>"gResize")) +modules/user/views/user_form.html.php 7 DIRTY $form +modules/watermark/views/admin_watermarks.html.php 20 DIRTY_ATTR $width +modules/watermark/views/admin_watermarks.html.php 20 DIRTY_ATTR $height +modules/watermark/views/admin_watermarks.html.php 20 DIRTY_ATTR $url +themes/admin_wind/views/admin.html.php 16 DIRTY_JS $theme->url() +themes/admin_wind/views/admin.html.php 33 DIRTY $theme->admin_head() +themes/admin_wind/views/admin.html.php 37 DIRTY $theme->admin_page_top() +themes/admin_wind/views/admin.html.php 45 DIRTY $theme->admin_header_top() +themes/admin_wind/views/admin.html.php 60 DIRTY_JS item::root()->url() +themes/admin_wind/views/admin.html.php 64 DIRTY $theme->admin_menu() +themes/admin_wind/views/admin.html.php 66 DIRTY $theme->admin_header_bottom() +themes/admin_wind/views/admin.html.php 73 DIRTY $content +themes/admin_wind/views/admin.html.php 79 DIRTY $sidebar +themes/admin_wind/views/admin.html.php 84 DIRTY $theme->admin_footer() +themes/admin_wind/views/admin.html.php 86 DIRTY $theme->admin_credits() +themes/admin_wind/views/admin.html.php 90 DIRTY $theme->admin_page_bottom() +themes/admin_wind/views/block.html.php 3 DIRTY_ATTR $anchor +themes/admin_wind/views/block.html.php 5 DIRTY $id +themes/admin_wind/views/block.html.php 5 DIRTY_ATTR $css_id +themes/admin_wind/views/block.html.php 13 DIRTY $title +themes/admin_wind/views/block.html.php 16 DIRTY $content +themes/admin_wind/views/pager.html.php 13 DIRTY_JS str_replace('{page}',1,$url) +themes/admin_wind/views/pager.html.php 20 DIRTY_JS str_replace('{page}',$previous_page,$url) +themes/admin_wind/views/pager.html.php 27 DIRTY $from_to_msg +themes/admin_wind/views/pager.html.php 30 DIRTY_JS str_replace('{page}',$next_page,$url) +themes/admin_wind/views/pager.html.php 37 DIRTY_JS str_replace('{page}',$last_page,$url) +themes/wind/views/album.html.php 16 DIRTY_ATTR $child->id +themes/wind/views/album.html.php 16 DIRTY_ATTR $item_class +themes/wind/views/album.html.php 18 DIRTY_JS $child->url() +themes/wind/views/album.html.php 19 DIRTY $child->thumb_img(array("class"=>"g-thumbnail")) +themes/wind/views/album.html.php 23 DIRTY_JS $child->url() +themes/wind/views/album.html.php 41 DIRTY $theme->paginator() +themes/wind/views/block.html.php 3 DIRTY_ATTR $anchor +themes/wind/views/block.html.php 5 DIRTY_ATTR $css_id +themes/wind/views/block.html.php 6 DIRTY $title +themes/wind/views/block.html.php 8 DIRTY $content +themes/wind/views/dynamic.html.php 11 DIRTY_ATTR $child->is_album()?"g-album":"" +themes/wind/views/dynamic.html.php 13 DIRTY_JS $child->url() +themes/wind/views/dynamic.html.php 14 DIRTY_ATTR $child->id +themes/wind/views/dynamic.html.php 15 DIRTY_ATTR $child->thumb_url() +themes/wind/views/dynamic.html.php 16 DIRTY_ATTR $child->thumb_width +themes/wind/views/dynamic.html.php 17 DIRTY_ATTR $child->thumb_height +themes/wind/views/dynamic.html.php 29 DIRTY $theme->paginator() +themes/wind/views/movie.html.php 5 DIRTY $theme->paginator() +themes/wind/views/movie.html.php 8 DIRTY $item->movie_img(array("class"=>"g-movie","id"=>"g-movie-id-{$item->id}")) +themes/wind/views/page.html.php 9 DIRTY $page_title +themes/wind/views/page.html.php 33 DIRTY_JS $theme->url() +themes/wind/views/page.html.php 42 DIRTY $new_width +themes/wind/views/page.html.php 43 DIRTY $new_height +themes/wind/views/page.html.php 44 DIRTY $thumb_proportion +themes/wind/views/page.html.php 81 DIRTY $header_text +themes/wind/views/page.html.php 83 DIRTY_JS item::root()->url() +themes/wind/views/page.html.php 87 DIRTY $theme->user_menu() +themes/wind/views/page.html.php 104 DIRTY_JS $parent->url($parent==$theme->item()->parent()?"show={$theme->item()->id}":null) +themes/wind/views/page.html.php 120 DIRTY $content +themes/wind/views/page.html.php 126 DIRTY newView("sidebar.html") +themes/wind/views/page.html.php 133 DIRTY $footer_text +themes/wind/views/paginator.html.php 32 DIRTY_JS $first_page_url +themes/wind/views/paginator.html.php 41 DIRTY_JS $previous_page_url +themes/wind/views/paginator.html.php 69 DIRTY_JS $next_page_url +themes/wind/views/paginator.html.php 78 DIRTY_JS $last_page_url +themes/wind/views/photo.html.php 8 DIRTY_JS $theme->item()->width +themes/wind/views/photo.html.php 8 DIRTY_JS $theme->item()->height +themes/wind/views/photo.html.php 18 DIRTY $theme->paginator() +themes/wind/views/photo.html.php 23 DIRTY_JS $item->file_url() +themes/wind/views/photo.html.php 25 DIRTY $item->resize_img(array("id"=>"g-photo-id-{$item->id}","class"=>"g-resize")) diff --git a/modules/gallery/views/admin_advanced_settings.html.php b/modules/gallery/views/admin_advanced_settings.html.php index c3595da5..ff4843ab 100644 --- a/modules/gallery/views/admin_advanced_settings.html.php +++ b/modules/gallery/views/admin_advanced_settings.html.php @@ -1,38 +1,39 @@ <?php defined("SYSPATH") or die("No direct script access.") ?> -<div id="gAdminAdvancedSettings"> - <h1> <?= t("Advanced Settings") ?> </h1> +<div id="g-admin-advanced-settings" class="g-block"> + <h1> <?= t("Advanced settings") ?> </h1> <p> <?= t("Here are internal Gallery configuration settings. Most of these settings are accessible elsewhere in the administrative console.") ?> </p> - <ul id="gMessage"> - <li class="gWarning"> - <b><?= t("Change these values at your own risk!") ?></b> - </li> + + <ul id="g-action-status" class="g-message-block"> + <li class="g-warning"><?= t("Change these values at your own risk!") ?></li> </ul> - <table> - <tr> - <th> <?= t("Module") ?> </th> - <th> <?= t("Name") ?> </th> - <th> <?= t("Value") ?></th> - </tr> - <? foreach ($vars as $var): ?> - <? if ($var->module_name == "gallery" && $var->name == "_cache") continue ?> - <tr class="setting"> - <td> <?= $var->module_name ?> </td> - <td> <?= html::clean($var->name) ?> </td> - <td> - <a href="<?= url::site("admin/advanced_settings/edit/$var->module_name/" . html::clean($var->name)) ?>" - class="gDialogLink" - title="<?= t("Edit %var (%module_name)", array("var" => $var->name, "module_name" => $var->module_name))->for_html_attr() ?>"> - <? if ($var->value): ?> - <?= html::clean($var->value) ?> - <? else: ?> - <i> <?= t("empty") ?> </i> - <? endif ?> - </a> - </td> - </tr> - <? endforeach ?> - </table> + <div class="g-block-content"> + <table> + <tr> + <th> <?= t("Module") ?> </th> + <th> <?= t("Name") ?> </th> + <th> <?= t("Value") ?></th> + </tr> + <? foreach ($vars as $var): ?> + <? if ($var->module_name == "gallery" && $var->name == "_cache") continue ?> + <tr class="<?= text::alternate("g-odd", "g-even") ?>"> + <td> <?= $var->module_name ?> </td> + <td> <?= html::clean($var->name) ?> </td> + <td> + <a href="<?= url::site("admin/advanced_settings/edit/$var->module_name/" . html::clean($var->name)) ?>" + class="g-dialog-link" + title="<?= t("Edit %var (%module_name)", array("var" => $var->name, "module_name" => $var->module_name))->for_html_attr() ?>"> + <? if ($var->value): ?> + <?= html::clean($var->value) ?> + <? else: ?> + <i> <?= t("empty") ?> </i> + <? endif ?> + </a> + </td> + </tr> + <? endforeach ?> + </table> + </div> </div> diff --git a/modules/gallery/views/admin_block_photo_stream.html.php b/modules/gallery/views/admin_block_photo_stream.html.php index 4968c39b..f9725eee 100644 --- a/modules/gallery/views/admin_block_photo_stream.html.php +++ b/modules/gallery/views/admin_block_photo_stream.html.php @@ -1,7 +1,7 @@ <?php defined("SYSPATH") or die("No direct script access.") ?> <ul> <? foreach ($photos as $photo): ?> - <li class="gItem gPhoto"> + <li class="g-item g-photo"> <a href="<?= $photo->url() ?>" title="<?= html::purify($photo->title)->for_html_attr() ?>"> <img <?= photo::img_dimensions($photo->width, $photo->height, 72) ?> src="<?= $photo->thumb_url() ?>" alt="<?= html::purify($photo->title)->for_html_attr() ?>" /> diff --git a/modules/gallery/views/admin_block_platform.html.php b/modules/gallery/views/admin_block_platform.html.php index f27b9e7a..b1b8a2f9 100644 --- a/modules/gallery/views/admin_block_platform.html.php +++ b/modules/gallery/views/admin_block_platform.html.php @@ -4,7 +4,7 @@ <?= t("Host name: %host_name", array("host_name" => php_uname("n"))) ?> </li> <li> - <?= t("Operating System: %os %version", array("os" => php_uname("s"), "version" => php_uname("r"))) ?> + <?= t("Operating system: %os %version", array("os" => php_uname("s"), "version" => php_uname("r"))) ?> </li> <li> <?= t("Apache: %apache_version", array("apache_version" => function_exists("apache_get_version") ? apache_get_version() : t("Unknown"))) ?> diff --git a/modules/gallery/views/admin_dashboard.html.php b/modules/gallery/views/admin_dashboard.html.php index 148de65f..f391547e 100644 --- a/modules/gallery/views/admin_dashboard.html.php +++ b/modules/gallery/views/admin_dashboard.html.php @@ -3,34 +3,34 @@ update_blocks = function() { $.get(<?= html::js_string(url::site("admin/dashboard/reorder")) ?>, {"csrf": "<?= $csrf ?>", - "dashboard_center[]": $("#gAdminDashboard").sortable( + "dashboard_center[]": $("#g-admin-dashboard").sortable( "toArray", {attribute: "block_id"}), - "dashboard_sidebar[]": $("#gAdminDashboardSidebar").sortable( + "dashboard_sidebar[]": $("#g-admin-dashboard-sidebar").sortable( "toArray", {attribute: "block_id"})}); }; $(document).ready(function(){ - $("#gAdminDashboard .gBlock .ui-widget-header").addClass("gDraggable"); - $("#gAdminDashboard").sortable({ - connectWith: ["#gAdminDashboardSidebar"], + $("#g-admin-dashboard .g-block .ui-widget-header").addClass("g-draggable"); + $("#g-admin-dashboard").sortable({ + connectWith: ["#g-admin-dashboard-sidebar"], cursor: "move", handle: $(".ui-widget-header"), opacity: 0.6, - placeholder: "gDropTarget", + placeholder: "g-target", stop: update_blocks }); - $("#gAdminDashboardSidebar .gBlock .ui-widget-header").addClass("gDraggable"); - $("#gAdminDashboardSidebar").sortable({ - connectWith: ["#gAdminDashboard"], + $("#g-admin-dashboard-sidebar .g-block .ui-widget-header").addClass("g-draggable"); + $("#g-admin-dashboard-sidebar").sortable({ + connectWith: ["#g-admin-dashboard"], cursor: "move", handle: $(".ui-widget-header"), opacity: 0.6, - placeholder: "gDropTarget", + placeholder: "g-target", stop: update_blocks }); }); </script> -<div id="gAdminDashboard"> +<div id="g-admin-dashboard"> <?= $blocks ?> </div> diff --git a/modules/gallery/views/admin_graphics.html.php b/modules/gallery/views/admin_graphics.html.php index f64c7f80..3a48e087 100644 --- a/modules/gallery/views/admin_graphics.html.php +++ b/modules/gallery/views/admin_graphics.html.php @@ -1,36 +1,39 @@ <?php defined("SYSPATH") or die("No direct script access.") ?> <script type="text/javascript"> $(document).ready(function() { + $(".g-available .g-block").equal_heights(); select_toolkit = function(el) { - if (!$(this).hasClass("gUnavailable")) { + if (!$(this).hasClass("g-unavailable")) { window.location = <?= html::js_string(url::site("admin/graphics/choose/__TK__?csrf=$csrf")) ?> .replace("__TK__", $(this).attr("id")); } }; - $("#gAdminGraphics div.gAvailable .gBlock").click(select_toolkit); + $("#g-admin-graphics div.g-available .g-block").click(select_toolkit); }); </script> -<div id="gAdminGraphics"> - <h1> <?= t("Graphics Settings") ?> </h1> +<div id="g-admin-graphics" class="g-block ui-helper-clearfix"> + <h1> <?= t("Graphics settings") ?> </h1> <p> <?= t("Gallery needs a graphics toolkit in order to manipulate your photos. Please choose one from the list below.") ?> </p> - <h2> <?= t("Active Toolkit") ?> </h2> - <? if ($active == "none"): ?> - <?= new View("admin_graphics_none.html") ?> - <? else: ?> - <?= new View("admin_graphics_$active.html", array("tk" => $tk->$active, "is_active" => true)) ?> - <? endif ?> - - <div class="gAvailable"> - <h2> <?= t("Available Toolkits") ?> </h2> - <? foreach (array_keys((array)$tk) as $id): ?> - <? if ($id != $active): ?> - <?= new View("admin_graphics_$id.html", array("tk" => $tk->$id, "is_active" => false)) ?> + <div class="g-block-content"> + <h2> <?= t("Active toolkit") ?> </h2> + <? if ($active == "none"): ?> + <?= new View("admin_graphics_none.html") ?> + <? else: ?> + <?= new View("admin_graphics_$active.html", array("tk" => $tk->$active, "is_active" => true)) ?> <? endif ?> - <? endforeach ?> + + <div class="g-available"> + <h2> <?= t("Available toolkits") ?> </h2> + <? foreach (array_keys((array)$tk) as $id): ?> + <? if ($id != $active): ?> + <?= new View("admin_graphics_$id.html", array("tk" => $tk->$id, "is_active" => false)) ?> + <? endif ?> + <? endforeach ?> + </div> </div> </div> diff --git a/modules/gallery/views/admin_graphics_gd.html.php b/modules/gallery/views/admin_graphics_gd.html.php index 010a31b4..1cc9dc9e 100644 --- a/modules/gallery/views/admin_graphics_gd.html.php +++ b/modules/gallery/views/admin_graphics_gd.html.php @@ -1,5 +1,5 @@ <?php defined("SYSPATH") or die("No direct script access.") ?> -<div id="gd" class="gBlock<?= $is_active ? " gSelected" : "" ?><?= $tk->installed ? " gInstalledToolkit" : " gUnavailable" ?>"> +<div id="gd" class="g-block<?= $is_active ? " g-selected" : "" ?><?= $tk->installed ? " g-installed-toolkit" : " g-unavailable" ?>"> <img class="logo" width="170" height="110" src="<?= url::file("modules/gallery/images/gd.png"); ?>" alt="<? t("Visit the GD lib project site") ?>" /> <h3> <?= t("GD") ?> </h3> <p> @@ -7,23 +7,23 @@ array("url" => "http://www.boutell.com/gd")) ?> </p> <? if ($tk->installed && $tk->rotate): ?> - <div class="gModuleStatus gInfo"> + <div class="g-module-status g-info"> <?= t("You have GD version %version.", array("version" => $tk->version)) ?> </div> <p> - <a class="gButtonLink ui-state-default ui-corner-all"><?= t("Activate GD") ?></a> + <a class="g-button ui-state-default ui-corner-all"><?= t("Activate GD") ?></a> </p> <? elseif ($tk->installed): ?> <? if ($tk->error): ?> - <p class="gModuleStatus gWarning"> + <p class="g-module-status g-warning"> <?= $tk->error ?> </p> <? endif ?> <p> - <a class="gButtonLink ui-state-default ui-corner-all"><?= t("Activate GD") ?></a> + <a class="g-button ui-state-default ui-corner-all"><?= t("Activate GD") ?></a> </p> <? else: ?> - <div class="gModuleStatus gInfo"> + <div class="g-module-status g-info"> <?= t("You do not have GD installed.") ?> </div> <? endif ?> diff --git a/modules/gallery/views/admin_graphics_graphicsmagick.html.php b/modules/gallery/views/admin_graphics_graphicsmagick.html.php index 97624850..5dae1442 100644 --- a/modules/gallery/views/admin_graphics_graphicsmagick.html.php +++ b/modules/gallery/views/admin_graphics_graphicsmagick.html.php @@ -1,5 +1,5 @@ <?php defined("SYSPATH") or die("No direct script access.") ?> -<div id="graphicsmagick" class="gBlock<?= $is_active ? " gSelected" : "" ?><?= $tk->installed ? " gInstalledToolkit" : " gUnavailable" ?>"> +<div id="graphicsmagick" class="g-block<?= $is_active ? " g-selected" : "" ?><?= $tk->installed ? " g-installed-toolkit" : " g-unavailable" ?>"> <img class="logo" width="107" height="76" src="<?= url::file("modules/gallery/images/graphicsmagick.png"); ?>" alt="<? t("Visit the GraphicsMagick project site") ?>" /> <h3> <?= t("GraphicsMagick") ?> </h3> <p> @@ -7,14 +7,14 @@ array("url" => "http://www.graphicsmagick.org")) ?> </p> <? if ($tk->installed): ?> - <div class="gModuleStatus gInfo"> + <div class="g-module-status g-info"> <?= t("GraphicsMagick version %version is available in %dir", array("version" => $tk->version, "dir" => $tk->dir)) ?> </div> <p> - <a class="gButtonLink ui-state-default ui-corner-all"><?= t("Activate Graphics Magic") ?></a> + <a class="g-button ui-state-default ui-corner-all"><?= t("Activate Graphics Magic") ?></a> </p> <? else: ?> - <div class="gModuleStatus gWarning"> + <div class="g-module-status g-warning"> <?= $tk->error ?> </div> <? endif ?> diff --git a/modules/gallery/views/admin_graphics_imagemagick.html.php b/modules/gallery/views/admin_graphics_imagemagick.html.php index cdff7c2c..9c1a9909 100644 --- a/modules/gallery/views/admin_graphics_imagemagick.html.php +++ b/modules/gallery/views/admin_graphics_imagemagick.html.php @@ -1,5 +1,5 @@ <?php defined("SYSPATH") or die("No direct script access.") ?> -<div id="imagemagick" class="gBlock<?= $is_active ? " gSelected" : "" ?><?= $tk->installed ? " gInstalledToolkit" : " gUnavailable" ?>"> +<div id="imagemagick" class="g-block<?= $is_active ? " g-selected" : "" ?><?= $tk->installed ? " g-installed-toolkit" : " g-unavailable" ?>"> <img class="logo" width="114" height="118" src="<?= url::file("modules/gallery/images/imagemagick.jpg"); ?>" alt="<? t("Visit the ImageMagick project site") ?>" /> <h3> <?= t("ImageMagick") ?> </h3> <p> @@ -7,14 +7,14 @@ array("url" => "http://www.imagemagick.org")) ?> </p> <? if ($tk->installed): ?> - <div class="gModuleStatus gInfo"> + <div class="g-module-status g-info"> <?= t("ImageMagick version %version is available in %dir", array("version" => $tk->version, "dir" => $tk->dir)) ?> </div> <p> - <a class="gButtonLink ui-state-default ui-corner-all"><?= t("Activate ImageMagick") ?></a> + <a class="g-button ui-state-default ui-corner-all"><?= t("Activate ImageMagick") ?></a> </p> <? elseif ($tk->error): ?> - <div class="gModuleStatus gWarning"> + <div class="g-module-status g-warning"> <?= $tk->error ?> </div> <? endif ?> diff --git a/modules/gallery/views/admin_graphics_none.html.php b/modules/gallery/views/admin_graphics_none.html.php index e6923a5a..e0fc4170 100644 --- a/modules/gallery/views/admin_graphics_none.html.php +++ b/modules/gallery/views/admin_graphics_none.html.php @@ -1,7 +1,7 @@ <?php defined("SYSPATH") or die("No direct script access.") ?> -<div id="none" class="gModuleStatus gWarning gBlock"> - <h3> <?= t("No Active Toolkit") ?> </h3> +<div id="none" class="g-module-status g-warning g-block"> + <h3> <?= t("No active toolkit") ?> </h3> <p> <?= t("We were unable to detect a graphics program. You must install one of the toolkits below in order to use many Gallery features.") ?> </p> diff --git a/modules/gallery/views/admin_identity.html.php b/modules/gallery/views/admin_identity.html.php new file mode 100644 index 00000000..51eaa58a --- /dev/null +++ b/modules/gallery/views/admin_identity.html.php @@ -0,0 +1,59 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> +<script type="text/javascript"> + $(document).ready(function() { + $("#g-modules form").submit(function() { + var eDialog = '<div id="g-dialog"></div>'; + var params = $(this).serialize(); + var url = $(this).attr("action"); + $("body").append(eDialog); + $.post($(this).attr("action"), $(this).serialize(), function(data, textStatus) { + $("#g-dialog").html(data); + $("#g-dialog").dialog({ + bgiframe: true, + title: <?= t("Confirm identity provider change")->for_js() ?>, + resizable: false, + height:180, + modal: true, + overlay: { + backgroundColor: '#000', + opacity: 0.5 + }, + buttons: { + "Continue": function() { + $("#g-dialog form").submit(); + }, + Cancel: function() { + $(this).dialog('destroy').remove(); + } + } + }); + }); + return false; + }); + }); + +</script> +<div id="g-modules"> + <h1> <?= t("Manage identity providers") ?> </h1> + <p> + <?= t("Choose a different user/group management provider.") ?> + </p> + + <form method="post" action="<?= url::site("admin/identity/confirm") ?>"> + <?= access::csrf_form_field() ?> + <table> + <tr> + <th> <?= t("Active") ?> </th> + <th> <?= t("Description") ?> </th> + </tr> + <? foreach ($available as $module_name => $description): ?> + <tr class="<?= text::alternate("g-odd", "g-even") ?>"> + <? $data = array("name" => "provider"); ?> + <td> <?= form::radio($data, $module_name, $module_name == $active) ?> </td> + <td> <?= t($description) ?> </td> + </tr> + <? endforeach ?> + </table> + <input type="submit" value="<?= t("Change")->for_html_attr() ?>" /> + </form> +</div> diff --git a/modules/gallery/views/admin_identity_confirm.html.php b/modules/gallery/views/admin_identity_confirm.html.php new file mode 100644 index 00000000..54aae9c8 --- /dev/null +++ b/modules/gallery/views/admin_identity_confirm.html.php @@ -0,0 +1,10 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> +<form method="post" action="<?= url::site("admin/identity/change") ?>"> + <?= access::csrf_form_field() ?> + <?= form::hidden("provider", $new_provider) ?> + + <p><span class="ui-icon ui-icon-alert" style="float: left; margin:0 7px 20px 0;"></span> + <?= t("Are you sure you want to change your Identity Provider? Continuing will delete all existing users.") ?> + </p> +</form> + diff --git a/modules/gallery/views/admin_languages.html.php b/modules/gallery/views/admin_languages.html.php index fb30c7ba..07134475 100644 --- a/modules/gallery/views/admin_languages.html.php +++ b/modules/gallery/views/admin_languages.html.php @@ -1,46 +1,8 @@ <?php defined("SYSPATH") or die("No direct script access.") ?> -<div id="gLanguages"> - <h1> <?= t("Languages") ?> </h1> - <p> - <?= t("Install new languages, update installed ones and set the default language for your Gallery.") ?> - </p> - - <form id="gLanguagesForm" method="post" action="<?= url::site("admin/languages/save") ?>"> - <?= access::csrf_form_field() ?> - <table> - <tr> - <th> <?= t("Installed") ?> </th> - <th> <?= t("Language") ?> </th> - <th> <?= t("Default language") ?> </th> - </tr> - <? $i = 0 ?> - <? foreach ($available_locales as $code => $display_name): ?> - <? if ($i == (count($available_locales)/2)): ?> - <table> - <tr> - <th> <?= t("Installed") ?> </th> - <th> <?= t("Language") ?> </th> - <th> <?= t("Default language") ?> </th> - </tr> - <? endif ?> - - <tr class="<?= (isset($installed_locales[$code])) ? "installed" : "" ?><?= ($default_locale == $code) ? " default" : "" ?>"> - <td> <?= form::checkbox("installed_locales[]", $code, isset($installed_locales[$code])) ?> </td> - <td> <?= $display_name ?> </td> - <td> - <?= form::radio("default_locale", $code, ($default_locale == $code), ((isset($installed_locales[$code]))?'':'disabled="disabled"') ) ?> - </td> - </tr> - <? $i++ ?> - - <? endforeach ?> - </table> - <input type="submit" value="<?= t("Update languages")->for_html_attr() ?>" /> - </form> - - <script type="text/javascript"> - var old_default_locale = <?= html::js_string($default_locale) ?>; +<script type="text/javascript"> + var old_default_locale = <?= html::js_string($default_locale) ?>; + $("#g-languages-form").ready(function() { $("input[name='installed_locales[]']").change(function (event) { if (this.checked) { $("input[type='radio'][value='" + this.value + "']").enable(); @@ -51,8 +13,8 @@ $("input[type='radio'][value='" + this.value + "']").attr("disabled", "disabled"); } }); - - $("#gLanguagesForm").ajaxForm({ + + $("#g-languages-form").ajaxForm({ dataType: "json", success: function(data) { if (data.result == "success") { @@ -62,42 +24,91 @@ } } }); - </script> -</div> + }); +</script> -<div id="gTranslations"> - <h1> <?= t("Translations") ?> </h1> - <p> - <?= t("Create your own translations and share them with the rest of the Gallery community.") ?> - </p> +<div class="g-block"> + <h1> <?= t("Languages and translation") ?> </h1> - <h3><?= t("Translating Gallery") ?></h3> + <div class="g-block-content"> - <div class="gBlock"> - <a href="http://codex.gallery2.org/Gallery3:Localization" target="_blank" - class="gDocLink ui-state-default ui-corner-all ui-icon ui-icon-help" - title="<?= t("Localization documentation")->for_html_attr() ?>"> - <?= t("Localization documentation") ?> - </a> + <div id="g-languages" class="g-block"> + <h2> <?= t("Languages") ?> </h2> + <p> + <?= t("Install new languages, update installed ones and set the default language for your Gallery.") ?> + </p> - <p><?= t("<strong>Step 1:</strong> Make sure the target language is installed and up to date (check above).") ?></p> + <div class="g-block-content ui-helper-clearfix"> + <form id="g-languages-form" method="post" action="<?= url::site("admin/languages/save") ?>"> + <?= access::csrf_form_field() ?> + <table class="g-left"> + <tr> + <th> <?= t("Installed") ?> </th> + <th> <?= t("Language") ?> </th> + <th> <?= t("Default language") ?> </th> + </tr> + <? $i = 0 ?> + <? foreach ($available_locales as $code => $display_name): ?> + <? if ($i == (count($available_locales)/2)): ?> + <table> + <tr> + <th> <?= t("Installed") ?> </th> + <th> <?= t("Language") ?> </th> + <th> <?= t("Default language") ?> </th> + </tr> + <? endif ?> + <tr class="<?= (isset($installed_locales[$code])) ? "g-available" : "" ?><?= ($default_locale == $code) ? " g-selected" : "" ?>"> + <td> <?= form::checkbox("installed_locales[]", $code, isset($installed_locales[$code])) ?> </td> + <td> <?= $display_name ?> </td> + <td> + <?= form::radio("default_locale", $code, ($default_locale == $code), ((isset($installed_locales[$code]))?'':'disabled="disabled"') ) ?> + </td> + </tr> + <? $i++ ?> + <? endforeach ?> + </table> + <input type="submit" value="<?= t("Update languages")->for_html_attr() ?>" /> + </form> + </div> + </div> - <p><?= t("<strong>Step 2:</strong> Make sure you have selected the right target language (currently %default_locale).", - array("default_locale" => locales::display_name())) ?></p> + <div id="g-translations" class="g-block"> + <h2> <?= t("Translations") ?> </h2> + <p> + <?= t("Create your own translations and share them with the rest of the Gallery community.") ?> + </p> - <p><?= t("<strong>Step 3:</strong> Start the translation mode and the translation interface will appear at the bottom of each Gallery page.") ?></p> + <div class="g-block-content"> + <a href="http://codex.gallery2.org/Gallery3:Localization" target="_blank" + class="g-right ui-state-default ui-corner-all ui-icon ui-icon-help" + title="<?= t("Localization documentation")->for_html_attr() ?>"> + <?= t("Localization documentation") ?> + </a> - <a href="<?= url::site("l10n_client/toggle_l10n_mode?csrf=".access::csrf_token()) ?>" - class="gButtonLink ui-state-default ui-corner-all ui-icon-left"> - <span class="ui-icon ui-icon-power"></span> - <? if (Session::instance()->get("l10n_mode", false)): ?> - <?= t("Stop translation mode") ?> - <? else: ?> - <?= t("Start translation mode") ?> - <? endif ?> - </a> -</div> + <h3><?= t("Translating Gallery") ?></h3> + + <p><?= t("Follow these steps to begin translating Gallery.") ?></p> + + <ol> + <li><?= t("Make sure the target language is installed and up to date (check above).") ?></li> + <li><?= t("Make sure you have selected the right target language (currently %default_locale).", + array("default_locale" => locales::display_name())) ?></li> + <li><?= t("Start the translation mode and the translation interface will appear at the bottom of each Gallery page.") ?></li> + </ol> + <a href="<?= url::site("l10n_client/toggle_l10n_mode?csrf=".access::csrf_token()) ?>" + class="g-button ui-state-default ui-corner-all ui-icon-left"> + <span class="ui-icon ui-icon-power"></span> + <? if (Session::instance()->get("l10n_mode", false)): ?> + <?= t("Stop translation mode") ?> + <? else: ?> + <?= t("Start translation mode") ?> + <? endif ?> + </a> + + <h3><?= t("Sharing your translations") ?></h3> + <?= $share_translations_form ?> + </div> + </div> -<h3><?= t("Sharing your translations") ?></h3> - <?= $share_translations_form ?> + </div> </div> diff --git a/modules/gallery/views/admin_maintenance.html.php b/modules/gallery/views/admin_maintenance.html.php index ce693d73..ac597715 100644 --- a/modules/gallery/views/admin_maintenance.html.php +++ b/modules/gallery/views/admin_maintenance.html.php @@ -1,193 +1,189 @@ <?php defined("SYSPATH") or die("No direct script access.") ?> -<div id="gAdminMaintenance"> - <h1> <?= t("Maintenance Tasks") ?> </h1> +<div id="g-admin-maintenance" class="g-block"> + <h1> <?= t("Maintenance tasks") ?> </h1> <p> <?= t("Occasionally your Gallery will require some maintenance. Here are some tasks you can use to keep it running smoothly.") ?> </p> - <div id="gAvailableTasks"> - <h2> <?= t("Available Tasks") ?> </h2> - <table> - <tr> - <th> - <?= t("Name") ?> - </th> - <th> - <?= t("Description") ?> - </th> - <th> - <?= t("Action") ?> - </th> - </tr> - <? $i = 0; ?> - <? foreach ($task_definitions as $task): ?> - <tr class="<?= ($i % 2 == 0) ? "gOddRow" : "gEvenRow" ?> <?= log::severity_class($task->severity) ?>"> - <td class="<?= log::severity_class($task->severity) ?>"> - <?= $task->name ?> - </td> - <td> - <?= $task->description ?> - </td> - <td> - <a href="<?= url::site("admin/maintenance/start/$task->callback?csrf=$csrf") ?>" - class="gDialogLink gButtonLink ui-icon-left ui-state-default ui-corner-all"> - <?= t("run") ?> - </a> - </td> - </tr> - <? $i++ ?> - <? endforeach ?> - </table> - </div> + <div class="g-block-content"> + <div id="g-available-tasks"> + <h2> <?= t("Available tasks") ?> </h2> + <table> + <tr> + <th> + <?= t("Name") ?> + </th> + <th> + <?= t("Description") ?> + </th> + <th> + <?= t("Action") ?> + </th> + </tr> + <? foreach ($task_definitions as $task): ?> + <tr class="<?= text::alternate("g-odd", "g-even") ?> <?= log::severity_class($task->severity) ?>"> + <td class="<?= log::severity_class($task->severity) ?>"> + <?= $task->name ?> + </td> + <td> + <?= $task->description ?> + </td> + <td> + <a href="<?= url::site("admin/maintenance/start/$task->callback?csrf=$csrf") ?>" + class="g-dialog-link g-button ui-icon-left ui-state-default ui-corner-all"> + <?= t("run") ?> + </a> + </td> + </tr> + <? endforeach ?> + </table> + </div> - <? if ($running_tasks->count()): ?> - <div id="gRunningTasks"> - <h2> <?= t("Running Tasks") ?> </h2> - <table> - <tr> - <th> - <?= t("Last Updated") ?> - </th> - <th> - <?= t("Name") ?> - </th> - <th> - <?= t("Status") ?> - </th> - <th> - <?= t("Info") ?> - </th> - <th> - <?= t("Owner") ?> - </th> - <th> - <?= t("Action") ?> - <a href="<?= url::site("admin/maintenance/cancel_running_tasks?csrf=$csrf") ?>" - class="gButtonLink ui-icon-left ui-state-default ui-corner-all right"> - <?= t("cancel all") ?></a> - </th> - </tr> - <? $i = 0; ?> - <? foreach ($running_tasks as $task): ?> - <tr class="<?= ($i % 2 == 0) ? "gOddRow" : "gEvenRow" ?> <?= $task->state == "stalled" ? "gWarning" : "" ?>"> - <td class="<?= $task->state == "stalled" ? "gWarning" : "" ?>"> - <?= gallery::date_time($task->updated) ?> - </td> - <td> - <?= $task->name ?> - </td> - <td> - <? if ($task->done): ?> - <? if ($task->state == "cancelled"): ?> - <?= t("Cancelled") ?> - <? endif ?> - <?= t("Close") ?> - <? elseif ($task->state == "stalled"): ?> - <?= t("Stalled") ?> - <? else: ?> - <?= t("%percent_complete% Complete", array("percent_complete" => $task->percent_complete)) ?> - <? endif ?> - </td> - <td> - <?= $task->status ?> - </td> - <td> - <?= html::clean($task->owner()->name) ?> - </td> - <td> - <? if ($task->state == "stalled"): ?> - <a class="gDialogLink gButtonLink ui-icon-left ui-state-default ui-corner-all" - href="<?= url::site("admin/maintenance/resume/$task->id?csrf=$csrf") ?>"> - <?= t("resume") ?> - </a> - <? endif ?> - <a href="<?= url::site("admin/maintenance/cancel/$task->id?csrf=$csrf") ?>" - class="gButtonLink ui-icon-left ui-state-default ui-corner-all right"> - <?= t("cancel") ?> - </a> - </td> - </tr> - <? $i++ ?> - <? endforeach ?> - </table> - </div> - <? endif ?> + <? if ($running_tasks->count()): ?> + <div id="g-running-tasks"> + <h2> <?= t("Running tasks") ?> </h2> + <table> + <tr> + <th> + <?= t("Last updated") ?> + </th> + <th> + <?= t("Name") ?> + </th> + <th> + <?= t("Status") ?> + </th> + <th> + <?= t("Info") ?> + </th> + <th> + <?= t("Owner") ?> + </th> + <th> + <a href="<?= url::site("admin/maintenance/cancel_running_tasks?csrf=$csrf") ?>" + class="g-button g-right ui-icon-left ui-state-default ui-corner-all"> + <?= t("cancel all") ?></a> + <?= t("Action") ?> + </th> + </tr> + <? foreach ($running_tasks as $task): ?> + <tr class="<?= text::alternate("g-odd", "g-even") ?> <?= $task->state == "stalled" ? "g-warning" : "" ?>"> + <td class="<?= $task->state == "stalled" ? "g-warning" : "" ?>"> + <?= gallery::date_time($task->updated) ?> + </td> + <td> + <?= $task->name ?> + </td> + <td> + <? if ($task->done): ?> + <? if ($task->state == "cancelled"): ?> + <?= t("Cancelled") ?> + <? endif ?> + <?= t("Close") ?> + <? elseif ($task->state == "stalled"): ?> + <?= t("Stalled") ?> + <? else: ?> + <?= t("%percent_complete% Complete", array("percent_complete" => $task->percent_complete)) ?> + <? endif ?> + </td> + <td> + <?= $task->status ?> + </td> + <td> + <?= html::clean($task->owner()->name) ?> + </td> + <td> + <a href="<?= url::site("admin/maintenance/cancel/$task->id?csrf=$csrf") ?>" + class="g-button g-right ui-icon-left ui-state-default ui-corner-all"> + <?= t("cancel") ?> + </a> + <? if ($task->state == "stalled"): ?> + <a class="g-dialog-link g-button ui-icon-left ui-state-default ui-corner-all" + href="<?= url::site("admin/maintenance/resume/$task->id?csrf=$csrf") ?>"> + <?= t("resume") ?> + </a> + <? endif ?> + </td> + </tr> + <? endforeach ?> + </table> + </div> + <? endif ?> - <? if ($finished_tasks->count()): ?> - <div id="gFinishedTasks"> - <h2> <?= t("Finished Tasks") ?> </h2> - <table> - <tr> - <th> - <?= t("Last Updated") ?> - </th> - <th> - <?= t("Name") ?> - </th> - <th> - <?= t("Status") ?> - </th> - <th> - <?= t("Info") ?> - </th> - <th> - <?= t("Owner") ?> - </th> - <th> - <?= t("Action") ?> - <a href="<?= url::site("admin/maintenance/remove_finished_tasks?csrf=$csrf") ?>" - class="gButtonLink ui-icon-left ui-state-default ui-corner-all right"> - <span class="ui-icon ui-icon-trash"></span><?= t("remove all finished") ?></a> - </th> - </tr> - <? $i = 0; ?> - <? foreach ($finished_tasks as $task): ?> - <tr class="<?= ($i % 2 == 0) ? "gOddRow" : "gEvenRow" ?> <?= $task->state == "success" ? "gSuccess" : "gError" ?>"> - <td class="<?= $task->state == "success" ? "gSuccess" : "gError" ?>"> - <?= gallery::date_time($task->updated) ?> - </td> - <td> - <?= $task->name ?> - </td> - <td> - <? if ($task->state == "success"): ?> - <?= t("Success") ?> - <? elseif ($task->state == "error"): ?> - <?= t("Failed") ?> - <? elseif ($task->state == "cancelled"): ?> - <?= t("Cancelled") ?> - <? endif ?> - </td> - <td> - <?= $task->status ?> - </td> - <td> - <?= html::clean($task->owner()->name) ?> - </td> - <td> - <? if ($task->done): ?> - <a href="<?= url::site("admin/maintenance/remove/$task->id?csrf=$csrf") ?>" class="gButtonLink ui-state-default ui-corner-all"> - <?= t("remove") ?> - </a> - <? if ($task->get_log()): ?> - <a href="<?= url::site("admin/maintenance/show_log/$task->id?csrf=$csrf") ?>" class="gDialogLink gButtonLink ui-state-default ui-corner-all"> - <?= t("browse log") ?> - </a> - <? endif ?> - <? else: ?> - <a href="<?= url::site("admin/maintenance/resume/$task->id?csrf=$csrf") ?>" class="gDialogLink gButtonLink" ui-state-default ui-corner-all> - <?= t("resume") ?> - </a> - <a href="<?= url::site("admin/maintenance/cancel/$task->id?csrf=$csrf") ?>" class="gButtonLink ui-state-default ui-corner-all"> - <?= t("cancel") ?> - </a> - <? endif ?> - </ul> - </td> - </tr> - <? endforeach ?> - <? $i++ ?> - </table> + <? if ($finished_tasks->count()): ?> + <div id="g-finished-tasks"> + <a href="<?= url::site("admin/maintenance/remove_finished_tasks?csrf=$csrf") ?>" + class="g-button g-right ui-icon-left ui-state-default ui-corner-all"> + <span class="ui-icon ui-icon-trash"></span><?= t("remove all finished") ?></a> + <h2> <?= t("Finished tasks") ?> </h2> + <table> + <tr> + <th> + <?= t("Last updated") ?> + </th> + <th> + <?= t("Name") ?> + </th> + <th> + <?= t("Status") ?> + </th> + <th> + <?= t("Info") ?> + </th> + <th> + <?= t("Owner") ?> + </th> + <th> + <?= t("Action") ?> + </th> + </tr> + <? foreach ($finished_tasks as $task): ?> + <tr class="<?= text::alternate("g-odd", "g-even") ?> <?= $task->state == "success" ? "g-success" : "g-error" ?>"> + <td class="<?= $task->state == "success" ? "g-success" : "g-error" ?>"> + <?= gallery::date_time($task->updated) ?> + </td> + <td> + <?= $task->name ?> + </td> + <td> + <? if ($task->state == "success"): ?> + <?= t("Success") ?> + <? elseif ($task->state == "error"): ?> + <?= t("Failed") ?> + <? elseif ($task->state == "cancelled"): ?> + <?= t("Cancelled") ?> + <? endif ?> + </td> + <td> + <?= $task->status ?> + </td> + <td> + <?= html::clean($task->owner()->name) ?> + </td> + <td> + <? if ($task->done): ?> + <a href="<?= url::site("admin/maintenance/remove/$task->id?csrf=$csrf") ?>" class="g-button ui-state-default ui-corner-all"> + <?= t("remove") ?> + </a> + <? if ($task->get_log()): ?> + <a href="<?= url::site("admin/maintenance/show_log/$task->id?csrf=$csrf") ?>" class="g-dialog-link g-button ui-state-default ui-corner-all"> + <?= t("browse log") ?> + </a> + <? endif ?> + <? else: ?> + <a href="<?= url::site("admin/maintenance/resume/$task->id?csrf=$csrf") ?>" class="g-dialog-link g-button" ui-state-default ui-corner-all> + <?= t("resume") ?> + </a> + <a href="<?= url::site("admin/maintenance/cancel/$task->id?csrf=$csrf") ?>" class="g-button ui-state-default ui-corner-all"> + <?= t("cancel") ?> + </a> + <? endif ?> + </ul> + </td> + </tr> + <? endforeach ?> + </table> + </div> + <? endif ?> </div> - <? endif ?> </div> diff --git a/modules/gallery/views/admin_maintenance_show_log.html.php b/modules/gallery/views/admin_maintenance_show_log.html.php index 8ea1beb6..d2472fdc 100644 --- a/modules/gallery/views/admin_maintenance_show_log.html.php +++ b/modules/gallery/views/admin_maintenance_show_log.html.php @@ -2,18 +2,18 @@ <script type="text/javascript"> dismiss = function() { window.location.reload(); - } - download = function(){ + }; + download = function() { // send request $('<form action="<?= url::site("admin/maintenance/save_log/$task->id?csrf=$csrf") ?>" method="post"></form>'). appendTo('body').submit().remove(); }; </script> -<div id="gTaskLogDialog"> +<div id="g-task-log-dialog"> <h1> <?= $task->name ?> </h1> - <div class="gTaskLog"> + <div class="g-task-log g-text-small"> <pre><?= html::purify($task->get_log()) ?></pre> </div> - <button id="gCloseButton" class="ui-state-default ui-corner-all" onclick="dismiss()"><?= t("Close") ?></button> - <button id="gSaveButton" class="ui-state-default ui-corner-all" onclick="download()"><?= t("Save") ?></button> + <button id="g-close" class="ui-state-default ui-corner-all" onclick="dismiss()"><?= t("Close") ?></button> + <button id="g-save" class="ui-state-default ui-corner-all" onclick="download()"><?= t("Save") ?></button> </div> diff --git a/modules/gallery/views/admin_maintenance_task.html.php b/modules/gallery/views/admin_maintenance_task.html.php index ddd5bd17..76756b66 100644 --- a/modules/gallery/views/admin_maintenance_task.html.php +++ b/modules/gallery/views/admin_maintenance_task.html.php @@ -4,7 +4,7 @@ var animation = null; var delta = 1; animate_progress_bar = function() { - var current_value = parseInt($(".gProgressBar div").css("width").replace("%", "")); + var current_value = parseInt($(".g-progress-bar div").css("width").replace("%", "")); if (target_value > current_value) { // speed up delta = Math.min(delta + 0.04, 3); @@ -14,10 +14,10 @@ } if (target_value == 100) { - $(".gProgressBar").progressbar("value", 100); + $(".g-progress-bar").progressbar("value", 100); } else if (current_value != target_value || delta != 1) { var new_value = Math.min(current_value + delta, target_value); - $(".gProgressBar").progressbar("value", new_value); + $(".g-progress-bar").progressbar("value", new_value); animation = setTimeout(function() { animate_progress_bar(target_value); }, 100); } else { animation = null; @@ -35,30 +35,30 @@ if (!animation) { animate_progress_bar(); } - $("#gStatus").html("" + data.task.status); + $("#g-status").html("" + data.task.status); if (data.task.done) { - $("#gPauseButton").hide(); - $("#gDoneButton").show(); + $("#g-pause-button").hide(); + $("#g-done-button").show(); } else { setTimeout(update, 100); } } }); } - $(".gProgressBar").progressbar({value: 0}); + $(".g-progress-bar").progressbar({value: 0}); update(); dismiss = function() { window.location.reload(); } </script> -<div id="gProgress"> +<div id="g-progress"> <h1> <?= $task->name ?> </h1> - <div class="gProgressBar"></div> - <div id="gStatus"> + <div class="g-progress-bar"></div> + <div id="g-status"> <?= t("Starting up...") ?> </div> - <div class="txtright"> - <button id="gPauseButton" class="ui-state-default ui-corner-all" onclick="dismiss()"><?= t("Pause") ?></button> - <button id="gDoneButton" class="ui-state-default ui-corner-all" style="display: none" onclick="dismiss()"><?= t("Close") ?></button> + <div class="g-text-right"> + <button id="g-pause-button" class="ui-state-default ui-corner-all" onclick="dismiss()"><?= t("Pause") ?></button> + <button id="g-done-button" class="ui-state-default ui-corner-all" style="display: none" onclick="dismiss()"><?= t("Close") ?></button> </div> </div> diff --git a/modules/gallery/views/admin_modules.html.php b/modules/gallery/views/admin_modules.html.php index 9cf03cb3..aebedf09 100644 --- a/modules/gallery/views/admin_modules.html.php +++ b/modules/gallery/views/admin_modules.html.php @@ -1,32 +1,32 @@ <?php defined("SYSPATH") or die("No direct script access.") ?> -<div id="gModules"> +<div class="g-block ui-helper-clearfix"> <h1> <?= t("Gallery Modules") ?> </h1> <p> <?= t("Power up your Gallery by adding more modules! Each module provides new cool features.") ?> </p> - <form method="post" action="<?= url::site("admin/modules/save") ?>"> - <?= access::csrf_form_field() ?> - <table> - <tr> - <th> <?= t("Installed") ?> </th> - <th> <?= t("Name") ?> </th> - <th> <?= t("Version") ?> </th> - <th> <?= t("Description") ?> </th> - </tr> - <? $i = 0 ?> - <? foreach ($available as $module_name => $module_info): ?> - <tr class="<?= ($i % 2 == 0) ? "gOddRow" : "gEvenRow" ?>"> - <? $data = array("name" => $module_name); ?> - <? if ($module_info->locked) $data["disabled"] = 1; ?> - <td> <?= form::checkbox($data, '1', module::is_active($module_name)) ?> </td> - <td> <?= t($module_info->name) ?> </td> - <td> <?= $module_info->version ?> </td> - <td> <?= t($module_info->description) ?> </td> - </tr> - <? $i++ ?> - <? endforeach ?> - </table> - <input type="submit" value="<?= t("Update")->for_html_attr() ?>"/> - </form> + <div class="g-block-content"> + <form method="post" action="<?= url::site("admin/modules/save") ?>"> + <?= access::csrf_form_field() ?> + <table> + <tr> + <th> <?= t("Installed") ?> </th> + <th> <?= t("Name") ?> </th> + <th> <?= t("Version") ?> </th> + <th> <?= t("Description") ?> </th> + </tr> + <? foreach ($available as $module_name => $module_info): ?> + <tr class="<?= text::alternate("g-odd", "g-even") ?>"> + <? $data = array("name" => $module_name); ?> + <? if ($module_info->locked) $data["disabled"] = 1; ?> + <td> <?= form::checkbox($data, '1', module::is_active($module_name)) ?> </td> + <td> <?= t($module_info->name) ?> </td> + <td> <?= $module_info->version ?> </td> + <td> <?= t($module_info->description) ?> </td> + </tr> + <? endforeach ?> + </table> + <input type="submit" value="<?= t("Update")->for_html_attr() ?>" /> + </form> + </div> </div> diff --git a/modules/gallery/views/admin_sidebar.html.php b/modules/gallery/views/admin_sidebar.html.php new file mode 100644 index 00000000..b394aa19 --- /dev/null +++ b/modules/gallery/views/admin_sidebar.html.php @@ -0,0 +1,64 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> +<script type="text/javascript"> + $(document).ready(function(){ + $(".g-admin-blocks-list").equal_heights(); + var extra_ht = $(".g-admin-blocks-list li").length * $(".g-admin-blocks-list li:first").height(); + $(".g-admin-blocks-list").height($(".g-admin-blocks-list").height() + extra_ht); + }); + + $(function() { + $(".g-admin-blocks-list ul").sortable({ + connectWith: ".g-sortable-blocks", + opacity: .7, + placeholder: "g-target", + update: function(event,ui) { + if ($(this).attr("id") == "g-active-blocks") { + var active_blocks = ""; + $("ul#g-active-blocks li").each(function(i) { + active_blocks += "&block["+i+"]="+$(this).attr("ref"); + }); + $.getJSON($("#g-site-blocks").attr("ref").replace("__ACTIVE__", active_blocks), function(data) { + if (data.result == "success") { + $("ul#g-available-blocks").html(data.available); + $("ul#g-active-blocks").html(data.active); + $("#g-action-status").remove(); + var message = "<ul id=\"g-action-status\" class=\"g-message-block\">"; + message += "<li class=\"g-success\">" + data.message + "</li>"; + message += "</ul>"; + $("#g-block-admin").before(message); + $("#g-action-status li").gallery_show_message(); + } + }); + } + } + }).disableSelection(); + }); +</script> + +<div id="g-block-admin" class="g-block ui-helper-clearfix"> + <h1> <?= t("Manage sidebar") ?> </h1> + <p> + <?= t("Select and drag blocks from the available column to the active column to add to the sidebar; remove by dragging the other way.") ?> + </p> + + <div class="g-block-content"> + <div id="g-site-blocks" ref="<?= url::site("admin/sidebar/update?csrf={$csrf}__ACTIVE__") ?>"> + <div class="g-admin-blocks-list"> + <div><h3><?= t("Available blocks") ?></h3></div> + <div> + <ul id="g-available-blocks" class="g-sortable-blocks"> + <?= $available ?> + </ul> + </div> + </div> + <div class="g-admin-blocks-list"> + <div><h3><?= t("Active blocks") ?></h3></div> + <div> + <ul id="g-active-blocks" class="g-sortable-blocks"> + <?= $active ?> + </ul> + </div> + </div> + </div> + </div> +</div> diff --git a/modules/gallery/views/admin_sidebar_blocks.html.php b/modules/gallery/views/admin_sidebar_blocks.html.php new file mode 100644 index 00000000..48aa3f05 --- /dev/null +++ b/modules/gallery/views/admin_sidebar_blocks.html.php @@ -0,0 +1,5 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> + +<? foreach ($blocks as $ref => $text): ?> +<li class="g-draggable" ref="<?= $ref ?>"><?= $text ?></li> +<? endforeach ?> diff --git a/modules/gallery/views/admin_theme_options.html.php b/modules/gallery/views/admin_theme_options.html.php index 724e6438..a4bf1c4e 100644 --- a/modules/gallery/views/admin_theme_options.html.php +++ b/modules/gallery/views/admin_theme_options.html.php @@ -1,6 +1,8 @@ <?php defined("SYSPATH") or die("No direct script access.") ?> -<div id="gAdminThemeOptions"> +<div class="g-block"> <h1> <?= t("Theme Options") ?> </h1> + <div class="g-block-content"> <?= $form ?> + </div> </div> diff --git a/modules/gallery/views/admin_themes.html.php b/modules/gallery/views/admin_themes.html.php index 0aac4717..d14e8bd4 100644 --- a/modules/gallery/views/admin_themes.html.php +++ b/modules/gallery/views/admin_themes.html.php @@ -7,83 +7,88 @@ } </script> -<h1> <?= t("Theme Choice") ?> </h1> -<p> - <?= t("Gallery allows you to choose a theme for browsing your Gallery, as well as a special theme for the administration interface. Click a theme to preview and activate it.") ?> -</p> +<div class="g-block ui-helper-clearfix"> + <h1> <?= t("Theme choice") ?> </h1> + <p> + <?= t("Gallery allows you to choose a theme for browsing your Gallery, as well as a special theme for the administration interface. Click a theme to preview and activate it.") ?> + </p> -<div id="gSiteTheme"> - <h2> <?= t("Gallery theme") ?> </h2> - <div class="gBlock gSelected"> - <img src="<?= url::file("themes/{$site}/thumbnail.png") ?>" - alt="<?= html::clean_attribute($themes[$site]->name) ?>" /> - <h3> <?= $themes[$site]->name ?> </h3> - <p> - <?= $themes[$site]->description ?> - </p> - </div> + <div class="g-block-content"> + <div id="g-site-theme"> + <h2> <?= t("Gallery theme") ?> </h2> + <div class="g-block g-selected ui-helper-clearfix"> + <img src="<?= url::file("themes/{$site}/thumbnail.png") ?>" + alt="<?= html::clean_attribute($themes[$site]->name) ?>" /> + <h3> <?= $themes[$site]->name ?> </h3> + <p> + <?= $themes[$site]->description ?> + </p> + </div> + + <h2> <?= t("Available Gallery themes") ?> </h2> + <div class="g-available"> + <? $count = 0 ?> + <? foreach ($themes as $id => $info): ?> + <? if (!$info->site) continue ?> + <? if ($id == $site) continue ?> + <div class="g-block ui-helper-clearfix"> + <a href="<?= url::site("admin/themes/preview/site/$id") ?>" class="g-dialog-link" title="<?= t("Theme Preview: %theme_name", array("theme_name" => $info->name))->for_html_attr() ?>"> + <img src="<?= url::file("themes/{$id}/thumbnail.png") ?>" + alt="<?= html::clean_attribute($info->name) ?>" /> + <h3> <?= $info->name ?> </h3> + <p> + <?= $info->description ?> + </p> + </a> + </div> + <? $count++ ?> + <? endforeach ?> - <h2> <?= t("Available Gallery themes") ?> </h2> - <div class="gAvailable"> - <? $count = 0 ?> - <? foreach ($themes as $id => $info): ?> - <? if (!$info->site) continue ?> - <? if ($id == $site) continue ?> - <div class="gBlock"> - <a href="<?= url::site("admin/themes/preview/site/$id") ?>" class="gDialogLink" title="<?= t("Theme Preview: %theme_name", array("theme_name" => $info->name))->for_html_attr() ?>"> - <img src="<?= url::file("themes/{$id}/thumbnail.png") ?>" - alt="<?= html::clean_attribute($info->name) ?>" /> - <h3> <?= $info->name ?> </h3> + <? if (!$count): ?> <p> - <?= $info->description ?> + <?= t("There are no other site themes available.") ?> </p> - </a> + <? endif ?> + </div> </div> - <? $count++ ?> - <? endforeach ?> - <? if (!$count): ?> - <p> - <?= t("There are no other site themes available.") ?> - </p> - <? endif ?> - </div> -</div> + <div id="g-admin-theme"> + <h2> <?= t("Admin theme") ?> </h2> + <div class="g-block g-selected ui-helper-clearfix"> + <img src="<?= url::file("themes/{$admin}/thumbnail.png") ?>" + alt="<?= html::clean_attribute($themes[$admin]->name) ?>" /> + <h3> <?= $themes[$admin]->name ?> </h3> + <p> + <?= $themes[$admin]->description ?> + </p> + </div> -<div id="gAdminTheme"> - <h2> <?= t("Admin theme") ?> </h2> - <div class="gBlock gSelected"> - <img src="<?= url::file("themes/{$admin}/thumbnail.png") ?>" - alt="<?= html::clean_attribute($themes[$admin]->name) ?>" /> - <h3> <?= $themes[$admin]->name ?> </h3> - <p> - <?= $themes[$admin]->description ?> - </p> - </div> + <h2> <?= t("Available admin themes") ?> </h2> + <div class="g-available"> + <? $count = 0 ?> + <? foreach ($themes as $id => $info): ?> + <? if (!$info->admin) continue ?> + <? if ($id == $admin) continue ?> + <div class="g-block ui-helper-clearfix"> + <a href="<?= url::site("admin/themes/preview/admin/$id") ?>" class="g-dialog-link" title="<?= t("Theme Preview: %theme_name", array("theme_name" => $info->name))->for_html_attr() ?>"> + <img src="<?= url::file("themes/{$id}/thumbnail.png") ?>" + alt="<?= html::clean_attribute($info->name) ?>" /> + <h3> <?= $info->name ?> </h3> + <p> + <?= $info->description ?> + </p> + </a> + </div> + <? $count++ ?> + <? endforeach ?> - <h2> <?= t("Available admin themes") ?> </h2> - <div class="gAvailable"> - <? $count = 0 ?> - <? foreach ($themes as $id => $info): ?> - <? if (!$info->admin) continue ?> - <? if ($id == $admin) continue ?> - <div class="gBlock"> - <a href="<?= url::site("admin/themes/preview/admin/$id") ?>" class="gDialogLink" title="<?= t("Theme Preview: %theme_name", array("theme_name" => $info->name))->for_html_attr() ?>"> - <img src="<?= url::file("themes/{$id}/thumbnail.png") ?>" - alt="<?= html::clean_attribute($info->name) ?>" /> - <h3> <?= $info->name ?> </h3> + <? if (!$count): ?> <p> - <?= $info->description ?> + <?= t("There are no other admin themes available.") ?> </p> - </a> + <? endif ?> + </div> </div> - <? $count++ ?> - <? endforeach ?> - <? if (!$count): ?> - <p> - <?= t("There are no other admin themes available.") ?> - </p> - <? endif ?> </div> </div>
\ No newline at end of file diff --git a/modules/gallery/views/form.html.php b/modules/gallery/views/form.html.php index 730d77cb..abc32164 100644 --- a/modules/gallery/views/form.html.php +++ b/modules/gallery/views/form.html.php @@ -44,7 +44,7 @@ if (!function_exists("DrawForm")) { print $input->render(); } else { if ($input->error_messages()) { - print "$prefix<li class=\"gError\">\n"; + print "$prefix<li class=\"g-error\">\n"; } else { print "$prefix<li>\n"; } @@ -58,7 +58,7 @@ if (!function_exists("DrawForm")) { } if ($input->error_messages()) { foreach ($input->error_messages() as $error_message) { - print "$prefix <p class=\"gError\">\n"; + print "$prefix <p class=\"g-message g-error\">\n"; print "$prefix $error_message\n"; print "$prefix </p>\n"; } diff --git a/modules/gallery/views/in_place_edit.html.php b/modules/gallery/views/in_place_edit.html.php new file mode 100644 index 00000000..03cbdc69 --- /dev/null +++ b/modules/gallery/views/in_place_edit.html.php @@ -0,0 +1,16 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> +<?= form::open($action, array("method" => "post", "id" => "g-in-place-edit-form", "class" => "g-short-form"), $hidden) ?> + <ul> + <li <? if (!empty($errors["input"])): ?> class="g-error"<? endif ?>> + <?= form::input("input", $form["input"], " class='textbox'") ?> + </li> + <li> + <?= form::submit(array("class" => "submit ui-state-default"), t("Save")) ?> + </li> + <li><a href="#" class="g-cancel"><?= t("Cancel") ?></a></li> + </ul> +<?= form::close() ?> +<? if (!empty($errors["input"])): ?> +<div id="g-in-place-edit-message" class="g-error"><?= $errors["input"] ?></div> +<? endif ?> + diff --git a/modules/gallery/views/kohana_error_page.php b/modules/gallery/views/kohana_error_page.php index 9361514d..0d8801e5 100644 --- a/modules/gallery/views/kohana_error_page.php +++ b/modules/gallery/views/kohana_error_page.php @@ -57,7 +57,7 @@ <title><?= t("Something went wrong!") ?></title> </head> <body> - <? try { $user = user::active(); } catch (Exception $e) { } ?> + <? try { $user = identity::active_user(); } catch (Exception $e) { } ?> <? $admin = php_sapi_name() == "cli" || isset($user) && $user->admin ?> <div class="big_box" id="framework_error"> <h1> @@ -117,6 +117,11 @@ <? endif ?> </div> </div> + <? else: ?> + <? $trace = $PHP_ERROR ? array_slice(debug_backtrace(), 1) : $exception->getTraceAsString(); ?> + <? if (!empty($trace)): ?> + <? Kohana::Log("error", print_r($trace, 1)); ?> + <? endif ?> <? endif ?> </body> </html> diff --git a/modules/gallery/views/l10n_client.html.php b/modules/gallery/views/l10n_client.html.php index b0f424be..9d14bbb2 100644 --- a/modules/gallery/views/l10n_client.html.php +++ b/modules/gallery/views/l10n_client.html.php @@ -2,13 +2,13 @@ <div id="l10n-client" class="hidden"> <div class="labels"> <span id="l10n-client-toggler"> - <a id="gMinimizeL10n">_</a> - <a id="gCloseL10n" title="<?= t("Stop the translation mode")->for_html_attr() ?>" + <a id="g-minimize-l10n">_</a> + <a id="g-close-l10n" title="<?= t("Stop the translation mode")->for_html_attr() ?>" href="<?= html::clean_attribute(url::site("l10n_client/toggle_l10n_mode?csrf=".access::csrf_token())) ?>">X</a> </span> - <div class="label strings"><h2><?= t("Page Text") ?> + <div class="label strings"><h2><?= t("Page text") ?> <? if (!Input::instance()->get('show_all_l10n_messages')): ?> - <a style="background-color:#fff" href="<?= url::site("admin/languages?show_all_l10n_messages=1") ?>"><?= t("(Show All)") ?></a> + <a style="background-color:#fff" href="<?= url::site("admin/languages?show_all_l10n_messages=1") ?>"><?= t("(Show all)") ?></a> <? endif; ?> </h2></div> <div class="label source"><h2><?= t("Source") ?></div> @@ -37,7 +37,7 @@ <p id="source-text-tmp-space" style="display:none"></p> </div> <div class="translation"> - <form method="post" action="<?= url::site("l10n_client/save") ?>" id="gL10nClientSaveForm"> + <form method="post" action="<?= url::site("l10n_client/save") ?>" id="g-l10n-client-save-form"> <?= access::csrf_form_field() ?> <?= form::hidden("l10n-message-key") ?> <?= form::textarea("l10n-edit-translation", "", ' rows="5" class="translationField"') ?> @@ -68,12 +68,12 @@ </div> <input type="submit" name="l10n-edit-save" value="<?= t("Save translation")->for_html_attr() ?>"/> <a href="javascript: Gallery.l10nClient.copySourceText()" - class="gButtonLink ui-state-default ui-corner-all"><?= t("Copy source text") ?></a> + class="g-button ui-state-default ui-corner-all"><?= t("Copy source text") ?></a> </form> </div> </div> <script type="text/javascript"> - var MSG_TRANSLATE_TEXT = <?= t("Translate Text")->for_js() ?>; + var MSG_TRANSLATE_TEXT = <?= t("Translate text")->for_js() ?>; var l10n_client_data = <?= json_encode($string_list) ?>; var plural_forms = <?= json_encode($plural_forms) ?>; var toggle_l10n_mode_url = <?= html::js_string(url::site("l10n_client/toggle_l10n_mode")) ?>; diff --git a/modules/gallery/views/login_ajax.html.php b/modules/gallery/views/login_ajax.html.php new file mode 100644 index 00000000..36647f9d --- /dev/null +++ b/modules/gallery/views/login_ajax.html.php @@ -0,0 +1,45 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> +<script type="text/javascript"> + $("#g-login-form").ready(function() { + $("#g-password-reset").click(function() { + $.ajax({ + url: "<?= url::site("password/reset") ?>", + success: function(data) { + $("#g-login").html(data); + $("#ui-dialog-title-g-dialog").html(<?= t("Reset password")->for_js() ?>); + $(".submit").addClass("g-button ui-state-default ui-corner-all"); + $(".submit").gallery_hover_init(); + ajaxify_login_reset_form(); + } + }); + }); + }); + + function ajaxify_login_reset_form() { + $("#g-login form").ajaxForm({ + dataType: "json", + success: function(data) { + if (data.form) { + $("#g-login form").replaceWith(data.form); + ajaxify_login_reset_form(); + } + if (data.result == "success") { + $("#g-dialog").dialog("close"); + window.location.reload(); + } + } + }); + }; +</script> +<div id="g-login"> + <ul> + <li id="g-login-form"> + <?= $form ?> + </li> + <? if (identity::is_writable()): ?> + <li> + <a href="#" id="g-password-reset" class="g-right g-text-small"><?= t("Forgot your password?") ?></a> + </li> + <? endif ?> + </ul> +</div> diff --git a/modules/gallery/views/login_current_user.html.php b/modules/gallery/views/login_current_user.html.php new file mode 100644 index 00000000..e3b3688f --- /dev/null +++ b/modules/gallery/views/login_current_user.html.php @@ -0,0 +1,11 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> +<li> + <? $name = $menu->label->for_html() ?> + <? if (identity::is_writable()): ?> + <?= t("Logged in as %name", array("name" => html::mark_clean( + "<a href='$menu->url' title='" . t("Edit your profile")->for_html_attr() . + "' id='$menu->id' class='g-dialog-link'>{$name}</a>"))) ?> + <? else: ?> + <?= t("Logged in as %name", array("name" => $name)) ?> + <? endif ?> +</li> diff --git a/modules/gallery/views/maintenance.html.php b/modules/gallery/views/maintenance.html.php index f80b6e7a..6351b6ab 100644 --- a/modules/gallery/views/maintenance.html.php +++ b/modules/gallery/views/maintenance.html.php @@ -2,7 +2,7 @@ <html> <head> <title> - <?= t("Gallery - Maintenance Mode") ?> + <?= t("Gallery - maintenance mode") ?> </title> <style> body { @@ -38,12 +38,12 @@ </head> <body> <h1> - <?= t("Gallery - Maintenance Mode") ?> + <?= t("Gallery - maintenance mode") ?> </h1> <p> <?= t("This site is currently only accessible by site administrators.") ?> </p> - <?= user::get_login_form("login/auth_html") ?> + <?= auth::get_login_form("login/auth_html") ?> </body> </html> diff --git a/modules/gallery/views/menu.html.php b/modules/gallery/views/menu.html.php new file mode 100644 index 00000000..cb49bcdf --- /dev/null +++ b/modules/gallery/views/menu.html.php @@ -0,0 +1,24 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> +<? if ($menu->elements): // Don't show the menu if it has no choices ?> +<? if ($menu->is_root): ?> +<ul <?= isset($menu->css_id) ? "id='$menu->css_id'" : "" ?> class="<?= $menu->css_class ?>"> + <? foreach ($menu->elements as $element): ?> + <?= $element->render() ?> + <? endforeach ?> +</ul> + +<? else: ?> + +<li title="<?= $menu->label->for_html_attr() ?>"> + <a href="#"> + <?= $menu->label->for_html() ?> + </a> + <ul> + <? foreach ($menu->elements as $element): ?> + <?= $element->render() ?> + <? endforeach ?> + </ul> +</li> + +<? endif ?> +<? endif ?> diff --git a/modules/gallery/views/menu_ajax_link.html.php b/modules/gallery/views/menu_ajax_link.html.php new file mode 100644 index 00000000..00a394bc --- /dev/null +++ b/modules/gallery/views/menu_ajax_link.html.php @@ -0,0 +1,10 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> +<li> + <a id="<?= $menu->css_id ?>" + class="g-ajax-link <?= $menu->css_class ?>" + href="<?= $menu->url ?>" + title="<?= $menu->label->for_html_attr() ?>" + ajax_handler="<?= $menu->ajax_handler ?>"> + <?= $menu->label->for_html() ?> + </a> +</li> diff --git a/modules/gallery/views/menu_dialog.html.php b/modules/gallery/views/menu_dialog.html.php new file mode 100644 index 00000000..99b1b013 --- /dev/null +++ b/modules/gallery/views/menu_dialog.html.php @@ -0,0 +1,9 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> +<li> + <a id="<?= $menu->css_id ?>" + class="g-dialog-link <?= $menu->css_class ?>" + href="<?= $menu->url ?>" + title="<?= $menu->label->for_html_attr() ?>"> + <?= $menu->label->for_html() ?> + </a> +</li> diff --git a/modules/gallery/views/menu_link.html.php b/modules/gallery/views/menu_link.html.php new file mode 100644 index 00000000..8e4cdb95 --- /dev/null +++ b/modules/gallery/views/menu_link.html.php @@ -0,0 +1,9 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> +<li> + <a id="<?= $menu->css_id ?>" + class="g-menu-link <?= $menu->css_class ?>" + href="<?= $menu->url ?>" + title="<?= $menu->label->for_html_attr() ?>"> + <?= $menu->label->for_html() ?> + </a> +</li> diff --git a/modules/gallery/views/move_browse.html.php b/modules/gallery/views/move_browse.html.php index 99728ecc..ce3fc2fd 100644 --- a/modules/gallery/views/move_browse.html.php +++ b/modules/gallery/views/move_browse.html.php @@ -3,14 +3,14 @@ var load_tree = function(target_id, locked) { var load_url = "<?= url::site("move/show_sub_tree/{$source->id}/__TARGETID__") ?>"; var node = $("#node_" + target_id); - $("#gMove .node a").removeClass("selected"); + $("#g-move .node a").removeClass("selected"); node.find("a:first").addClass("selected"); if (locked) { - $("#gMoveButton").attr("disabled", "disabled"); - $("#gMove form input[name=target_id]").attr("value", ""); + $("#g-move-button").attr("disabled", "disabled"); + $("#g-move form input[name=target_id]").attr("value", ""); } else { - $("#gMoveButton").removeAttr("disabled"); - $("#gMove form input[name=target_id]").attr("value", target_id); + $("#g-move-button").removeAttr("disabled"); + $("#g-move form input[name=target_id]").attr("value", target_id); } var sub_tree = $("#tree_" + target_id); if (sub_tree.length) { @@ -33,7 +33,7 @@ <? t("Move this album to a new album") ?> <? endif ?> </h1> -<div id="gMove"> +<div id="g-move"> <ul id="tree_0"> <li id="node_1" class="node"> <?= $tree ?> @@ -42,6 +42,6 @@ <form method="post" action="<?= url::site("move/save/$source->id") ?>"> <?= access::csrf_form_field() ?> <input type="hidden" name="target_id" value="" /> - <input type="submit" id="gMoveButton" value="<?= t("Move")->for_html_attr() ?>" disabled="disabled"/> + <input type="submit" id="g-move-button" value="<?= t("Move")->for_html_attr() ?>" disabled="disabled"/> </form> </div> diff --git a/modules/gallery/views/movieplayer.html.php b/modules/gallery/views/movieplayer.html.php index e9783eb8..f7af8d93 100644 --- a/modules/gallery/views/movieplayer.html.php +++ b/modules/gallery/views/movieplayer.html.php @@ -1,6 +1,6 @@ <?php defined("SYSPATH") or die("No direct script access.") ?> <?= html::anchor($item->file_url(true), "", $attrs) ?> -<script> +<script type="text/javascript"> flowplayer( "<?= $attrs["id"] ?>", { diff --git a/modules/gallery/views/permissions_browse.html.php b/modules/gallery/views/permissions_browse.html.php index 519734d6..0b27336e 100644 --- a/modules/gallery/views/permissions_browse.html.php +++ b/modules/gallery/views/permissions_browse.html.php @@ -5,9 +5,9 @@ $.ajax({ url: form_url.replace("__ITEM__", id), success: function(data) { - $("#gEditPermissionForm").html(data); - $(".active").removeClass("active"); - $("#item-" + id).addClass("active"); + $("#g-edit-permissions-form").html(data); + $(".g-active").removeClass("g-active"); + $("#item-" + id).addClass("g-active"); } }); } @@ -19,15 +19,15 @@ url: action_url.replace("__CMD__", cmd).replace("__GROUP__", group_id). replace("__PERM__", perm_id).replace("__ITEM__", item_id), success: function(data) { - $("#gEditPermissionForm").load(form_url.replace("__ITEM__", item_id)); + $("#g-edit-permissions-form").load(form_url.replace("__ITEM__", item_id)); } }); } </script> -<div id="gPermissions"> +<div id="g-permissions"> <? if (!$htaccess_works): ?> - <ul id="gMessage"> - <li class="gError"> + <ul id="g-action-status" class="g-message-block"> + <li class="g-error"> <?= t("Oh no! Your server needs a configuration change in order for you to hide photos! Ask your server administrator to enable <a %mod_rewrite_attrs>mod_rewrite</a> and set <a %apache_attrs><i>AllowOverride FileInfo Options</i></a> to fix this.", array("mod_rewrite_attrs" => html::mark_clean('href="http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html" target="_blank"'), "apache_attrs" => html::mark_clean('href="http://httpd.apache.org/docs/2.0/mod/core.html#allowoverride" target="_blank"'))) ?> @@ -37,26 +37,26 @@ <p><?= t("Edit permissions for album:") ?></p> - <ul class="gBreadcrumbs"> + <ul class="g-breadcrumbs"> + <? $i = 0 ?> <? foreach ($parents as $parent): ?> - <li id="item-<?= $parent->id ?>"> + <li id="item-<?= $parent->id ?>"<? if ($i == 0) print " class=\"g-first\"" ?>> <? if (access::can("edit", $parent)): ?> - <a href="javascript:show(<?= $parent->id ?>)"> - <?= html::purify($parent->title) ?> - </a> + <a href="javascript:show(<?= $parent->id ?>)"> <?= html::purify($parent->title) ?> </a> <? else: ?> <?= html::purify($parent->title) ?> <? endif ?> </li> + <? $i++ ?> <? endforeach ?> - <li class="active" id="item-<?= $item->id ?>"> + <li class="g-active" id="item-<?= $item->id ?>"> <a href="javascript:show(<?= $item->id ?>)"> <?= html::purify($item->title) ?> </a> </li> </ul> - <div id="gEditPermissionForm"> + <div id="g-edit-permissions-form"> <?= $form ?> </div> </div> diff --git a/modules/gallery/views/permissions_form.html.php b/modules/gallery/views/permissions_form.html.php index a0bb35f2..f1714119 100644 --- a/modules/gallery/views/permissions_form.html.php +++ b/modules/gallery/views/permissions_form.html.php @@ -1,7 +1,6 @@ <?php defined("SYSPATH") or die("No direct script access.") ?> <fieldset> <legend> <?= t('Edit Permissions') ?> </legend> - <table> <tr> <th> </th> @@ -12,73 +11,75 @@ <? foreach ($permissions as $permission): ?> <tr> - <td> <?= t($permission->display_name) ?> </td> + <td> <?= t($permission->display_name) ?> + </td> <? foreach ($groups as $group): ?> <? $intent = access::group_intent($group, $permission->name, $item) ?> <? $allowed = access::group_can($group, $permission->name, $item) ?> <? $lock = access::locked_by($group, $permission->name, $item) ?> <? if ($lock): ?> - <td class="gDenied"> - <img src="<?= url::file('themes/default/images/ico-denied.png') ?>" title="<?= t('denied and locked through parent album')->for_html_attr() ?>" alt="<?= t('denied icon')->for_html_attr() ?>" /> + <td class="g-denied"> + <img src="<?= url::file(gallery::find_file("images", "ico-denied.png")) ?>" + title="<?= t('denied and locked through parent album')->for_html_attr() ?>" + alt="<?= t('denied icon')->for_html_attr() ?>" /> <a href="javascript:show(<?= $lock->id ?>)" title="<?= t('click to go to parent album')->for_html_attr() ?>"> - <img src="<?= url::file('themes/default/images/ico-lock.png') ?>" alt="<?= t('locked icon')->for_html_attr() ?>" /> + <img src="<?= url::file(gallery::find_file("images", "ico-lock.png")) ?>" alt="<?= t('locked icon')->for_html_attr() ?>" /> </a> </td> <? else: ?> <? if ($intent === access::INHERIT): ?> <? if ($allowed): ?> - <td class="gAllowed"> - <a href="javascript:set('allow',<?= $group->id ?>,<?= $permission->id ?>,<?= $item->id ?>)" - title="<?= t('allowed through parent album, click to allow explicitly')->for_html_attr() ?>"> - <img src="<?= url::file('themes/default/images/ico-success-pale.png') ?>" alt="<?= t('passive allowed icon')->for_html_attr() ?>" /> + <td class="g-allowed"> + <a href="javascript:set('allow',<?= $group->id ?>,<?= $permission->id ?>,<?= $item->id ?>)" title="<?= t('allowed through parent album, click to allow explicitly')->for_html_attr() ?>"> + <img src="<?= url::file(gallery::find_file("images", "ico-success-passive.png")) ?>" alt="<?= t('passive allowed icon')->for_html_attr() ?>" /> </a> <a href="javascript:set('deny',<?= $group->id ?>,<?= $permission->id ?>,<?= $item->id ?>)" title="<?= t('click to deny')->for_html_attr() ?>"> - <img src="<?= url::file('themes/default/images/ico-denied-gray.png') ?>" alt="<?= t('inactive denied icon')->for_html_attr() ?>" /> + <img src="<?= url::file(gallery::find_file("images", "ico-denied-inactive.png")) ?>" alt="<?= t('inactive denied icon')->for_html_attr() ?>" /> </a> </td> <? else: ?> - <td class="gDenied"> + <td class="g-denied"> <a href="javascript:set('allow',<?= $group->id ?>,<?= $permission->id ?>,<?= $item->id ?>)" title="<?= t('click to allow')->for_html_attr() ?>"> - <img src="<?= url::file('themes/default/images/ico-success-gray.png') ?>" alt="<?= t('inactive allowed icon')->for_html_attr() ?>" /> + <img src="<?= url::file(gallery::find_file("images", "ico-success-inactive.png")) ?>" alt="<?= t('inactive allowed icon')->for_html_attr() ?>" /> </a> <a href="javascript:set('deny',<?= $group->id ?>,<?= $permission->id ?>,<?= $item->id ?>)" title="<?= t('denied through parent album, click to deny explicitly')->for_html_attr() ?>"> - <img src="<?= url::file('themes/default/images/ico-denied-pale.png') ?>" alt="<?= t('passive denied icon')->for_html_attr() ?>" /> + <img src="<?= url::file(gallery::find_file("images", "ico-denied-passive.png")) ?>" alt="<?= t('passive denied icon')->for_html_attr() ?>" /> </a> </td> <? endif ?> <? elseif ($intent === access::DENY): ?> - <td class="gDenied"> + <td class="g-denied"> <a href="javascript:set('allow',<?= $group->id ?>,<?= $permission->id ?>,<?= $item->id ?>)" title="<?= t('click to allow')->for_html_attr() ?>"> - <img src="<?= url::file('themes/default/images/ico-success-gray.png') ?>" alt="<?= t('inactive allowed icon')->for_html_attr() ?>" /> + <img src="<?= url::file(gallery::find_file("images", "ico-success-inactive.png")) ?>" alt="<?= t('inactive allowed icon')->for_html_attr() ?>" /> </a> <? if ($item->id == 1): ?> - <img src="<?= url::file('themes/default/images/ico-denied.png') ?>" alt="<?= t('denied icon')->for_html_attr() ?>" title="<?= t('denied')->for_html_attr() ?>"/> + <img src="<?= url::file(gallery::find_file("images", "ico-denied.png")) ?>" alt="<?= t('denied icon')->for_html_attr() ?>" title="<?= t('denied')->for_html_attr() ?>"/> <? else: ?> <a href="javascript:set('reset',<?= $group->id ?>,<?= $permission->id ?>,<?= $item->id ?>)" title="<?= t('denied, click to reset')->for_html_attr() ?>"> - <img src="<?= url::file('themes/default/images/ico-denied.png') ?>" alt="<?= t('denied icon')->for_html_attr() ?>" /> + <img src="<?= url::file(gallery::find_file("images", "ico-denied.png")) ?>" alt="<?= t('denied icon')->for_html_attr() ?>" /> </a> <? endif ?> </td> <? elseif ($intent === access::ALLOW): ?> - <td class="gAllowed"> + <td class="g-allowed"> <? if ($item->id == 1): ?> - <img src="<?= url::file('themes/default/images/ico-success.png') ?>" title="<?= t("allowed")->for_html_attr() ?>" alt="<?= t('allowed icon')->for_html_attr() ?>" /> + <img src="<?= url::file(gallery::find_file("images", "ico-success.png")) ?>" title="<?= t("allowed")->for_html_attr() ?>" alt="<?= t('allowed icon')->for_html_attr() ?>" /> <? else: ?> <a href="javascript:set('reset',<?= $group->id ?>,<?= $permission->id ?>,<?= $item->id ?>)" title="<?= t('allowed, click to reset')->for_html_attr() ?>"> - <img src="<?= url::file('themes/default/images/ico-success.png') ?>" alt="<?= t('allowed icon')->for_html_attr() ?>" /> + <img src="<?= url::file(gallery::find_file("images", "ico-success.png")) ?>" alt="<?= t('allowed icon')->for_html_attr() ?>" /> </a> <? endif ?> <a href="javascript:set('deny',<?= $group->id ?>,<?= $permission->id ?>,<?= $item->id ?>)" title="<?= t('click to deny')->for_html_attr() ?>"> - <img src="<?= url::file('themes/default/images/ico-denied-gray.png') ?>" alt="<?= t('inactive denied icon')->for_html_attr() ?>" /> + <img src="<?= url::file(gallery::find_file("images", "ico-denied-inactive.png")) ?>" alt="<?= t('inactive denied icon')->for_html_attr() ?>" /> </a> </td> <? endif ?> diff --git a/modules/gallery/views/simple_uploader.html.php b/modules/gallery/views/simple_uploader.html.php index 7f8a96df..10e748b6 100644 --- a/modules/gallery/views/simple_uploader.html.php +++ b/modules/gallery/views/simple_uploader.html.php @@ -1,274 +1,134 @@ <?php defined("SYSPATH") or die("No direct script access.") ?> -<script type="text/javascript" src="<?= url::file("lib/swfupload/swfupload.js") ?>"></script> -<script type="text/javascript" src="<?= url::file("lib/swfupload/swfupload.queue.js") ?>"></script> -<script type="text/javascript" src="<?= url::file("lib/jquery.scrollTo.js") ?>"></script> +<script type="text/javascript" src="<?= url::file("lib/swfobject.js") ?>"></script> +<script type="text/javascript" src="<?= url::file("lib/uploadify/jquery.uploadify.min.js") ?>"></script> +<script type="text/javascript"> + $("#g-add-photos-canvas").ready(function () { + $("#g-uploadify").uploadify({ + uploader: "<?= url::file("lib/uploadify/uploadify.swf") ?>", + script: "<?= url::site("simple_uploader/add_photo/{$item->id}") ?>", + scriptData: <?= json_encode(array( + "g3sid" => Session::instance()->id(), + "user_agent" => Input::instance()->server("HTTP_USER_AGENT"), + "csrf" => $csrf)) ?>, + fileExt: "*.gif;*.jpg;*.jpeg;*.png;*.flv;*.mp4;*.GIF;*.JPG;*.JPEG;*.PNG;*.FLV;*.MP4", + fileDesc: <?= t("Photos and movies")->for_js() ?>, + cancelImg: "<?= url::file("lib/uploadify/cancel.png") ?>", + buttonText: <?= t("Select Photos ...")->for_js() ?>, + simUploadLimit: 10, + //wmode: "transparent", + hideButton: false, /* should be true */ + auto: true, + multi: true, + onAllComplete: function(filesUploaded, errors, allbytesLoaded, speed) { + $("#g-upload-cancel-all") + .addClass("ui-state-disabled") + .attr("disabled", "disabled"); + return true; + }, + onClearQueue: function(event) { + $("#g-upload-cancel-all") + .addClass("ui-state-disabled") + .attr("disabled", "disabled"); + return true; + }, + onComplete: function(event, queueID, fileObj, response, data) { + // @todo handle a response of "Error: xxxx" as an error + var re = /^error: (.*)$/i; + var msg = re.exec(response); + if (msg) { + $("#g-add-photos-status ul").append( + "<li class=\"g-error\">" + fileObj.name + " - " + msg[1] + "</li>"); + } else { + $("#g-add-photos-status ul").append( + "<li class=\"g-success\">" + fileObj.name + " - <?= t("Completed") ?></li>"); + } + return true; + }, + + onError: function(event, queueID, fileObj, errorObj) { + var msg = " - "; + if (errorObj.type == "HTTP") { + if (errorObj.info == "500") { + msg += "Error occurred processing the file"; + // Server error - check server logs + } else if (errorObj.info == "404") { + msg += "The upload script was not found."; + // Server script not found + } else { + // Server Error: status: errorObj.info + msg += "Error occurred communication with the server, status: " + errorObj.info; + } + } else if (errorObj.type == "File Size") { + var sizelimit = $("#g-uploadify").uploadifySettings(sizeLimit); + msg += fileObj.name+' '+errorObj.type+' Limit: '+Math.round(d.sizeLimit/1024)+'KB'; + } else { + msg += "Error occurred communication with the server, error " + errorObj.type + ": " + errorObj.info; + } + $("#g-add-photos-status ul").append( + "<li class=\"g-error\">" + fileObj.name + msg + "</li>"); + $("#g-uploadify" + queueID).remove(); + //return false; + }, + onSelect: function(event) { + if ($("#g-upload-cancel-all").hasClass("ui-state-disabled")) { + $("#g-upload-cancel-all") + .removeClass("ui-state-disabled") + .attr("disabled", null); + } + return true; + } + }); + + // @todo figure out how to actually get the offset or why it comes back 0 0 + var offset = $("#g-add-photos-button").offset(); + //$("#g-uploadifyUploader").css({top: "97px", position: "absolute", left: "198px"}); + //$("#g-add-photos-button").height("40px").width("120px"); + }); +</script> -<!-- hack to set the title for the dialog --> -<form id="gAddPhotosForm" action="<?= url::site("simple_uploader/finish?csrf=$csrf") ?>"> +<form id="g-add-photos-form" action="<?= url::site("simple_uploader/finish?csrf=$csrf") ?>"> <fieldset> <legend> <?= t("Add photos to %album_title", array("album_title" => html::purify($item->title))) ?> </legend> - </fieldset> -</form> -<div id="gAddPhotos"> - <? if (ini_get("suhosin.session.encrypt")): ?> - <ul id="gMessage"> - <li class="gError"> - <?= t("Error: your server is configured to use the <a href=\"%encrypt_url\"><code>suhosin.session.encrypt</code></a> setting from <a href=\"%suhosin_url\">Suhosin</a>. You must disable this setting to upload photos.", + </fieldset> + <div id="g-add-photos"> + <? if (ini_get("suhosin.session.encrypt")): ?> + <ul id="g-action-status" class="g-message-block"> + <li class="g-error"> + <?= t("Error: your server is configured to use the <a href=\"%encrypt_url\"><code>suhosin.session.encrypt</code></a> setting from <a href=\"%suhosin_url\">Suhosin</a>. You must disable this setting to upload photos.", array("encrypt_url" => "http://www.hardened-php.net/suhosin/configuration.html#suhosin.session.encrypt", - "suhosin_url" => "http://www.hardened-php.net/suhosin/")) ?> - </li> - </ul> - <? endif ?> - - <p> - <?= t("Photos will be uploaded to album: ") ?> - </p> - <ul class="gBreadcrumbs"> - <? foreach ($item->parents() as $parent): ?> - <li> <?= html::clean($parent->title) ?> </li> - <? endforeach ?> - <li class="active"> <?= html::purify($item->title) ?> </li> - </ul> - - <p> - <span id="gUploadQueueInfo"> - <?= t("Upload Queue") ?> - </span> - <a id="gUploadCancel" title="<?= t("Cancel all the pending uploads")->for_html_attr() ?>" onclick="swfu.cancelQueue();"><?= t("cancel") ?></a> - </p> - <div id="gAddPhotosCanvas" style="text-align: center;"> - <div id="gAddPhotosQueue"></div> - <div id="gEditPhotosQueue"></div> - <span id="gChooseFilesButtonPlaceholder"></span> + "suhosin_url" => "http://www.hardened-php.net/suhosin/")) ?> + </li> + </ul> + <? endif ?> + + <div> + <p> + <?= t("Photos will be uploaded to album: ") ?> + </p> + <ul class="g-breadcrumbs"> + <? foreach ($item->parents() as $i => $parent): ?> + <li<? if ($i == 0) print " class=\"g-first\"" ?>> <?= html::clean($parent->title) ?> </li> + <? endforeach ?> + <li class="g-active"> <?= html::purify($item->title) ?> </li> + </ul> + </div> + + <div id="g-add-photos-canvas" style="text-align: center;"> + <!-- a id="g-add-photos-button" class="ui-corner-all" style="padding-bottom: 1em;" href="#"><?= t("Select Photos...") ?></a --> + <span id="g-uploadify"></span> + </div> + <div id="g-add-photos-status" style="text-align: center;"> + <ul> + </ul> + </div> + + <!-- Proxy the done request back to our form, since its been ajaxified --> + <button id="g-upload-done" class="ui-state-default ui-corner-all" onclick="$('#g-add-photos-form').submit();return false;"> + <?= t("Done") ?> + </button> + <button id="g-upload-cancel-all" class="ui-state-default ui-corner-all ui-state-disabled" onclick="$('#g-uploadify').uploadifyClearQueue();return false;" disabled="disabled"> + <?= t("Cancel All") ?> + </button> </div> - <!-- - <button id="gUploadCancel" class="ui-state-default ui-corner-all" type="button" - onclick="swfu.cancelQueue();" - disabled="disabled"> - <?= t("Cancel all") ?> - </button> - --> - - <!-- Proxy the done request back to our form, since its been ajaxified --> - <button class="ui-state-default ui-corner-all" onclick="$('#gAddPhotosForm').submit()"> - <?= t("Close") ?> - </button> -</div> - -<style> - #SWFUpload_0 { - margin-top: 100px; - } - #gAddPhotos .gBreadcrumbs { - border: 0; - margin: 0; - padding-left:10px; - } - #gAddPhotosCanvas { - border: 1px solid #CCCCCC; - margin: .5em 0 .5em 0; - width: 469px; - } - #gAddPhotos button { - margin-bottom: .5em; - float: right; - } - #gAddPhotos #gUploadCancel { - display: none; - cursor: pointer; - } -</style> - -<script type="text/javascript"> - var swfu = new SWFUpload({ - flash_url: <?= html::js_string(url::file("lib/swfupload/swfupload.swf")) ?>, - upload_url: <?= html::js_string(url::site("simple_uploader/add_photo/$item->id")) ?>, - post_params: <?= json_encode(array( - "g3sid" => Session::instance()->id(), - "user_agent" => Input::instance()->server("HTTP_USER_AGENT"), - "csrf" => $csrf)) ?>, - file_size_limit: <?= html::js_string(ini_get("upload_max_filesize") ? num::convert_to_bytes(ini_get("upload_max_filesize"))."B" : "100MB") ?>, - file_types: "*.gif;*.jpg;*.jpeg;*.png;*.flv;*.mp4;*.GIF;*.JPG;*.JPEG;*.PNG;*.FLV;*.MP4", - file_types_description: <?= t("Photos and Movies")->for_js() ?>, - file_upload_limit: 1000, - file_queue_limit: 0, - custom_settings: { }, - debug: false, - - // Button settings - button_image_url: <?= html::js_string(url::file("themes/default/images/select-photos-backg.png")) ?>, - button_width: "202", - button_height: "45", - button_placeholder_id: "gChooseFilesButtonPlaceholder", - button_text: <?= json_encode('<span class="swfUploadFont">' . t("Select photos...") . '</span>') ?>, - button_text_style: ".swfUploadFont { color: #2E6E9E; font-size: 16px; font-family: Lucida Grande,Lucida Sans,Arial,sans-serif; font-weight: bold; }", - button_text_left_padding: 30, - button_text_top_padding: 10, - - // The event handler functions are defined in handlers.js - file_queued_handler: file_queued, - file_queue_error_handler: file_queue_error, - file_dialog_complete_handler: file_dialog_complete, - upload_start_handler: upload_start, - upload_progress_handler: upload_progress, - upload_error_handler: upload_error, - upload_success_handler: upload_success, - upload_complete_handler: upload_complete, - queue_complete_handler: queue_complete - }); - - // @todo add support for cancelling individual uploads - function File_Progress(file) { - this.box = $("#" + file.id); - if (!this.box.length) { - $("#gAddPhotosQueue").append( - "<div class=\"box\" id=\"" + file.id + "\">" + - "<div class=\"title\"></div>" + - "<div class=\"status\"></div>" + - "<div class=\"progressbar\"></div>" + - "</div>"); - this.box = $("#" + file.id); - } - this.title = this.box.find(".title"); - this.status = this.box.find(".status"); - this.progress_bar = this.box.find(".progressbar"); - this.progress_bar.progressbar(); - this.progress_bar.css("visibility", "hidden"); - } - - File_Progress.prototype.set_status = function(status_class, msg) { - this.box.removeClass("pending error uploading complete").addClass(status_class); - this.status.html(msg); - } - - function file_queued(file) { - var fp = new File_Progress(file); - fp.title.html(file.name); - fp.set_status("pending", <?= t("Pending...")->for_js() ?>); - // @todo add cancel button to call this.cancelUpload(file.id) - } - - function file_queue_error(file, error_code, message) { - if (error_code === SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED) { - alert(<?= t("You have attempted to queue too many files.")->for_js() ?>); - return; - } - - var fp = new File_Progress(file); - switch (error_code) { - case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT: - fp.title.html(file.name); - fp.set_status("error", <?= t("<strong>File is too big.</strong> A likely error source is a too low value for <em>upload_max_filesize</em> (%upload_max_filesize) in your <em>php.ini</em>.", array("upload_max_filesize" => ini_get("upload_max_filesize")))->for_js() ?>); - break; - case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE: - fp.title.html(file.name); - fp.set_status("error", <?= t("Cannot upload empty files.")->for_js() ?>); - break; - case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE: - fp.title.html(file.name); - fp.set_status("error", <?= t("Invalid file type.")->for_js() ?>); - break; - default: - if (file !== null) { - fp.title.html(file.name); - fp.set_status("error", <?= t("Unknown error")->for_js() ?>); - } - break; - } - } - - function file_dialog_complete(num_files_selected, num_files_queued) { - if (num_files_selected > 0) { - $("#gUploadCancel").show(); - $("#gUploadQueueInfo").text(get_completed_status_msg(this.getStats())); - } - - // Auto start the upload - this.startUpload(); - } - - function upload_start(file) { - // Do all file validation on the server side. Update the UI here because in Linux - // no uploadProgress events are called (limitation in the Linux Flash VM). - var fp = new File_Progress(file); - fp.title.html(file.name); - fp.set_status("uploading", <?= t("Uploading...")->for_js() ?>); - $("#gAddPhotosCanvas").scrollTo(fp.box, 1000); - return true; - // @todo add cancel button to call this.cancelUpload(file.id) - } - - function upload_progress(file, bytes_loaded, bytes_total) { - var percent = Math.ceil((bytes_loaded / bytes_total) * 100); - var fp = new File_Progress(file); - fp.set_status("uploading", <?= t("Uploading...")->for_js() ?>); - fp.progress_bar.css("visibility", "visible"); - fp.progress_bar.progressbar("value", percent); - } - - function upload_success(file, serverData) { - var fp = new File_Progress(file); - fp.progress_bar.progressbar("value", 100); - fp.set_status("complete", <?= t("Complete.")->for_js() ?>); - } - - function upload_error(file, error_code, message) { - var fp = new File_Progress(file); - switch (error_code) { - case SWFUpload.UPLOAD_ERROR.HTTP_ERROR: - fp.set_status("error", <?= t("Upload error: bad image file")->for_js() ?>); - break; - case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED: - fp.set_status("error", <?= t("Upload failed")->for_js() ?>); - break; - case SWFUpload.UPLOAD_ERROR.IO_ERROR: - fp.set_status("error", <?= t("Server error")->for_js() ?>); - break; - case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR: - fp.set_status("error", <?= t("Security error")->for_js() ?>); - break; - case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED: - fp.set_status("error", <?= t("Upload limit exceeded")->for_js() ?>); - break; - case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED: - fp.set_status("error", <?= t("Failed validation. File skipped")->for_js() ?>); - break; - case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED: - // If there aren't any files left (they were all cancelled) disable the cancel button - if (this.getStats().files_queued === 0) { - $("#gUploadCancel").hide(); - } - fp.set_status("error", <?= t("Cancelled")->for_js() ?>); - break; - case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED: - fp.set_status("error", <?= t("Stopped")->for_js() ?>); - break; - default: - fp.set_status("error", <?= t("Unknown error: ")->for_js() ?> + error_code); - break; - } - } - - function upload_complete(file) { - var stats = this.getStats(); - $("#gUploadQueueInfo").text(get_completed_status_msg(stats)); - if (stats.files_queued === 0) { - $("#gUploadCancel").hide(); - } - } - - function get_completed_status_msg(stats) { - var msg = <?= t("Upload Queue (completed %completed of %total)", array("completed" => "__COMPLETED__", "total" => "__TOTAL__"))->for_js() ?>; - msg = msg.replace("__COMPLETED__", stats.successful_uploads); - msg = msg.replace("__TOTAL__", stats.files_queued + stats.successful_uploads + - stats.upload_errors + stats.upload_cancelled + stats.queue_errors); - return msg; - } - - // This event comes from the Queue Plugin - function queue_complete(num_files_uploaded) { - var status_msg = <?= t("Uploaded: __COUNT__")->for_js() ?>; - $("#gUploadStatus").html(status_msg.replace("__COUNT__", num_files_uploaded)); - } -</script> +</form> diff --git a/modules/gallery/views/upgrader.html.php b/modules/gallery/views/upgrader.html.php index 8a01cd29..5cd1cd77 100644 --- a/modules/gallery/views/upgrader.html.php +++ b/modules/gallery/views/upgrader.html.php @@ -1,7 +1,7 @@ <?php defined("SYSPATH") or die("No direct script access.") ?> <html> <head> - <title><?= t("Gallery 3 Upgrader") ?></title> + <title><?= t("Gallery 3 upgrader") ?></title> <link rel="stylesheet" type="text/css" href="<?= url::file("modules/gallery/css/upgrader.css") ?>" media="screen,print,projection" /> <script src="<?= url::file("lib/jquery.js") ?>" type="text/javascript"></script> @@ -11,29 +11,54 @@ <img src="<?= url::file("modules/gallery/images/gallery.png") ?>" /> <div id="inner"> <? if ($can_upgrade): ?> - <? if ($done): ?> - <div id="confirmation"> - <a onclick="$('#confirmation').slideUp(); return false;" href="#" class="close">[x]</a> - <div> + <div id="dialog" style="visibility: hidden"> + <a id="dialog_close_link" style="display: none" onclick="$('#dialog').fadeOut(); return false;" href="#" class="close">[x]</a> + <div id="busy" style="display: none"> + <h1> + <img width="16" height="16" src="<?= url::file("lib/images/loading-small.gif") ?>"/> + <?= t("Upgrade in progress!") ?> + </h1> + <p> + <?= t("Please don't refresh or leave the page.") ?> + </p> + </div> + <div id="done" style="display: none"> <h1> <?= t("That's it!") ?> </h1> <p> <?= t("Your <a href=\"%url\">Gallery</a> is up to date.", - array("url" => html::mark_clean(item::root()->url()))) ?> + array("url" => html::mark_clean(item::root()->url()))) ?> </p> </div> </div> <script type="text/javascript"> $(document).ready(function() { - $("#confirmation").css("left", Math.round(($(window).width() - $("#confirmation").width()) / 2)); - $("#confirmation").css("top", Math.round(($(window).height() - $("#confirmation").height()) / 2)); + $("#dialog").css("left", Math.round(($(window).width() - $("#dialog").width()) / 2)); + $("#dialog").css("top", Math.round(($(window).height() - $("#dialog").height()) / 2)); + $("#upgrade_link").click(function(event) { show_busy() }); + + <? if ($done): ?> + show_done(); + <? endif ?> }); + + var show_busy = function() { + $("#dialog").css("visibility", "visible"); + $("#busy").show(); + $("#upgrade_link").parent().removeClass("button-active"); + $("#upgrade_link").replaceWith($("#upgrade_link").html()) + } + + var show_done = function() { + $("#dialog").css("visibility", "visible"); + $("#done").show(); + $("#dialog_close_link").show(); + } </script> - <? endif ?> - <p class="gray_on_done"> + <p class="<?= $done ? "muted" : "" ?>"> <?= t("Welcome to the Gallery upgrader. One click and you're done!") ?> </p> <table> - <tr class="gray_on_done"> + <tr class="<?= $done ? "muted" : "" ?>"> <th> <?= t("Module name") ?> </th> <th> <?= t("Installed version") ?> </th> <th> <?= t("Available version") ?> </th> @@ -58,17 +83,23 @@ <? endforeach ?> </table> - <div class="button gray_on_done"> - <a href="<?= url::site("upgrader/upgrade") ?>"> + <? if ($done): ?> + <div class="button muted"> + <?= t("Upgrade all") ?> + </div> + <? else: ?> + <div class="button button-active"> + <a id="upgrade_link" href="<?= url::site("upgrader/upgrade") ?>"> <?= t("Upgrade all") ?> </a> </div> + <? endif ?> <? if (@$inactive): ?> - <p class="gray_on_done"> + <p class="<?= $done ? "muted" : "" ?>"> <?= t("The following modules are inactive and don't require an upgrade.") ?> </p> - <ul class="gray_on_done"> + <ul class="<?= $done ? "muted" : "" ?>"> <? foreach ($available as $module): ?> <? if (!$module->active): ?> <li> diff --git a/modules/gallery/views/user_languages_block.html.php b/modules/gallery/views/user_languages_block.html.php new file mode 100644 index 00000000..89185967 --- /dev/null +++ b/modules/gallery/views/user_languages_block.html.php @@ -0,0 +1,19 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> +<?= form::dropdown("g-select-session-locale", $installed_locales, $selected) ?> +<script type="text/javascript"> + $("#g-select-session-locale").change(function() { + var old_locale_preference = <?= html::js_string($selected) ?>; + var locale = $(this).val(); + if (old_locale_preference == locale) { + return; + } + + var expires = -1; + if (locale) { + expires = 365; + } + $.cookie("g_locale", locale, {"expires": expires, "path": "/"}); + window.location.reload(true); + }); +</script> + diff --git a/modules/gallery/views/welcome_message.html.php b/modules/gallery/views/welcome_message.html.php index 5515c3dc..24d01bab 100644 --- a/modules/gallery/views/welcome_message.html.php +++ b/modules/gallery/views/welcome_message.html.php @@ -1,5 +1,5 @@ <?php defined("SYSPATH") or die("No direct script access.") ?> -<div id="gWelcomeMessage"> +<div id="g-welcome-message"> <h1 style="display: none"> <?= t("Welcome to Gallery 3!") ?> </h1> @@ -16,13 +16,13 @@ <p> <a href="<?= url::site("form/edit/users/{$user->id}") ?>" - title="<?= t("Edit Your Profile")->for_html_attr() ?>" - id="gAfterInstallChangePasswordLink" - class="gButtonLink ui-state-default ui-corners-all"> - <?= t("Change Password Now") ?> + title="<?= t("Edit your profile")->for_html_attr() ?>" + id="g-after-install-change-password-link" + class="g-button ui-state-default ui-corners-all"> + <?= t("Change password now") ?> </a> - <script> - $("#gAfterInstallChangePasswordLink").gallery_dialog(); + <script type="text/javascript"> + $("#g-after-install-change-password-link").gallery_dialog(); </script> </p> diff --git a/modules/gallery/views/welcome_message_loader.html.php b/modules/gallery/views/welcome_message_loader.html.php index 2c6bffca..d1ff2f3f 100644 --- a/modules/gallery/views/welcome_message_loader.html.php +++ b/modules/gallery/views/welcome_message_loader.html.php @@ -1,7 +1,7 @@ <?php defined("SYSPATH") or die("No direct script access.") ?> -<span id="gWelcomeMessageLink" +<span id="g-welcome-message-link" title="<?= t("Welcome to Gallery 3")->for_html_attr() ?>" href="<?= url::site("welcome_message") ?>"/> <script type="text/javascript"> - $(document).ready(function(){$("#gWelcomeMessageLink").gallery_dialog({immediate: true});}); + $(document).ready(function(){$("#g-welcome-message-link").gallery_dialog({immediate: true});}); </script> |