Changeset 536 for trunk/Common/Form
- Timestamp:
- May 18, 2013, 6:51:10 PM (12 years ago)
- Location:
- trunk/Common/Form
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/Form/Form.php
r529 r536 9 9 var $Definition; 10 10 var $Values; 11 var $ValuesFilter; 11 12 var $OnSubmit; 12 13 var $Database; … … 18 19 $this->Definition = array(); 19 20 $this->Values = array(); 21 $this->ValuesFilter = array(); 20 22 $this->OnSubmit = ''; 21 23 } … … 49 51 $Edit = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnView', 50 52 array('Value' => $this->Values[$Index], 'Name' => $Index, 51 'Type' => $Item['Type'], 'Values' => $this->Values)); 53 'Type' => $Item['Type'], 'Values' => $this->Values, 54 'Filter' => $this->ValuesFilter[$Index])); 52 55 if(array_key_exists('Suffix', $Item)) $Edit .= ' '.$Item['Suffix']; 53 56 if(!$this->FormManager->Type->IsHidden($UseType)) … … 116 119 117 120 function LoadValuesFromDatabase($Id) 118 { 119 $DbResult = $this->Database->query('SELECT T.* FROM '.$this->Definition['Table'].' AS T WHERE T.Id='.$Id); 121 { 122 foreach($this->Definition['Items'] as $Index => $Item) 123 if(!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 124 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 125 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) 126 { 127 if(!array_key_exists($Index, $this->Values) and isset($Item['Default'])) $this->Values[$Index] = $Item['Default']; 128 if(array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 129 { 130 if(!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 131 $this->FormManager->Type->RegisterType($Item['Type'], '', 132 $this->FormManager->FormTypes[$Item['Type']]); 133 if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference') 134 $UseType = 'OneToMany'; 135 else if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration') 136 $UseType = 'Enumeration'; 137 } else $UseType = $Item['Type']; 138 $Columns[] = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnFilterNameQuery', 139 array('Name' => $Index, 'Type' => $Item['Type'])); 140 } 141 $Columns = implode(',', $Columns); 142 $DbResult = $this->Database->query('SELECT '.$Columns.' FROM `'.$this->Definition['Table'].'` AS `T` WHERE `T`.`Id`='.$Id); 120 143 $DbRow = $DbResult->fetch_array(); 121 144 foreach($this->Definition['Items'] as $Index => $Item) … … 138 161 array('Value' => $DbRow[$Index], 'Name' => $Index, 139 162 'Type' => $Item['Type'], 'Values' => $this->Values)); 163 $this->ValuesFilter[$Index] = $DbRow[$Index.'_Filter']; 140 164 } 141 165 } -
trunk/Common/Form/Types/Base.php
r501 r536 44 44 return(addslashes($Value)); 45 45 } 46 47 function OnFilterName($Item) 48 { 49 return('`'.$Item['Name'].'`'); 50 } 51 52 function OnFilterNameQuery($Item) 53 { 54 return('`'.$Item['Name'].'`, `'.$Item['Name'].'` AS `'.$Item['Name'].'_Filter`'); 55 } 46 56 } 47 57 -
trunk/Common/Form/Types/OneToMany.php
r531 r536 12 12 if($Item['Value'] != '') 13 13 { 14 if(array_key_exists('View', $Type['Parameters'])) $Table = $Type['Parameters']['View'];14 /*if(array_key_exists('View', $Type['Parameters'])) $Table = $Type['Parameters']['View']; 15 15 else $Table = $Type['Parameters']['Table']; 16 16 $DbResult = $this->Database->query('SELECT '.$Type['Parameters']['Name']. 17 ' AS `Name` FROM '.$Table.'WHERE `'.17 ' AS `Name` FROM `'.$Table.'` WHERE `'. 18 18 $Type['Parameters']['Id'].'`='.$Item['Value']); 19 19 $DbRow = $DbResult->fetch_assoc(); 20 20 $Output = '<a href="?t='.$Type['Parameters']['Table'].'&a='. 21 'view'.'&i='.$Item['Value'].'">'.$DbRow['Name'].'</a>'; 22 } else $Output = ''; 21 'view'.'&i='.$Item['Value'].'">'.$DbRow['Name'].'</a>';*/ 22 $Output = '<a href="?t='.$Type['Parameters']['Table'].'&a='. 23 'view'.'&i='.$Item['Value'].'">'.$Item['Filter'].'</a>'; 24 } else $Output = ''; 23 25 return($Output); 24 26 } … … 60 62 else return($Item['Value']); 61 63 } 64 65 function OnFilterName($Item) 66 { 67 return('`'.$Item['Name'].'_Filter`'); 68 } 69 70 function OnFilterNameQuery($Item) 71 { 72 $Type = $this->FormManager->Type->TypeDefinitionList[$Item['Type']]; 73 //if($Item['Value'] != '') 74 //{ 75 if(array_key_exists('View', $Type['Parameters'])) $Table = $Type['Parameters']['View']; 76 else $Table = $Type['Parameters']['Table']; 77 $Output = '`'.$Item['Name'].'`, (SELECT '.$Type['Parameters']['Name']. 78 ' AS `Name` FROM `'.$Table.'` WHERE `'. 79 $Type['Parameters']['Id'].'`=`'.$Item['Name'].'`) AS `'.$Item['Name'].'_Filter`'; 80 //} else $Output = '`'.$Item['Name'].'`, `'.$Item['Name'].'` AS `'.$Item['Name'].'_Filter`'; 81 return($Output); 82 } 62 83 } 63 84
Note:
See TracChangeset
for help on using the changeset viewer.