[Fusionforge-commits] r13598 - branches/Branch_5_1/src/common/docman/include

Alain Peyrat aljeux at fusionforge.org
Mon Jun 27 18:43:57 CEST 2011


Author: aljeux
Date: 2011-06-27 18:43:57 +0200 (Mon, 27 Jun 2011)
New Revision: 13598

Modified:
   branches/Branch_5_1/src/common/docman/include/utils.php
Log:
docman: split js for xhtml

Modified: branches/Branch_5_1/src/common/docman/include/utils.php
===================================================================
--- branches/Branch_5_1/src/common/docman/include/utils.php	2011-06-27 16:43:48 UTC (rev 13597)
+++ branches/Branch_5_1/src/common/docman/include/utils.php	2011-06-27 16:43:57 UTC (rev 13598)
@@ -6,6 +6,7 @@
  * Copyright 2000, Quentin Cregan/SourceForge
  * Copyright 2002-2004, GForge Team
  * Copyright 2010, Franck Villaume - Capgemini
+ * Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
  * http://fusionforge.org
  *
  * This file is part of FusionForge. FusionForge is free software;
@@ -135,17 +136,8 @@
 	echo "</ul>";
 }
 
-/*
- * docman_display_documents - Recursive function to show the documents inside the groups tree
- * @todo : remove the css code
- * @todo : use the javascript controler
- * @todo : use jquery
- */
-function docman_display_documents(&$nested_groups, &$document_factory, $is_editor, $stateid = 0, $parent_group = 0) {
+function docman_editdata_js() {
 	global $group_id;
-	if (!array_key_exists("$parent_group", $nested_groups) || !is_array($nested_groups["$parent_group"])) {
-		return;
-	}
 	
 	echo '<script language="JavaScript" type="text/javascript">/* <![CDATA[ */';
 	echo 'var lockInterval = new Array();';
@@ -160,8 +152,22 @@
 	echo '		clearInterval(lockInterval[iddiv]);';
 	echo '	}';
 	echo '}';
-	echo '/* ]]> */</script>';
-	echo '<ul style="list-style-type: none">';
+	echo '/* ]]> */</script>'."\n";
+}
+
+/*
+ * docman_display_documents - Recursive function to show the documents inside the groups tree
+ * @todo : remove the css code
+ * @todo : use the javascript controler
+ * @todo : use jquery
+ */
+function docman_display_documents(&$nested_groups, &$document_factory, $is_editor, $stateid = 0, $parent_group = 0) {
+	global $group_id;
+	if (!array_key_exists("$parent_group", $nested_groups) || !is_array($nested_groups["$parent_group"])) {
+		return;
+	}
+	
+	echo "\n".'<ul style="list-style-type: none">';
 	$child_count = count($nested_groups["$parent_group"]);
 	
 	for ($i=0; $i < $child_count; $i++) {
@@ -169,7 +175,7 @@
 		
 		if ($doc_group->hasDocuments($nested_groups, $document_factory, $stateid)) {
 			$icon = 'ofolder15.png';
-			echo '<li>'.html_image('docman/directory.png', '22', '22', array('border'=>'0'))." ".$doc_group->getName()."</li>";
+			echo '<li>'.html_image('docman/directory.png', '22', '22', array('border'=>'0'))." ".$doc_group->getName();
 			docman_display_documents($nested_groups, $document_factory, $is_editor, $stateid, $doc_group->getID());
 		}
 
@@ -183,30 +189,29 @@
 		if (is_array($docs)) {
 			$docs_count = count($docs);
 
-			echo "<ul style='list-style-type: none'>";
+				echo "\n<ul style='list-style-type: none'>";
 			for ($j=0; $j < $docs_count; $j++) {
 				$tooltip = $docs[$j]->getFileName() . " (" .
 							($docs[$j]->getUpdated() ?
 							date(_('Y-m-d H:i'), $docs[$j]->getUpdated()) :
 							date(_('Y-m-d H:i'),$docs[$j]->getCreated())) .
 							") ";
-				if ($docs[$j]->getFileSize() > 1024) {
-					$tooltip .= floor($docs[$j]->getFileSize()/1024) . "KB";
-				} else {
-					$tooltip .= $docs[$j]->getFileSize() . "B";
-				}
+				$tooltip .= human_readable_bytes($docs[$j]->getFileSize());
 				$tooltip = htmlspecialchars($tooltip);
 				echo '<li>'.  html_image('docman/file_type_unknown.png', '22', '22', array("border"=>"0")). 
-					$docs[$j]->getName(). ' - ' . $tooltip . ' <a href="#" onclick="javascript:EditData(\''.$docs[$j]->getID().'\')" >'. html_image('docman/edit-file.png', '22', '22', array('alt'=>'editfile')) .'</a></li>';
-				echo "<i>".$docs[$j]->getDescription()."</i><br/>";
+					$docs[$j]->getName(). ' - ' . $tooltip . ' <a href="#" onclick="javascript:EditData(\''.$docs[$j]->getID().'\')" >'. html_image('docman/edit-file.png', '22', '22', array('alt'=>'editfile')) .'</a>';
+				echo "<br /><i>".$docs[$j]->getDescription()."</i><br/>";
 				echo '<div class="docman_div_include" id="editdata'.$docs[$j]->getID().'" style="display:none">';
 				document_editdata($docs[$j]);
-				echo '</div>';
+				echo '</div></li>'."\n";
 			}
-			echo "</ul>";
+				echo "</ul>\n";
 		}
+		if ($doc_group->hasDocuments($nested_groups, $document_factory, $stateid)) {
+			echo '</li>';
 	}
-	echo "</ul>";
+	}
+	echo "</ul>\n";
 }
 
 /*
@@ -265,7 +270,7 @@
 		</td>
 		<td>
 			<?php if ($document->isURL()) {
-					echo '<a href="'.inputSpecialchars($d->getFileName()).'">[View File URL]</a>';
+					echo '<a href="'.inputSpecialchars($document->getFileName()).'">[View File URL]</a>';
 				} else { ?>
 					<a target="_blank" href="/docman/view.php/<?php echo $group_id.'/'.$document->getID().'/'.urlencode($document->getFileName()) ?>"><?php echo $document->getName(); ?></a>
 			<?php } ?>
@@ -287,19 +292,19 @@
 					$params['name'] = 'details'.$document->getID();
 					$params['width'] = "800";
 					$params['height'] = "300";
-					$params['body'] = $d->getFileData();
+					$params['body'] = $document->getFileData();
 					$params['group'] = $group_id;
 					plugin_hook("text_editor",$params);
 					if (!$GLOBALS['editor_was_set_up']) {
 						echo '<textarea name="details'.$document->getID().'" rows="15" cols="70">'. $document->getFileData()  .'</textarea><br />';
 					}
-					echo '<input type="hidden" name="filetype" value="text/html">';
+					echo '<input type="hidden" name="filetype" value="text/html" />';
 					unset($GLOBALS['editor_was_set_up']);
 					break;
 				}
 				default: {
 					echo '<textarea name="details'.$document->getID().'" rows="15" cols="70">'. $document->getFileData()  .'</textarea><br />';
-					echo '<input type="hidden" name="filetype" value="text/plain">';
+					echo '<input type="hidden" name="filetype" value="text/plain" />';
 				}
 			}
 




More information about the Fusionforge-commits mailing list