Changeset 21
- Timestamp:
- Oct 22, 2008, 10:33:11 AM (16 years ago)
- Files:
-
- 8 edited
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 -
forms.php
r20 r21 9 9 var $OnSubmit = ''; 10 10 11 function DefinitionTextTypeToNumericType()12 {13 global $TypeNames;14 15 foreach($this->Definition['Items'] as $Index => $Definition)16 if(!is_numeric($Definition['Type'])) $this->Definition['Items'][$Index]['Type'] = $TypeNames[$Definition['Type']];17 }18 19 11 function ShowEditForm() 20 12 { 21 $this->DefinitionTextTypeToNumericType();22 13 $Output = '<center><form enctype="multipart/form-data" action="'.$this->OnSubmit.'" method="post"><div align="center">'; 23 14 $Table = $this->ShowEditBlock(); … … 28 19 function ShowEditBlock($Context = '') 29 20 { 30 global $Database , $Types, $TypeNames;21 global $Database; 31 22 32 23 $Table = array( … … 37 28 foreach($this->Definition['Items'] as $Index => $Item) 38 29 { 39 if($Item['Type'] != $TypeNames['Hidden'])30 if($Item['Type'] != TypeHiddenId) 40 31 { 41 32 if(!array_key_exists($Index, $this->Values) and isset($Item['Value'])) $this->Values[$Index] = $Item['Value']; … … 49 40 function ShowHiddenBlock($Context = '') 50 41 { 51 global $Database , $Types, $TypeNames;42 global $Database; 52 43 53 44 $Output = ''; … … 55 46 foreach($this->Definition['Items'] as $Item) 56 47 { 57 if($Item['Type'] == $TypeNames['Hidden'])48 if($Item['Type'] == TypeHiddenId) 58 49 { 59 50 if(!array_key_exists($Item['Name'], $this->Values) and isset($Item['Value'])) $this->Values[$Item['Name']] = $Item['Value']; … … 67 58 function ShowReadOnlyForm() 68 59 { 69 $this->DefinitionTextTypeToNumericType();70 71 60 $Output = '<center><div align="center">'; 72 61 $Table = $this->ShowReadOnlyBlock(); … … 77 66 function ShowReadOnlyBlock($Context = '') 78 67 { 79 global $Database , $Types;68 global $Database; 80 69 81 70 $Table = array( … … 138 127 function LoadValuesFromForm() 139 128 { 140 $this->DefinitionTextTypeToNumericType();141 129 $this->Values = $this->LoadValuesFromFormBlock(); 142 130 } … … 144 132 function LoadValuesFromFormBlock($Context = '') 145 133 { 146 global $FormTypes;147 148 134 $Values = array(); 149 135 foreach($this->Definition['Items'] as $Index => $Item) -
global.php
r20 r21 49 49 $System->AddModule(new User()); 50 50 $System->Modules['User']->Check(); 51 LoadTypeDefinition();52 51 53 52 $MonthNames = array('', 'Leden', 'Únor', 'Březen', 'Duben', 'Květen', 'Červen', 'Červenec', 'Srpen', 'Září', 'Říjen', 'Listopad', 'Prosinec'); -
index.php
r18 r21 15 15 'SubmitBuffonText' => 'Přihlásit', 16 16 'Items' => array( 17 array('Name' => 'UserName', 'Type' => 'String', 'Caption' => 'Jméno', 'Value' => ''),18 array('Name' => 'Password', 'Type' => 'Password', 'Caption' => 'Heslo', 'Value' => ''),17 array('Name' => 'UserName', 'Type' => TypeStringId, 'Caption' => 'Jméno', 'Value' => ''), 18 array('Name' => 'Password', 'Type' => TypePasswordId, 'Caption' => 'Heslo', 'Value' => ''), 19 19 ), 20 20 ); … … 25 25 'SubmitBuffonText' => 'Registrovat', 26 26 'Items' => array( 27 array('Name' => 'UserName', 'Type' => 'String', 'Caption' => 'Přihlašovací jméno', 'Value' => ''),28 array('Name' => 'Password', 'Type' => 'Password', 'Caption' => 'Heslo', 'Value' => ''),29 array('Name' => 'Password2', 'Type' => 'Password', 'Caption' => 'Potvrzení hesla', 'Value' => ''),30 array('Name' => 'Email', 'Type' => 'String', 'Caption' => 'E-mail', 'Value' => ''),31 array('Name' => 'FirstName', 'Type' => 'String', 'Caption' => 'Křestní jméno', 'Value' => ''),32 array('Name' => 'SecondName', 'Type' => 'String', 'Caption' => 'Příjmení', 'Value' => ''),27 array('Name' => 'UserName', 'Type' => TypeStringId, 'Caption' => 'Přihlašovací jméno', 'Value' => ''), 28 array('Name' => 'Password', 'Type' => TypePasswordId, 'Caption' => 'Heslo', 'Value' => ''), 29 array('Name' => 'Password2', 'Type' => TypePasswordId, 'Caption' => 'Potvrzení hesla', 'Value' => ''), 30 array('Name' => 'Email', 'Type' => TypeStringId, 'Caption' => 'E-mail', 'Value' => ''), 31 array('Name' => 'FirstName', 'Type' => TypeStringId, 'Caption' => 'Křestní jméno', 'Value' => ''), 32 array('Name' => 'SecondName', 'Type' => TypeStringId, 'Caption' => 'Příjmení', 'Value' => ''), 33 33 ), 34 34 ); -
types/Enumeration.php
r19 r21 5 5 function OnView($Item) 6 6 { 7 global $Types; 8 9 $Output = $Types[$Item['Type']]['Parameters'][$Item['Value']]; 7 $Type = GetTypeDefinition($Item['Type']); 8 $Output = $Type['Parameters'][$Item['Value']]; 10 9 return($Output); 11 10 } … … 13 12 function OnEdit($Item) 14 13 { 15 global $Types; 16 14 $Type = GetTypeDefinition($Item['Type']); 17 15 $Output = '<select name="'.$Item['Name'].'">'; 18 foreach($Type s[$Item['Type']]['Parameters'] as $Index => $StateName)16 foreach($Type['Parameters'] as $Index => $StateName) 19 17 { 20 18 if($Item['Value'] == $Index) $Selected = ' selected="1"'; else $Selected = ''; -
types/File/FileDownload.php
r19 r21 10 10 } 11 11 12 chdir('.. ');12 chdir('../..'); 13 13 include('global.php'); 14 14 $DbResult = $Database->select('SystemFile', '*', 'Id='.addslashes($_GET['Id'])); -
types/PointerOneToOne.php
r20 r21 47 47 function OnView($Item) 48 48 { 49 global $Database , $Types;49 global $Database; 50 50 51 $Type = $Types[$Item['Type']];51 $Type = GetTypeDefinition($Item['Type']); 52 52 $TargetTable = $Type['Parameters'][0]; 53 53 $TargetName = $this->GetTablePointerName($Type, $Item); -
types/include.php
r19 r21 17 17 include('types/GPS.php'); 18 18 19 define(TypeIntegerId, 1); 20 define(TypeBooleanId, 4); 21 define(TypeStringId, 3); 22 define(TypeDateId, 2); 23 define(TypePasswordId, 15); 24 define(TypeFloatId, 16); 25 define(TypeHiddenId, 20); 26 define(TypePointerToUserId, 37); 27 19 28 ?>
Note:
See TracChangeset
for help on using the changeset viewer.