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

Franck VILLAUME nerville at libremir.placard.fr.eu.org
Tue Nov 16 20:56:09 CET 2010


Author: nerville
Date: 2010-11-16 20:56:09 +0100 (Tue, 16 Nov 2010)
New Revision: 11551

Modified:
   trunk/src/common/docman/DocumentFactory.class.php
   trunk/src/common/docman/DocumentGroup.class.php
   trunk/src/common/docman/DocumentGroupFactory.class.php
   trunk/src/common/docman/Parsedata.class.php
Log:
cleanup

Modified: trunk/src/common/docman/DocumentFactory.class.php
===================================================================
--- trunk/src/common/docman/DocumentFactory.class.php	2010-11-16 19:55:15 UTC (rev 11550)
+++ trunk/src/common/docman/DocumentFactory.class.php	2010-11-16 19:56:09 UTC (rev 11551)
@@ -13,7 +13,7 @@
  * 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
@@ -33,25 +33,26 @@
 	/**
 	 * The Group object.
 	 *
-	 * @var	 object  $Group.
+	 * @var	object	$Group.
 	 */
 	var $Group;
 
 	/**
 	 * The Documents dictionary.
 	 *
-	 * @var	 array	Contains doc_group_id as key and the array of documents associated to that id. 
+	 * @var	array	Contains doc_group_id as key and the array of documents associated to that id. 
 	 */
 	var $Documents;
+
 	var $stateid;
 	var $docgroupid;
 	var $sort='group_name, title';
 
 	/**
-	 *  Constructor.
+	 * Constructor.
 	 *
-	 *	@param	object	The Group object to which this DocumentFactory is associated.
-	 *	@return	boolean	success.
+	 * @param	object	The Group object to which this DocumentFactory is associated.
+	 * @return	boolean	success.
 	 */
 	function DocumentFactory(&$Group) {
 		$this->Error();
@@ -59,55 +60,56 @@
 			$this->setError(_('ProjectGroup:: No Valid Group Object'));
 			return false;
 		}
+
 		if ($Group->isError()) {
 			$this->setError('ProjectGroup:: '.$Group->getErrorMessage());
 			return false;
 		}
+
 		$this->Group =& $Group;
-
 		return true;
 	}
 
 	/**
-	 *	getGroup - get the Group object this DocumentFactory is associated with.
+	 * getGroup - get the Group object this DocumentFactory is associated with.
 	 *
-	 *	@return object	the Group object.
+	 * @return	object	the Group object.
 	 */
 	function &getGroup() {
 		return $this->Group;
 	}
 
 	/**
-	 *	setStateID - call this before getDocuments() if you want to limit to a specific state.
+	 * setStateID - call this before getDocuments() if you want to limit to a specific state.
 	 *
-	 *	@param	int	The stateid from the doc_states table.
+	 * @param	int	The stateid from the doc_states table.
 	 */
 	function setStateID($stateid) {
 		$this->stateid=$stateid;
 	}
 
 	/**
-	 *	setDocGroupID - call this before getDocuments() if you want to limit to a specific doc_group.
+	 * setDocGroupID - call this before getDocuments() if you want to limit to a specific doc_group.
 	 *
-	 *	@param	int	The doc_group from the doc_groups table.
+	 * @param	int	The doc_group from the doc_groups table.
 	 */
 	function setDocGroupID($docgroupid) {
 		$this->docgroupid=$docgroupid;
 	}
 
 	/**
-	 *	setSort - call this before getDocuments() if you want to control the sorting.
+	 * setSort - call this before getDocuments() if you want to control the sorting.
 	 *
-	 *	@param	string	The name of the field to sort on.
+	 * @param	string	The name of the field to sort on.
 	 */
 	function setSort($sort) {
 		$this->sort=$sort;
 	}
 
 	/**
-	 *	getDocuments - returns an array of Document objects.
+	 * getDocuments - returns an array of Document objects.
 	 *
-	 *	@return	array	Document objects.
+	 * @return	array	Document objects.
 	 */
 	function &getDocuments() {
 		if (!$this->Documents) {
@@ -155,13 +157,13 @@
 						$valid = false;
 					}
 				}
-				
+
 				if ($valid) {
 					$return[] =& $doc;
 				}
 			}
 		}
-		
+
 		if (count($return) == 0) {
 			$this->setError(_('No Documents Found'));
 			$return = NULL;
@@ -170,7 +172,7 @@
 
 		return $return;
 	}
-	
+
 	/**
 	 * getFromDB - Retrieve documents from database.
 	 */
@@ -191,7 +193,7 @@
 			$this->Documents[$doc_group_id][] = new Document($this->Group, $arr['docid'], $arr);
 		}
 	}
-	
+
 	/**
 	 * getStates - Return an array of states that have documents associated to them
 	 */

Modified: trunk/src/common/docman/DocumentGroup.class.php
===================================================================
--- trunk/src/common/docman/DocumentGroup.class.php	2010-11-16 19:55:15 UTC (rev 11550)
+++ trunk/src/common/docman/DocumentGroup.class.php	2010-11-16 19:56:09 UTC (rev 11551)
@@ -33,25 +33,25 @@
 	/**
 	 * The Group object.
 	 *
-	 * @var		object	$Group.
+	 * @var	object	$Group.
 	 */
 	var $Group; //object
 
 	/**
 	 * Array of data.
 	 *
-	 * @var		array	$data_array.
+	 * @var	array	$data_array.
 	 */
 	var $data_array;
 
 	/**
-	 *  DocumentGroup - constructor.
+	 * DocumentGroup - constructor.
 	 *
-	 *  Use this constructor if you are modifying an existing doc_group.
+	 * Use this constructor if you are modifying an existing doc_group.
 	 *
-	 *	@param	object	Group object.
-	 *  @param	array	(all fields from doc_groups) OR doc_group from database.
-	 *  @return boolean	success.
+	 * @param	object	Group object.
+	 * @param	array	(all fields from doc_groups) OR doc_group from database.
+	 * @return boolean	success.
 	 */
 	function DocumentGroup(&$Group, $data=false) {
 		$this->Error();
@@ -86,10 +86,10 @@
 	}
 
 	/**
-	 *	create - create a new item in the database.
+	 * create - create a new item in the database.
 	 *
-	 *	@param	string	Item name.
-	 *  @return id on success / false on failure.
+	 * @param	string	Item name.
+	 * @return	boolean	on success / false on failure.
 	 */
 	function create($name,$parent_doc_group=0) {
 		//
@@ -153,7 +153,7 @@
 	/**
 	 * delete - delete a DocumentGroup.
 	 *          delete is recursive and permanent
-	 * @param	int		Document Group Id, integer Project Group Id
+	 * @param	int	Document Group Id, integer Project Group Id
 	 * @return	boolean	success
 	 */
 	function delete($doc_groupid,$project_group_id) {
@@ -191,10 +191,10 @@
 	}
 
 	/**
-	 *	fetchData - re-fetch the data for this DocumentGroup from the database.
+	 * fetchData - re-fetch the data for this DocumentGroup from the database.
 	 *
-	 *	@param	int		ID of the doc_group.
-	 *	@return boolean	success
+	 * @param	int	ID of the doc_group.
+	 * @return	boolean	success
 	 */
 	function fetchData($id) {
 		$res = db_query_params ('SELECT * FROM doc_groups WHERE doc_group=$1',
@@ -209,55 +209,55 @@
 	}
 
 	/**
-	 *	getGroup - get the Group Object this DocumentGroup is associated with.
+	 * getGroup - get the Group Object this DocumentGroup is associated with.
 	 *
-	 *	@return Object Group.
+	 * @return Object Group.
 	 */
 	function &getGroup() {
 		return $this->Group;
 	}
 
 	/**
-	 *	getID - get this DocumentGroup's ID.
+	 * getID - get this DocumentGroup's ID.
 	 *
-	 *	@return	int	The id #.
+	 * @return	int	The id #.
 	 */
 	function getID() {
 		return $this->data_array['doc_group'];
 	}
 	
 	/**
-	 *	getID - get parent DocumentGroup's id.
+	 * getID - get parent DocumentGroup's id.
 	 *
-	 *	@return	int	The id #.
+	 * @return	int	The id #.
 	 */
 	function getParentID() {
 		return $this->data_array['parent_doc_group'];
 	}
 
 	/**
-	 *	getName - get the name.
+	 * getName - get the name.
 	 *
-	 *	@return	String	The name.
+	 * @return	String	The name.
 	 */
 	function getName() {
 		return $this->data_array['groupname'];
 	}
 
 	/**
-	 *	getState - get the state id.
+	 * getState - get the state id.
 	 *
-	 *	@return	Int	The state id.
+	 * @return	Int	The state id.
 	 */
 	function getState() {
 		return $this->data_array['stateid'];
 	}
 
 	/**
-	 *  update - update a DocumentGroup.
+	 * update - update a DocumentGroup.
 	 *
-	 *  @param	string	Name of the category.
-	 *  @return boolean.
+	 * @param	string	Name of the category.
+	 * @return boolean.
 	 */
 	function update($name,$parent_doc_group) {
 		$perm =& $this->Group->getPermission ();
@@ -313,7 +313,7 @@
 	*
 	* @param	array	Array of nested groups information, fetched from DocumentGroupFactory class
 	* @param	object	The DocumentFactory object
-	* @param	int		(optional) State of the documents
+	* @param	int	(optional) State of the documents
 	* @return	boolean	success
 	*/
 	function hasDocuments(&$nested_groups, &$document_factory, $stateid=0) {

Modified: trunk/src/common/docman/DocumentGroupFactory.class.php
===================================================================
--- trunk/src/common/docman/DocumentGroupFactory.class.php	2010-11-16 19:55:15 UTC (rev 11550)
+++ trunk/src/common/docman/DocumentGroupFactory.class.php	2010-11-16 19:56:09 UTC (rev 11551)
@@ -27,31 +27,31 @@
  */
 
 /*
-	Document Groups
+ Document Groups
 */
 
 require_once $gfcommon.'include/Error.class.php';
 
 class DocumentGroupFactory extends Error {
 	/**
-	 * This variable holds the document groups
+	 * This variable holds the document groups.
 	 */
 	var $flat_groups;
 
 	/**
-	 * This variable holds the document groups for reading them in nested form
+	 * This variable holds the document groups for reading them in nested form.
 	 */
 	var $nested_groups;
 
 	/**
-	 * The Group object
+	 * The Group object.
 	 */
 	var $Group;
 
 	/**
-	 *  Constructor.
+	 * Constructor.
 	 *
-	 *	@return	boolean	success.
+	 * @return	boolean	success.
 	 */
 	function DocumentGroupFactory(&$Group) {
 		$this->Error();
@@ -70,10 +70,10 @@
 	}
 
 	/**
-	 *	getNested - Return an array of DocumentGroup objects arranged for nested views.
+	 * getNested - Return an array of DocumentGroup objects arranged for nested views.
 	 *
-	 *	@param int		The stateid of DocumentGroup
-	 *	@return	array	The array of DocumentGroup.
+	 * @param	int	The stateid of DocumentGroup.
+	 * @return	array	The array of DocumentGroup.
 	 */
 	function &getNested($stateid=1) {
 		if ($this->nested_groups) {
@@ -81,7 +81,7 @@
 		}
 		
 		$result = db_query_params ('SELECT * FROM doc_groups WHERE group_id=$1 AND stateid=$2 ORDER BY groupname ASC',
-					   array ($this->Group->getID(),$stateid));
+						array ($this->Group->getID(),$stateid));
 		$rows = db_numrows($result);
 		
 		if (!$result) {
@@ -97,25 +97,24 @@
 		$count = count($this->flat_groups);
 		for ($i=0; $i < $count; $i++) {
 			$this->nested_groups["".$this->flat_groups[$i]->getParentID()][] =& $this->flat_groups[$i];
-			
 		}
 
 		return $this->nested_groups;
 	}
 
 	/**
-	 *	getDocumentGroups - Return an array of DocumentGroup objects.
+	 * getDocumentGroups - Return an array of DocumentGroup objects.
 	 *
-	 *	@param int		The stateid of DocumentGroups
-	 *	@return	array	The array of DocumentGroup.
+	 * @param	int	The stateid of DocumentGroups
+	 * @return	array	The array of DocumentGroup.
 	 */
 	function &getDocumentGroups($stateid=1) {
 		if ($this->flat_groups) {
 			return $this->flat_groups;
 		}
-		
+
 		$result = db_query_params ('SELECT * FROM doc_groups WHERE group_id=$1 AND stateid=$2 ORDER BY groupname ASC',
-					   array ($this->Group->getID(),$stateid)) ;
+						array ($this->Group->getID(),$stateid)) ;
 		$rows = db_numrows($result);
 
 		if (!$result || $rows < 1) {
@@ -126,7 +125,7 @@
 				$this->flat_groups[] = new DocumentGroup($this->Group, $arr);
 			}
 		}
-		
+
 		return $this->flat_groups;
 	}
 }

Modified: trunk/src/common/docman/Parsedata.class.php
===================================================================
--- trunk/src/common/docman/Parsedata.class.php	2010-11-16 19:55:15 UTC (rev 11550)
+++ trunk/src/common/docman/Parsedata.class.php	2010-11-16 19:56:09 UTC (rev 11551)
@@ -26,41 +26,37 @@
 
 class Parsedata {
 	/**
-	 *  Constructor.
+	 * Constructor.
 	 *
-	 *	@param  string
-	 *	@return true
+	 * @param	string
+	 * @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;
 		return true;
 	}
-	function get_parse_data ($data, $title, $description, $filetype)
-	{
+
+	function get_parse_data ($data, $title, $description, $filetype) {
 		$parser = "";
 		$rep = "";
 		$data1 = $data;
-		if (array_key_exists($filetype, $this->parsers))
-		{ 
+		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);
-			
 			$cmd = "php -f $parser $filename";
 			$rep = shell_exec ($cmd);
 			if ( file_exists ($filename ) ) {
 				unlink($filename);
 			}
-			
 		}
 		// always parse titre and description
 		$data2 = utf8_decode("$title $description");
@@ -75,28 +71,22 @@
 		// dont need to unlink the filename because parser_text already remove it
 		return preg_replace("/\n/", " ", "$rep $rep1");
 	}
-	
-	
-	function print_debug ($text)
-	{
+
+	function print_debug ($text) 
 		echo "$text \n";
 		ob_flush();
 	}
 }
 
-function get_parser_list ($parser_path)
-{
+function get_parser_list ($parser_path) {
 	$file = $parser_path."parser_list.txt";
 	$rep = array();
 	$fp = fopen ($file, "r");
-	if ($fp)
-	{
+	if ($fp) {
 		$buff = fread($fp, 2048);
 		$a1 = explode ("\n", $buff);
-		foreach ($a1 as $a)
-		{
-			if (trim($a) != "" && substr($a, 0,1) != "#")
-			{
+		foreach ($a1 as $a) {
+			if (trim($a) != "" && substr($a, 0,1) != "#") {
 				$a2 = explode ("|", $a);
 				$rep[$a2[0]] = $a2[1];
 			}




More information about the Fusionforge-commits mailing list