[Fusionforge-commits] r8950 - in trunk/gforge: common/docman common/docman/engine packaging/cron.d www/docman/admin

Franck VILLAUME nerville at libremir.placard.fr.eu.org
Fri Mar 5 10:02:24 CET 2010


Author: nerville
Date: 2010-03-05 10:02:24 +0100 (Fri, 05 Mar 2010)
New Revision: 8950

Added:
   trunk/gforge/common/docman/engine/parser_html.php
Modified:
   trunk/gforge/common/docman/Document.class.php
   trunk/gforge/common/docman/Parsedata.class.php
   trunk/gforge/common/docman/engine/parser_list.txt
   trunk/gforge/common/docman/engine/parser_oo.php
   trunk/gforge/common/docman/engine/parser_pdf.php
   trunk/gforge/common/docman/engine/parser_text.php
   trunk/gforge/packaging/cron.d/cron.fusionforge
   trunk/gforge/www/docman/admin/index.php
Log:
docman :
- add html parser
- fix copyrights
- fix temp file
- fix update data_words
- remove cronjob in crontab but keeped it in case of reinit data_words

Modified: trunk/gforge/common/docman/Document.class.php
===================================================================
--- trunk/gforge/common/docman/Document.class.php	2010-03-05 08:18:32 UTC (rev 8949)
+++ trunk/gforge/common/docman/Document.class.php	2010-03-05 09:02:24 UTC (rev 8950)
@@ -5,6 +5,7 @@
  * Copyright 2000, Quentin Cregan/Sourceforge
  * Copyright 2002-2003, Tim Perdue/GForge, LLC
  * Copyright 2009, Roland Mas
+ * Copyright 2010, Franck Villaume
  *
  * This file is part of FusionForge.
  *
@@ -41,12 +42,12 @@
 	 *
 	 * @var	 object  $Group.
 	 */
-	  /**
-       * The Search engine path.
-       *
-       * @var  string $engine_path
-       */
-       var $engine_path;
+	/**
+	 * The Search engine path.
+	 *
+	 * @var  string $engine_path
+	 */
+	var $engine_path;
 
 	/**
 	 *  Constructor.
@@ -143,10 +144,9 @@
 		}
 		$data1 = $data;
 
-         // key words for in-document search
-         $kw = new Parsedata ($this->engine_path);
-         $kwords = $kw->get_parse_data (stripslashes($data1), htmlspecialchars($title1), htmlspecialchars($description), $filetype);
-         // $kwords = "";
+		// key words for in-document search
+		$kw = new Parsedata ($this->engine_path);
+		$kwords = $kw->get_parse_data (stripslashes($data1), htmlspecialchars($title), htmlspecialchars($description), $filetype);
 
 		$filesize = strlen($data);
 
@@ -487,12 +487,19 @@
 		}
 
 		if ($data) {
-			$res = db_query_params ('UPDATE doc_data SET data=$1, filesize=$2 WHERE group_id=$3 AND docid=$4',
+			$data1 = $data;
+
+			// key words for in-document search
+			$kw = new Parsedata ($this->engine_path);
+			$kwords = $kw->get_parse_data (stripslashes($data1), htmlspecialchars($title), htmlspecialchars($description), $filetype);
+
+			$res = db_query_params ('UPDATE doc_data SET data=$1, filesize=$2, data_words=$3 WHERE group_id=$4 AND docid=$5',
 						array (base64_encode(stripslashes($data)),
 						       strlen($data),
+						       $kwords,
 						       $this->Group->getID(),
 						       $this->getID())) ;
-			
+
 			if (!$res || db_affected_rows($res) < 1) {
 				$this->setOnUpdateError(db_error());
 				return false;

Modified: trunk/gforge/common/docman/Parsedata.class.php
===================================================================
--- trunk/gforge/common/docman/Parsedata.class.php	2010-03-05 08:18:32 UTC (rev 8949)
+++ trunk/gforge/common/docman/Parsedata.class.php	2010-03-05 09:02:24 UTC (rev 8950)
@@ -3,6 +3,7 @@
  * FusionForge document manager
  *
  * Copyright 2005, Fabio Bertagnin
+ * Copyright 2009-2010, Franck Villaume
  *
  * This file is part of FusionForge.
  *
@@ -26,7 +27,7 @@
 	/**
 	 *  Constructor.
 	 *
-	 *	@param	string
+	 *	@param  string
 	 *	@return true
 	 */
 	 var $parsers;
@@ -48,30 +49,30 @@
 		{ 
 			// parse data if good parser exists
 			$parser = $this->p_path.$this->parsers[$filetype];
-			$filename = rand(10000,99999);
-			$filename = "/tmp/gfd$filename.tmp";
+			$filename = tempnam("/tmp/","tmp");
 			$fp = fopen ($filename, "w");
 			fwrite ($fp, $data1);
 			fclose ($fp);
 			
 			$cmd = "php -f $parser $filename";
 			$rep = shell_exec ($cmd);
-			unlink ("$filename");
+			if ( file_exists ($filename ) ) {
+				unlink($filename);
+			}
 			
 		}
 		// always parse titre and description
-		$data2 = utf8_decode(" $title");
-		$data2 .= utf8_decode(" $description");
+		$data2 = utf8_decode("$title $description");
 		// $data2 = ereg_replace ("\n", " ", $data2);
 		// temporary file for traitement
-		$filename = rand(10000,99999);
-		$filename = "/tmp/gfi$filename.tmp";
+		$filename = tempnam("/tmp", "tmp");
 		$fp = fopen ($filename, "w");
 		fwrite ($fp, $data2);
 		fclose ($fp);
 		$cmd = $this->p_path.$this->parsers["text/plain"];
 		$cmd = "php -f $cmd $filename";
 		$rep1 = shell_exec ($cmd);
+		// dont need to unlink the filename because parser_text already remove it
 		return ereg_replace ("\n", " ", "$rep $rep1");
 	}
 	

Added: trunk/gforge/common/docman/engine/parser_html.php
===================================================================
--- trunk/gforge/common/docman/engine/parser_html.php	                        (rev 0)
+++ trunk/gforge/common/docman/engine/parser_html.php	2010-03-05 09:02:24 UTC (rev 8950)
@@ -0,0 +1,59 @@
+#! /usr/bin/php
+<?php
+/**
+ * FusionForge document search engine
+ *
+ * Copyright 2009-2010, Franck Villaume
+ *
+ * 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 dirname(__FILE__).'/../../../www/env.inc.php';
+
+require_once $gfcommon.'docman/engine/parser_text.inc.php';
+
+if ($argc != 2)
+{
+	echo "Usage : parser_html.php <filename>\n";
+	exit (1);
+}
+$fichin = $argv[1];
+if (!is_file($fichin)) exit (1);
+
+$fd = fopen($fichin, "r");
+$contents = fread($fd, filesize($fichin));
+fclose($fd);
+
+$strip_content = strip_tags($contents);
+$filename = tempnam("/tmp","tmp");
+$fd = fopen($filename, "w");
+fwrite ( $fd , $strip_content );
+fclose($fd);
+
+$rep = parser_text($filename);
+// envoi du résultat sur stdout
+echo "$rep";
+// efface le fichier source
+unlink ($fichin);
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
+?>

Modified: trunk/gforge/common/docman/engine/parser_list.txt
===================================================================
--- trunk/gforge/common/docman/engine/parser_list.txt	2010-03-05 08:18:32 UTC (rev 8949)
+++ trunk/gforge/common/docman/engine/parser_list.txt	2010-03-05 09:02:24 UTC (rev 8950)
@@ -3,6 +3,7 @@
 # FusionForge document search engine
 #
 # Copyright 2005, Fabio Bertagnin
+# Copyright 2009-2010, Franck Villaume
 #
 # This file is part of FusionForge.
 #
@@ -21,11 +22,12 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 # USA
 #
-# Tupple : type file   parser file
+# Tupple : mime type file   parser file
+# syntax :
+# mime-type|parser
 # This list is used by the ParserData class to find if any parser is available for that type of file
-# syntax sample :
-# mime-type|parser_type.php
 text/plain|parser_text.php
+text/html|parser_html.php
 application/pdf|parser_pdf.php
 application/vnd.oasis.opendocument.presentation|parser_oo.php
 application/vnd.oasis.opendocument.text|parser_oo.php

Modified: trunk/gforge/common/docman/engine/parser_oo.php
===================================================================
--- trunk/gforge/common/docman/engine/parser_oo.php	2010-03-05 08:18:32 UTC (rev 8949)
+++ trunk/gforge/common/docman/engine/parser_oo.php	2010-03-05 09:02:24 UTC (rev 8950)
@@ -3,7 +3,7 @@
 /**
  * FusionForge document search engine
  *
- * Copyright 2005, Fabio Bertagnin
+ * Copyright 2010, Franck Villaume
  *
  * This file is part of FusionForge.
  *

Modified: trunk/gforge/common/docman/engine/parser_pdf.php
===================================================================
--- trunk/gforge/common/docman/engine/parser_pdf.php	2010-03-05 08:18:32 UTC (rev 8949)
+++ trunk/gforge/common/docman/engine/parser_pdf.php	2010-03-05 09:02:24 UTC (rev 8950)
@@ -4,6 +4,7 @@
  * FusionForge document search engine
  *
  * Copyright 2005, Fabio Bertagnin
+ * Copyright 2009-2010, Franck Villaume
  *
  * This file is part of FusionForge.
  *
@@ -36,11 +37,10 @@
 
 $fichin = $argv[1];
 if (!is_file($fichin)) exit (1);
-$fichout = "/tmp/gfo".rand(10000, 99999).".tmp";
-$cmd = "/usr/bin/pdftotext $fichin - > $fichout";
+$fichout = tempnam("/tmp","tmp");
+$cmd = "/usr/bin/pdftotext $fichin $fichout";
 $res = shell_exec($cmd);
 
-
 $rep = parser_text($fichout);
 // envoi du résultat sur stdout
 echo "$rep";

Modified: trunk/gforge/common/docman/engine/parser_text.php
===================================================================
--- trunk/gforge/common/docman/engine/parser_text.php	2010-03-05 08:18:32 UTC (rev 8949)
+++ trunk/gforge/common/docman/engine/parser_text.php	2010-03-05 09:02:24 UTC (rev 8950)
@@ -4,6 +4,7 @@
  * FusionForge document search engine
  *
  * Copyright 2005, Fabio Bertagnin
+ * Copyright 2009-2010, Franck Villaume
  *
  * This file is part of FusionForge.
  *
@@ -29,7 +30,7 @@
 
 if ($argc != 2)
 {
-	echo "Usage : parser_oo.php <filename>\n";
+	echo "Usage : parser_text.php <filename>\n";
 	exit (1);
 }
 $fichin = $argv[1];

Modified: trunk/gforge/packaging/cron.d/cron.fusionforge
===================================================================
--- trunk/gforge/packaging/cron.d/cron.fusionforge	2010-03-05 08:18:32 UTC (rev 8949)
+++ trunk/gforge/packaging/cron.d/cron.fusionforge	2010-03-05 09:02:24 UTC (rev 8950)
@@ -102,6 +102,3 @@
 
 # Create SVN tarballs
 5 3 * * * root $PHP $GFORGE/plugins/scmsvn/cronjobs/tarballs.php
-
-# Docman parse word engine
-56 * * * * $FFUSER $PHP $FFCRON/update_docdata_dataword.php

Modified: trunk/gforge/www/docman/admin/index.php
===================================================================
--- trunk/gforge/www/docman/admin/index.php	2010-03-05 08:18:32 UTC (rev 8949)
+++ trunk/gforge/www/docman/admin/index.php	2010-03-05 09:02:24 UTC (rev 8950)
@@ -1,24 +1,33 @@
 <?php
 /**
- * GForge Doc Mgr Facility
+ * FusionForge document manager
  *
- * Copyright 2002 GForge, LLC
- * http://gforge.org/
+ * Copyright 2000, Quentin Cregan/Sourceforge
+ * Copyright 2002-2003, Tim Perdue/GForge, LLC
+ * Copyright 2009, Roland Mas
+ * Copyright 2010, Franck Villaume
  *
+ * 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
  */
 
 
 /*
-	Document Manager
-
-	by Quentin Cregan, SourceForge 06/2000
-
-	Complete OO rewrite by Tim Perdue 1/2003
-*/
-/*
-
    Ftp upload option is commented-out
-
 */
 
 require_once('../../env.inc.php');
@@ -70,7 +79,7 @@
 		$filetype = getStringFromRequest('filetype');
 		$editor = getStringFromRequest('editor');
 
-		$d= new Document($g,$docid);
+		$d= new Document($g,$docid,false,$sys_engine_path);
 		if ($d->isError()) {
 			exit_error(_('Error'),$d->getErrorMessage());
 		}




More information about the Fusionforge-commits mailing list