Changeset 2 for data_types.php
- Timestamp:
- Sep 10, 2008, 8:07:24 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
data_types.php
r1 r2 3 3 include('types.php'); 4 4 include('lists.php'); 5 include('common.php'); 5 6 6 7 function ShowList($List) 7 8 { 8 global $Database, $Types ;9 global $Database, $Types, $Config; 9 10 10 11 $Output = '<table class="WideTable"><tr>'; 11 12 foreach($List['Items'] as $Item) 12 13 { 13 $Output .= '<th>'.$Item['TextBefore'].'</th>'; 14 if($Item['VisibleInList'] == 1) 15 $Output .= '<th>'.$Item['TextBefore'].'</th>'; 14 16 } 15 17 $Output .= '<th>Akce</th></tr>'; 16 18 17 $DbResult = $Database->select($List['TableName'], '*'); 19 if(array_key_exists('ParentTable', $_GET) and array_key_exists('ParentId', $_GET)) 20 { 21 //$_SESSION['ParentId'] = $_GET['ParentId']; 22 //$_SESSION['ParentTable'] = $_GET['ParentTable']; 23 $Where = $_GET['ParentTable'].'='.$_GET['ParentId'].' '; 24 } 25 else $Where = '1'; 26 27 if(array_key_exists('Page', $_GET)) $Page = $_GET['Page']; else $Page = 0; 28 $DbResult = $Database->select($List['TableName'], 'COUNT(*)', $Where); 29 $DbRow = $DbResult->fetch_array(); 30 $TotalItemCount = $DbRow[0]; 31 32 $DbResult = $Database->select($List['TableName'], '*', $Where.' LIMIT '.($Page * $Config['Web']['ItemsPerPage']).', '.$Config['Web']['ItemsPerPage']); 18 33 while($DbRow = $DbResult->fetch_array()) 19 34 { … … 21 36 foreach($List['Items'] as $Index => $Item) 22 37 { 23 $Type = $Types[$Item['Type']]; 24 if(is_callable($Type['ViewHtml'])) $Value = $Type['ViewHtml']($Type, $DbRow[$Index]); 25 else $Value = $Type['ViewHtml']; 26 $Value = str_replace('%value%', $DbRow[$Index], $Value); 27 $Output .= '<td>'.$Value.'</td>'; 38 if($Item['VisibleInList'] == 1) 39 { 40 $Type = $Types[$Item['Type']]; 41 if(is_callable($Type['ViewHtml'])) $Value = $Type['ViewHtml']($Type, $DbRow[$Index], $List['TableName'], $DbRow['Id']); 42 else $Value = $Type['ViewHtml']; 43 $Value = str_replace('%value%', $DbRow[$Index], $Value); 44 $Output .= '<td>'.$Value.'</td>'; 45 } 28 46 } 29 47 $Output .= '<td><a href="?Action=View&Id='.$DbRow['Id'].'">Zobrazit</a> <a href="?Action=Edit&Id='.$DbRow['Id'].'">Edit</a> <a href="?Action=Delete&Id='.$DbRow['Id'].'">Smazat</a></td></tr>'; 30 48 } 31 49 $Output .= '</table>'; 50 $Output .= PagesList($Page, $TotalItemCount).'<br />'; 32 51 $Output .= '<a href="?Action=Add">Přidat</a>'; 33 52 return($Output); … … 47 66 { 48 67 $Type = $Types[$Item['Type']]; 49 if(is_callable($Type['EditHtml'])) $Value = $Type['EditHtml']($Type, $DbRow[$Index] );68 if(is_callable($Type['EditHtml'])) $Value = $Type['EditHtml']($Type, $DbRow[$Index], $List['TableName'], $DbRow['Id']); 50 69 else $Value = $Type['EditHtml']; 51 70 $Value = str_replace('%value%', $DbRow[$Index], $Value); … … 84 103 { 85 104 $Type = $Types[$Item['Type']]; 86 if(is_callable($Type['EditHtml'])) $Value = $Type['EditHtml']($Type, $Type['InitValue'] );105 if(is_callable($Type['EditHtml'])) $Value = $Type['EditHtml']($Type, $Type['InitValue'], $List['TableName'], 0); 87 106 else $Value = $Type['EditHtml']; 88 107 $Value = str_replace('%value%', $Type['InitValue'], $Value); … … 123 142 { 124 143 $Type = $Types[$Item['Type']]; 125 if(is_callable($Type['ViewHtml'])) $Value = $Type['ViewHtml']($Type, $DbRow[$Index] );144 if(is_callable($Type['ViewHtml'])) $Value = $Type['ViewHtml']($Type, $DbRow[$Index], $List['TableName'], $DbRow['Id']); 126 145 else $Value = $Type['ViewHtml']; 127 146 $Value = str_replace('%value%', $DbRow[$Index], $Value); … … 199 218 } 200 219 220 function LoadListDefinition() 221 { 222 global $Database, $Lists; 223 224 $DbResult = $Database->select('List', '*'); 225 while($DbRow = $DbResult->fetch_assoc()) 226 { 227 $Items = array(); 228 $DbResult2 = $Database->select('ListItem', '`Name`, `TextBefore`, `TextAfter`, `Type`, `Default`, `Help`, `Required`, `Editable`, `VisibleInList`', 'List='.$DbRow['Id']); 229 while($DbRow2 = $DbResult2->fetch_assoc()) 230 { 231 $Items[$DbRow2['Name']] = $DbRow2; 232 } 233 $List = array( 234 'TableName' => $DbRow['TableName'], 235 'Title' => $DbRow['Title'], 236 'Items' => $Items, 237 ); 238 $Lists[] = $List; 239 } 240 } 201 241 ?>
Note:
See TracChangeset
for help on using the changeset viewer.