guntersammet
Joined: 18 Dec 2006
Posts: 1
|
| Posted: Wed Jan 24, 2007 5:15 pm Post subject: Code explanation |
|
|
Hi all:
I'm pretty new to vtiger. Working on a new custom field type (picklist with associated value). Just stumbled over this piece of code (function getDetailBlockInformation in DetailViewUtils.php) and I am not sure if I am missing something:
Code:
for($i=0; $i<$noofrows; $i++)
{
$fieldtablename = $adb->query_result($result,$i,"tablename");
$fieldcolname = $adb->query_result($result,$i,"columnname");
$uitype = $adb->query_result($result,$i,"uitype");
$fieldname = $adb->query_result($result,$i,"fieldname");
$fieldlabel = $adb->query_result($result,$i,"fieldlabel");
$maxlength = $adb->query_result($result,$i,"maximumlength");
$block = $adb->query_result($result,$i,"block");
$generatedtype = $adb->query_result($result,$i,"generatedtype");
$tabid = $adb->query_result($result,$i,"tabid");
$custfld = getDetailViewOutputHtml($uitype, $fieldname, $fieldlabel, $col_fields,$generatedtype,$tabid);
if(is_array($custfld))
{
$label_data[$block][] = array($custfld[0]=>array("value"=>$custfld[1],"ui"=>$custfld[2],"options"=>$custfld["options"],"secid"=>$custfld["secid"],"link"=>$custfld["link"],"cursymb"=>$custfld["cursymb"],"salut"=>$custfld["salut"],"cntimage"=>$custfld["cntimage"],"isadmin"=>$custfld["isadmin"],"tablename"=>$fieldtablename,"fldname"=>$fieldname));
}
$i++;
if($i<$noofrows)
{
$fieldtablename = $adb->query_result($result,$i,"tablename");
$fieldcolname = $adb->query_result($result,$i,"columnname");
$uitype = $adb->query_result($result,$i,"uitype");
$fieldname = $adb->query_result($result,$i,"fieldname");
$fieldlabel = $adb->query_result($result,$i,"fieldlabel");
$maxlength = $adb->query_result($result,$i,"maximumlength");
$block = $adb->query_result($result,$i,"block");
$generatedtype = $adb->query_result($result,$i,"generatedtype");
$tabid = $adb->query_result($result,$i,"tabid");
$custfld = getDetailViewOutputHtml($uitype, $fieldname, $fieldlabel, $col_fields,$generatedtype,$tabid);
if(is_array($custfld))
{
$label_data[$block][] = array($custfld[0]=>array("value"=>$custfld[1],"ui"=>$custfld[2],"options"=>$custfld["options"],"secid"=>$custfld["secid"],"link"=>$custfld["link"],"cursymb"=>$custfld["cursymb"],"salut"=>$custfld["salut"],"cntimage"=>$custfld["cntimage"],"isadmin"=>$custfld["isadmin"],"tablename"=>$fieldtablename,"fldname"=>$fieldname));
}
}
}
if I refactor this to the following:
Code:
for($i=0; $i<$noofrows; $i++)
{
$fieldtablename = $adb->query_result($result,$i,"tablename");
$fieldcolname = $adb->query_result($result,$i,"columnname");
$uitype = $adb->query_result($result,$i,"uitype");
$fieldname = $adb->query_result($result,$i,"fieldname");
$fieldlabel = $adb->query_result($result,$i,"fieldlabel");
$maxlength = $adb->query_result($result,$i,"maximumlength");
$block = $adb->query_result($result,$i,"block");
$generatedtype = $adb->query_result($result,$i,"generatedtype");
$tabid = $adb->query_result($result,$i,"tabid");
$custfld = getDetailViewOutputHtml($uitype, $fieldname, $fieldlabel, $col_fields,$generatedtype,$tabid);
if(is_array($custfld))
{
$label_data[$block][] = array($custfld[0]=>array("value"=>$custfld[1],"ui"=>$custfld[2],"options"=>$custfld["options"],"secid"=>$custfld["secid"],"link"=>$custfld["link"],"cursymb"=>$custfld["cursymb"],"salut"=>$custfld["salut"],"cntimage"=>$custfld["cntimage"],"isadmin"=>$custfld["isadmin"],"tablename"=>$fieldtablename,"fldname"=>$fieldname));
}
}
wouldn't that have the same functionality?
I have to modify this and I'd like to avoid having to put if then else in both places. However, I am afraid that I break something somewhere else.
Anybody out there that could shed some light into this?
TIA
Gunter[/code] |
|