[Fusionforge-commits] r14706 - in trunk/src: common/tracker/actions common/tracker/include www/pm

Alain Peyrat aljeux at fusionforge.org
Tue Oct 25 12:17:16 CEST 2011


Author: aljeux
Date: 2011-10-25 12:17:16 +0200 (Tue, 25 Oct 2011)
New Revision: 14706

Added:
   trunk/src/common/tracker/actions/csv.php
   trunk/src/common/tracker/actions/format_csv.php
Modified:
   trunk/src/common/tracker/actions/tracker.php
   trunk/src/common/tracker/include/ArtifactHtml.class.php
   trunk/src/common/tracker/include/ArtifactTypeHtml.class.php
   trunk/src/www/pm/csv.php
   trunk/src/www/pm/format_csv.php
Log:
Improve CSV export in trackers, allow changing separator & headers or not (like for tasks)

Copied: trunk/src/common/tracker/actions/csv.php (from rev 14704, trunk/src/www/pm/format_csv.php)
===================================================================
--- trunk/src/common/tracker/actions/csv.php	                        (rev 0)
+++ trunk/src/common/tracker/actions/csv.php	2011-10-25 10:17:16 UTC (rev 14706)
@@ -0,0 +1,89 @@
+<?php
+/*
+ * Copyright (C) 2009 Alain Peyrat, Alcatel-Lucent
+ *
+ * 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 Licence, 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+/*
+ * Standard Alcatel-Lucent disclaimer for contributing to open source
+ *
+ * "The provided file ("Contribution") has not been tested and/or
+ * validated for release as or in products, combinations with products or
+ * other commercial use. Any use of the Contribution is entirely made at
+ * the user's own responsibility and the user can not rely on any features,
+ * functionalities or performances Alcatel-Lucent has attributed to the
+ * Contribution.
+ *
+ * THE CONTRIBUTION BY ALCATEL-LUCENT IS PROVIDED AS IS, WITHOUT WARRANTY
+ * OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, COMPLIANCE,
+ * NON-INTERFERENCE AND/OR INTERWORKING WITH THE SOFTWARE TO WHICH THE
+ * CONTRIBUTION HAS BEEN MADE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * ALCATEL-LUCENT BE LIABLE FOR ANY DAMAGES OR OTHER LIABLITY, WHETHER IN
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * CONTRIBUTION OR THE USE OR OTHER DEALINGS IN THE CONTRIBUTION, WHETHER
+ * TOGETHER WITH THE SOFTWARE TO WHICH THE CONTRIBUTION RELATES OR ON A STAND
+ * ALONE BASIS."
+ */
+
+//
+//	This page contains a form with a file-upload button
+//	so a user can choose a file to upload a .csv file and store it in task mgr
+//
+
+
+//pm_header(array('title'=>_('Upload data into the tasks.'),'group_project_id'=>$group_project_id));
+$ath->header(array('atid'=>$ath->getID(), 'title'=>$ath->getName()));
+
+$default = array('headers' => 1, 'sep' => ',');
+
+if (session_loggedin()) {
+	$u = session_get_user();
+	$pref = $u->getPreference('csv');
+	if ($pref) {
+		$default = unserialize($pref);
+	}
+}
+
+$headers = getIntFromRequest('headers', $default['headers']);
+$sep = getStringFromRequest('sep', $default['sep']);
+
+if (session_loggedin()) {
+	if ( ($sep !== $default['sep']) || ($headers !== $default['headers']) ) {
+		$pref = array_merge( $default, array('headers' => $headers, 'sep' => $sep));
+		$u->setPreference('csv', serialize($pref));
+	}
+}
+
+$url_set_format = '/tracker/?group_id='.$group_id.'&atid='.$ath->getID().'&func=format_csv&sep='.urlencode($sep).'&headers='.$headers;
+
+$url_export = '/tracker/?group_id='.$group_id.'&atid='.$ath->getID().'&func=downloadcsv&sep='.urlencode($sep).'&headers='.$headers;
+
+$format = $headers ? ' with headers' : ' without headers';
+$format .= " using '$sep' as separator.";
+?>
+<p><?php echo _('This page allows you to export the items using a CSV (<a href="http://en.wikipedia.org/wiki/Comma-separated_values">Comma Separated Values</a>) File. This format can be used to view your entries using MS Excel.'); ?></p>
+<h2><?php echo _('Export as a CSV file'); ?></h2>
+
+<strong><?php echo _('Selected CSV Format :'); ?></strong> CSV<?php echo $format ?> <a href="<?php echo $url_set_format ?>">(Change)</a>
+
+<p><a href="<?php echo $url_export ?>"><?php echo _('Download CSV file'); ?></a></p>
+
+<p />
+<?php
+$ath->footer(array());
+?>

Copied: trunk/src/common/tracker/actions/format_csv.php (from rev 14704, trunk/src/www/pm/format_csv.php)
===================================================================
--- trunk/src/common/tracker/actions/format_csv.php	                        (rev 0)
+++ trunk/src/common/tracker/actions/format_csv.php	2011-10-25 10:17:16 UTC (rev 14706)
@@ -0,0 +1,93 @@
+<?php
+/*
+ * Copyright (C) 2009 Alain Peyrat, Alcatel-Lucent
+ *
+ * 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 Licence, 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+/*
+ * Standard Alcatel-Lucent disclaimer for contributing to open source
+ *
+ * "The provided file ("Contribution") has not been tested and/or
+ * validated for release as or in products, combinations with products or
+ * other commercial use. Any use of the Contribution is entirely made at
+ * the user's own responsibility and the user can not rely on any features,
+ * functionalities or performances Alcatel-Lucent has attributed to the
+ * Contribution.
+ *
+ * THE CONTRIBUTION BY ALCATEL-LUCENT IS PROVIDED AS IS, WITHOUT WARRANTY
+ * OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, COMPLIANCE,
+ * NON-INTERFERENCE AND/OR INTERWORKING WITH THE SOFTWARE TO WHICH THE
+ * CONTRIBUTION HAS BEEN MADE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * ALCATEL-LUCENT BE LIABLE FOR ANY DAMAGES OR OTHER LIABLITY, WHETHER IN
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * CONTRIBUTION OR THE USE OR OTHER DEALINGS IN THE CONTRIBUTION, WHETHER
+ * TOGETHER WITH THE SOFTWARE TO WHICH THE CONTRIBUTION RELATES OR ON A STAND
+ * ALONE BASIS."
+ */
+
+//
+//	This page contains a form with a file-upload button
+//	so a user can choose a file to upload a .csv file and store it in task mgr
+//
+
+
+//pm_header(array('title'=>_('Upload data into the tasks.'),'group_project_id'=>$group_project_id));
+$ath->header(array('atid'=>$ath->getID(), 'title'=>$ath->getName()));
+
+$headers = getIntFromRequest('headers', 1);
+$sep = getStringFromRequest('sep', ',');
+
+?>
+<center>
+<table>
+	<tr>
+		<td>
+		<fieldset><legend><b>CSV Format</b></legend>
+		<form action="/tracker/" method="get">
+			<input type="hidden" name="group_id" value="<?php echo $group_id ?>" />
+			<input type="hidden" name="atid" value="<?php echo $ath->getID() ?>" />
+			<input type="hidden" name="func" value="csv" />
+		<table>
+			<tr>
+				<td class="top"><b>Separator :</b></td>
+				<td><input type="radio" name="sep" value=","<?php if ($sep==',') echo ' checked="checked"' ?>/>Comma (char: ',')<br />
+				<input type="radio" name="sep" value=";"<?php if ($sep==';') echo ' checked="checked"' ?>/>Semi-colon (char: ';')</td>
+			</tr>
+			<tr><td colspan="2"></td></tr>
+			<tr>
+				<td class="top"><b>Header :</b></td>
+				<td><input type="radio" name="headers" value="1"<?php if ($headers) echo ' checked="checked"' ?>/>Included<br />
+				<input type="radio" name="headers" value="0"<?php if (!$headers) echo ' checked="checked"' ?>/>None</td>
+			</tr>
+		</table>
+		<input type="submit" name="Submit" /></form>
+		</fieldset>
+		</td>
+	</tr>
+</table>
+</center>
+<p><strong>Notes:</strong></p>
+<div>
+<ul>
+<li><strong>Comma/Semi-colon :</strong> Some international version of MS Excel uses ';' instead of ','.</li>
+<li><strong>Headers Included or not :</strong> Add a line with the name of the fields at the fist line.</li>
+</ul>
+</div>
+<?php
+$ath->footer(array());
+?>

Modified: trunk/src/common/tracker/actions/tracker.php
===================================================================
--- trunk/src/common/tracker/actions/tracker.php	2011-10-25 09:55:31 UTC (rev 14705)
+++ trunk/src/common/tracker/actions/tracker.php	2011-10-25 10:17:16 UTC (rev 14706)
@@ -548,6 +548,14 @@
 			include $gfcommon.'tracker/actions/query.php';
 			break;
 		}
+		case 'csv' : {
+			include $gfcommon.'tracker/actions/csv.php';
+			break;
+		}
+		case 'format_csv' : {
+			include $gfcommon.'tracker/actions/format_csv.php';
+			break;
+		}
 		case 'downloadcsv' : {
 			include $gfcommon.'tracker/actions/downloadcsv.php';
 			break;

Modified: trunk/src/common/tracker/include/ArtifactHtml.class.php
===================================================================
--- trunk/src/common/tracker/include/ArtifactHtml.class.php	2011-10-25 09:55:31 UTC (rev 14705)
+++ trunk/src/common/tracker/include/ArtifactHtml.class.php	2011-10-25 10:17:16 UTC (rev 14706)
@@ -1,5 +1,5 @@
 <?php
-/**
+/*
  *
  * SourceForge Generic Tracker facility
  *

Modified: trunk/src/common/tracker/include/ArtifactTypeHtml.class.php
===================================================================
--- trunk/src/common/tracker/include/ArtifactTypeHtml.class.php	2011-10-25 09:55:31 UTC (rev 14705)
+++ trunk/src/common/tracker/include/ArtifactTypeHtml.class.php	2011-10-25 10:17:16 UTC (rev 14706)
@@ -64,8 +64,8 @@
 		$labels[] = $this->getName();
 		$links[]  = '/tracker/?func=browse&group_id='.$group_id.'&atid='. $this->getID();
 		$attr[]   = array('title' => _('Browse this tracker.'), 'class' => 'tabtitle');
-		$labels[] = _('Download .csv');
-		$links[]  = '/tracker/?func=downloadcsv&group_id='.$group_id.'&atid='. $this->getID();
+		$labels[] = _('Export CSV');
+		$links[]  = '/tracker/?func=csv&group_id='.$group_id.'&atid='. $this->getID();
 		$attr[]   = array('title' => _('Download data from this tracker as csv file.'), 'class' => 'tabtitle');
 		if ($this->allowsAnon() || session_loggedin()) {
 			$labels[] = _('Submit New');

Modified: trunk/src/www/pm/csv.php
===================================================================
--- trunk/src/www/pm/csv.php	2011-10-25 09:55:31 UTC (rev 14705)
+++ trunk/src/www/pm/csv.php	2011-10-25 10:17:16 UTC (rev 14706)
@@ -102,7 +102,7 @@
 
 <h2>Record Layout</h2>
 
-<table align="center" border="1" cellspacing="0" cellpadding="3">
+<table align="center" border="1" cellpadding="3">
 <tr><td><strong>Field Name</strong></td><td><strong>Description</strong></td></tr>
 <tr><td>project_task_id</td><td>this is the ID in gforge database</td></tr>
 <tr><td>external_task_id</td><td>optional, the equivalent of project_task_id but determined by

Modified: trunk/src/www/pm/format_csv.php
===================================================================
--- trunk/src/www/pm/format_csv.php	2011-10-25 09:55:31 UTC (rev 14705)
+++ trunk/src/www/pm/format_csv.php	2011-10-25 10:17:16 UTC (rev 14706)
@@ -65,19 +65,19 @@
 			name="func" value="csv" />
 		<table>
 			<tr>
-				<td valign="top"><b>Content :</b></td>
+				<td class="top"><b>Content :</b></td>
 				<td><input type="radio" name="full" value="1"<?php if ($full) echo ' checked="checked"' ?>/>Full<br />
 				<input type="radio" name="full" value="0"<?php if (!$full) echo ' checked="checked"' ?> />Normal</td>
 			</tr>
-			<tr><td colspan="2"> </td></tr>
+			<tr><td colspan="2"></td></tr>
 			<tr>
-				<td valign="top"><b>Separator :</b></td>
+				<td class="top"><b>Separator :</b></td>
 				<td><input type="radio" name="sep" value=","<?php if ($sep==',') echo ' checked="checked"' ?>/>Comma (char: ',')<br />
 				<input type="radio" name="sep" value=";"<?php if ($sep==';') echo ' checked="checked"' ?>/>Semi-colon (char: ';')</td>
 			</tr>
-			<tr><td colspan="2"> </td></tr>
+			<tr><td colspan="2"></td></tr>
 			<tr>
-				<td valign="top"><b>Header :</b></td>
+				<td class="top"><b>Header :</b></td>
 				<td><input type="radio" name="headers" value="1"<?php if ($headers) echo ' checked="checked"' ?>/>Included<br />
 				<input type="radio" name="headers" value="0"<?php if (!$headers) echo ' checked="checked"' ?>/>None</td>
 			</tr>




More information about the Fusionforge-commits mailing list