[Vtigercrm-commits] [vtiger-commits] r6420 - in /vtigercrm/trunk/include/utils: CommonUtils.php DetailViewUtils.php

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Thu May 25 10:17:16 EDT 2006


Author: saraj
Date: Thu May 25 08:17:12 2006
New Revision: 6420

Log:
* Modified the hardcoded path as a function were we will get the file storage path based on the module

Modified:
    vtigercrm/trunk/include/utils/CommonUtils.php
    vtigercrm/trunk/include/utils/DetailViewUtils.php

Modified: vtigercrm/trunk/include/utils/CommonUtils.php
==============================================================================
--- vtigercrm/trunk/include/utils/CommonUtils.php (original)
+++ vtigercrm/trunk/include/utils/CommonUtils.php Thu May 25 08:17:12 2006
@@ -2174,5 +2174,29 @@
 	return $filepath;
 }
 
+/**
+ * 	This function is used to get the Path in where we store the files based on the module.
+ *	@param string $module   - module name
+ * 	return string $storage_path - path inwhere the file will be uploaded (also where it was stored) will be return based on the module
+*/
+function getModuleFileStoragePath($module)
+{
+	global $log;
+	$log->debug("Entering into getModuleFileStoragePath($module) method ...");
+	
+	$storage_path = "test/";
+
+	if($module == 'Products')
+	{
+		$storage_path .= 'product/';
+	}
+	if($module == 'Contacts')
+	{
+		$storage_path .= 'contact/';
+	}
+
+	$log->debug("Exiting from getModuleFileStoragePath($module) method. return storage_path = \"$storage_path\"");
+	return $storage_path;
+}
 
 ?>

Modified: vtigercrm/trunk/include/utils/DetailViewUtils.php
==============================================================================
--- vtigercrm/trunk/include/utils/DetailViewUtils.php (original)
+++ vtigercrm/trunk/include/utils/DetailViewUtils.php Thu May 25 08:17:12 2006
@@ -359,33 +359,37 @@
 			if($tabid==14)
 			{
 				$images=array();
-				$image_array=explode("###",$col_fields[$fieldname]);
-				$image_array = array_slice($image_array,0,count($image_array)-1);
+				$image_array=explode("###",trim($col_fields[$fieldname],"###"));
+				$image_array = array_slice($image_array,0,count($image_array));
+
+				$imgpath = getModuleFileStoragePath('Products');
 				if(count($image_array)>1)
 				{
 					if(count($image_array) < 4)
 						$sides=count($image_array)*2;
 					else
 						$sides=8;
+						
 					$image_lists = '<div id="Carousel" style="position:relative;vertical-align: middle;">
 						<img src="modules/Products/placeholder.gif" width="371" height="227" style="position:relative;">
 						</div><script>var Car_NoOfSides='.$sides.'; Car_Image_Sources=new Array(';
-								$imgpath = "test/product/";
-								foreach($image_array as $image)
-								{
-								$images[]='"'.$imgpath.$image.'","'.$imgpath.$image.'"';
-								}	
-								$image_lists .=implode(',',$images).');</script>';	
+
+						foreach($image_array as $image)
+						{
+							$images[]='"'.$imgpath.$image.'","'.$imgpath.$image.'"';
+						}	
+						$image_lists .=implode(',',$images).');</script>';	
+
 					$label_fld[] =$image_lists;
 				}else
 				{
-					$imgpath = "test/product/".$col_fields[$fieldname];
+					$imgpath .= $col_fields[$fieldname];
 					$label_fld[] ='<img src="'.$imgpath.'" border="0" width="450" height="300">';
 				}
 			}	
-            if($tabid==4)
-            {
-				$imgpath = "test/contact/".$col_fields[$fieldname];
+			if($tabid==4)
+        		{
+				$imgpath = getModuleFileStoragePath('Contacts').$col_fields[$fieldname];
 				$label_fld[] ='<img src="'.$imgpath.'" border="0">';
 			}
 		}





More information about the vtigercrm-commits mailing list