diff options
| author | Tim Almdal <tnalmdal@shaw.ca> | 2009-08-28 13:47:36 -0700 | 
|---|---|---|
| committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-08-28 13:47:36 -0700 | 
| commit | 31d63a0d0a27212435a78eb38461320f486b5f95 (patch) | |
| tree | 68782a88d954e7ae4f0d793b3b2483e720a74beb /modules/gallery/controllers | |
| parent | 1d5262f9c354a8564f05a8a31b915ad479f4d361 (diff) | |
| parent | 1855642bd169a1cae69cd9efb8da4458ea6e4a3c (diff) | |
Merge branch 'master' of git://github.com/gallery/gallery3
Diffstat (limited to 'modules/gallery/controllers')
| -rw-r--r-- | modules/gallery/controllers/admin_languages.php | 52 | 
1 files changed, 19 insertions, 33 deletions
| 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();    } | 
