[Fusionforge-commits] r12660 - trunk/src/common/docman

Franck VILLAUME nerville at fusionforge.org
Thu Mar 10 21:00:55 CET 2011


Author: nerville
Date: 2011-03-10 21:00:55 +0100 (Thu, 10 Mar 2011)
New Revision: 12660

Modified:
   trunk/src/common/docman/Document.class.php
   trunk/src/common/docman/Parsedata.class.php
Log:
more OO & cleanup

Modified: trunk/src/common/docman/Document.class.php
===================================================================
--- trunk/src/common/docman/Document.class.php	2011-03-10 16:28:27 UTC (rev 12659)
+++ trunk/src/common/docman/Document.class.php	2011-03-10 20:00:55 UTC (rev 12660)
@@ -6,6 +6,7 @@
  * Copyright 2002-2003, Tim Perdue/GForge, LLC
  * Copyright 2009, Roland Mas
  * Copyright 2010-2011, Franck Villaume - Capgemini
+ * Copyright 2011, Franck Villaume - TrivialDev
  * http://fusionforge.org
  *
  * This file is part of FusionForge.
@@ -981,8 +982,6 @@
 									$this->getID()));
 				$res = db_query_qpa($qpa);
 				if (!$res || db_affected_rows($res) < 1) {
-					var_dump($qpa);
-					exit;
 					$this->setOnUpdateError(db_error().print_r($qpa));
 					return false;
 				}

Modified: trunk/src/common/docman/Parsedata.class.php
===================================================================
--- trunk/src/common/docman/Parsedata.class.php	2011-03-10 16:28:27 UTC (rev 12659)
+++ trunk/src/common/docman/Parsedata.class.php	2011-03-10 20:00:55 UTC (rev 12660)
@@ -4,6 +4,7 @@
  *
  * Copyright 2005, Fabio Bertagnin
  * Copyright 2009-2010, Franck Villaume - Capgemini
+ * Copyright 2011, Franck Villaume - TrivialDev
  * http://fusionforge.org
  *
  * This file is part of FusionForge.
@@ -28,16 +29,15 @@
 	/**
 	 * Constructor.
 	 *
-	 * @param	string
+	 * @param	string	path to the parser list file
 	 * @return	boolean	true
 	 */
 	var $parsers;
 	var $p_path = "";
 
-	function Parsedata($ppath="") {
+	function Parsedata($ppath = "") {
 		$this->p_path = $ppath;
-		$p = get_parser_list ($ppath);
-		$this->parsers = $p;
+		$this->parsers = $this->get_parser_list($ppath);
 		return true;
 	}
 
@@ -48,13 +48,13 @@
 		if (array_key_exists($filetype, $this->parsers)) {
 			// parse data if good parser exists
 			$parser = $this->p_path.$this->parsers[$filetype];
-			$filename = tempnam("/tmp/","tmp");
-			$fp = fopen ($filename, "w");
-			fwrite ($fp, $data1);
-			fclose ($fp);
+			$filename = tempnam("/tmp/", "tmp");
+			$fp = fopen($filename, "w");
+			fwrite($fp, $data1);
+			fclose($fp);
 			$cmd = "php -f $parser $filename";
-			$rep = shell_exec ($cmd);
-			if ( file_exists ($filename ) ) {
+			$rep = shell_exec($cmd);
+			if (file_exists($filename)) {
 				unlink($filename);
 			}
 		}
@@ -62,12 +62,12 @@
 		$data2 = utf8_decode("$title $description");
 		// temporary file for treatement
 		$filename = tempnam("/tmp", "tmp");
-		$fp = fopen ($filename, "w");
-		fwrite ($fp, $data2);
-		fclose ($fp);
+		$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);
+		$rep1 = shell_exec($cmd);
 		// dont need to unlink the filename because parser_text already remove it
 		return preg_replace("/\n/", " ", "$rep $rep1");
 	}
@@ -76,23 +76,23 @@
 		echo "$text \n";
 		ob_flush();
 	}
-}
 
-function get_parser_list($parser_path) {
-	$file = $parser_path."parser_list.txt";
-	$rep = array();
-	$fp = fopen ($file, "r");
-	if ($fp) {
-		$buff = fread($fp, 2048);
-		$a1 = explode ("\n", $buff);
-		foreach ($a1 as $a) {
-			if (trim($a) != "" && substr($a, 0,1) != "#") {
-				$a2 = explode ("|", $a);
-				$rep[$a2[0]] = $a2[1];
+	function get_parser_list($parser_path) {
+		$file = $parser_path."parser_list.txt";
+		$rep = array();
+		$fp = fopen($file, "r");
+		if ($fp) {
+			$buff = fread($fp, 2048);
+			$a1 = explode("\n", $buff);
+			foreach ($a1 as $a) {
+				if (trim($a) != "" && substr($a, 0,1) != "#") {
+					$a2 = explode ("|", $a);
+					$rep[$a2[0]] = $a2[1];
+				}
 			}
 		}
+		return $rep;
 	}
-	return $rep;
 }
 
 // Local Variables:




More information about the Fusionforge-commits mailing list