Changeset 2
- Timestamp:
- Sep 10, 2008, 8:07:24 PM (16 years ago)
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
config.sample.php
r1 r2 10 10 'Charset' => 'utf8', 11 11 ), 12 'Web' => array( 13 'ItemsPerPage' => 20, 14 ), 12 15 ); 13 16 -
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 ?> -
index.php
r1 r2 16 16 </head><body>'; 17 17 18 LoadListDefinition(); 18 19 echo($Output); 19 20 echo(TableList()); 20 21 echo(Output()); 21 22 echo('</body></html>'); 22 23 //echo(phpinfo()); 23 24 ?> -
lists.php
r1 r2 14 14 'Required' => 1, 15 15 'Editable' => 1, 16 'VisibleInList' => 1, 16 17 ), 17 18 'Title' => array( … … 23 24 'Required' => 1, 24 25 'Editable' => 1, 26 'VisibleInList' => 1, 25 27 ), 26 28 'Items' => array( 27 29 'TextBefore' => 'Položky', 28 30 'TextAfter' => '', 29 'Type' => ' ',31 'Type' => 'ListItemPointer', 30 32 'Help' => 'Definujte potřebné položky pro seznam.', 31 33 'Default' => '', 32 34 'Required' => 1, 33 35 'Editable' => 1, 36 'VisibleInList' => 0, 34 37 ), 35 38 ), … … 47 50 'Required' => 1, 48 51 'Editable' => 1, 52 'VisibleInList' => 1, 49 53 ), 50 54 'TextAfter' => array( … … 56 60 'Required' => 1, 57 61 'Editable' => 1, 62 'VisibleInList' => 0, 58 63 ), 59 64 'Type' => array( … … 65 70 'Required' => 1, 66 71 'Editable' => 1, 72 'VisibleInList' => 1, 67 73 ), 68 74 'Help' => array( … … 74 80 'Required' => 1, 75 81 'Editable' => 1, 82 'VisibleInList' => 0, 76 83 ), 77 84 'Required' => array( … … 83 90 'Required' => 1, 84 91 'Editable' => 1, 92 'VisibleInList' => 0, 85 93 ), 86 94 'Editable' => array( … … 92 100 'Required' => 1, 93 101 'Editable' => 1, 102 'VisibleInList' => 0, 94 103 ), 95 ), 96 ), 97 'User' => array( 98 'TableName' => 'User', 99 'Title' => 'Seznam uživatelů', 100 'Items' => array( 101 'FirstName' => array( 102 'TextBefore' => 'Jméno', 104 'VisibleInList' => array( 105 'TextBefore' => 'Viditelné v seznamu', 103 106 'TextAfter' => '', 104 'Type' => ' String',105 'Help' => ' Zadejte jméno',107 'Type' => 'Boolean', 108 'Help' => 'Určuje viditelnost této položky v seznamu', 106 109 'Default' => '', 107 110 'Required' => 1, 108 111 'Editable' => 1, 109 ), 110 'SecondName' => array( 111 'TextBefore' => 'Příjmení', 112 'TextAfter' => '', 113 'Type' => 'String', 114 'Help' => 'Zadejte příjmení', 115 'Default' => '', 116 'Required' => 1, 117 'Editable' => 1, 118 ), 119 'Email' => array( 120 'TextBefore' => 'E-mail', 121 'TextAfter' => '', 122 'Type' => 'String', 123 'Help' => 'Zadejte emailovou adresu', 124 'Default' => '', 125 'Required' => 1, 126 'Editable' => 1, 127 ), 128 'Age' => array( 129 'TextBefore' => 'Věk', 130 'TextAfter' => 'roků', 131 'Type' => 'Integer', 132 'Help' => 'Zadejte stáří osoby', 133 'Default' => 0, 134 'Required' => 0, 135 'Editable' => 1, 136 ), 137 'Sex' => array( 138 'TextBefore' => 'Pohlaví', 139 'TextAfter' => '', 140 'Type' => 'Sex', 141 'Help' => 'Vyberte pohlaví osoby', 142 'Default' => 0, 143 'Required' => 0, 144 'Editable' => 1, 145 ), 146 'BirthDay' => array( 147 'TextBefore' => 'Datum narození', 148 'TextAfter' => '', 149 'Type' => 'Date', 150 'Help' => 'Vyberte datum narození.', 151 'Default' => 0, 152 'Required' => 0, 153 'Editable' => 1, 154 ), 155 ), 156 ), 157 'Host' => array( 158 'TableName' => 'Host', 159 'Title' => 'Seznam počítačů', 160 'Items' => array( 161 'DomainName' => array( 162 'TextBefore' => 'Doménové jméno', 163 'TextAfter' => '', 164 'Type' => 'String', 165 'Help' => 'Zadejte jméno počítače v doméně', 166 'Default' => '', 167 'Required' => 1, 168 'Editable' => 1, 169 ), 170 'NetBIOSName' => array( 171 'TextBefore' => 'NetBIOS jméno', 172 'TextAfter' => '', 173 'Type' => 'String', 174 'Help' => 'Zadejte jméno počítače v rámci protokolů NetBIOS a sdílení souborů', 175 'Default' => '', 176 'Required' => 0, 177 'Editable' => 1, 178 ), 179 'LocalIPAddress' => array( 180 'TextBefore' => 'Místní IP adresa', 181 'TextAfter' => '', 182 'Type' => 'String', 183 'Help' => 'Zadejte síťovou adresu používanou v rámci místní sítě.', 184 'Default' => '', 185 'Required' => 1, 186 'Editable' => 1, 187 ), 188 'PublicIPAddress' => array( 189 'TextBefore' => 'Veřejná IP adresa', 190 'TextAfter' => '', 191 'Type' => 'String', 192 'Help' => 'Zadejte síťovou adresu používanou v rámci Internetu.', 193 'Default' => '', 194 'Required' => 1, 195 'Editable' => 1, 196 ), 197 'LastOnlineDate' => array( 198 'TextBefore' => 'Naposledy online', 199 'TextAfter' => '', 200 'Type' => 'Date', 201 'Help' => 'Čas posledního úspěšného měření dostupnosti počítače.', 202 'Default' => 0, 203 'Required' => 0, 204 'Editable' => 0, 112 'VisibleInList' => 0, 205 113 ), 206 114 ), -
types.php
r1 r2 1 1 <?php 2 2 3 function TypeEnumerationViewHtml($Type, $Parameter )3 function TypeEnumerationViewHtml($Type, $Parameter, $Table, $Id) 4 4 { 5 5 $Output = $Type['TypeDefinition'][$Parameter]; … … 7 7 } 8 8 9 function TypeEnumerationEditHtml($Type, $Parameter )9 function TypeEnumerationEditHtml($Type, $Parameter, $Table, $Id) 10 10 { 11 11 $Output = '<select name="%name%">'; … … 21 21 $MonthList = array('0', 'Leden', 'Únor', 'Březen', 'Duben', 'Květen', 'Červen', 'Červenec', 'Srpen', 'Září', 'Říjen', 'Listopad', 'Prosinec'); 22 22 23 function TypeDateViewHtml($Type, $Parameter )23 function TypeDateViewHtml($Type, $Parameter, $Table, $Id) 24 24 { 25 25 global $MonthList; … … 31 31 } 32 32 33 function TypeDateEditHtml($Type, $Parameter )33 function TypeDateEditHtml($Type, $Parameter, $Table, $Id) 34 34 { 35 35 global $MonthList; … … 61 61 } 62 62 $Output .= '</select>'; 63 return($Output); 64 } 65 66 function TypePointerViewHtml($Type, $Parameter, $Table, $Id) 67 { 68 $Output = '<a href="?Action=SelectList&Id='.$Type['TypeDefinition'].'&ParentTable='.$Table.'&ParentId='.$Id.'">Seznam</a>'; 63 69 return($Output); 64 70 } … … 115 121 'Logitude' => 'Integer', 116 122 ), 117 ) 123 ), 124 'ListItemPointer' => array( 125 'Type' => 'Pointer', 126 'TypeDefinition' => 'ListItem', 127 'ViewHtml' => 'TypePointerViewHtml', 128 'EditHtml' => 'TypePointerViewHtml', 129 'DatabaseType' => 'INT', 130 'InitValue' => '0', 131 'ParseFunction' => '', 132 ), 118 133 ); 119 134
Note:
See TracChangeset
for help on using the changeset viewer.