aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabio Comuni <fabrix.xm@gmail.com>2012-04-13 11:56:21 +0200
committerFabio Comuni <fabrix.xm@gmail.com>2012-04-13 11:56:21 +0200
commit4496d075e50c7dd8bd3506bac5d97ed2a913ab86 (patch)
treed38eb8f8ac5d196b14a6b3a4c29d04ae2415c574
parentfdf50b8574b32464fa814e8d9116903884155ea1 (diff)
downloadvolse-hubzilla-4496d075e50c7dd8bd3506bac5d97ed2a913ab86.tar.gz
volse-hubzilla-4496d075e50c7dd8bd3506bac5d97ed2a913ab86.tar.bz2
volse-hubzilla-4496d075e50c7dd8bd3506bac5d97ed2a913ab86.zip
move html out of lang_selector() and new template lang_selector.tpl
-rw-r--r--include/text.php25
-rw-r--r--view/lang_selector.tpl10
2 files changed, 26 insertions, 9 deletions
diff --git a/include/text.php b/include/text.php
index 4ec59a665..8c8db66a9 100644
--- a/include/text.php
+++ b/include/text.php
@@ -1068,10 +1068,12 @@ function unamp($s) {
if(! function_exists('lang_selector')) {
function lang_selector() {
global $lang;
- $o = '<div id="lang-select-icon" class="icon language" title="' . t('Select an alternate language') . '" onclick="openClose(\'language-selector\');" ></div>';
- $o .= '<div id="language-selector" style="display: none;" >';
- $o .= '<form action="#" method="post" ><select name="system_language" onchange="this.form.submit();" >';
+
$langs = glob('view/*/strings.php');
+
+ $lang_options = array();
+ $selected = "";
+
if(is_array($langs) && count($langs)) {
$langs[] = '';
if(! in_array('view/en/strings.php',$langs))
@@ -1079,17 +1081,22 @@ function lang_selector() {
asort($langs);
foreach($langs as $l) {
if($l == '') {
- $default_selected = ((! x($_SESSION,'language')) ? ' selected="selected" ' : '');
- $o .= '<option value="" ' . $default_selected . '>' . t('default') . '</option>';
+ $lang_options[""] = t('default');
continue;
}
$ll = substr($l,5);
$ll = substr($ll,0,strrpos($ll,'/'));
- $selected = (($ll === $lang && (x($_SESSION, 'language'))) ? ' selected="selected" ' : '');
- $o .= '<option value="' . $ll . '"' . $selected . '>' . $ll . '</option>';
+ $selected = (($ll === $lang && (x($_SESSION, 'language'))) ? $ll : $selected);
+ $lang_options[$ll]=$ll;
}
}
- $o .= '</select></form></div>';
+
+ $tpl = get_markup_template("lang_selector.tpl");
+ $o = replace_macros($tpl, array(
+ '$title' => t('Select an alternate language'),
+ '$langs' => array($lang_options, $selected),
+
+ ));
return $o;
}}
@@ -1510,4 +1517,4 @@ function fix_mce_lf($s) {
$s = str_replace("\r\n","\n",$s);
$s = str_replace("\n\n","\n",$s);
return $s;
-} \ No newline at end of file
+}
diff --git a/view/lang_selector.tpl b/view/lang_selector.tpl
new file mode 100644
index 000000000..b3a527b40
--- /dev/null
+++ b/view/lang_selector.tpl
@@ -0,0 +1,10 @@
+<div id="lang-select-icon" class="icon s22 language" title="$title" onclick="openClose('language-selector');" >lang</div>
+<div id="language-selector" style="display: none;" >
+ <form action="#" method="post" >
+ <select name="system_language" onchange="this.form.submit();" >
+ {{ for $langs.0 as $v=>$l }}
+ <option value="$v" {{if $v==$langs.1}}selected="selected"{{endif}}>$l</option>
+ {{ endfor }}
+ </select>
+ </form>
+</div>