[evolvis-commits] r17515: tooltip support for extratabs (tentative)

mirabilos at evolvis.org mirabilos at evolvis.org
Fri Sep 2 14:23:17 CEST 2011


Author: mirabilos
Date: 2011-09-02 14:23:17 +0200 (Fri, 02 Sep 2011)
New Revision: 17515

Modified:
   branches/ev48fixes/plugins/fusionforge-plugin-extratabs/data/usr/share/gforge/plugins/extratabs/common/ExtraTabsPlugin.class.php
   branches/ev48fixes/plugins/fusionforge-plugin-extratabs/data/usr/share/gforge/plugins/extratabs/www/iframe.php
   branches/ev48fixes/plugins/fusionforge-plugin-extratabs/data/usr/share/gforge/plugins/extratabs/www/index.php
Log:
tooltip support for extratabs (tentative)


Modified: branches/ev48fixes/plugins/fusionforge-plugin-extratabs/data/usr/share/gforge/plugins/extratabs/common/ExtraTabsPlugin.class.php
===================================================================
--- branches/ev48fixes/plugins/fusionforge-plugin-extratabs/data/usr/share/gforge/plugins/extratabs/common/ExtraTabsPlugin.class.php	2011-09-02 12:01:32 UTC (rev 17514)
+++ branches/ev48fixes/plugins/fusionforge-plugin-extratabs/data/usr/share/gforge/plugins/extratabs/common/ExtraTabsPlugin.class.php	2011-09-02 12:23:17 UTC (rev 17515)
@@ -5,6 +5,7 @@
  * Copyright 2005, Raphaël Hertzog
  * Copyright 2009, Roland Mas
  * Copyright (C) 2010 Alain Peyrat - Alcatel-Lucent
+ * Copyright © 2011 Thorsten Glaser <t.glaser at tarent.de>
  *
  * This file is part of FusionForge.
  *
@@ -109,10 +110,15 @@
 				return;
 			if (!$project->isProject())
 				return;
-			$res_tabs = db_query_params ('SELECT tab_name, tab_url, type FROM plugin_extratabs_main WHERE group_id=$1 ORDER BY index',
+			$res_tabs = db_query_params ('SELECT tab_name, tab_url, type, tooltip FROM plugin_extratabs_main WHERE group_id=$1 ORDER BY index',
 						     array ($group_id)) ;
+			if (!isset($params['TOOLTIPS'])) {
+				$tooltips_array = array();
+				$params['TOOLTIPS'] = &$tooltips_array;
+			}
 			while ($row_tab = db_fetch_array($res_tabs)) {
 				$params['TITLES'][] = $row_tab['tab_name'];
+				$params['TOOLTIPS'][count($params['TITLES']) - 1] = $row_tab['tooltip'];
 				switch ($row_tab['type']) {
 					case 0: // Link
 						$params['DIRS'][] = $row_tab['tab_url'];
@@ -131,21 +137,23 @@
 			}
 		} elseif ($hookname == "clone_project_from_template") {
 			$tabs = array () ;
-			$res = db_query_params ('SELECT tab_name, tab_url, index FROM plugin_extratabs_main WHERE group_id=$1 ORDER BY index',
+			$res = db_query_params ('SELECT tab_name, tab_url, index, tooltip FROM plugin_extratabs_main WHERE group_id=$1 ORDER BY index',
 						     array ($params['template']->getID())) ;
 			while ($row = db_fetch_array($res)) {
 				$data = array () ;
 				$data['tab_url'] = $params['project']->replaceTemplateStrings ($row['tab_url']) ;
 				$data['tab_name'] = $params['project']->replaceTemplateStrings ($row['tab_name']) ;
+				$data['tooltip'] = $params['project']->replaceTemplateStrings ($row['tooltip']) ;
 				$data['index'] = $row['index'] ;
 				$tabs[] = $data ;
 			}			 
 
 			foreach ($tabs as $tab) {
-				db_query_params ('INSERT INTO plugin_extratabs_main (tab_url, tab_name, index, group_id) VALUES ($1,$2,$3,$4)',
+				db_query_params ('INSERT INTO plugin_extratabs_main (tab_url, tab_name, index, group_id, tooltip) VALUES ($1,$2,$3,$5,$4)',
 						 array ($data['tab_url'],
 							$data['tab_name'],
 							$data['index'],
+							$data['tooltip'],
 							$params['project']->getID())) ;
 			}
 		}

Modified: branches/ev48fixes/plugins/fusionforge-plugin-extratabs/data/usr/share/gforge/plugins/extratabs/www/iframe.php
===================================================================
--- branches/ev48fixes/plugins/fusionforge-plugin-extratabs/data/usr/share/gforge/plugins/extratabs/www/iframe.php	2011-09-02 12:01:32 UTC (rev 17514)
+++ branches/ev48fixes/plugins/fusionforge-plugin-extratabs/data/usr/share/gforge/plugins/extratabs/www/iframe.php	2011-09-02 12:23:17 UTC (rev 17515)
@@ -41,7 +41,8 @@
 	$tab_url = rtrim(db_result($result, 0, 'tab_url'), '/');
 	site_project_header(array('title'=>_($tab_name), 'group' => $group_id, 'toptab'=>$tab_name));
 	?>
-	<iframe src="<?php echo $tab_url ?>" frameborder="0" height="600px" width="100%"></iframe>
+	<iframe src="<?php echo util_html_secure($tab_url) ?>"
+	 frameborder="0" height="600px" width="100%"></iframe>
 	<?php
 	site_project_footer(array());
 }

Modified: branches/ev48fixes/plugins/fusionforge-plugin-extratabs/data/usr/share/gforge/plugins/extratabs/www/index.php
===================================================================
--- branches/ev48fixes/plugins/fusionforge-plugin-extratabs/data/usr/share/gforge/plugins/extratabs/www/index.php	2011-09-02 12:01:32 UTC (rev 17514)
+++ branches/ev48fixes/plugins/fusionforge-plugin-extratabs/data/usr/share/gforge/plugins/extratabs/www/index.php	2011-09-02 12:23:17 UTC (rev 17515)
@@ -39,6 +39,8 @@
 $tab_rename = htmlspecialchars(trim(getStringFromRequest ('tab_rename')));
 $tab_url = htmlspecialchars(trim(getStringFromRequest ('tab_url', 'http://')));
 $tab_new_url = htmlspecialchars(trim(getStringFromRequest ('tab_new_url')));
+$tab_tooltip = htmlspecialchars(trim(getStringFromRequest ('tab_tooltip')));
+$tab_new_tooltip = htmlspecialchars(trim(getStringFromRequest ('tab_new_tooltip')));
 $type = getIntFromRequest('type', 0);
 $new_type = getIntFromRequest('new_type', -1);
 
@@ -99,16 +101,18 @@
 		if ($res && db_numrows($res) > 0) {
 			$error_msg = _('ERROR: Name for tab is already used.');
 		} else if (!($res = $group->addHistory('extratab-new',
-		    $newid . '=' . $new_type2 . ':' . $tab_name, $tab_url)) ||
+		    $newid . '=' . $new_type2 . ':' . $tab_name . '(' .
+		    $tab_tooltip . ')', $tab_url)) ||
 		    db_affected_rows($res) < 1) {
 			$error_msg = sprintf (_('Cannot insert audit trail entry: %s'),
 			    db_error());
 		} else {
-			$res = db_query_params ('INSERT INTO plugin_extratabs_main (group_id, index, tab_name, tab_url, type) VALUES ($1,$2,$3,$4, $5)',
+			$res = db_query_params ('INSERT INTO plugin_extratabs_main (group_id, index, tab_name, tab_url, type, tooltip) VALUES ($1,$2,$3,$4,$6,$5)',
 						array ($group_id,
 						       $newid,
 						       $tab_name,
 						       $tab_url,
+						       $tab_tooltip,
 						       $type)) ;
 			if (!$res || db_affected_rows($res) < 1) {
 				$error_msg = sprintf (_('Cannot insert new tab entry: %s'),
@@ -116,6 +120,7 @@
 			} else {
 				$tab_name = '';
 				$tab_url = 'http://';
+				$tab_tooltip = '';
 				$feedback = _('Tab successfully added');
 			}
 		}
@@ -127,6 +132,7 @@
 		$old_tab_url = db_result($res, 0, 'tab_url');
 		$old_tab_name = db_result($res, 0, 'tab_name');
 		$old_tab_type = db_result($res, 0, 'type');
+		$old_tab_tooltip = db_result($res, 0, 'tooltip');
 		if ($old_tab_type === 0) {
 			$old_tab_type2 = 'Link';
 		} else if ($old_tab_type == -1) {
@@ -141,6 +147,7 @@
 		$old_tab_url = '?';
 		$old_tab_name = '?';
 		$old_tab_type2 = '?';
+		$old_tab_tooltip = '?';
 	}
 	$res = db_query_params ('DELETE FROM plugin_extratabs_main WHERE group_id=$1 AND index=$2',
 				array ($group_id,
@@ -149,7 +156,8 @@
 		$error_msg = sprintf (_('Cannot delete tab entry: %s'), db_error());
 	} else {
 		$group->addHistory('extratab-del', $index . '=' .
-		    $old_tab_type2 . ':' . $old_tab_name, $old_tab_url);
+		    $old_tab_type2 . ':' . $old_tab_name . '(' .
+		    $old_tab_tooltip . ')', $old_tab_url);
 		$res = db_query_params ('SELECT index FROM plugin_extratabs_main WHERE group_id=$1 AND index > $2 ORDER BY index ASC',
 					array ($group_id,
 					       $index)) ;
@@ -236,6 +244,7 @@
 		$old_tab_url = db_result($res, 0, 'tab_url');
 		$old_tab_name = db_result($res, 0, 'tab_name');
 		$old_tab_type = db_result($res, 0, 'type');
+		$old_tab_tooltip = db_result($res, 0, 'tooltip');
 		if ($tab_new_url && $tab_new_url != 'http://') {
 			$tab_new_url2 = $old_tab_url . ' -> ' . $tab_new_url;
 		} else {
@@ -257,6 +266,9 @@
 		} else {
 			$tab_name2 = '-unchanged<' . $old_tab_name;
 		}
+		if ($tab_new_tooltip) {
+			$tab_name2 = '{' . $old_tab_tooltip . '|' . $tab_new_tooltip . '}';
+		}
 	}
   if (!($res = $group->addHistory('extratab-mod', $index . '=' . $new_type2 .
     $tab_name2, $tab_new_url2)) || db_affected_rows($res) < 1) {
@@ -275,6 +287,18 @@
 			$done = 1;
 		}
 	}
+	if ($tab_new_tooltip) {
+		$res = db_query_params ('UPDATE plugin_extratabs_main SET tooltip=$1 WHERE group_id=$2 AND index=$3',
+					array ($tab_new_tooltip,
+						   $group_id,
+						   $index));
+		if (!$res || db_affected_rows($res) < 1) {
+			$error_msg = sprintf (_('Cannot change the tab tooltip: %s'), db_error());
+		} else {
+			$feedback .= ($feedback ? '. ' : '') . _('Tab successfully renamed');
+			$done = 1;
+		}
+	}
 	if ($tab_new_url && $tab_new_url != 'http://') {
 		/*if (!util_check_url($tab_new_url)) {
 			$error_msg = _('ERROR: Malformed URL (only http, https and ftp allowed)');
@@ -341,6 +365,11 @@
 <input type="text" size="20" maxlength="20" name="tab_name" value="<?php echo $tab_name ?>" /><br />
 </p>
 <p>
+<strong><?php echo _('Tooltip:') ?></strong>
+<br />
+<input type="text" size="60" name="tab_tooltip" value="<?php echo util_html_secure($tab_tooltip) ?>" /><br />
+</p>
+<p>
 <strong><?php echo _('URL of the tab:') ?></strong><?php echo utils_requiredField(); ?>
 <br />
 <input type="text" size="60" name="tab_url" value="<?php echo $tab_url ?>" /><br/>
@@ -382,9 +411,9 @@
 $options = '';
 while ($row = db_fetch_array($res)) {
     if ($row['index'] == $selected) {
-	$options .= "<option selected=\"selected\" value='" . $row['index'] . "'>" . $row['tab_name'] .  "</option>";
+	$options .= "<option selected=\"selected\" value='" . $row['index'] . "'>" . util_html_secure($row['tab_name']) .  "</option>";
     } else {
-	$options .= "<option value='" . $row['index'] . "'>" . $row['tab_name'] .  "</option>";
+	$options .= "<option value='" . $row['index'] . "'>" . util_html_secure($row['tab_name']) .  "</option>";
     }
 }
 echo $options;
@@ -394,6 +423,9 @@
 	<td><?php echo _('Rename to:'); ?></td>
 	<td><input type="text" size="20" maxlength="20" name="tab_rename" value="" /></td>
 </tr><tr>
+	<td><?php echo _('New tooltip:'); ?></td>
+	<td><input type="text" size="20" maxlength="20" name="tab_new_tooltip" value="" /></td>
+</tr><tr>
 	<td><?php echo _('New URL:'); ?></td>
 	<td><input type="text" size="60" name="tab_new_url" value="http://" /></td>
 </tr><tr>



More information about the evolvis-commits mailing list