From 1855642bd169a1cae69cd9efb8da4458ea6e4a3c Mon Sep 17 00:00:00 2001 From: jhilden Date: Fri, 28 Aug 2009 16:19:41 -0400 Subject: improved UI for the languages admin this should take care of bug #329 --- modules/gallery/controllers/admin_languages.php | 52 +++++++----------- modules/gallery/views/admin_languages.html.php | 71 ++++++++++++++++++++++--- 2 files changed, 82 insertions(+), 41 deletions(-) (limited to 'modules/gallery') diff --git a/modules/gallery/controllers/admin_languages.php b/modules/gallery/controllers/admin_languages.php index ae90ad07..6dc242c6 100644 --- a/modules/gallery/controllers/admin_languages.php +++ b/modules/gallery/controllers/admin_languages.php @@ -21,7 +21,10 @@ class Admin_Languages_Controller extends Admin_Controller { public function index($share_translations_form=null) { $v = new Admin_View("admin.html"); $v->content = new View("admin_languages.html"); - $v->content->settings_form = $this->_languages_form(); + $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(); } @@ -32,14 +35,21 @@ class Admin_Languages_Controller extends Admin_Controller { public function save() { access::verify_csrf(); - - $form = $this->_languages_form(); - if ($form->validate()) { - module::set_var("gallery", "default_locale", $form->choose_language->locale->value); - locales::update_installed($form->choose_language->installed_locales->value); - message::success(t("Settings saved")); - } - url::redirect("admin/languages"); + + 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")); } public function share() { @@ -88,30 +98,6 @@ class Admin_Languages_Controller extends Admin_Controller { } } - private function _languages_form() { - $all_locales = locales::available(); - $installed_locales = locales::installed(); - $form = new Forge("admin/languages/save", "", "post", array("id" => "gLanguageSettingsForm")); - $group = $form->group("choose_language") - ->label(t("Language settings")); - $group->dropdown("locale") - ->options($installed_locales) - ->selected(module::get_var("gallery", "default_locale")) - ->label(t("Default language")) - ->rules('required'); - - $installation_options = array(); - foreach ($all_locales as $code => $display_name) { - $installation_options[$code] = array($display_name, isset($installed_locales->$code)); - } - $group->checklist("installed_locales") - ->label(t("Installed Languages")) - ->options($installation_options) - ->rules("required"); - $group->submit("save")->value(t("Save settings")); - return $form; - } - private function _outgoing_translations_count() { return ORM::factory("outgoing_translation")->count_all(); } diff --git a/modules/gallery/views/admin_languages.html.php b/modules/gallery/views/admin_languages.html.php index f41694b4..fc3a87dc 100644 --- a/modules/gallery/views/admin_languages.html.php +++ b/modules/gallery/views/admin_languages.html.php @@ -1,14 +1,69 @@
-

+

+

+ +

- - -

- " - class="gDialogLink"> - - +
"> + + + + + + + + + $display_name): ?> + + +
+ + + + + + + + "> + + + + + + + +
+ +
+ " /> +
+ +

-- cgit v1.2.3 From c234f9fd392d355bb7a143e28474bb689ed65e48 Mon Sep 17 00:00:00 2001 From: jhilden Date: Fri, 28 Aug 2009 20:53:06 -0400 Subject: improved translations admin interface --- modules/gallery/controllers/l10n_client.php | 13 +++-- modules/gallery/views/admin_languages.html.php | 80 ++++++++++++++++++-------- themes/admin_default/css/admin_screen.css | 12 +++- 3 files changed, 75 insertions(+), 30 deletions(-) (limited to 'modules/gallery') diff --git a/modules/gallery/controllers/l10n_client.php b/modules/gallery/controllers/l10n_client.php index 831c79c1..0775791e 100644 --- a/modules/gallery/controllers/l10n_client.php +++ b/modules/gallery/controllers/l10n_client.php @@ -90,10 +90,15 @@ class L10n_Client_Controller extends Controller { } $session = Session::instance(); - $session->set("l10n_mode", - !$session->get("l10n_mode", false)); - - url::redirect("albums/1"); + $l10n_mode = $session->get("l10n_mode", false); + $session->set("l10n_mode", !$l10n_mode); + + $redirect_url = "admin/languages"; + if (!$l10n_mode) { + $redirect_url .= "#l10n-client"; + } + + url::redirect($redirect_url); } private static function _l10n_client_search_form() { diff --git a/modules/gallery/views/admin_languages.html.php b/modules/gallery/views/admin_languages.html.php index fc3a87dc..4025437a 100644 --- a/modules/gallery/views/admin_languages.html.php +++ b/modules/gallery/views/admin_languages.html.php @@ -2,7 +2,7 @@

- +

"> @@ -40,31 +40,61 @@
+ dataType: "json", + success: function(data) { + if (data.result == "success") { + el = $('">'); // this is a little hack to trigger the update_l10n task in a dialog + el.gallery_dialog(); + el.trigger('click'); + } + } + }); + +
-

+
+

+

+ +

+ +

+ + + +

Sharing your translations

+
diff --git a/themes/admin_default/css/admin_screen.css b/themes/admin_default/css/admin_screen.css index 913631dc..3083114c 100644 --- a/themes/admin_default/css/admin_screen.css +++ b/themes/admin_default/css/admin_screen.css @@ -463,8 +463,18 @@ li.gDefaultGroup h4, li.gDefaultGroup .gUser { background-color: #C5DBEC; font-weight: bold; } -#gLanguagesForm input, #gShareTranslationsForm, #gLanguages h2 { +#gLanguagesForm input { clear: both; } +#gTranslations { + padding: 2em 0 0 0; + clear: both; +} +#gTranslations .gButtonLink { + padding: .5em; +} +.gDocLink { + float: right; +} -- cgit v1.2.3