Legend:
- Unmodified
- Added
- Removed
-
base.php
r20 r21 3 3 function ShowList($List, $Column = '', $ColumnValue = 0, $Title = '') 4 4 { 5 global $Database, $ Types, $Config;5 global $Database, $Config; 6 6 7 7 if(!CheckPermission('Read', $List['ItemId'])) … … 85 85 function ShowHistory($List, $Id, $Title = '') 86 86 { 87 global $Database, $ Types, $Config, $TypeNames;87 global $Database, $Config; 88 88 89 89 if($Title == '') $Output = '<div>'.$List['Title'].'</div>'; … … 136 136 } 137 137 } 138 $Item = array('Name' => 'Author', 'Type' => $TypeNames['PointerToUser']);138 $Item = array('Name' => 'Author', 'Type' => TypePointerToUserId); 139 139 $ItemDefinition = array('Name' => $Item['Name'], 'Value' => $DbRow[$Item['Name']], 'SourceTable' => $List['TableName'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']); 140 140 $Output .= '<td>'.ExecuteTypeEvent($Item['Type'], 'OnView', $ItemDefinition).'</td>'; … … 151 151 function ShowEditItem($List, $Id) 152 152 { 153 global $Database , $Types;153 global $Database; 154 154 155 155 if(!CheckPermission('Write', $List['ItemId'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění')); … … 160 160 foreach($List['Items'] as $Index => $Item) 161 161 { 162 if($Types[$Item['Type']]['BaseType'] != 'PointerOneToMany') 162 $Type = GetTypeDefinition($Item['Type']); 163 if($Type['BaseType'] != 'PointerOneToMany') 163 164 { 164 165 if($Item['Editable'] == 1) … … 190 191 function ShowEditItemFinish($List, $Id) 191 192 { 192 global $Database, $ Types, $System, $LogActionType;193 global $Database, $System, $LogActionType; 193 194 194 195 if(!CheckPermission('Write', $List['ItemId'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění')); … … 199 200 foreach($List['Items'] as $Index => $Item) 200 201 { 201 if($Types[$Item['Type']]['BaseType'] != 'PointerOneToMany') 202 $Type = GetTypeDefinition($Item['Type']); 203 if($Type['BaseType'] != 'PointerOneToMany') 202 204 { 203 205 $DefinitionItems[] = array('Name' => $Index, 'Caption' => $Item['TextBefore'].$Required, 'Value' => $DbRow[$Index], 'SourceTable' => $List['TableName'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']); … … 227 229 function ShowAddItem($List, $Column = '', $ColumnValue = 0) 228 230 { 229 global $Database , $Types;231 global $Database; 230 232 231 233 if(!CheckPermission('Write', $List['ItemId'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění')); … … 235 237 { 236 238 //echo($Item['Name'].','); 237 if(($Types[$Item['Type']]['BaseType'] != 'PointerOneToMany') and ($Item['Name'] != $Column)) 239 $Type = GetTypeDefinition($Item['Type']); 240 if(($Type['BaseType'] != 'PointerOneToMany') and ($Item['Name'] != $Column)) 238 241 { 239 242 if($Item['Required'] == 1) $Required = '*'; else $Required = ''; … … 269 272 function ShowAddItemFinish($List) 270 273 { 271 global $Database, $ Types, $System, $LogActionType;274 global $Database, $System, $LogActionType; 272 275 273 276 if(!CheckPermission('Write', $List['ItemId'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění')); … … 277 280 { 278 281 //echo($Item['Name'].','); 279 if(($Types[$Item['Type']]['BaseType'] != 'PointerOneToMany') and ($Item['Name'] != $Column)) 282 $Type = GetTypeDefinition($Item['Type']); 283 if(($Type['BaseType'] != 'PointerOneToMany') and ($Item['Name'] != $Column)) 280 284 { 281 285 if($Item['Required'] == 1) $Required = '*'; else $Required = ''; … … 308 312 function ShowViewItem($List, $Id, $Column = '', $ColumnValue = 0) 309 313 { 310 global $Database , $Types;314 global $Database; 311 315 312 316 if(!CheckPermission('Read', $List['ItemId'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění')); … … 319 323 foreach($List['Items'] as $Index => $Item) 320 324 { 321 if($Types[$Item['Type']]['BaseType'] != 'PointerOneToMany') 325 $Type = GetTypeDefinition($Item['Type']); 326 if($Type['BaseType'] != 'PointerOneToMany') 322 327 { 323 328 $DefinitionItems[] = array('Name' => $Index, 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'].$Required, 'Value' => $DbRow[$Index], 'SourceTable' => $List['TableName'], 'SourceItemId' => 0); … … 344 349 foreach($List['Items'] as $Index => $Item) 345 350 { 346 if($Types[$Item['Type']]['BaseType'] == 'PointerOneToMany') 347 { 348 $SubList = GetListDefinition($Types[$Item['Type']]['Parameters'][0]); 349 $Output .= ShowList($SubList, $Types[$Item['Type']]['Parameters'][1], $DbRow['ItemId'], $Item['TextBefore']).'<br /><br />'; 351 $Type = GetTypeDefinition($Item['Type']); 352 if($Type['BaseType'] == 'PointerOneToMany') 353 { 354 $SubList = GetListDefinition($Type['Parameters'][0]); 355 $Output .= ShowList($SubList, $Type['Parameters'][1], $DbRow['ItemId'], $Item['TextBefore']).'<br /><br />'; 350 356 } 351 357 } … … 469 475 } 470 476 471 function LoadTypeDefinition() 472 { 473 global $Database, $Types, $TypeNames; 474 475 $Types = array(); 476 $TypeNames = array(); 477 $DbResult = $Database->query('SELECT t1.* FROM `SystemType` AS t1 LEFT JOIN `SystemType` AS t2 ON t1.ItemId=t2.ItemId AND t1.Id < t2.Id WHERE (t2.ItemId IS NULL) AND (t1.DeletionTime IS NULL)'); 478 while($DbRow = $DbResult->fetch_assoc()) 479 { 480 $DbRow['Parameters'] = explode('|', $DbRow['Parameters']); 481 $DbRow['BaseType'] = $DbRow['Name']; 482 $Types[$DbRow['ItemId']] = $DbRow; 483 $TypeNames[$DbRow['Name']] = $DbRow['ItemId']; 484 } 485 486 // Merge parent type definition 487 foreach($Types as $Index => $Type) 488 { 489 if($Type['ParentType'] != 0) 490 { 491 foreach($Type as $Index2 => $Item) 492 if($Item == '') 493 { 494 $Types[$Index][$Index2] = $Types[$Type['ParentType']][$Index2]; 495 } 496 $Types[$Index]['BaseType'] = $Types[$Type['ParentType']]['Name']; 497 } 477 function GetTypeDefinition($Id) 478 { 479 global $Database, $Types; 480 481 if(!array_key_exists($Id, $Types)) 482 { 483 $DbResult = $Database->query('SELECT t1.* FROM `SystemType` AS t1 LEFT JOIN `SystemType` AS t2 ON t1.ItemId=t2.ItemId AND t1.Id < t2.Id WHERE (t2.ItemId IS NULL) AND (t1.DeletionTime IS NULL) AND t1.ItemId='.$Id); 484 if($DbResult->num_rows > 0) 485 { 486 $DbRow = $DbResult->fetch_assoc(); 487 $DbRow['Parameters'] = explode('|', $DbRow['Parameters']); 488 $DbRow['BaseType'] = $DbRow['Name']; 489 490 // Merge parent type definition 491 if($DbRow['ParentType'] != 0) 492 { 493 $ParentType = GetTypeDefinition($DbRow['ParentType']); 494 foreach($DbRow as $Index => $Item) 495 if($Item == '') 496 { 497 $DbRow[$Index] = $ParentType[$Index]; 498 } 499 $DbRow['BaseType'] = $ParentType['Name']; 500 } 501 $Types[$DbRow['ItemId']] = $DbRow; 502 } else $Types[$DbRow['ItemId']] = NULL; 498 503 } 499 504 //print_r($Types); 505 return($Types[$Id]); 500 506 } 501 507 … … 508 514 function ExecuteTypeEvent($Type, $Event, $Parameters) 509 515 { 510 global $Type s, $TypeDefinitionList;511 512 $Type Object = $TypeDefinitionList[$Types[$Type]['BaseType']];513 //echo($Callback.',');516 global $TypeDefinitionList; 517 518 $TypeDefinition = GetTypeDefinition($Type); 519 $TypeObject = $TypeDefinitionList[$TypeDefinition['BaseType']]; 514 520 if(is_callable(array($TypeObject, $Event))) return($TypeObject->$Event($Parameters)); 515 else return($Type s[$Type]['BaseType'].'->'.$Event.'('.$Type.')');521 else return($TypeDefinition['BaseType'].'->'.$Event.'('.$Type.')'); 516 522 } 517 523
Note:
See TracChangeset
for help on using the changeset viewer.