From 45910ffdc051ab4298269f1398f43d00517d4884 Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Thu, 18 Feb 2010 14:43:18 -0800 Subject: Improve setlocale() call, using some of G2's locale fallback code to match the platform's locale names. --- modules/gallery/libraries/Gallery_I18n.php | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'modules') diff --git a/modules/gallery/libraries/Gallery_I18n.php b/modules/gallery/libraries/Gallery_I18n.php index 160543c9..26d1de2c 100644 --- a/modules/gallery/libraries/Gallery_I18n.php +++ b/modules/gallery/libraries/Gallery_I18n.php @@ -73,12 +73,26 @@ class Gallery_I18n_Core { public function locale($locale=null) { if ($locale) { $this->_config['default_locale'] = $locale; - // Attempt to set PHP's locale as well (for number formatting, collation, etc.) - // TODO: See G2 for better fallack code. - $locale_prefs = array($locale); - $locale_prefs[] = 'en_US'; - $new_locale = setlocale(LC_ALL, $locale_prefs); - if (is_string($new_locale) && strpos($new_locale, 'tr') === 0) { + $php_locale = setlocale(LC_ALL, 0); + list ($php_locale, $unused) = explode('.', $php_locale . '.'); + if ($php_locale != $locale) { + // Attempt to set PHP's locale as well (for number formatting, collation, etc.) + $locale_prefs = array($locale); + // Try appending some character set names; some systems (like FreeBSD) need this. + // Some systems require a format with hyphen (eg. Gentoo) and others without (eg. FreeBSD). + $charsets = array('utf8', 'UTF-8', 'UTF8', 'ISO8859-1', 'ISO-8859-1'); + if (substr($locale, 0, 2) != 'en') { + $charsets = array_merge($charsets, array( + 'EUC', 'Big5', 'euc', 'ISO8859-2', 'ISO8859-5', 'ISO8859-7', + 'ISO8859-9', 'ISO-8859-2', 'ISO-8859-5', 'ISO-8859-7', 'ISO-8859-9')); + } + foreach ($charsets as $charset) { + $locale_prefs[] = $locale . '.' . $charset; + } + $locale_prefs[] = 'en_US'; + $php_locale = setlocale(LC_ALL, $locale_prefs); + } + if (is_string($php_locale) && substr($php_locale, 0, 2) == 'tr') { // Make PHP 5 work with Turkish (the localization results are mixed though). // Hack for http://bugs.php.net/18556 setlocale(LC_CTYPE, 'C'); -- cgit v1.2.3 From 22bc871e2b04633c7c50bdd86ae73c8e41aaaaae Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Thu, 18 Feb 2010 17:54:29 -0800 Subject: Fix for tickets #1024 and #1025: Fix formatting of album tree list in the organize dialog, and (magically) drag and drop move to another album works as well again. Tested in FF3.5, Chrome5 on Ubuntu Linux. --- modules/organize/views/organize_tree.html.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'modules') diff --git a/modules/organize/views/organize_tree.html.php b/modules/organize/views/organize_tree.html.php index 33d7b4c9..044b6858 100644 --- a/modules/organize/views/organize_tree.html.php +++ b/modules/organize/views/organize_tree.html.php @@ -3,24 +3,27 @@ ref="id ?>"> - " + " ref="id ?>"> title) ?> -
    - children(null, null, array(array("type", "=", "album"))) as $child): ?> + viewable()->children(null, null, array(array("type", "=", "album"))); ?> + +
      + contains($selected)): ?> $selected, "album" => $child)); ?>
    • " ref="id ?>"> - " ref="id ?>"> + " ref="id ?>"> title) ?>
    + -- cgit v1.2.3 From d3e07f8a97627a500bad07ce0a68ac91a766ccd4 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 18 Feb 2010 16:19:41 -0800 Subject: Revert "Fix for ticket #1017: Handle the common case of t(html::clean($var)) by casting SafeString instances to string in translate()." This reverts commit 4ca55a90ee2f8e1d8595b0ec53a601d6c65475f6. --- modules/gallery/libraries/Gallery_I18n.php | 3 --- 1 file changed, 3 deletions(-) (limited to 'modules') diff --git a/modules/gallery/libraries/Gallery_I18n.php b/modules/gallery/libraries/Gallery_I18n.php index 26d1de2c..ac0588e3 100644 --- a/modules/gallery/libraries/Gallery_I18n.php +++ b/modules/gallery/libraries/Gallery_I18n.php @@ -131,9 +131,6 @@ class Gallery_I18n_Core { $count = isset($options['count']) ? $options['count'] : null; $values = $options; unset($values['locale']); - if ($message instanceof SafeString) { - $message = (string) $message; - } $this->log($message, $options); $entry = $this->lookup($locale, $message); -- cgit v1.2.3 From 99c131e845b5bbfa22b93fa783b5ce671bc27e40 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 18 Feb 2010 16:20:23 -0800 Subject: Revert "Never assign a SafeString instance to a Model member (or hell will break loose)." This reverts commit dcddc68f58dac2f0fe71f5a00ea4af32618efa13. --- modules/gallery/helpers/gallery_installer.php | 2 +- modules/user/helpers/user_installer.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index b594ddcf..45d991af 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -287,7 +287,7 @@ class gallery_installer { // Mark string for translation $powered_by_string = t("Powered by %gallery_version", array("locale" => "root")); - module::set_var("gallery", "credits", (string) $powered_by_string); + module::set_var("gallery", "credits", $powered_by_string); module::set_var("gallery", "simultaneous_upload_limit", 5); module::set_var("gallery", "admin_area_timeout", 90 * 60); module::set_version("gallery", 29); diff --git a/modules/user/helpers/user_installer.php b/modules/user/helpers/user_installer.php index 9e757ecd..c57ad010 100644 --- a/modules/user/helpers/user_installer.php +++ b/modules/user/helpers/user_installer.php @@ -98,25 +98,25 @@ class user_installer { DEFAULT CHARSET=utf8;"); $everybody = ORM::factory("group"); - $everybody->name = (string) t("Everybody", array("locale" => "root")); + $everybody->name = t("Everybody", array("locale" => "root")); $everybody->special = true; $everybody->save(); $registered = ORM::factory("group"); - $registered->name = (string) t("Registered Users", array("locale" => "root")); + $registered->name = t("Registered Users", array("locale" => "root")); $registered->special = true; $registered->save(); $guest = ORM::factory("user"); $guest->name = "guest"; - $guest->full_name = (string) t("Guest User", array("locale" => "root")); + $guest->full_name = t("Guest User", array("locale" => "root")); $guest->password = ""; $guest->guest = true; $guest->save(); $admin = ORM::factory("user"); $admin->name = "admin"; - $admin->full_name = (string) t("Gallery Administrator", array("locale" => "root")); + $admin->full_name = t("Gallery Administrator", array("locale" => "root")); $admin->password = "admin"; $admin->email = "unknown@unknown.com"; $admin->admin = true; -- cgit v1.2.3 From 7d98d4b7b9d16f32ed98c8eeb051be4149468dc6 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 18 Feb 2010 16:20:59 -0800 Subject: Revert "Fix for ticket #491: Make user and group names translatable." This reverts commit 409121942590e12692eaf4e6e9e8b71bfe5ed60c. --- modules/gallery/controllers/user_profile.php | 5 ++--- modules/gallery/helpers/gallery_event.php | 3 --- modules/gallery/views/permissions_form.html.php | 2 +- modules/user/helpers/user_installer.php | 8 ++++---- modules/user/models/user.php | 2 +- modules/user/views/admin_users.html.php | 2 +- modules/user/views/admin_users_group.html.php | 6 +++--- 7 files changed, 12 insertions(+), 16 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/user_profile.php b/modules/gallery/controllers/user_profile.php index 05373466..327d2ff1 100644 --- a/modules/gallery/controllers/user_profile.php +++ b/modules/gallery/controllers/user_profile.php @@ -23,8 +23,7 @@ class User_Profile_Controller extends Controller { $user = identity::lookup_user($id); $active_user = identity::active_user(); $is_current_active = $active_user->id == $id; - $can_edit = $is_current_active && !$active_user->guest; - $display_all = $active_user->admin || $can_edit; + $display_all = $active_user->admin || ($is_current_active && !$active_user->guest); $v = new Theme_View("page.html", "other", "profile"); $v->page_title = t("%name Profile", array("name" => $user->display_name())); @@ -33,7 +32,7 @@ class User_Profile_Controller extends Controller { // @todo modify user_home to supply a link to their album, $v->content->user = $user; $v->content->not_current = !$is_current_active; - $v->content->editable = identity::is_writable() && $can_edit; + $v->content->editable = identity::is_writable() && $display_all; $event_data = (object)array("user" => $user, "display_all" => $display_all, "content" => array()); module::event("show_user_profile", $event_data); diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index 3f77bc42..faf1c0c6 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -423,9 +423,6 @@ class gallery_event_Core { if ($field == "locale") { $value = locales::display_name($value); } - if ($field == "full_name") { - $value = t($value); - } $v->user_profile_data[(string) $label] = $value; } } diff --git a/modules/gallery/views/permissions_form.html.php b/modules/gallery/views/permissions_form.html.php index b486acb7..f1714119 100644 --- a/modules/gallery/views/permissions_form.html.php +++ b/modules/gallery/views/permissions_form.html.php @@ -5,7 +5,7 @@ - name)) ?> + name) ?> diff --git a/modules/user/helpers/user_installer.php b/modules/user/helpers/user_installer.php index c57ad010..729f087a 100644 --- a/modules/user/helpers/user_installer.php +++ b/modules/user/helpers/user_installer.php @@ -98,25 +98,25 @@ class user_installer { DEFAULT CHARSET=utf8;"); $everybody = ORM::factory("group"); - $everybody->name = t("Everybody", array("locale" => "root")); + $everybody->name = "Everybody"; $everybody->special = true; $everybody->save(); $registered = ORM::factory("group"); - $registered->name = t("Registered Users", array("locale" => "root")); + $registered->name = "Registered Users"; $registered->special = true; $registered->save(); $guest = ORM::factory("user"); $guest->name = "guest"; - $guest->full_name = t("Guest User", array("locale" => "root")); + $guest->full_name = "Guest User"; $guest->password = ""; $guest->guest = true; $guest->save(); $admin = ORM::factory("user"); $admin->name = "admin"; - $admin->full_name = t("Gallery Administrator", array("locale" => "root")); + $admin->full_name = "Gallery Administrator"; $admin->password = "admin"; $admin->email = "unknown@unknown.com"; $admin->admin = true; diff --git a/modules/user/models/user.php b/modules/user/models/user.php index aa752203..4404ee63 100644 --- a/modules/user/models/user.php +++ b/modules/user/models/user.php @@ -113,7 +113,7 @@ class User_Model extends ORM implements User_Definition { * @return string */ public function display_name() { - return empty($this->full_name) ? $this->name : t($this->full_name); + return empty($this->full_name) ? $this->name : $this->full_name; } /** diff --git a/modules/user/views/admin_users.html.php b/modules/user/views/admin_users.html.php index 69d97547..270a7207 100644 --- a/modules/user/views/admin_users.html.php +++ b/modules/user/views/admin_users.html.php @@ -78,7 +78,7 @@ name) ?> - full_name)) ?> + full_name) ?> email) ?> diff --git a/modules/user/views/admin_users_group.html.php b/modules/user/views/admin_users_group.html.php index 8317d393..6c6c341e 100644 --- a/modules/user/views/admin_users_group.html.php +++ b/modules/user/views/admin_users_group.html.php @@ -1,9 +1,9 @@

    - name)) ?> + name) ?> special): ?> id") ?>" - title=" t(html::clean($group->name))))->for_html_attr() ?>" + title=" $group->name))->for_html_attr() ?>" class="g-dialog-link g-button g-right"> @@ -22,7 +22,7 @@ $user->name, "group" => t(html::clean($group->name))))->for_html_attr() ?>"> + array("user" => $user->name, "group" => $group->name))->for_html_attr() ?>"> -- cgit v1.2.3 From 0d72daf3d2d831ca3588ebabe720029bab3ccb8f Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 18 Feb 2010 16:32:25 -0800 Subject: Restore the gallery_installer change from reverted dcddc68f58dac2f0fe71f5a00ea4af32618efa13 that casts $powered_by_string from SafeString to string. --- modules/gallery/helpers/gallery_installer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index 45d991af..b594ddcf 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -287,7 +287,7 @@ class gallery_installer { // Mark string for translation $powered_by_string = t("Powered by %gallery_version", array("locale" => "root")); - module::set_var("gallery", "credits", $powered_by_string); + module::set_var("gallery", "credits", (string) $powered_by_string); module::set_var("gallery", "simultaneous_upload_limit", 5); module::set_var("gallery", "admin_area_timeout", 90 * 60); module::set_version("gallery", 29); -- cgit v1.2.3 From 4c637530440860a90ac39fe04037ed8adfcbe17a Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 18 Feb 2010 16:33:57 -0800 Subject: Restore the user_profile.php change from reverted 409121942590e12692eaf4e6e9e8b71bfe5ed60c that had this comment in the change: "Also fixed a UI bug: No longer showing the edit user buttons to admins in the profile view (to be consistent with the requirements in the controller)." --- modules/gallery/controllers/user_profile.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/user_profile.php b/modules/gallery/controllers/user_profile.php index 327d2ff1..05373466 100644 --- a/modules/gallery/controllers/user_profile.php +++ b/modules/gallery/controllers/user_profile.php @@ -23,7 +23,8 @@ class User_Profile_Controller extends Controller { $user = identity::lookup_user($id); $active_user = identity::active_user(); $is_current_active = $active_user->id == $id; - $display_all = $active_user->admin || ($is_current_active && !$active_user->guest); + $can_edit = $is_current_active && !$active_user->guest; + $display_all = $active_user->admin || $can_edit; $v = new Theme_View("page.html", "other", "profile"); $v->page_title = t("%name Profile", array("name" => $user->display_name())); @@ -32,7 +33,7 @@ class User_Profile_Controller extends Controller { // @todo modify user_home to supply a link to their album, $v->content->user = $user; $v->content->not_current = !$is_current_active; - $v->content->editable = identity::is_writable() && $display_all; + $v->content->editable = identity::is_writable() && $can_edit; $event_data = (object)array("user" => $user, "display_all" => $display_all, "content" => array()); module::event("show_user_profile", $event_data); -- cgit v1.2.3