[Fusionforge-commits] r11834 - in branches/Branch_5_1/src: . plugins/extratabs/common plugins/extratabs/db plugins/extratabs/www

Alain Peyrat aljeux at libremir.placard.fr.eu.org
Sat Dec 18 13:46:59 CET 2010


Author: aljeux
Date: 2010-12-18 13:46:58 +0100 (Sat, 18 Dec 2010)
New Revision: 11834

Added:
   branches/Branch_5_1/src/plugins/extratabs/db/20101203-add_type_for_iframe.sql
   branches/Branch_5_1/src/plugins/extratabs/www/iframe.php
Modified:
   branches/Branch_5_1/src/CHANGES
   branches/Branch_5_1/src/plugins/extratabs/common/ExtraTabsPlugin.class.php
   branches/Branch_5_1/src/plugins/extratabs/www/index.php
Log:
Implement [#226] iframe option for extratabs plugin

Modified: branches/Branch_5_1/src/CHANGES
===================================================================
--- branches/Branch_5_1/src/CHANGES	2010-12-18 11:14:41 UTC (rev 11833)
+++ branches/Branch_5_1/src/CHANGES	2010-12-18 12:46:58 UTC (rev 11834)
@@ -29,6 +29,8 @@
 * Reorganised, modular Apache configuration (Roland Mas)
 * New User Widget : documents monitoring (Capgemini)
 * RPM packages for Red Hat (and derived) distributions
+* New extratabs iframe option to allow embeding another site using an
+  iframe (Alcatel-Lucent)
 
 FusionForge-5.0.2:
 * Maintenance release, bugfixes mostly.

Modified: branches/Branch_5_1/src/plugins/extratabs/common/ExtraTabsPlugin.class.php
===================================================================
--- branches/Branch_5_1/src/plugins/extratabs/common/ExtraTabsPlugin.class.php	2010-12-18 11:14:41 UTC (rev 11833)
+++ branches/Branch_5_1/src/plugins/extratabs/common/ExtraTabsPlugin.class.php	2010-12-18 12:46:58 UTC (rev 11834)
@@ -50,11 +50,25 @@
 				return;
 			if (!$project->isProject())
 				return;
-			$res_tabs = db_query_params ('SELECT tab_name, tab_url FROM plugin_extratabs_main WHERE group_id=$1 ORDER BY index',
+			$res_tabs = db_query_params ('SELECT tab_name, tab_url, type FROM plugin_extratabs_main WHERE group_id=$1 ORDER BY index',
 						     array ($group_id)) ;
 			while ($row_tab = db_fetch_array($res_tabs)) {
-				$params['DIRS'][] = $row_tab['tab_url'];
 				$params['TITLES'][] = $row_tab['tab_name'];
+				switch ($row_tab['type']) {
+					case 0: // Link
+						$params['DIRS'][] = $row_tab['tab_url'];
+						break;
+
+					case 1: // Iframe
+						$params['DIRS'][] = '/plugins/'.$this->name.'/iframe.php?group_id='.$group_id.'&tab_name='.$row_tab['tab_name'];
+						if (isset($params['toptab'])) {
+							($params['toptab'] == $this->name ? $params['selected'] = count($params['TITLES']) - 1 : '' );
+						}
+						break;
+
+					default:
+						return;
+				}
 			}
 		} elseif ($hookname == "clone_project_from_template") {
 			$tabs = array () ;

Added: branches/Branch_5_1/src/plugins/extratabs/db/20101203-add_type_for_iframe.sql
===================================================================
--- branches/Branch_5_1/src/plugins/extratabs/db/20101203-add_type_for_iframe.sql	                        (rev 0)
+++ branches/Branch_5_1/src/plugins/extratabs/db/20101203-add_type_for_iframe.sql	2010-12-18 12:46:58 UTC (rev 11834)
@@ -0,0 +1,2 @@
+ALTER TABLE plugin_extratabs_main ADD COLUMN type INTEGER;
+ALTER TABLE plugin_extratabs_main ALTER COLUMN type SET DEFAULT 0;

Added: branches/Branch_5_1/src/plugins/extratabs/www/iframe.php
===================================================================
--- branches/Branch_5_1/src/plugins/extratabs/www/iframe.php	                        (rev 0)
+++ branches/Branch_5_1/src/plugins/extratabs/www/iframe.php	2010-12-18 12:46:58 UTC (rev 11834)
@@ -0,0 +1,54 @@
+<?php
+/**
+ * Extra tabs plugin
+ * Copyright (C) 2010 Alain Peyrat - Alcatel-Lucent
+ * http://fusionforge.org/
+ *
+ * This file is part of FusionForge.
+ *
+ * FusionForge 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 of the License, or
+ * (at your option) any later version.
+ *
+ * FusionForge 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 FusionForge; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+require_once ('../../../www/env.inc.php');
+require_once $gfcommon.'include/pre.php';
+
+$group_id = getIntFromRequest('group_id');
+if (! $group_id) {
+	exit_no_group();
+}
+
+$group =& group_get_object($group_id);
+if (!$group || !is_object($group) || $group->isError()) {
+	exit_no_group();
+}
+
+$tab_name = htmlspecialchars(trim(getStringFromRequest ('tab_name')));
+$result = db_query_params('SELECT * FROM plugin_extratabs_main WHERE group_id=$1 AND tab_name=$2',
+						array ($group_id, $tab_name));
+if ($result && db_numrows($result)) {
+	$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>
+	<?php
+	site_project_footer(array());
+}
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
+?>
\ No newline at end of file

Modified: branches/Branch_5_1/src/plugins/extratabs/www/index.php
===================================================================
--- branches/Branch_5_1/src/plugins/extratabs/www/index.php	2010-12-18 11:14:41 UTC (rev 11833)
+++ branches/Branch_5_1/src/plugins/extratabs/www/index.php	2010-12-18 12:46:58 UTC (rev 11834)
@@ -34,7 +34,11 @@
 $index = getIntFromRequest ('index') ;
 
 $tab_name = htmlspecialchars(trim(getStringFromRequest ('tab_name')));
+$tab_rename = htmlspecialchars(trim(getStringFromRequest ('tab_rename')));
 $tab_url = htmlspecialchars(trim(getStringFromRequest ('tab_url', 'http://')));
+$tab_new_url = htmlspecialchars(trim(getStringFromRequest ('tab_new_url')));
+$type = getIntFromRequest('type', 0);
+$new_type = getIntFromRequest('new_type', -1);
 
 session_require_perm ('project_admin', $group_id) ;
 
@@ -68,11 +72,12 @@
 		if ($res && db_numrows($res) > 0) {
 			$error_msg = _('ERROR: Name for tab is already used.');
 		} else {
-			$res = db_query_params ('INSERT INTO plugin_extratabs_main (group_id, index, tab_name, tab_url) VALUES ($1,$2,$3,$4)',
+			$res = db_query_params ('INSERT INTO plugin_extratabs_main (group_id, index, tab_name, tab_url, type) VALUES ($1,$2,$3,$4, $5)',
 						array ($group_id,
 						       $newid,
 						       $tab_name,
-						       $tab_url)) ;
+						       $tab_url,
+						       $type)) ;
 			if (!$res || db_affected_rows($res) < 1) {
 				$error_msg = sprintf (_('Cannot insert new tab entry: %s'),
 						      db_error());
@@ -148,6 +153,51 @@
 		$warning_msg = _('Tab not moved, already at last position');
 		$selected = $index;
 	}
+} elseif (getStringFromRequest ('modify') != '') {
+	$done = 0;
+	if ($tab_rename) {
+		$res = db_query_params ('UPDATE plugin_extratabs_main SET tab_name=$1 WHERE group_id=$2 AND index=$3',
+					array ($tab_rename,
+						   $group_id,
+						   $index));
+		if (!$res || db_affected_rows($res) < 1) {
+			$error_msg = sprintf (_('Cannot rename the tab: %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)');
+		} else {
+			$res = db_query_params ('UPDATE plugin_extratabs_main SET tab_url=$1 WHERE group_id=$2 AND index=$3',
+					array ($tab_new_url,
+						   $group_id,
+						   $index));
+			if (!$res || db_affected_rows($res) < 1) {
+				$error_msg .= ($error_msg ? '. ' : '') . sprintf (_('Cannot change URL: %s'), db_error());
+			} else {
+				$feedback .= ($feedback ? '. ' : '') . _('URL successfully changed');
+				$done = 1;
+			}
+		}
+	}
+	if ($new_type != -1) {
+		$res = db_query_params ('UPDATE plugin_extratabs_main SET type=$1 WHERE group_id=$2 AND index=$3',
+					array ($new_type,
+						   $group_id,
+						   $index));
+		if (!$res || db_affected_rows($res) < 1) {
+			$error_msg .= ($error_msg ? '. ' : '') . sprintf (_('Cannot set type: %s'), db_error());
+		} else {
+			$feedback .= ($feedback ? '. ' : '') . _('Type successfully changed');
+			$done = 1;
+		}
+	}
+	if (!$error_msg && !$done) {
+		$warning_msg .= ($warning_msg ? '. ' : '') . _('Nothing done');
+	}
 }
 if (!$res) {
 	db_rollback();
@@ -160,26 +210,30 @@
 
 ?>
 
-<h1><?php echo _('Manage extra tabs') ;?></h1>
-
 <h2><?php echo _('Add new tab'); ?></h2>
 
 <p><?php echo _('You can add your own tabs in the menu bar with the form below.') ?></p>
 
-<form name="new_tab" action="<?php echo util_make_url ('/plugins/extratabs/'); ?>" method="post">
+<form name="new_tab" action="<?php echo util_make_uri ('/plugins/extratabs/'); ?>" method="post">
 <fieldset>
-<legend>Add new tab</legend>
+<legend><?php echo _('Add new tab'); ?></legend>
 <p>
 <input type="hidden" name="group_id" value="<?php echo $group->getID() ?>" />
 <input type="hidden" name="addtab" value="1" />
-	<strong><?php echo _('Name of the tab:') ?></strong>
-<?php echo utils_requiredField(); ?><br/>
-<input type="text" size="20" maxlength="255" name="tab_name" value="<?php echo $tab_name ?>" /><br />
-	<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 ?>" />
+<strong><?php echo _('Name of the tab:') ?></strong><?php echo utils_requiredField(); ?>
+<br />
+<input type="text" size="20" maxlength="20" name="tab_name" value="<?php echo $tab_name ?>" /><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/>
+</p>
+<p>
+<input type="radio" name="type" value="0" checked="checked"/><?php echo _('Link') ?>
+<input type="radio" name="type" value="1" /><?php echo _('Iframe') ?>
+</p>
+<p>
 <input type="submit" value="<?php echo _('Add tab') ?>" />
 </p>
 </fieldset>
@@ -192,16 +246,56 @@
 	
 ?>
 
-<h2><?php echo _('Move or delete extra tabs') ;?></h2>
+<h2><?php echo _('Modify extra tabs'); ?></h2>
 <p>
-	<?php echo _('You can move and delete the tabs that you already added. Please note that those extra tabs can only appear after the standard tabs. And you can only move them inside the set of extra tabs.') ;
+<?php echo _('You can modify the tabs that you already added.');
+?>
+</p>
 
+<form name="modify_tab" action="<?php echo util_make_uri('/plugins/extratabs/'); ?>" method="post">
+<fieldset>
+<legend><?php echo _('Modify tab'); ?></legend>
+<p>
+<input type="hidden" name="group_id" value="<?php echo $group->getID() ?>" />
+<?php echo _('Tab to modify:') ?> <select name="index">
+<?php
+$options = '';
+while ($row = db_fetch_array($res)) {
+    if ($row['index'] == $selected) {
+	$options .= "<option selected=\"selected\" value='" . $row['index'] . "'>" . $row['tab_name'] .  "</option>";
+    } else {
+	$options .= "<option value='" . $row['index'] . "'>" . $row['tab_name'] .  "</option>";
+    }
+}
+echo $options;
 ?>
+</select>
 </p>
+<p>
+<?php echo _('Rename to:'); ?> <input type="text" size="20" maxlength="20" name="tab_rename" value="" />
+</p>
+<p>
+<?php echo _('New URL:'); ?> <input type="text" size="60" name="tab_new_url" value="http://" />
+</p>
+<p>
+<input type="radio" name="new_type" value="0" /><?php echo _('Link') ?>
+<input type="radio" name="new_type" value="1" /><?php echo _('Iframe') ?>
+</p>
+<p>
+<input type="submit" name="modify" value="<?php echo _('Modify tab') ?>" />
+</p>
+</fieldset>
+</form>
 
-<form name="change_tab" action="<?php echo util_make_url ('/plugins/extratabs/'); ?>" method="post">
+<h2><?php echo _('Move or delete extra tabs') ;?></h2>
+<p>
+<?php echo _('You can move and delete the tabs that you already added. Please note that those extra tabs can only appear after the standard tabs. And you can only move them inside the set of extra tabs.');
+?>
+</p>
+
+<form name="change_tab" action="<?php echo util_make_uri('/plugins/extratabs/'); ?>" method="post">
 <fieldset>
-<legend>Move or delete tab</legend>
+<legend><?php echo _('Move or delete tab'); ?></legend>
 <p>
 <input type="hidden" name="group_id" value="<?php echo $group->getID() ?>" />
 <?php
@@ -209,13 +303,8 @@
 ?>
 <select name="index">
 <?php
-while ($row = db_fetch_array($res)) {
-    if ($row['index'] == $selected) {
-	echo "<option selected=\"selected\" value='" . $row['index'] . "'>" . $row['tab_name'] .  "</option>";
-    } else {
-	echo "<option value='" . $row['index'] . "'>" . $row['tab_name'] .  "</option>";
-    }
-} ?>
+echo $options;
+?>
 </select>
 </p>
 <p>




More information about the Fusionforge-commits mailing list