[Fusionforge-commits] r15547 - in trunk/src/common/docman: . engine

Franck VILLAUME nerville at fusionforge.org
Wed May 23 00:30:43 CEST 2012


Author: nerville
Date: 2012-05-23 00:30:43 +0200 (Wed, 23 May 2012)
New Revision: 15547

Modified:
   trunk/src/common/docman/Document.class.php
   trunk/src/common/docman/Parsedata.class.php
   trunk/src/common/docman/engine/parser_list.txt
Log:
add more text parsers & remove useless var copy

Modified: trunk/src/common/docman/Document.class.php
===================================================================
--- trunk/src/common/docman/Document.class.php	2012-05-22 15:23:58 UTC (rev 15546)
+++ trunk/src/common/docman/Document.class.php	2012-05-22 22:30:43 UTC (rev 15547)
@@ -151,12 +151,11 @@
 			function_exists('mb_detect_encoding')) {
 			$data = mb_convert_encoding($data, 'UTF-8', mb_detect_encoding($data));
 		}
-		$data1 = $data;
 
 		// key words for in-document search
 		if ($this->Group->useDocmanSearch()) {
 			$kw = new Parsedata();
-			$kwords = $kw->get_parse_data($data1, htmlspecialchars($title), htmlspecialchars($description), $filetype);
+			$kwords = $kw->get_parse_data($data, htmlspecialchars($title), htmlspecialchars($description), $filetype);
 		} else {
 			$kwords ='';
 		}
@@ -702,7 +701,8 @@
 			case "text/plain":
 			case "text/x-php":
 			case "application/xml":
-			case "text/x-c": {
+			case "text/x-c":
+			case "text/x-diff": {
 				$image = 'docman/file_type_plain.png';
 				break;
 			}
@@ -837,12 +837,10 @@
 		}
 
 		if ($data) {
-			$data1 = $data;
-
 			// key words for in-document search
 			if ($this->Group->useDocmanSearch()) {
 				$kw = new Parsedata();
-				$kwords = $kw->get_parse_data($data1, htmlspecialchars($title), htmlspecialchars($description), $filetype);
+				$kwords = $kw->get_parse_data($data, htmlspecialchars($title), htmlspecialchars($description), $filetype);
 			} else {
 				$kwords = '';
 			}

Modified: trunk/src/common/docman/Parsedata.class.php
===================================================================
--- trunk/src/common/docman/Parsedata.class.php	2012-05-22 15:23:58 UTC (rev 15546)
+++ trunk/src/common/docman/Parsedata.class.php	2012-05-22 22:30:43 UTC (rev 15547)
@@ -4,7 +4,7 @@
  *
  * Copyright 2005, Fabio Bertagnin
  * Copyright 2009-2010, Franck Villaume - Capgemini
- * Copyright 2011, Franck Villaume - TrivialDev
+ * Copyright 2011-2012, Franck Villaume - TrivialDev
  * Copyright (C) 2011-2012 Alain Peyrat - Alcatel-Lucent
  * http://fusionforge.org
  *
@@ -44,13 +44,12 @@
 	function get_parse_data($data, $title, $description, $filetype) {
 		$parser = "";
 		$rep = "";
-		$data1 = $data;
 		if (array_key_exists($filetype, $this->parsers)) {
 			// parse data if good parser exists
 			$parser = $this->p_path.$this->parsers[$filetype];
 			$filename = tempnam("/tmp/", "tmp");
 			$handle = fopen($filename, "w");
-			fwrite($handle, $data1);
+			fwrite($handle, $data);
 			fclose($handle);
 			$cmd = "php -f $parser $filename";
 			$rep = shell_exec($cmd);
@@ -59,11 +58,11 @@
 			}
 		}
 		// always parse titre and description
-		$data2 = utf8_decode("$title $description");
+		$data1 = utf8_decode("$title $description");
 		// temporary file for treatement
 		$filename = tempnam("/tmp", "tmp");
 		$handle = fopen($filename, "w");
-		fwrite($handle, $data2);
+		fwrite($handle, $data1);
 		fclose($handle);
 		$cmd = $this->p_path.$this->parsers["text/plain"];
 		$cmd = "php -f $cmd $filename";

Modified: trunk/src/common/docman/engine/parser_list.txt
===================================================================
--- trunk/src/common/docman/engine/parser_list.txt	2012-05-22 15:23:58 UTC (rev 15546)
+++ trunk/src/common/docman/engine/parser_list.txt	2012-05-22 22:30:43 UTC (rev 15547)
@@ -4,6 +4,7 @@
 #
 # Copyright 2005, Fabio Bertagnin
 # Copyright 2009-2010, Franck Villaume - Capgemini
+# Copyright 2012, Franck Villaume - TrivialDev
 # http://fusionforge.org
 #
 # This file is part of FusionForge.
@@ -27,6 +28,9 @@
 # mime-type|parser
 # This list is used by the ParserData class to find if any parser is available for that type of file
 text/plain|parser_text.php
+text/x-diff|parser_text.php
+text/x-php|parser_text.php
+text/x-c|parser_text.php
 text/html|parser_html.php
 application/pdf|parser_pdf.php
 application/vnd.oasis.opendocument.presentation|parser_oo.php




More information about the Fusionforge-commits mailing list