From a18ddd2fe9a920115df580a1ded5b2e33bb12a02 Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Sat, 27 Feb 2010 15:39:36 -0800 Subject: Add more randomness to reset password mechanism. --- modules/user/controllers/password.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/user/controllers/password.php b/modules/user/controllers/password.php index f5190974..38fa66be 100644 --- a/modules/user/controllers/password.php +++ b/modules/user/controllers/password.php @@ -52,7 +52,7 @@ class Password_Controller extends Controller { $user_name = $form->reset->inputs["name"]->value; $user = user::lookup_by_name($user_name); if ($user && !empty($user->email)) { - $user->hash = md5(rand()); + $user->hash = md5(uniqid(mt_rand(), true)); $user->save(); $message = new View("reset_password.html"); $message->confirm_url = url::abs_site("password/do_reset?key=$user->hash"); -- cgit v1.2.3 From 48193371e4a1fc315a5f24986dbdad002270e061 Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Sat, 27 Feb 2010 18:54:36 -0800 Subject: Incremental fix for ticket #1042: Delete translation from outgoing_translations when the user submits a form with an empty translation. --- modules/gallery/controllers/l10n_client.php | 36 +++++++++++++++++------------ 1 file changed, 21 insertions(+), 15 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/l10n_client.php b/modules/gallery/controllers/l10n_client.php index be0aaa11..e3b47681 100644 --- a/modules/gallery/controllers/l10n_client.php +++ b/modules/gallery/controllers/l10n_client.php @@ -60,25 +60,31 @@ class L10n_Client_Controller extends Controller { ->where("locale", "=", $locale) ->find(); - if (!$entry->loaded()) { - $entry->key = $key; - $entry->locale = $locale; - $entry->message = $root_message->message; - $entry->base_revision = null; - } + if (empty($translation)) { + if ($entry->loaded()) { + $entry->delete(); + } + } else { + if (!$entry->loaded()) { + $entry->key = $key; + $entry->locale = $locale; + $entry->message = $root_message->message; + $entry->base_revision = null; + } - $entry->translation = serialize($translation); + $entry->translation = serialize($translation); - $entry_from_incoming = ORM::factory("incoming_translation") - ->where("key", "=", $key) - ->where("locale", "=", $locale) - ->find(); + $entry_from_incoming = ORM::factory("incoming_translation") + ->where("key", "=", $key) + ->where("locale", "=", $locale) + ->find(); - if (!$entry_from_incoming->loaded()) { - $entry->base_revision = $entry_from_incoming->revision; - } + if (!$entry_from_incoming->loaded()) { + $entry->base_revision = $entry_from_incoming->revision; + } - $entry->save(); + $entry->save(); + } Gallery_I18n::clear_cache($locale); -- cgit v1.2.3 From 8366f58ef9621679600ae0862cf72418d3e6f6fd Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Sat, 27 Feb 2010 19:13:22 -0800 Subject: Client (UI) side fix for ticket #1042, based on a patch from fpaterno (Florent Paterno). Mark message as untranslated if the translation is empty. --- modules/gallery/js/l10n_client.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/js/l10n_client.js b/modules/gallery/js/l10n_client.js index d0d6f619..c9009d97 100644 --- a/modules/gallery/js/l10n_client.js +++ b/modules/gallery/js/l10n_client.js @@ -260,18 +260,26 @@ Gallery.behaviors.l10nClient = function(context) { // Store translation in local js var translation = {}; + var is_non_empty = false; if (is_plural) { for (var i = 0; i < num_plural_forms; i++) { var form = plural_forms[i]; translation[form] = $('#g-l10n-client-save-form #l10n-edit-plural-translation-' + form).attr('value'); + is_non_empty |= translation[form]; } } else { translation = $('#l10n-edit-translation').attr('value'); + is_non_empty = translation; } Gallery.l10nClient.setString(Gallery.l10nClient.selected, translation); - // Mark message as translated. - $('#l10n-client-string-select li').eq(Gallery.l10nClient.selected).removeClass('untranslated').removeClass('active').addClass('translated'); + // Mark message as translated / untranslated. + var source_element = $('#l10n-client-string-select li').eq(Gallery.l10nClient.selected); + if (is_non_empty) { + source_element.removeClass('untranslated').removeClass('active').addClass('translated'); + } else { + source_element.removeClass('active').removeClass('translated').addClass('untranslated'); + } // Clear the translation form fields Gallery.l10nClient.showSourceMessage('', false); -- cgit v1.2.3 From caf9ae88badfa5c2b8eb3eac03e298f1beea79a3 Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Sat, 27 Feb 2010 19:47:08 -0800 Subject: Fix l10n client, copy of existing plural translation to form fields. I think this was broken in a recent jQuery update. It used to allow matching the HTML "name" attribute with #name_value, now you need to match by elementName[name=name_value]. --- modules/gallery/js/l10n_client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/js/l10n_client.js b/modules/gallery/js/l10n_client.js index c9009d97..a77667f3 100644 --- a/modules/gallery/js/l10n_client.js +++ b/modules/gallery/js/l10n_client.js @@ -124,7 +124,7 @@ jQuery.extend(Gallery, { if (translation[form] == undefined) { translation[form] = ''; } - $('#l10n-edit-plural-translation-' + form) + $("#plural-" + form + " textarea[name='l10n-edit-plural-translation-" + form + "']") .attr('value', translation[form]); $('#plural-' + form).removeClass('hidden'); } -- cgit v1.2.3 From dacb58ceed224fea34fa9cff740e6f30c70f0a7f Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Sat, 27 Feb 2010 20:06:37 -0800 Subject: Additional fixes for plural handling when deleting translations / marking them as untranslated. --- modules/gallery/controllers/l10n_client.php | 5 ++++- modules/gallery/js/l10n_client.js | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/l10n_client.php b/modules/gallery/controllers/l10n_client.php index e3b47681..084f88af 100644 --- a/modules/gallery/controllers/l10n_client.php +++ b/modules/gallery/controllers/l10n_client.php @@ -38,6 +38,7 @@ class L10n_Client_Controller extends Controller { } $is_plural = Gallery_I18n::is_plural_message(unserialize($root_message->message)); + $is_empty = true; if ($is_plural) { $plural_forms = l10n_client::plural_forms($locale); $translation = array(); @@ -47,9 +48,11 @@ class L10n_Client_Controller extends Controller { throw new Exception("@todo bad request data"); } $translation[$plural_form] = $value; + $is_empty = $is_empty && empty($value); } } else { $translation = $input->post("l10n-edit-translation"); + $is_empty = empty($translation); if (null === $translation || !is_string($translation)) { throw new Exception("@todo bad request data"); } @@ -60,7 +63,7 @@ class L10n_Client_Controller extends Controller { ->where("locale", "=", $locale) ->find(); - if (empty($translation)) { + if ($is_empty) { if ($entry->loaded()) { $entry->delete(); } diff --git a/modules/gallery/js/l10n_client.js b/modules/gallery/js/l10n_client.js index a77667f3..a1170e2d 100644 --- a/modules/gallery/js/l10n_client.js +++ b/modules/gallery/js/l10n_client.js @@ -166,7 +166,7 @@ jQuery.extend(Gallery, { if (form == 'one') { text = source['one']; } - $('#l10n-edit-plural-translation-' + form) + $("#plural-" + form + " textarea[name='l10n-edit-plural-translation-" + form + "']") .attr('value', text); } } else { @@ -264,8 +264,8 @@ Gallery.behaviors.l10nClient = function(context) { if (is_plural) { for (var i = 0; i < num_plural_forms; i++) { var form = plural_forms[i]; - translation[form] = $('#g-l10n-client-save-form #l10n-edit-plural-translation-' + form).attr('value'); - is_non_empty |= translation[form]; + translation[form] = $("#plural-" + form + " textarea[name='l10n-edit-plural-translation-" + form + "']").attr('value'); + is_non_empty = is_non_empty || translation[form]; } } else { translation = $('#l10n-edit-translation').attr('value'); @@ -287,7 +287,7 @@ Gallery.behaviors.l10nClient = function(context) { for (var i = 0; i < num_plural_forms; i++) { var form = plural_forms[i]; - $('#g-l10n-client-save-form #l10n-edit-plural-translation-' + form).val(''); + $("#plural-" + form + " textarea[name='l10n-edit-plural-translation-" + form + "']").val(''); } $("#g-l10n-client-save-form input[name='l10n-message-key']").val(''); }, -- cgit v1.2.3 From 74113f869a37bd5eda1175c9eb520b938c4793c4 Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Sat, 27 Feb 2010 20:21:22 -0800 Subject: Fix for ticket #1037: Only show language drop-down when there's actually a choice. --- modules/gallery/helpers/gallery_block.php | 2 +- modules/user/controllers/users.php | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/gallery_block.php b/modules/gallery/helpers/gallery_block.php index 46742743..eabdcebc 100644 --- a/modules/gallery/helpers/gallery_block.php +++ b/modules/gallery/helpers/gallery_block.php @@ -93,7 +93,7 @@ class gallery_block_Core { case "language": $locales = locales::installed(); - if (count($locales)) { + if (count($locales) > 1) { foreach ($locales as $locale => $display_name) { $locales[$locale] = SafeString::of_safe_html($display_name); } diff --git a/modules/user/controllers/users.php b/modules/user/controllers/users.php index cd7d271f..a5fdd994 100644 --- a/modules/user/controllers/users.php +++ b/modules/user/controllers/users.php @@ -30,7 +30,8 @@ class Users_Controller extends Controller { $user->full_name = $form->edit_user->full_name->value; $user->url = $form->edit_user->url->value; - if ($user->locale != $form->edit_user->locale->value) { + if (count(locales::installed()) > 1 && + $user->locale != $form->edit_user->locale->value) { $user->locale = $form->edit_user->locale->value; $flush_locale_cookie = true; } @@ -221,6 +222,10 @@ class Users_Controller extends Controller { /** @todo combine with Admin_Users_Controller::_add_locale_dropdown */ private function _add_locale_dropdown(&$form, $user=null) { $locales = locales::installed(); + if (count($locales) <= 1) { + return; + } + foreach ($locales as $locale => $display_name) { $locales[$locale] = SafeString::of_safe_html($display_name); } -- cgit v1.2.3 From 70837b5212966e173c886c376fae20a29cee8737 Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Sat, 27 Feb 2010 21:26:38 -0800 Subject: Fix for ticket #1035: Make .htaccess access rules work for the case when index.php isn't part of generated URLs. --- modules/gallery/helpers/access.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/access.php b/modules/gallery/helpers/access.php index 7e8b079a..af336798 100644 --- a/modules/gallery/helpers/access.php +++ b/modules/gallery/helpers/access.php @@ -637,8 +637,22 @@ class access_Core { $dirs[] = dirname($album->thumb_path()); } - $base_url = url::site("?kohana_uri=/file_proxy"); - $base_url = str_replace("/?", "?", $base_url); + $base_url = url::base(true); + $sep = "?"; + if (strpos($base_url, "?") !== false) { + $sep = "&"; + } + $base_url .= $sep . "kohana_uri=/file_proxy"; + // Replace "/index.php/?kohana..." with "/index.php?koahan..." + // Doesn't apply to "/?kohana..." or "/foo/?kohana..." + // Can't check for "index.php" since the file might be renamed, and + // there might be more Apache aliases / rewrites at work. + $url_path = parse_url($base_url, PHP_URL_PATH); + // Does the URL path have a file component? + if (preg_match("#[^/]+\.php#i", $url_path)) { + $base_url = str_replace("/?", "?", $base_url); + } + foreach ($dirs as $dir) { if ($value === self::DENY) { $fp = fopen("$dir/.htaccess", "w+"); -- cgit v1.2.3 From 107909043add11045c76866564dead06a3385fb6 Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Sun, 28 Feb 2010 13:09:57 -0800 Subject: Fix profiler display: It looks like it was broken by an API change in the latest kohana upgrade. --- modules/gallery/helpers/gallery_theme.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'modules') diff --git a/modules/gallery/helpers/gallery_theme.php b/modules/gallery/helpers/gallery_theme.php index d6944323..7f2d4ec7 100644 --- a/modules/gallery/helpers/gallery_theme.php +++ b/modules/gallery/helpers/gallery_theme.php @@ -71,6 +71,7 @@ class gallery_theme_Core { static function page_bottom($theme) { $session = Session::instance(); if ($session->get("profiler", false)) { + Profiler::enable(); $profiler = new Profiler(); $profiler->render(); } @@ -87,6 +88,7 @@ class gallery_theme_Core { static function admin_page_bottom($theme) { $session = Session::instance(); if ($session->get("profiler", false)) { + Profiler::enable(); $profiler = new Profiler(); $profiler->render(); } -- cgit v1.2.3 From a19b97f8d637ead3a4b038bdbd975be8a7583c59 Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Sun, 28 Feb 2010 13:35:58 -0800 Subject: First step towards fixing ticket #1038: Allowing for custom page in admin pages, just like in non-admin pages. TODO: Set $view->page_title in the many admin controllers we have. I just set it for admin_maintenance.php to show how it's intended to be used. I copied the title from views/admin_maintenance.html.php to the controller. --- modules/gallery/controllers/admin_maintenance.php | 1 + modules/gallery/libraries/Admin_View.php | 1 + themes/admin_wind/views/admin.html.php | 8 +++++++- 3 files changed, 9 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/controllers/admin_maintenance.php b/modules/gallery/controllers/admin_maintenance.php index c16c5c41..6ef21d41 100644 --- a/modules/gallery/controllers/admin_maintenance.php +++ b/modules/gallery/controllers/admin_maintenance.php @@ -40,6 +40,7 @@ class Admin_Maintenance_Controller extends Admin_Controller { } $view = new Admin_View("admin.html"); + $view->page_title = t("Maintenance tasks"); $view->content = new View("admin_maintenance.html"); $view->content->task_definitions = task::get_definitions(); $view->content->running_tasks = ORM::factory("task") diff --git a/modules/gallery/libraries/Admin_View.php b/modules/gallery/libraries/Admin_View.php index e3f9dff0..f07bebf4 100644 --- a/modules/gallery/libraries/Admin_View.php +++ b/modules/gallery/libraries/Admin_View.php @@ -38,6 +38,7 @@ class Admin_View_Core extends Gallery_View { $this->set_global("user", identity::active_user()); $this->set_global("page_type", "admin"); $this->set_global("page_subtype", $name); + $this->set_global("page_title", null); } public function admin_menu() { diff --git a/themes/admin_wind/views/admin.html.php b/themes/admin_wind/views/admin.html.php index fa79119a..2f64c847 100644 --- a/themes/admin_wind/views/admin.html.php +++ b/themes/admin_wind/views/admin.html.php @@ -4,7 +4,13 @@ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> - <title><?= t("Admin dashboard") ?> + + <? if ($page_title): ?> + <?= $page_title ?> + <? else: ?> + <?= t("Admin dashboard") ?> + <? endif ?> + " type="image/x-icon" /> css("yui/reset-fonts-grids.css") ?> -- cgit v1.2.3 From 5f985b3e2aa404d9b1145796dff8bc4c1e48b3f0 Mon Sep 17 00:00:00 2001 From: Chad Kieffer Date: Sun, 28 Feb 2010 18:46:43 -0700 Subject: Updates to upload CSS to make it themeable and RTL compatible. Use absolute positioning to handle upload button positioning. Remove color definitions to allow jQuery UI theme to set button colors. Consolidate upload dialog CSS to modules/css/gallery.css. Closes #885. --- lib/gallery.common.css | 66 ++++---------------------- modules/gallery/css/gallery.css | 68 +++++++++++++++++++++++++++ modules/gallery/views/form_uploadify.html.php | 29 ++---------- 3 files changed, 80 insertions(+), 83 deletions(-) (limited to 'modules') diff --git a/lib/gallery.common.css b/lib/gallery.common.css index 98b4ee40..31988b67 100644 --- a/lib/gallery.common.css +++ b/lib/gallery.common.css @@ -273,7 +273,7 @@ form li.g-warning { } .g-short-form li.g-error { - padding: .3em 0 .3em 0; + padding: .3em 0; } form.g-error input[type="text"], @@ -294,7 +294,8 @@ li.g-error select { .g-error, .g-denied, -tr.g-error td.g-error { +tr.g-error td.g-error, +#g-add-photos-status .g-error { background: #f6cbca url('images/ico-error.png') no-repeat .4em 50%; color: #f00; } @@ -304,7 +305,8 @@ tr.g-error td.g-error { } .g-success, -.g-allowed { +.g-allowed, +#g-add-photos-status .g-success { background: #d9efc2 url('images/ico-success.png') no-repeat .4em 50%; } @@ -603,60 +605,6 @@ div#g-action-status { margin-left: 0; } -/* Simple uploader ~~~~~~~~~~~~~~~~~~~~~~~ */ - -#g-add-photos-canvas { - border: 1px solid #ccc; - height: 200px; - margin: .5em 0; - overflow: auto; - width: 469px; -} - -#g-add-photos-status { - border: 1px solid #ccc; - height: 125px; - margin: .5em 0; - overflow: auto; - width: 469px; -} - -#g-add-photos button { - float: right; - margin-bottom: .5em; - margin-left: .5em; -} - -#g-add-photos-status li { - text-align: left; - padding-left: 2em; -} - -#g-add-photos-status li.g-success { - background: #d9efc2 url('images/ico-success.png') no-repeat .4em 50%; - width: 429px; -} - -#g-add-photos-status li.g-error { - background: #f6cbca url('images/ico-error.png') no-repeat .4em 50%; - width: 429px; -/* color: #f00;*/ -} - -#g-add-photos-button { - background: #DFEFFC; - border: 1px solid #C5DBEC; - color: #2E6E9E -} - -#g-add-photos p { - margin: 0 -} - -#g-add-photos .g-breadcrumbs li { - padding-top: .5em; -} - /** ******************************************************************* * 7) Right to left language styles **********************************************************************/ @@ -685,7 +633,9 @@ div#g-action-status { .rtl .g-error, .rtl .g-info, .rtl .g-success, -.rtl .g-warning { +.rtl .g-warning, +.rtl #g-add-photos-status .g-success, +.rtl #g-add-photos-status .g-error { background-position: center right; padding-right: 30px !important; } diff --git a/modules/gallery/css/gallery.css b/modules/gallery/css/gallery.css index f3e5ec6d..ed9986bf 100644 --- a/modules/gallery/css/gallery.css +++ b/modules/gallery/css/gallery.css @@ -11,6 +11,70 @@ * 1) End-user **********************************************************************/ +/* Uploader ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#g-add-photos-canvas, +#g-add-photos-status { + width: 469px; +} + +#g-add-photos-canvas { + border: 1px solid #ccc; + height: 200px; + margin: .5em 0; + padding: 1.8em 0 0 0; + overflow: auto; + position: relative; +} + +#g-add-photos-canvas object, +#g-add-photos-button { + left: 137px; + margin: 0 0 .5em 0; + padding: .4em 1em; + position: absolute; + top: 0; + width: 175px; +} + +#g-add-photos-canvas object { + margin: 0; + z-index: 100; +} + +#g-add-photos-canvas .uploadifyQueueItem { + margin: 0; +} + +#g-add-photos-button { + z-index: 1; +} + +#g-add-photos-status { + border: 1px solid #ccc; + height: 125px; + margin: .4em 0; + overflow: auto; +} + +#g-add-photos-status .g-message-block { + border: none; +} + +#g-add-photos-status #g-action-status li { + margin: 0 0 1px 0; + padding-top: .7em; + width: 433px; +} + +#g-add-photos-form .g-breadcrumbs { + margin: 0; +} + +#g-add-photos-form p { + margin-bottom: 0 +} + /* Permissions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #g-edit-permissions-form { @@ -121,6 +185,10 @@ * 3) Right to left language styles **********************************************************************/ +.rtl #g-add-photos-status #g-action-status li { + width: 407px; +} + .rtl #g-block-admin .g-left { margin-left: 1em; margin-right: 0; diff --git a/modules/gallery/views/form_uploadify.html.php b/modules/gallery/views/form_uploadify.html.php index 137cb353..2cb690ea 100644 --- a/modules/gallery/views/form_uploadify.html.php +++ b/modules/gallery/views/form_uploadify.html.php @@ -1,25 +1,4 @@ -