Legend:
- Unmodified
- Added
- Removed
-
base.php
r9 r10 12 12 include('types/Float.php'); 13 13 include('types/Hyperlink.php'); 14 include('types/Hidden.php'); 15 16 // Include list events definitions 17 include('lists/SystemList.php'); 18 include('lists/SystemListItem.php'); 14 19 15 20 function ShowList($List, $Column = '', $ColumnValue = 0, $Title = '') … … 73 78 if($Item['VisibleInList'] == 1) 74 79 { 75 $ItemType = explode(':', $Item['Type']);76 $Type = $Types[$ItemType[0]];77 80 $ItemDefinition = array('Name' => $Index, 'Value' => $DbRow[$Index], 'SourceTable' => $List['TableName'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']); 78 if(is_callable($Type['CallbackView'])) $Value = $Type['CallbackView']($Type, $ItemDefinition); 79 else $Value = $Type['CallbackView']; 80 $Output .= '<td>'.$Value.'</td>'; 81 $Output .= '<td>'.ExecuteTypeEvent($Item['Type'], 'OnView', $ItemDefinition).'</td>'; 81 82 } 82 83 } … … 101 102 $Output .= '<th><a href="?OrderColumn='.$Item['Name'].'">'.$Item['TextBefore'].'</a></th>'; 102 103 } 103 $Output .= '<th> Akce</th></tr>';104 $Output .= '<th><a href="?OrderColumn=Author">Autor</a></th><th><a href="?OrderColumn=CreationTime">Čas vytvoření</a></th><th>Akce</th></tr>'; 104 105 105 106 $Where = ' AND (ItemId='.$Id.')'; … … 129 130 $TotalItemCount = $DbRow[0]; 130 131 131 $DbResult = $Database->query('SELECT * FROM `'.$List['TableName'].'` WHERE 1'.$Where.' LIMIT '.($Page * $Config['Web']['ItemsPerPage']).', '.$Config['Web']['ItemsPerPage']);132 $DbResult = $Database->query('SELECT * FROM `'.$List['TableName'].'` AS t1 WHERE 1'.$Where.' LIMIT '.($Page * $Config['Web']['ItemsPerPage']).', '.$Config['Web']['ItemsPerPage']); 132 133 //echo($Database->LastQuery.'<br>'); 133 134 while($DbRow = $DbResult->fetch_array()) 134 135 { 135 136 $Output .= '<tr>'; 136 foreach($List['Items'] as $I ndex => $Item)137 foreach($List['Items'] as $Item) 137 138 { 138 139 if($Item['VisibleInList'] == 1) 139 140 { 140 $ItemType = explode(':', $Item['Type']); 141 $Type = $Types[$ItemType[0]]; 142 $ItemDefinition = array('Name' => $Index, 'Value' => $DbRow[$Index], 'SourceTable' => $List['TableName'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']); 143 if(is_callable($Type['CallbackView'])) $Value = $Type['CallbackView']($Type, $ItemDefinition); 144 else $Value = $Type['CallbackView']; 145 $Output .= '<td>'.$Value.'</td>'; 146 } 147 } 141 $ItemDefinition = array('Name' => $Item['Name'], 'Value' => $DbRow[$Item['Name']], 'SourceTable' => $List['TableName'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']); 142 $Output .= '<td>'.ExecuteTypeEvent($Item['Type'], 'OnView', $ItemDefinition).'</td>'; 143 } 144 } 145 $Item = array('Name' => 'Author', 'Type' => 'PointerOneToOne:User'); 146 $ItemType = explode(':', $Item['Type']); 147 $Type = $Types[$ItemType[0]]; 148 $ItemDefinition = array('Name' => $Item['Name'], 'Value' => $DbRow[$Item['Name']], 'SourceTable' => $List['TableName'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']); 149 if(is_callable($Type['CallbackView'])) $Value = $Type['CallbackView']($Type, $ItemDefinition); 150 else $Value = $Type['CallbackView']; 151 $Output .= '<td>'.$Value.'</td>'; 152 153 $Output .= '<td>'.$DbRow['CreationTime'].'</td>'; 148 154 $Output .= '<td><a href="?Action=ViewItem&Table='.$List['TableName'].'&Item='.$DbRow['Id'].'">Zobrazit</a> </td></tr>'; 149 155 } 150 156 $Output .= '</table>'; 151 157 $Output .= PagesList($Page, $TotalItemCount); 152 $Output .= '<a href="?Action= AddItem&Table='.$List['TableName'].$ColumnSelection.'">Přidat</a> '.$FullListLink;158 $Output .= '<a href="?Action=ShowList&Table='.$List['TableName'].'">Celkový seznam</a>'; 153 159 return($Output); 154 160 } … … 164 170 foreach($List['Items'] as $Index => $Item) 165 171 { 166 $ItemType = explode(':', $Item['Type']); 167 if($ItemType[0] != 'PointerOneToMany') 172 if($Types[$Item['Type']]['BaseType'] != 'PointerOneToMany') 168 173 { 169 174 $DefinitionItems[] = array('Name' => $Index, 'Caption' => $Item['TextBefore'].$Required, 'Value' => $DbRow[$Index], 'SourceTable' => $List['TableName'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']); … … 197 202 foreach($List['Items'] as $Index => $Item) 198 203 { 199 $ItemType = explode(':', $Item['Type']); 200 if($ItemType[0] != 'PointerOneToMany') 204 if($Types[$Item['Type']]['BaseType'] != 'PointerOneToMany') 201 205 { 202 206 $Values[$Index] = $_POST[$Index]; … … 222 226 $DefinitionItems = array(); 223 227 $AfterTableOutput = ''; 224 foreach($List['Items'] as $I ndex => $Item)225 { 226 $ItemType = explode(':', $Item['Type']);227 if(($ ItemType[0] != 'PointerOneToMany') and ($Item['Name'] != $Column))228 foreach($List['Items'] as $Item) 229 { 230 //echo($Item['Name'].','); 231 if(($Types[$Item['Type']]['BaseType'] != 'PointerOneToMany') and ($Item['Name'] != $Column)) 228 232 { 229 233 if($Item['Required'] == 1) $Required = '*'; else $Required = ''; 230 $DefinitionItems[] = array('Name' => $I ndex, 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'].$Required, 'Value' => '', 'SourceTable' => $List['TableName'], 'SourceItemId' => 0);234 $DefinitionItems[] = array('Name' => $Item['Name'], 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'].$Required, 'Value' => '', 'SourceTable' => $List['TableName'], 'SourceItemId' => 0); 231 235 } else 232 236 if($Item['Name'] == $Column) 233 237 { 234 $DefinitionItems[] = array('Name' => $Column, 'Type' => 'String', 'Caption' => '', 'Value' => $ColumnValue); 235 } 236 } 238 $DefinitionItems[] = array('Name' => $Column, 'Type' => 'Hidden', 'Caption' => '', 'Value' => $ColumnValue); 239 } 240 } 241 $DefinitionItems[] = array('Name' => 'Column', 'Type' => 'Hidden', 'Caption' => '', 'Value' => $Column); 242 237 243 $Form = new Form(); 238 244 $Form->Definition = array … … 261 267 foreach($List['Items'] as $Index => $Item) 262 268 { 263 $ItemType = explode(':', $Item['Type']); 264 if($ItemType[0] != 'PointerOneToMany') 269 if($Types[$Item['Type']]['BaseType'] != 'PointerOneToMany') 265 270 { 266 271 $Values[$Index] = $_POST[$Index]; … … 278 283 $Output = 'Položka přidána'; 279 284 $Output .= ShowViewItem($List, $Database->insert_id); 285 $Values['Column'] = $_POST['Column']; 286 ExecuteListEvent($List['TableName'], 'OnAdd', $Values); 280 287 return($Output); 281 288 } … … 292 299 foreach($List['Items'] as $Index => $Item) 293 300 { 294 $ItemType = explode(':', $Item['Type']); 295 if($ItemType[0] != 'PointerOneToMany') 301 if($Types[$Item['Type']]['BaseType'] != 'PointerOneToMany') 296 302 { 297 303 $DefinitionItems[] = array('Name' => $Index, 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'].$Required, 'Value' => $DbRow[$Index], 'SourceTable' => $List['TableName'], 'SourceItemId' => 0); … … 318 324 foreach($List['Items'] as $Index => $Item) 319 325 { 320 $ItemType = explode(':', $Item['Type']); 321 if($ItemType[0] == 'PointerOneToMany') 322 { 323 $SubList = $Lists[$ItemType[1]]; 324 $Output .= ShowList($SubList, $ItemType[2], $DbRow['Id'], $Item['TextBefore']).'<br /><br />'; 326 if($Types[$Item['Type']]['BaseType'] == 'PointerOneToMany') 327 { 328 $SubList = $Lists[$Types[$Item['Type']]['Parameters'][0]]; 329 $Output .= ShowList($SubList, $Types[$Item['Type']]['Parameters'][1], $DbRow['Id'], $Item['TextBefore']).'<br /><br />'; 325 330 } 326 331 } … … 362 367 if(array_key_exists($Var, $_GET)) $_SESSION[$Var] = $_GET[$Var]; 363 368 } 364 365 369 $Output = ''; 366 370 if(array_key_exists('Table', $_SESSION) and array_key_exists($_SESSION['Table'], $Lists)) … … 434 438 { 435 439 $DbRow['Parameters'] = explode('|', $DbRow['Parameters']); 436 $Types[$DbRow['Name']] = $DbRow; 440 $DbRow['BaseType'] = $DbRow['Name']; 441 $Types[$DbRow['Id']] = $DbRow; 437 442 } 438 443 … … 440 445 foreach($Types as $Index => $Type) 441 446 { 442 if($Type['ParentType'] != '')447 if($Type['ParentType'] != 0) 443 448 { 444 449 foreach($Type as $Index2 => $Item) … … 447 452 $Types[$Index][$Index2] = $Types[$Type['ParentType']][$Index2]; 448 453 } 454 $Types[$Index]['BaseType'] = $Types[$Type['ParentType']]['Name']; 449 455 } 450 456 } … … 452 458 } 453 459 460 function ExecuteListEvent($Table, $Event, $Parameters) 461 { 462 $Callback = 'List'.$Table.$Event; 463 if(is_callable($Callback)) $Callback($Parameters); 464 } 465 466 function ExecuteTypeEvent($Type, $Event, $Parameters) 467 { 468 global $Types; 469 470 $Callback = 'Type'.$Types[$Type]['BaseType'].$Event; 471 //echo($Callback.','); 472 if(is_callable($Callback)) return($Callback($Parameters)); 473 else return($Callback); 474 } 475 454 476 ?>
Note:
See TracChangeset
for help on using the changeset viewer.