[evolvis-commits] r18370: theme-evolvis pending merges:↵ Thorsten Glaser 2012-04-24 in Evolvis, do *not* use the browser’s accept-language for guessing↵ Thorsten Glaser 2012-04-24 upon failure to change the account, render the account prefs page inline↵ Thorsten Glaser 2012-04-24 put a “switch to English” knob on the Evolvis theme

mirabilos at evolvis.org mirabilos at evolvis.org
Tue Apr 24 16:34:50 CEST 2012


Author: mirabilos
Date: 2012-04-24 16:34:50 +0200 (Tue, 24 Apr 2012)
New Revision: 18370

Added:
   trunk/gforge_base/evolvisforge-5.1/src/image-sources/english.svg
   trunk/gforge_base/evolvisforge-5.1/src/www/images/english.png
Modified:
   trunk/gforge_base/evolvisforge-5.1/src/common/include/gettext.php
   trunk/gforge_base/evolvisforge-5.1/src/www/account/index.php
   trunk/gforge_base/evolvisforge-5.1/src/www/account/setlang.php
   trunk/gforge_base/evolvisforge-5.1/src/www/themes/evolvis/EvStyle.class.php
   trunk/gforge_base/evolvisforge-5.1/src/www/themes/evolvis/evolvis.css
Log:
theme-evolvis pending merges:
  Thorsten Glaser 2012-04-24 in Evolvis, do *not* use the browser’s accept-language for guessing
    Thorsten Glaser 2012-04-24 upon failure to change the account, render the account prefs page inline
    Thorsten Glaser 2012-04-24 put a “switch to English” knob on the Evolvis theme

Modified: trunk/gforge_base/evolvisforge-5.1/src/common/include/gettext.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/common/include/gettext.php	2012-04-24 14:34:46 UTC (rev 18369)
+++ trunk/gforge_base/evolvisforge-5.1/src/common/include/gettext.php	2012-04-24 14:34:50 UTC (rev 18370)
@@ -61,6 +61,7 @@
 		return lang_id_to_language_name ($cookie_language_id) ;
 	}
 
+    if (0) {
 	// Try with the browser's preferred language
 	$ranges = explode (',', getStringFromServer ('HTTP_ACCEPT_LANGUAGE')) ;
 	$languages = array() ; $lcount = count ($ranges) ;
@@ -98,6 +99,7 @@
 			}
 		}
 	}
+    }
 
 	// Okay, let's use the site-wide default language
 	if (forge_get_config('default_language')) {

Added: trunk/gforge_base/evolvisforge-5.1/src/image-sources/english.svg
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/image-sources/english.svg	                        (rev 0)
+++ trunk/gforge_base/evolvisforge-5.1/src/image-sources/english.svg	2012-04-24 14:34:50 UTC (rev 18370)
@@ -0,0 +1,72 @@
+<?xml version="1.0"?>
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="27" height="18" version="1.0">
+  <defs>
+    <polygon id="us_star" fill="white" points="0,-1 0.587785252292473129168705954639072768597652,0.809016994374947424102293417182819058860155 -0.951056516295153572116439333379382143405699,-0.309016994374947424102293417182819058860155 0.951056516295153572116439333379382143405699,-0.309016994374947424102293417182819058860155 -0.587785252292473129168705954639072768597652,0.809016994374947424102293417182819058860155" transform="scale(0.486315789474)"/>
+    <g id="star_row_6" transform="scale(1.17619047619)">
+      <use xlink:href="#us_star" x="1"/>
+      <use xlink:href="#us_star" x="3"/>
+      <use xlink:href="#us_star" x="5"/>
+      <use xlink:href="#us_star" x="7"/>
+      <use xlink:href="#us_star" x="9"/>
+      <use xlink:href="#us_star" x="11"/>
+    </g>
+    <g id="star_row_5" transform="scale(1.17619047619)">
+      <use xlink:href="#us_star" x="2"/>
+      <use xlink:href="#us_star" x="4"/>
+      <use xlink:href="#us_star" x="6"/>
+      <use xlink:href="#us_star" x="8"/>
+      <use xlink:href="#us_star" x="10"/>
+    </g>
+    <rect id="bar" fill="#9B1C2c" width="7410" height="300"/>
+    <polygon id="eu_star" fill="#FFCC00" points="0,-1 0.587785252292473129168705954639072768597652,0.809016994374947424102293417182819058860155 -0.951056516295153572116439333379382143405699,-0.309016994374947424102293417182819058860155 0.951056516295153572116439333379382143405699,-0.309016994374947424102293417182819058860155 -0.587785252292473129168705954639072768597652,0.809016994374947424102293417182819058860155"/>
+    <clipPath id="clp_eu">
+      <path d="M 27 18 L 27 0 L 0 18 z"/>
+    </clipPath>
+    <clipPath id="clp_us">
+      <path d="M 0 0 L 27 0 L 0 18 z"/>
+    </clipPath>
+  </defs>
+  <g id="us_flag" clip-path="url(#clp_us)">
+    <g transform="scale(0.0046)">
+      <rect width="7410" height="3900" fill="white"/>
+      <use xlink:href="#bar"/>
+      <use xlink:href="#bar" y="600"/>
+      <use xlink:href="#bar" y="1200"/>
+      <use xlink:href="#bar" y="1800"/>
+      <use xlink:href="#bar" y="2400"/>
+      <use xlink:href="#bar" y="3000"/>
+      <use xlink:href="#bar" y="3600"/>
+      <g id="field">
+        <rect width="2964" height="2100" fill="#33335F"/>
+        <g id="50_stars" transform="scale(210)">
+          <use xlink:href="#star_row_6" y="1"/>
+          <use xlink:href="#star_row_5" y="2"/>
+          <use xlink:href="#star_row_6" y="3"/>
+          <use xlink:href="#star_row_5" y="4"/>
+          <use xlink:href="#star_row_6" y="5"/>
+          <use xlink:href="#star_row_5" y="6"/>
+          <use xlink:href="#star_row_6" y="7"/>
+          <use xlink:href="#star_row_5" y="8"/>
+          <use xlink:href="#star_row_6" y="9"/>
+        </g>
+      </g>
+    </g>
+  </g>
+  <g id="eu_flag" clip-path="url(#clp_eu)">
+    <rect width="27" height="18" fill="#003399"/>
+    <g transform="translate(13.5 9)">
+      <use xlink:href="#eu_star" transform="translate(6,0)"/>
+      <use xlink:href="#eu_star" transform="rotate(30) translate(6,0) rotate(-30)"/>
+      <use xlink:href="#eu_star" transform="rotate(60) translate(6,0) rotate(-60)"/>
+      <use xlink:href="#eu_star" transform="rotate(90) translate(6,0) rotate(-90)"/>
+      <use xlink:href="#eu_star" transform="rotate(120) translate(6,0) rotate(-120)"/>
+      <use xlink:href="#eu_star" transform="rotate(150) translate(6,0) rotate(-150)"/>
+      <use xlink:href="#eu_star" transform="rotate(180) translate(6,0) rotate(-180)"/>
+      <use xlink:href="#eu_star" transform="rotate(210) translate(6,0) rotate(-210)"/>
+      <use xlink:href="#eu_star" transform="rotate(240) translate(6,0) rotate(-240)"/>
+      <use xlink:href="#eu_star" transform="rotate(270) translate(6,0) rotate(-270)"/>
+      <use xlink:href="#eu_star" transform="rotate(300) translate(6,0) rotate(-300)"/>
+      <use xlink:href="#eu_star" transform="rotate(330) translate(6,0) rotate(-330)"/>
+    </g>
+  </g>
+</svg>

Modified: trunk/gforge_base/evolvisforge-5.1/src/www/account/index.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/www/account/index.php	2012-04-24 14:34:46 UTC (rev 18369)
+++ trunk/gforge_base/evolvisforge-5.1/src/www/account/index.php	2012-04-24 14:34:50 UTC (rev 18370)
@@ -30,6 +30,12 @@
 
 $feedback = htmlspecialchars(getStringFromRequest('feedback'));
 $error_msg = htmlspecialchars(getStringFromRequest('error_msg'));
+if (util_ifsetor($account_from_setlang) === true) {
+	$feedback = '';
+	$error_msg = '';
+} else {
+	$account_from_setlang = false;
+}
 
 session_require_login () ;
 
@@ -43,7 +49,7 @@
 
 $datefrmt = $u->getPreference('datepick_format');
 
-if (getStringFromRequest('submit')) {
+if (!$account_from_setlang && getStringFromRequest('submit')) {
 	if (!form_key_is_valid(getStringFromRequest('form_key'))) {
 		exit_form_double_submit('my');
 	}
@@ -90,17 +96,24 @@
 }
 
 $title = _('Account Maintenance');
-site_user_header(array('title'=>$title));
+if (!$account_from_setlang) {
+	site_user_header(array('title'=>$title));
+}
 
 echo '<form action="'.util_make_url('/account/').'" method="post">';
 echo '<input type="hidden" name="form_key" value="'.form_generate_key().'"/>';
 echo $HTML->boxTop(_('Account Maintenance'), '', false, 'account_maint');
 
+if (!$account_from_setlang) {
 ?>
 
 <p> <?php echo _('Welcome'); ?> <strong><?php print $u->getRealName(); ?></strong>. </p>
 <p>
-
+<?php
+} else {
+	echo $u->getRealName() . ' ';
+}
+?>
 <?php echo _('Account options:'); ?>
 </p>
 <ul>

Modified: trunk/gforge_base/evolvisforge-5.1/src/www/account/setlang.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/www/account/setlang.php	2012-04-24 14:34:46 UTC (rev 18369)
+++ trunk/gforge_base/evolvisforge-5.1/src/www/account/setlang.php	2012-04-24 14:34:50 UTC (rev 18370)
@@ -1,8 +1,10 @@
 <?php
-/**
- * Set default language for not-logged-on sessions (via cookie)
+/*-
+ * Set default language for the current and future sessions
  *
- * Copyright 1999-2001 (c) VA Linux Systems
+ * Copyright © 2012
+ *	Thorsten “mirabilos” Glaser <t.glaser at tarent.de>
+ * All rights reserved.
  *
  * This file is part of FusionForge. FusionForge is free software;
  * you can redistribute it and/or modify it under the terms of the
@@ -23,22 +25,69 @@
 require_once('../env.inc.php');
 require_once $gfcommon.'include/pre.php';
 
-$language_id=getIntFromRequest('language_id');
+$force = getIntFromRequest('force');
+$language_id = getIntFromRequest('language_id');
+
+/* validate */
+$language_name = lang_id_to_language_name($language_id);
+if (!$language_id || !$language_name ||
+    !language_name_to_lang_id($language_name)) {
+	$language_name = 'English';
+	$language_id = language_name_to_lang_id($language_name);
+	$language_id = $language_id ? $language_id : 1;
+}
+$language_name = lang_id_to_language_name($language_id);
+if (!$language_id || !$language_name ||
+    !language_name_to_lang_id($language_name)) {
+	exit_error('Cannot find a working language or English fallback');
+}
+
+/* switch to new language now already */
+setup_gettext_from_langname($language_name);
+
+/* not logged-in users get a cookie */
+setcookie('cookie_language_id', $language_id, (time() + 2592000), '/', '', 0);
+$cookie_language_id = $language_id;
+
+/* logged-in users can get their preferences forcibly changed */
+if ($force == 1 && session_loggedin()) {
+	$res = db_query_params('UPDATE users SET language=$1 WHERE user_id=$2',
+	    array(
+		$language_id,
+		user_getid(),
+	    ));
+	$force = db_affected_rows($result) == 1 ? 2 : 1;
+} else {
+	$force = 0;
+}
+
 setcookie('cookie_language_id',$language_id,(time()+2592000),'/','',0);
 $cookie_language_id = $language_id;
 
-echo $HTML->header(array('title'=>"Change Language"));
+site_header(array(
+	'title' => _('Change Language'),
+    ));
 
-?>
+echo '<h2>' . _('Language Updated') . "</h2>\n";
 
-<h2>Language Updated</h2>
-<p>
-Your language preference has been saved in a cookie and will be
-remembered next time you visit the site.
-</p>
+echo '<p>' . _('Your language preference has been saved in a cookie and will be remembered next time you visit the site.') . "</p>\n";
 
-<?php
+switch ($force) {
+case 0:
+	echo '<p>' . _('Your account preferences – if you are a registered user on the site – have not been changed.') . "</p>\n";
+	break;
+case 1:
+	echo '<p>' . _('Your account settings have also been changed to the new language.') . "</p>\n";
+	break;
+case 2:
+	echo '<p>' . _('Your account settings could not be changed due to an error.') . "</p>\n";
+	echo "<hr />\n";
+	$account_from_setlang = true;
+	include $gfwww.'account/index.php';
+	die;
+}
 
-echo $HTML->footer(array());
+echo '<p>' . sprintf(_('Your new language is #%1$d (%2$s).'),
+    $language_id, $language_name) . "</p>\n";
 
-?>
+site_footer(array());

Added: trunk/gforge_base/evolvisforge-5.1/src/www/images/english.png
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/www/images/english.png	                        (rev 0)
+++ trunk/gforge_base/evolvisforge-5.1/src/www/images/english.png	2012-04-24 14:34:50 UTC (rev 18370)
@@ -0,0 +1,12 @@
+‰PNG
+
+   
+IHDR         ªÛ¥   sBIT|dˆ   	pHYs  
+×  
+×B(›x   tEXtSoftware www.inkscape.org›î<  ¬IDAT8µ”]L[eÆíi¡tí ”R>Ê(])&8¶
+⢉Ù.LüˆwÞè¢Þà…ƨɢ‰‰W&Þ’x¡.ٝӸ˜hÄà•	Û…SΠ”R(J?èiôx3È´#&>—Ïûñ{Ÿÿû_ÍÀÀ;ªÝ^Íâb”öv'33x½ÍƒËØí2™Š’ãÌ;Á`˜ÎN»ÿðBr‘“*©5Ê_V¿*júú®ªUU&¬ÖJ¶¶ÒX­§‘å$&“DbAÐb0”‘Íæ±XN§pWyw°çD ï&3þ/~Oy
+*V h©¬4!ËIêêªY[Û¤¶ÖB4ºÉd$Ÿß%•Ê`³YåuuVôåZÌŽ†’Ô®üòW¢¸°žóí{ŸïmÕd2ÒÔTK4ºÃa'^Åf³‹ÅÑëu˜Íln¦hjª%YÇš/YÆc·ÿ†yÀ£¢±>éëôzuuÕ,/Çp¹¤.W#’´LMMŠ’c}}‹ææzB¡UÜn–s-¼1ôÚHl+'_þhL”¢Û¾#ƒ€.Ÿß!YÇãi"\Æëm&XÄé¬gii
+ƒ¡Œúz++´µ5#ŠKtÔyôã/‡6šM‡üŸŒ–{¤˜íX€Î`(Ãé¬'ÑÕåæÁƒ ]]nîßâpØÉdÂáØãN}Dww+ñ¿Æ˜ž AþLxI|å’äSvº‹–@°Û»®%“iº»[™š¹pÁËää.ÂáUAKCƒÙÙ==mÜ»'Òsåy†n|ͨå¢ÿý¿ÍÖ4ež‰“TÖP¦3
+¸ÝMLNðùžalì!½½çŸ¦¥¥‘tZA’V8¾»wgèïïbþÏ	¹±OWòå%³œÊpµÿ6Ãwˆo‡¹Ê
+¨á%¼&T@¤Ý,°=ÄkÐl¬Q¡ÑPce~žv³ÀØ„ì÷§z<*º›„RAEù	¥¢h2ªªjÉ쏵¶©ÈϽõ“8Nm€§Ió«ç©°‘ŠNÿuCÿ‘w³/½°ÇЋ#ÜœziÝVt]﵋Ƴ{òψßÿz±dš=L¾Œì®¾ä¡5Ӂc“
+ÿñ|]òT¬§ÊsôŸ•¸#e;W~0§˜_Lº®¼~ÈØÿ¡cBÕAšBAË{—F¹l=ÔuÙ¼þÀ?‰%{2M±Z­Ê§ƒ·øüÖ …‚æDØÃáoUYQå7oæÄ¥„úŸ;í$R‹U—?˜¶[9<ÿ'à_ȏ“P*ñÛ™    IEND®B`‚
\ No newline at end of file

Modified: trunk/gforge_base/evolvisforge-5.1/src/www/themes/evolvis/EvStyle.class.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/www/themes/evolvis/EvStyle.class.php	2012-04-24 14:34:46 UTC (rev 18369)
+++ trunk/gforge_base/evolvisforge-5.1/src/www/themes/evolvis/EvStyle.class.php	2012-04-24 14:34:50 UTC (rev 18370)
@@ -149,6 +149,12 @@
               <div id="ev_toplogo"><a href="<?php echo util_make_url("/"); ?>"><img
                src="<?php echo util_make_url("/themes/evolvis/images/logo_internal_repo.png"); ?>"
                alt="Evolvis Repository" border="0" /></a></div>
+              <div id="ev_english"><a href="<?php
+    echo util_make_url("/account/setlang.php?force=1&language_id=" .
+     language_name_to_lang_id('English')); ?>"><img
+               src="<?php echo util_make_url("/images/english.png"); ?>"
+               title="Switch the site to English language texts"
+               alt="English Language flag" border="0" height="18" width="27" /></a></div>
               <span id="ev_globalmenu">
 <?php
     echo rtrim($gm);

Modified: trunk/gforge_base/evolvisforge-5.1/src/www/themes/evolvis/evolvis.css
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/www/themes/evolvis/evolvis.css	2012-04-24 14:34:46 UTC (rev 18369)
+++ trunk/gforge_base/evolvisforge-5.1/src/www/themes/evolvis/evolvis.css	2012-04-24 14:34:50 UTC (rev 18370)
@@ -276,6 +276,10 @@
 	overflow:hidden;
 }
 
+#ev_english {
+	margin-right:6px;
+}
+
 #ev_globalmenu {
 	padding-right:0px;
 }



More information about the evolvis-commits mailing list