[Fusionforge-commits] r11557 - trunk/src/common/docman/include

Franck VILLAUME nerville at libremir.placard.fr.eu.org
Wed Nov 17 15:27:18 CET 2010


Author: nerville
Date: 2010-11-17 15:27:18 +0100 (Wed, 17 Nov 2010)
New Revision: 11557

Modified:
   trunk/src/common/docman/include/DocumentGroupHTML.class.php
   trunk/src/common/docman/include/utils.php
Log:
cleanup

Modified: trunk/src/common/docman/include/DocumentGroupHTML.class.php
===================================================================
--- trunk/src/common/docman/include/DocumentGroupHTML.class.php	2010-11-17 14:16:47 UTC (rev 11556)
+++ trunk/src/common/docman/include/DocumentGroupHTML.class.php	2010-11-17 14:27:18 UTC (rev 11557)
@@ -27,14 +27,14 @@
 require_once $gfwww.'include/note.php';
 
 /**
- *	Wrap many group display related functions
+ * Wrap many group display related functions
  */
 class DocumentGroupHTML extends Error {
 	var $Group;
 
 	function DocumentGroupHTML(&$Group) {
 		$this->Error();
-		
+
 		if (!$Group || !is_object($Group)) {
 			$this->setError(_('DocumentGroupHTML:: Invalid Project'));
 			return false;
@@ -51,40 +51,41 @@
 	/**
 	 * showSelectNestedGroups - Display the tree of document groups inside a <select> tag
 	 *
-	 * @param array	Array of groups.
-	 * @param string	The name that will be assigned to the input
-	 * @param bool	Allow selection of "None"
-	 * @param int	The ID of the group that should be selected by default (if any)
-	 * @param array	Array of IDs of groups that should not be displayed
+	 * @param	array	Array of groups.
+	 * @param	string	The name that will be assigned to the input
+	 * @param	bool	Allow selection of "None"
+	 * @param	int	The ID of the group that should be selected by default (if any)
+	 * @param	array	Array of IDs of groups that should not be displayed
+	 * @return	string	html select box code
 	 */
-	function showSelectNestedGroups (&$group_arr, $select_name, $allow_none=true, $selected_id=0, $dont_display=array()) {
+	function showSelectNestedGroups (&$group_arr, $select_name, $allow_none = true, $selected_id = 0, $dont_display = array()) {
 		// Build arrays for calling html_build_select_box_from_arrays()
 		$id_array = array();
 		$text_array = array();
-		
+
 		if ($allow_none) {
 			// First option to be displayed
 			$id_array[] = 0;
 			$text_array[] = "(None)";
 		}
-		
+
 		// Recursively build the document group tree
 		$this->buildArrays($group_arr, $id_array, $text_array, $dont_display);
 		
-		echo html_build_select_box_from_arrays($id_array,$text_array,$select_name,$selected_id,false);
+		echo html_build_select_box_from_arrays($id_array, $text_array, $select_name, $selected_id, false);
 	}
-	
+
 	/**
 	 * buildArrays - Build the arrays to call html_build_select_box_from_arrays()
 	 *
-	 * @param array Array of groups.
-	 * @param array Reference to the array of ids that will be build
-	 * @param array Reference to the array of group names
-	 * @param array	Array of IDs of groups that should not be displayed
-	 * @param int The ID of the parent whose childs are being showed (0 for root groups)
-	 * @param int The current level
+	 * @param	array	Array of groups.
+	 * @param	array	Reference to the array of ids that will be build
+	 * @param	array	Reference to the array of group names
+	 * @param	array	Array of IDs of groups that should not be displayed
+	 * @param	int	The ID of the parent whose childs are being showed (0 for root groups)
+	 * @param	int	The current level
 	 */
-	function buildArrays(&$group_arr, &$id_array, &$text_array, &$dont_display, $parent=0, $level=0) {
+	function buildArrays(&$group_arr, &$id_array, &$text_array, &$dont_display, $parent = 0, $level = 0) {
 		if (!is_array($group_arr) || !array_key_exists("$parent", $group_arr)) return;
 
 		$child_count = count($group_arr["$parent"]);
@@ -102,7 +103,6 @@
 			// Show childs (if any)
 			$this->buildArrays($group_arr, $id_array, $text_array, $dont_display, $doc_group->getID(), $level+1);
 		}
-
 	}
 }
 

Modified: trunk/src/common/docman/include/utils.php
===================================================================
--- trunk/src/common/docman/include/utils.php	2010-11-17 14:16:47 UTC (rev 11556)
+++ trunk/src/common/docman/include/utils.php	2010-11-17 14:27:18 UTC (rev 11557)
@@ -27,34 +27,33 @@
 
 /* tooling library */
 
-function getNameDocGroup($id,$group) {
-	$group_object = & group_get_object($group);;
+function getNameDocGroup($id, $group) {
+	$group_object = group_get_object($group);
 	$res = db_query_params ('SELECT groupname FROM doc_groups WHERE doc_group=$1 AND group_id=$2',
-							array ($id,$group));
+				array ($id, $group));
 	if (!$res || db_numrows($res) < 1) {
-		$group_object->setError(_('DocumentGroup: Invalid DocumentGroup ID'));
+		$group_object->setError('DocumentGroup::'. _('Invalid DocumentGroup ID'));
 		return false;
 	} else {
 		return (db_result($res,0,'groupname'));
 	}
 }
 
-function getStateDocGroup($id,$group) {
-	$group_object = & group_get_object($group);;
+function getStateDocGroup($id, $group) {
+	$group_object = group_get_object($group);
 	$res = db_query_params ('SELECT stateid FROM doc_groups WHERE doc_group=$1 AND group_id=$2',
-							array ($id,$group));
+				array ($id, $group));
 	if (!$res || db_numrows($res) < 1) {
-		$group_object->setError(_('DocumentGroup: Invalid DocumentGroup ID'));
+		$group_object->setError('DocumentGroup:: '. _('Invalid DocumentGroup ID'));
 		return false;
 	} else {
 		return (db_result($res,0,'stateid'));
 	}
 }
 
-function doc_get_state_box($checkedval='xzxz') {
-    $res_states=db_query_params ('select * from doc_states', array());
-    echo html_build_select_box ($res_states,'stateid',$checkedval,false);
-
+function doc_get_state_box($checkedval = 'xzxz') {
+	$res_states=db_query_params ('select * from doc_states', array());
+	echo html_build_select_box ($res_states,'stateid',$checkedval,false);
 }
 
 /*
@@ -64,43 +63,43 @@
 	global $nested_groups,$group_id;
 	global $idExposeTreeIndex,$dirid,$idhtml;
 
-    if (is_array(@$nested_groups[$docgroup])) {
-        foreach ($nested_groups[$docgroup] as $dg) {
-            $idhtml++;
+	if (is_array(@$nested_groups[$docgroup])) {
+		foreach ($nested_groups[$docgroup] as $dg) {
+			$idhtml++;
 
-            if ($dirid == $dg->getID())
-                $idExposeTreeIndex = $idhtml;
+			if ($dirid == $dg->getID())
+				$idExposeTreeIndex = $idhtml;
 
-            echo "
-                ['".'<span class="JSCookTreeFolderClosed"><i><img alt="" src="\' + ctThemeXPBase + \'folder1.gif" /></i></span><span class="JSCookTreeFolderOpen"><i><img alt="" src="\' + ctThemeXPBase + \'folderopen1.gif"></i></span>'."', '".addslashes($dg->getName())."', '?group_id=".$group_id."&view=listfile&dirid=".$dg->getID()."', '', '',";
-	            docman_recursive_display($dg->getID());
-            echo ",
-                    ],";
-        }
-    }
+			echo "
+				['".'<span class="JSCookTreeFolderClosed"><i><img alt="" src="\' + ctThemeXPBase + \'folder1.gif" /></i></span><span class="JSCookTreeFolderOpen"><i><img alt="" src="\' + ctThemeXPBase + \'folderopen1.gif"></i></span>'."', '".addslashes($dg->getName())."', '?group_id=".$group_id."&view=listfile&dirid=".$dg->getID()."', '', '',";
+					docman_recursive_display($dg->getID());
+			echo ",
+				],";
+		}
+	}
 }
 
 /*
  * docman_fill_zip - Recursive function to add docgroup and documents inside zip for backup
  *
- * @param	$object		zip
- * @param	$array		nested groups
- * @param	$object		documentfactory
- * @param	$integer	documentgroup id : default value = 0
- * @param	$string		documentgroup parent name : default value = empty
+ * @param	$object	zip
+ * @param	$array	nested groups
+ * @param	$object	documentfactory
+ * @param	$int	documentgroup id : default value = 0
+ * @param	$string	documentgroup parent name : default value = empty
  */
 function docman_fill_zip($zip, $nested_groups, $document_factory, $docgroup = 0, $parent_docname = '') {
 	if (is_array(@$nested_groups[$docgroup])) {
 		foreach ($nested_groups[$docgroup] as $dg) {
-            if (!$zip->addEmptyDir($parent_docname.'/'.$dg->getName()))
-                return false;
+			if (!$zip->addEmptyDir($parent_docname.'/'.$dg->getName()))
+				return false;
 
 			$document_factory->setDocGroupID($dg->getID());
 			$docs = $document_factory->getDocuments();
 			if (is_array($docs) && count($docs) > 0) {      // this group has documents
 				foreach ($docs as $doc) {
-                    if ( !$zip->addFromString($parent_docname.'/'.$dg->getName().'/'.$doc->getFileName(),$doc->getFileData()))
-                        return false;
+					if ( !$zip->addFromString($parent_docname.'/'.$dg->getName().'/'.$doc->getFileName(),$doc->getFileData()))
+						return false;
 				}
 			}
 			docman_fill_zip($zip, $nested_groups, $document_factory, $dg->getID(), $parent_docname.'/'.$dg->getName());
@@ -109,12 +108,12 @@
 	return true;
 }
 
-function docman_recursive_stateid($docgroup,$nested_groups,$nested_docs,$stateid=2) {
-    if (is_array(@$nested_groups[$docgroup])) {
-        foreach ($nested_groups[$docgroup] as $dg) {
-		$dg->setStateID($stateid);
-        }
-    }
+function docman_recursive_stateid($docgroup, $nested_groups, $nested_docs, $stateid = 2) {
+	if (is_array(@$nested_groups[$docgroup])) {
+		foreach ($nested_groups[$docgroup] as $dg) {
+			$dg->setStateID($stateid);
+		}
+	}
 	if (isset($nested_docs[$docgroup]) && is_array($nested_docs[$docgroup])) {
 		foreach ($nested_docs[$docgroup] as $d) {
 			$d->setStateID($stateid);
@@ -124,8 +123,9 @@
 
 /**
  * docman_display_trash - function to show the documents inside the groups tree with specific status : 2 = deleted
+ *@todo: remove css code
  */
-function docman_display_trash(&$document_factory,$parent_group=0) {
+function docman_display_trash(&$document_factory, $parent_group = 0) {
 	$nested_groups =& $document_factory->getNested(2);
 	$child_count = count($nested_groups["$parent_group"]);
 	echo "<ul style='list-style-type: none'>\n";
@@ -139,7 +139,7 @@
 /*
  * docman_display_documents - Recursive function to show the documents inside the groups tree
  */
-function docman_display_documents(&$nested_groups, &$document_factory, $is_editor, $stateid=0, $parent_group=0) {
+function docman_display_documents(&$nested_groups, &$document_factory, $is_editor, $stateid = 0, $parent_group = 0) {
 	if (!array_key_exists("$parent_group",$nested_groups) || !is_array($nested_groups["$parent_group"])) {
 		return;
 	}




More information about the Fusionforge-commits mailing list