[Fusionforge-commits] r15076 - in trunk/src: common/docman/actions common/docman/views www/docman www/docman/scripts

Franck VILLAUME nerville at fusionforge.org
Sun Feb 26 16:30:40 CET 2012


Author: nerville
Date: 2012-02-26 16:30:40 +0100 (Sun, 26 Feb 2012)
New Revision: 15076

Added:
   trunk/src/common/docman/actions/getfile.php
Modified:
   trunk/src/common/docman/actions/editfile.php
   trunk/src/common/docman/views/editfile.php
   trunk/src/www/docman/index.php
   trunk/src/www/docman/scripts/DocManController.js
Log:
re-enable online text editing in docman with modal window + fix update URL

Modified: trunk/src/common/docman/actions/editfile.php
===================================================================
--- trunk/src/common/docman/actions/editfile.php	2012-02-21 18:05:15 UTC (rev 15075)
+++ trunk/src/common/docman/actions/editfile.php	2012-02-26 15:30:40 UTC (rev 15076)
@@ -58,7 +58,7 @@
 $docid = getIntFromRequest('docid');
 $title = getStringFromRequest('title');
 $description = getStringFromRequest('description');
-$data = getStringFromRequest('details'.$docid);
+$data = getStringFromRequest('details');
 $file_url = getStringFromRequest('file_url');
 $uploaded_data = getUploadedFile('uploaded_data');
 $stateid = getIntFromRequest('stateid');

Added: trunk/src/common/docman/actions/getfile.php
===================================================================
--- trunk/src/common/docman/actions/getfile.php	                        (rev 0)
+++ trunk/src/common/docman/actions/getfile.php	2012-02-26 15:30:40 UTC (rev 15076)
@@ -0,0 +1,80 @@
+<?php
+/**
+ * FusionForge Documentation Manager
+ *
+ * Copyright 2012, Franck Villaume - TrivialDev
+ * 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 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.
+ */
+
+/* please do not add require here : use www/docman/index.php to add require */
+/* global variables used */
+global $dirid; //id of doc_group
+global $group_id; // id of group
+global $LUSER; // User object
+
+$sysdebug_enable = false;
+
+$urlparam = '/docman/?group_id='.$group_id;
+if (isset($childgroup_id) && $childgroup_id) {
+	$g = group_get_object($childgroup_id);
+	$urlparam .= '&childgroup_id='.$childgroup_id;
+}
+
+$doc_group = getIntFromRequest('doc_group');
+$fromview = getStringFromRequest('fromview');
+
+switch ($fromview) {
+	case 'listrashfile': {
+		$urlparam .= '&view='.$fromview;
+		break;
+	}
+	default: {
+		$urlparam .= '&view=listfile&dirid='.$doc_group;
+		break;
+	}
+}
+
+if (!forge_check_perm('docman', $group_id, 'approve')) {
+	$return_msg = _('Document Manager Action Denied.');
+	session_redirect($urlparam.'&warning_msg='.urlencode($return_msg));
+}
+
+$fileid = getIntFromRequest('fileid');
+$childgroup_id = getIntFromRequest('childgroup_id');
+$details = getIntFromRequest('details');
+if ($childgroup_id) {
+	$g = group_get_object($childgroup_id);
+}
+$d = new Document($g, $fileid);
+if ($d->isError())
+	session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
+
+$filearray = array();
+if ($details) {
+	$filearray["name"] = $d->getFileName();
+	$filearray["type"] = $d->getFileType();
+	$filearray["title"] = $d->getName();
+	$filearray["description"] = $d->getDescription();
+	$filearray["stateid"] = $d->getStateID();
+	$filearray["docgroupid"] = $d->getDocGroupID();
+	$filearray["isurl"] = $d->isURL();
+}
+$filearray["body"] = $d->getFileData();
+echo json_encode($filearray);
+exit;
+?>

Modified: trunk/src/common/docman/views/editfile.php
===================================================================
--- trunk/src/common/docman/views/editfile.php	2012-02-21 18:05:15 UTC (rev 15075)
+++ trunk/src/common/docman/views/editfile.php	2012-02-26 15:30:40 UTC (rev 15076)
@@ -52,14 +52,14 @@
 echo '			<a id="filelink" />';
 echo '		</td>';
 echo '	</tr>';
-// if ($g->useCreateOnline()) {
-// 	echo '	<tr id="editonlineroweditfile" >';
-// 	echo '		<td>'. _('Edit the contents to your desire or leave them as they are to remain unmodified.') .'<br />';
-// 	echo '			<textarea id="defaulteditzone" name="details" rows="15" cols="70"></textarea><br />';
-// 	echo '			<input id="defaulteditfiletype" type="hidden" name="filetype" value="text/plain" />';
-// 	echo '		</td>';
-// 	echo '	</tr>';
-// }
+if ($g->useCreateOnline()) {
+	echo '	<tr id="editonlineroweditfile" >';
+	echo '		<td>'. _('Edit the contents to your desire or leave them as they are to remain unmodified.') .'<br />';
+	echo '			<textarea id="defaulteditzone" name="details" rows="15" cols="70"></textarea><br />';
+	echo '			<input id="defaulteditfiletype" type="hidden" name="filetype" value="text/plain" />';
+	echo '		</td>';
+	echo '	</tr>';
+}
 echo '	<tr>';
 echo '		<td><strong>'. _('Folder that document belongs in:') .'</strong><br />';
 echo '			<select name="doc_group" id="doc_group" />';

Modified: trunk/src/www/docman/index.php
===================================================================
--- trunk/src/www/docman/index.php	2012-02-21 18:05:15 UTC (rev 15075)
+++ trunk/src/www/docman/index.php	2012-02-26 15:30:40 UTC (rev 15076)
@@ -6,6 +6,7 @@
  * Copyright 2002-2003, Tim Perdue/GForge, LLC
  * Copyright 2010-2011, Franck Villaume - Capgemini
  * Copyright (C) 2010-2011 Alain Peyrat - Alcatel-Lucent
+ * Copyright 2012, Franck Villaume - TrivialDev
  * http://fusionforge.org
  *
  * This file is part of FusionForge. FusionForge is free software;
@@ -77,6 +78,7 @@
 	case "emptytrash":
 	case "enforcereserve":
 	case "forcereindexenginesearch":
+	case "getfile":
 	case "injectzip":
 	case "lockfile":
 	case "monitorfile":

Modified: trunk/src/www/docman/scripts/DocManController.js
===================================================================
--- trunk/src/www/docman/scripts/DocManController.js	2012-02-21 18:05:15 UTC (rev 15075)
+++ trunk/src/www/docman/scripts/DocManController.js	2012-02-26 15:30:40 UTC (rev 15076)
@@ -178,8 +178,10 @@
 		jQuery('#docid').attr('value', this.docparams.id);
 		if (this.docparams.isURL) {
 			jQuery('#uploadnewroweditfile').hide();
+			jQuery('#fileurlroweditfile').show();
 		} else {
 			jQuery('#fileurlroweditfile').hide();
+			jQuery('#uploadnewroweditfile').show();
 		}
 		if (!this.docparams.useCreateOnline || !this.docparams.isText) {
 			jQuery('#editonlineroweditfile').hide();
@@ -202,6 +204,11 @@
 			jQuery('#stateid').append(jQuery("<option>").text(key).attr("value",value));
 		});
 		jQuery('#stateid option[value='+this.docparams.statusId+']').attr("selected", "selected");
+		if (this.docparams.isText) {
+			jQuery.getJSON(this.docparams.docManURL + '/?group_id=' + this.docparams.groupId + '&action=getfile&fileid=' + this.docparams.id , jQuery.proxy(function(data){
+			jQuery('#defaulteditzone').text(data.body);
+			}, this));
+		}
 		jQuery('#editdocdata').attr('action', this.docparams.action);
 		
 // 		jQuery.get(this.docparams.docManURL, {




More information about the Fusionforge-commits mailing list