Changeset 9 for types/PointerOneToOne.php
- Timestamp:
- Oct 11, 2008, 11:06:21 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
types/PointerOneToOne.php
r8 r9 1 1 <?php 2 2 3 function TypePointerOneToOneViewHtml($Type, $Item)3 function GetTablePointerName($Type, $Item) 4 4 { 5 5 global $Database, $Lists; 6 6 7 //print_r($Type);8 $Output = '';9 7 $Columns = ''; 10 8 $ItemType = explode(':', $Item['Type']); … … 18 16 if($DbResult->num_rows > 0) 19 17 { 20 $DbRow = $DbResult->fetch_array(); 21 $Output = '<a href="?Action=ViewItem&Table='.$TargetTable.'&Item='.$DbRow['Id'].'">'.$DbRow['Name'].'</a>'; 22 } 18 return($DbResult->fetch_assoc()); 19 } else return(''); 20 } 21 22 function GetTablePointerNameList($Type, $Item) 23 { 24 global $Database, $Lists; 25 26 $Columns = ''; 27 $ItemType = explode(':', $Item['Type']); 28 $TargetTable = $ItemType[1]; 29 30 foreach($Lists[$TargetTable]['Items'] as $ListItem) 31 if($ListItem['VisibleInPointer'] == 1) $Columns .= '`'.$ListItem['Name'].'`," ",'; 32 $Columns = 'CONCAT('.substr($Columns, 0, -1).') AS Name, Id'; 33 $DbResult = $Database->select($TargetTable, $Columns); 34 //echo($Database->LastQuery); 35 if($DbResult->num_rows > 0) 36 { 37 $Result = array(); 38 while($DbRow = $DbResult->fetch_assoc()) 39 $Result[] = $DbRow; 40 return($Result); 41 } else return(array()); 42 } 43 44 function TypePointerOneToOneViewHtml($Type, $Item) 45 { 46 global $Database, $Lists; 47 48 $ItemType = explode(':', $Item['Type']); 49 $TargetTable = $ItemType[1]; 50 $TargetName = GetTablePointerName($Type, $Item); 51 $Output = '<a href="?Action=ViewItem&Table='.$TargetTable.'&Item='.$TargetName['Id'].'">'.$TargetName['Name'].'</a>'; 23 52 return($Output); 24 53 } … … 29 58 30 59 $Output = '<select name="'.$Item['Name'].'">'; 31 $Columns = ''; 32 $ItemType = explode(':', $Item['Type']); 33 $TargetTable = $ItemType[1]; 34 foreach($Lists[$TargetTable]['Items'] as $ListItem) 35 if($ListItem['VisibleInPointer'] == 1) $Columns .= '`'.$ListItem['Name'].'`," ",'; 36 $Columns = 'CONCAT('.substr($Columns, 0, -1).') AS Name, Id'; 37 $DbResult = $Database->select($TargetTable, $Columns); 60 $TargetNameList = GetTablePointerNameList($Type, $Item); 38 61 //echo($Database->LastQuery); 39 while($DbRow = $DbResult->fetch_array())62 foreach($TargetNameList as $TargetName) 40 63 { 41 if($ Parameter == $DbRow['Id']) $Selected = ' selected="1"'; else $Selected = '';42 $Output .= '<option value="'.$ DbRow['Id'].'"'.$Selected.'>'.$DbRow['Name'].'</option>';64 if($Item['Value'] == $TargetName['Id']) $Selected = ' selected="1"'; else $Selected = ''; 65 $Output .= '<option value="'.$TargetName['Id'].'"'.$Selected.'>'.$TargetName['Name'].'</option>'; 43 66 } 44 67 $Output .= '</select>';
Note:
See TracChangeset
for help on using the changeset viewer.