From 29c8fa080e28f6c1c43343d68c36de96f7f9f086 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 4 Apr 2013 18:15:37 +0400 Subject: [PATCH] add language dropdown to prefs --- classes/pref/prefs.php | 47 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index b491a930e..730d556a5 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -99,6 +99,8 @@ class Pref_Prefs extends Handler_Protected { if (!isset($_POST[$pref])) $_POST[$pref] = 'false'; } + $need_reload = false; + foreach (array_keys($_POST) as $pref_name) { $pref_name = db_escape_string($this->link, $pref_name); @@ -113,11 +115,25 @@ class Pref_Prefs extends Handler_Protected { } } - set_pref($this->link, $pref_name, $value); + if ($pref_name == "language") { + if ($_SESSION["language"] != $value) { + setcookie("ttrss_lang", $value, + time() + SESSION_COOKIE_LIFETIME); + $_SESSION["language"] = $value; + + $need_reload = true; + } + } else { + set_pref($this->link, $pref_name, $value); + } } - print __("The configuration was saved."); + if ($need_reload) { + print "PREFS_NEED_RELOAD"; + } else { + print __("The configuration was saved."); + } } function getHelp() { @@ -438,8 +454,15 @@ class Pref_Prefs extends Handler_Protected { parameters: dojo.objectToQuery(this.getValues()), onComplete: function(transport) { var msg = transport.responseText; - notify_info(msg); - if (quit) gotoMain(); + if (quit) { + gotoMain(); + } else { + if (msg == 'PREFS_NEED_RELOAD') { + window.location.reload(); + } else { + notify_info(msg); + } + } } }); } "; @@ -520,6 +543,22 @@ class Pref_Prefs extends Handler_Protected { print "

".$section_name."

"; $lnum = 0; + + if ($active_section == 2) { + print ""; + + print ""; + print ""; + + print ""; + print_select_hash("language", $_COOKIE["ttrss_lang"], get_translations(), + "style='width : 220px; margin : 0px' dojoType='dijit.form.Select'"); + print ""; + print ""; + } + } print "";