[Mapbender-commits] r2284 - in branches/2.5/http: javascripts php
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Thu Mar 20 11:34:19 EDT 2008
Author: christoph
Date: 2008-03-20 11:34:19 -0400 (Thu, 20 Mar 2008)
New Revision: 2284
Added:
branches/2.5/http/php/mod_tab_messages.php
Modified:
branches/2.5/http/javascripts/core.js
branches/2.5/http/javascripts/map.js
branches/2.5/http/javascripts/mod_tab.js
Log:
Tab and button localization
Modified: branches/2.5/http/javascripts/core.js
===================================================================
--- branches/2.5/http/javascripts/core.js 2008-03-20 15:29:34 UTC (rev 2283)
+++ branches/2.5/http/javascripts/core.js 2008-03-20 15:34:19 UTC (rev 2284)
@@ -48,6 +48,11 @@
var eventInitMap = new MapbenderEvent();
/**
+ * Switches the locale. Triggered by module switch_locale or onload(?)
+ */
+var eventLocalize = new MapbenderEvent();
+
+/**
* Triggered after the map object has been created.
*/
var eventAfterMapObjectConstruction = new MapbenderEvent(); // possibly obsolete!
@@ -136,7 +141,8 @@
* @deprecated
*/
function mb_registerL10nFunctions(stringFunction) {
- mb_l10nFunctions[mb_l10nFunctions.length] = stringFunction;
+ eventLocalize.register(stringFunction)
+// mb_l10nFunctions[mb_l10nFunctions.length] = stringFunction;
}
var mb_PanSubElements = [];
Modified: branches/2.5/http/javascripts/map.js
===================================================================
--- branches/2.5/http/javascripts/map.js 2008-03-20 15:29:34 UTC (rev 2283)
+++ branches/2.5/http/javascripts/map.js 2008-03-20 15:34:19 UTC (rev 2284)
@@ -31,9 +31,12 @@
}
function localize() {
+ eventLocalize.trigger();
+/*
for(var i=0; i<mb_l10nFunctions.length; i++){
eval(mb_l10nFunctions[i]);
}
+*/
}
function mb_execloadWmsSubFunctions(){
eventAfterLoadWMS.trigger();
@@ -1899,22 +1902,36 @@
}
}
function updateButtonTooltips(obj) {
-// console.log("begin tooltip update");
+/*
+ * the buttons are only initialized on mouseover!
+ * So when localizing, not all buttons may have been registered
+ *
for(var i=0; i<mb_button.length; i++){
// console.log("button %i", i);
for(var j=0; j<obj.length; j++){
+ if (mb_button[i].elName == obj[j].id) {
// console.log("%s %s", mb_button[i].elName, obj[j].id);
- if (mb_button[i].elName == obj[j].id) {
if (mb_button[i].frameName !== "") {
window.frames[mb_button[i].frameName].document.getElementById(mb_button[i].elName).title = obj[j].title;
}
else {
document.getElementById(mb_button[i].elName).title = obj[j].title;
}
-
}
}
}
+*/
+
+ // an alternative, fixes above error,
+ // but this one only changes those in the main frame
+ var imageArray = document.getElementsByTagName("img");
+ for (var i = 0; i < imageArray.length; i++) {
+ for(var j=0; j<obj.length; j++){
+ if (imageArray[i].id == obj[j].id) {
+ document.getElementById(imageArray[i].id).title = obj[j].title;
+ }
+ }
+ }
}
function mb_localizeButtons() {
mb_ajax_json("../php/mod_button_tooltips.php", function(obj, status){
Modified: branches/2.5/http/javascripts/mod_tab.js
===================================================================
--- branches/2.5/http/javascripts/mod_tab.js 2008-03-20 15:29:34 UTC (rev 2283)
+++ branches/2.5/http/javascripts/mod_tab.js 2008-03-20 15:34:19 UTC (rev 2284)
@@ -16,6 +16,11 @@
var tabs;
mb_registerInitFunctions('tab_init()');
+eventLocalize.register(function() {
+ mb_ajax_json("../php/mod_tab_messages.php", function(obj, status){
+ tabs.setTitles(obj);
+ });
+});
function tab_init(){
var obj = document.getElementById("tabs").style;
@@ -210,6 +215,20 @@
};
/**
+ * Sets the titles of each single tab after l10n
+ *
+ * @param {Object} obj an array containing objects with id and title
+ */
+ this.setTitles = function (obj) {
+ for (var i = 0; i < this.count(); i++) {
+ for(var j=0; j<obj.length; j++){
+ if (this.get(i).module == obj[j].id) {
+ this.get(i).getNode().innerHTML = obj[j].title;
+ }
+ }
+ }
+ }
+ /**
* Returns the absolute coordinates of tab by the module ID
*
* @param {String} id the ID of the GUI element within the tab.
Added: branches/2.5/http/php/mod_tab_messages.php
===================================================================
--- branches/2.5/http/php/mod_tab_messages.php (rev 0)
+++ branches/2.5/http/php/mod_tab_messages.php 2008-03-20 15:34:19 UTC (rev 2284)
@@ -0,0 +1,46 @@
+<?php
+#$Id$
+#$Header: /cvsroot/mapbender/mapbender/http/javascripts/mod_insertWmcIntoDb.php,v 1.19 2006/03/09 14:02:42 uli_rothstein Exp $
+# 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.
+
+require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
+require_once(dirname(__FILE__)."/../extensions/JSON.php");
+require_once(dirname(__FILE__)."/../classes/class_mb_exception.php");
+
+$buttonObj = array();
+
+$sql = "SELECT e_id, gettext($1, e_title) AS e_title FROM gui_element, " .
+ "(SELECT v.var_value AS current_e_id FROM gui_element AS e, " .
+ "gui_element_vars AS v WHERE e.e_id = v.fkey_e_id AND ".
+ "e.fkey_gui_id = v.fkey_gui_id AND e.e_id = 'tabs' AND ".
+ "v.var_name LIKE 'tab_ids%' AND e.fkey_gui_id = $2) ".
+ "AS gui_element_temp WHERE gui_element_temp.current_e_id = e_id ".
+ "AND fkey_gui_id = $3";
+
+$v = array($_SESSION["mb_lang"], $_SESSION["mb_user_gui"], $_SESSION["mb_user_gui"]);
+$t = array("s", "s");
+$res = db_prep_query($sql, $v, $t);
+while ($row = db_fetch_array($res)) {
+ array_push($buttonObj, array("id" => $row["e_id"], "title" => $row["e_title"]));
+}
+
+$json = new Services_JSON();
+$output = $json->encode($buttonObj);
+
+header("Content-type:text/plain; charset=utf-8");
+echo $output;
+?>
\ No newline at end of file
Property changes on: branches/2.5/http/php/mod_tab_messages.php
___________________________________________________________________
Name: svn:keywords
+ HeadURL Id LastChangedBy LastChangedDate LastChangedRevision
More information about the Mapbender_commits
mailing list