[Mapbender-commits] r1638 - in trunk/mapbender/http: include javascripts

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Aug 9 04:46:20 EDT 2007


Author: christoph
Date: 2007-08-09 04:46:20 -0400 (Thu, 09 Aug 2007)
New Revision: 1638

Added:
   trunk/mapbender/http/javascripts/mod_tab_translation.php
Modified:
   trunk/mapbender/http/include/dyn_php.php
   trunk/mapbender/http/javascripts/mod_tab.php
Log:
mod_tab i18n

Modified: trunk/mapbender/http/include/dyn_php.php
===================================================================
--- trunk/mapbender/http/include/dyn_php.php	2007-08-09 08:43:57 UTC (rev 1637)
+++ trunk/mapbender/http/include/dyn_php.php	2007-08-09 08:46:20 UTC (rev 1638)
@@ -19,16 +19,21 @@
 
 if(isset($gui_id))
 {
-	$sql = "SELECT * FROM gui_element_vars WHERE fkey_gui_id = $1 and var_type='php_var'";
-	$v = array($gui_id);
-	$t = array('s');
+	$sql = "SELECT * FROM gui_element_vars WHERE fkey_gui_id = $1 and fkey_e_id = $2 and var_type='php_var' ORDER BY var_name";
+	$v = array($gui_id, $e_id);
+	$t = array('s', 's');
    	$res = db_prep_query($sql,$v,$t);
 
 	echo "\n";
 	while($row = db_fetch_array($res))
 	{
-		$$row["var_name"] = stripslashes($row["var_value"]);
-		echo "\n";
+		if (preg_match("/\w+\[\d+\]/", $row["var_name"])) {
+			$varname = mb_substr($row["var_name"], 0, mb_strpos($row["var_name"], "["));	
+			array_push($$varname, stripslashes($row["var_value"]));
+		}
+		else {
+			$$row["var_name"] = stripslashes($row["var_value"]);
+		}
 	}
 }
 ?>
\ No newline at end of file

Modified: trunk/mapbender/http/javascripts/mod_tab.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_tab.php	2007-08-09 08:43:57 UTC (rev 1637)
+++ trunk/mapbender/http/javascripts/mod_tab.php	2007-08-09 08:46:20 UTC (rev 1638)
@@ -21,8 +21,31 @@
 
 $gui_id = $_REQUEST["gui_id"];
 $e_id_css = 'tabs';
+$e_id = 'tabs';
+include(dirname(__FILE__).'/../extensions/JSON.php');
+require_once(dirname(__FILE__).'/../classes/class_mb_exception.php');
 include(dirname(__FILE__).'/../include/dyn_js.php');
 
+$tab_ids = array();
+include(dirname(__FILE__).'/../include/dyn_php.php');
+
+
+echo "var tab_titles = [];\n";
+for ($i=0; $i < count($tab_ids); $i++) {
+	$sql = "SELECT gettext($1, e_title) AS e_title FROM gui_element WHERE fkey_gui_id = $2 AND e_id = $3";
+	$v = array($_SESSION["mb_lang"], $gui_id, $tab_ids[$i]);
+	$t = array("s", "s", "s");
+	$res = db_prep_query($sql, $v, $t);
+	$row = db_fetch_array($res);
+	echo "tab_titles[" . $i . "] = '" . $row["e_title"] . "';\n";	
+}
+
+$json = new Services_JSON();
+$output = $json->encode($tab_ids);
+
+$e = new mb_exception("tab_ids" . $output);
+echo "var tab_ids = " . $output . ";";	
+
 ?>
 var tab_height = false;
 var tab_width = false;

Added: trunk/mapbender/http/javascripts/mod_tab_translation.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_tab_translation.php	                        (rev 0)
+++ trunk/mapbender/http/javascripts/mod_tab_translation.php	2007-08-09 08:46:20 UTC (rev 1638)
@@ -0,0 +1,184 @@
+<?php
+# $Id: mod_tab.php 855 2006-11-20 14:06:28Z christoph $
+# http://www.mapbender.org/index.php/mod_tab.php
+# Copyright (C) 2002 CCGIS 
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+/********** Configuration*************************************************/
+
+$gui_id = $_REQUEST["gui_id"];
+$e_id_css = 'tabs';
+$e_id = 'tabs';
+include(dirname(__FILE__).'/../extensions/JSON.php');
+include(dirname(__FILE__).'/../classes/class_mb_exception.php');
+$e = new mb_exception("tab_ids");
+include(dirname(__FILE__).'/../include/dyn_js.php');
+
+$tab_ids = array();
+include(dirname(__FILE__).'/../include/dyn_php.php');
+
+
+echo "var tab_titles = [];\n";
+for ($i=0; $i < count($tab_ids); $i++) {
+	$sql = "SELECT gettext(e_title) AS e_title FROM gui_element WHERE fkey_gui_id = $1 AND e_id = $2";
+	$v = array($gui_id, $tab_ids[$i]);
+	$t = array("s", "s");
+	$res = db_prep_query($sql, $v, $t);
+	$row = db_fetch_array($res);
+	echo "tab_titles[" . $i . "] = '" . $row["e_title"] . "';\n";	
+}
+
+$json = new Services_JSON();
+$output = $json->encode($tab_ids);
+
+$e = new mb_exception("tab_ids" . $output);
+echo "var tab_ids = " . $output . ";";	
+
+?>
+var tab_height = false;
+var tab_width = false;
+var tab_topOffset = false;
+var tab_leftOffset = false;
+var tab_active = -1;
+var tab_check = new Array();
+var tab_iv1 = false;
+var tab_wait = false;
+
+try{
+	if (open_tab){}
+}
+catch(e){
+	open_tab = false;
+}
+
+/********** Configuration*************************************************/
+mb_registerInitFunctions('tab_init()');
+function tab_init(){
+	var obj = document.getElementById("tabs").style;
+	tab_topOffset = parseInt(obj.top);
+	tab_leftOffset = parseInt(obj.left);
+	tab_width = parseInt(obj.width);
+	tab_height = parseInt(obj.height);
+	var str = "";
+
+	for(var i = 0; i<tab_ids.length; i++){
+		document.getElementById(tab_ids[i]).style.visibility = 'hidden';
+		tab_titles[i] = tab_prefix + tab_titles[i];
+		var newId = "tab_" + i;
+		str += "<div id='"+newId+"' ";
+		str += "style='";
+		str += tab_style;
+		str += "width:"+tab_width+"px;";
+		str += "height:"+tab_height+"px;";        
+		str += "top:" + ((i * tab_height)) + "px;";
+		str += "'";
+		str += " onclick='tab_set("+i+")'>";
+		str += tab_titles[i];
+		str += "</div>";
+	}
+	document.getElementById("tabs").innerHTML = str;
+
+	if (open_tab != 'false'){
+		tab_set(open_tab);
+	}
+}
+function tab_set(ind){
+	if(tab_wait){
+		return;
+	}
+	tab_unsetFrame();
+	if(ind == tab_active){
+		tab_wait = true;
+		tab_active = -1;
+		tab_check = new Array();
+		tab_iv1 = setInterval("tab_move("+tab_active+")",1);
+		return;
+	}	
+	else{
+		tab_wait = true;
+		tab_active = ind;
+		tab_check = new Array();
+		tab_iv1 = setInterval("tab_move("+tab_active+")",1);
+		return;
+	}
+}
+function tab_setFrame(ind){
+	for(var i = 0; i<tab_ids.length; i++){		
+		if(i == ind){
+			var obj = document.getElementById(tab_ids[i]).style;
+			var newpos = ((i+1) * tab_height) + parseInt(tab_topOffset);
+			obj.top = (newpos + 1) + "px";
+			obj.left = (tab_leftOffset) + "px";
+			obj.width = tab_width;
+			obj.height = (parseInt(tab_frameHeight[ind]) - 2);
+			obj.visibility = 'visible';
+		}
+	}
+}
+function tab_unsetFrame(){
+	for(var i = 0; i<tab_ids.length; i++){
+		var obj = document.getElementById(tab_ids[i]).style;
+		obj.visibility = 'hidden';
+	}
+}
+function tab_open(tabid){
+	var t = false;
+	for(var i = 0; i<tab_ids.length; i++){
+		if(tab_ids[i] == tabid){
+			t = i;
+		}
+	}
+	if(tab_active != t){
+		tab_set(t);
+	}
+}
+function tab_move(ind){			
+	for(var i = 0; i<tab_ids.length; i++){
+		var newpos = (i * tab_height);
+		if(i > ind && tab_active >= 0){
+			newpos += parseInt(tab_frameHeight[ind]);
+		}
+		var myid = "tab_" + i;		
+		var pos = parseInt(document.getElementById(myid).style.top);
+		if(pos == newpos){
+			tab_check[i] = true;
+		}
+		else if(pos < newpos){			
+			document.getElementById(myid).style.top = (pos + 10) + "px"; 
+			tab_check[i] = false;
+		}
+		else if(pos > newpos){
+			document.getElementById(myid).style.top = (pos - 10) + "px";
+			tab_check[i] = false;
+		}		
+	}
+	
+	var check = true;
+	for(var j=0; j<tab_check.length; j++){
+		if(tab_check[j] == false){
+			check = false;
+		}
+	}
+	if(check == true){
+		clearInterval(tab_iv1);
+		tab_check = new Array();
+		tab_wait = false;
+		if(ind >= 0){
+			tab_setFrame(ind);
+		}
+		return;
+	}
+}
\ No newline at end of file



More information about the Mapbender_commits mailing list