Legend:
- Unmodified
- Added
- Removed
-
base.php
r3 r4 5 5 include('common.php'); 6 6 7 function ShowList($List )7 function ShowList($List, $Column = '', $ParentId = 0) 8 8 { 9 9 global $Database, $Types, $Config; 10 10 11 $Output = '< table class="WideTable"><tr>';11 $Output = '<div>'.$List['Title'].'</div><table class="WideTable"><tr>'; 12 12 foreach($List['Items'] as $Item) 13 13 { … … 17 17 $Output .= '<th>Akce</th></tr>'; 18 18 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 } 19 if(($Column != '') and ($ParentId != 0)) 20 $Where = $Column.'='.$ParentId; 25 21 else $Where = '1'; 26 22 … … 43 39 if(array_key_exists('Page', $_GET)) $Page = $_GET['Page']; else $Page = 0; 44 40 $DbResult = $Database->select($List['TableName'], 'COUNT(*)', $Where); 45 echo($Database->LastQuery);41 //echo($Database->LastQuery); 46 42 $DbRow = $DbResult->fetch_array(); 47 43 $TotalItemCount = $DbRow[0]; … … 55 51 if($Item['VisibleInList'] == 1) 56 52 { 57 $Type = $Types[$Item['Type']]; 53 $ItemType = explode(':', $Item['Type']); 54 $Type = $Types[$ItemType[0]]; 55 if(count($ItemType) > 1) $Type['Parameter'] = $ItemType[1]; 58 56 if(is_callable($Type['ViewHtml'])) $Value = $Type['ViewHtml']($Type, $DbRow[$Index], $List['TableName'], $DbRow['Id']); 59 57 else $Value = $Type['ViewHtml']; … … 62 60 } 63 61 } 64 $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>';62 $Output .= '<td><a href="?Action=ViewItem&TableId='.$List['TableName'].'&ItemId='.$DbRow['Id'].'">Zobrazit</a> <a href="?Action=EditItem&TableId='.$List['TableName'].'&ItemId='.$DbRow['Id'].'">Editovat</a> <a href="?Action=DeleteItem&TableId='.$List['TableName'].'&ItemId='.$DbRow['Id'].'">Smazat</a></td></tr>'; 65 63 } 66 64 $Output .= '</table>'; 67 $Output .= PagesList($Page, $TotalItemCount) .'<br />';68 $Output .= '<a href="?Action=Add ">Přidat</a>';65 $Output .= PagesList($Page, $TotalItemCount); 66 $Output .= '<a href="?Action=AddItem&TableId='.$List['TableName'].'">Přidat</a>'; 69 67 return($Output); 70 68 } … … 74 72 global $Database, $Types; 75 73 76 $Output = '<form action="?Action=Edit Finish&Id='.$Id.'" method="post"><table class="WideTable">';74 $Output = '<form action="?Action=EditItemFinish&ItemId='.$Id.'" method="post"><table class="WideTable">'; 77 75 $Output .= '<tr><th>Jméno položky</th><th>Hodnota</th></tr>'; 78 79 76 $DbResult = $Database->select($List['TableName'], '*', 'Id='.$Id); 80 77 while($DbRow = $DbResult->fetch_array()) … … 82 79 foreach($List['Items'] as $Index => $Item) 83 80 { 84 $Type = $Types[$Item['Type']]; 85 if(is_callable($Type['EditHtml'])) $Value = $Type['EditHtml']($Type, $DbRow[$Index], $List['TableName'], $DbRow['Id']); 86 else $Value = $Type['EditHtml']; 87 $Value = str_replace('%value%', $DbRow[$Index], $Value); 88 $Value = str_replace('%name%', $Index, $Value); 89 $Output .= '<tr><td>'.$Item['TextBefore'].':</td><td title="'.$Item['Help'].'">'.$Value.'</td></tr>'; 90 } 91 } 92 $Output .= '</table><input type="submit" value="Uložit"></form>'; 81 $ItemType = explode(':', $Item['Type']); 82 if($ItemType[0] != 'PointerOneToMany') 83 { 84 $Type = $Types[$ItemType[0]]; 85 if(count($ItemType) > 1) $Type['Parameter'] = $ItemType[1]; 86 if(is_callable($Type['EditHtml'])) $Value = $Type['EditHtml']($Type, $DbRow[$Index], $List['TableName'], $DbRow['Id']); 87 else $Value = $Type['EditHtml']; 88 $Value = str_replace('%value%', $DbRow[$Index], $Value); 89 $Value = str_replace('%name%', $Index, $Value); 90 if($Item['Required'] == 1) $Required = ' *'; else $Required = ''; 91 $Output .= '<tr><td>'.$Item['TextBefore'].':'.$Required.'</td><td title="'.$Item['Help'].'">'.$Value.'</td></tr>'; 92 } 93 } 94 } 95 $Output .= '</table><input type="submit" value="Uložit"></form><a href="?">Zpět</a>'; 93 96 return($Output); 94 97 } … … 101 104 foreach($List['Items'] as $Index => $Item) 102 105 { 103 $Values[$Index] = $_POST[$Index]; 106 $ItemType = explode(':', $Item['Type']); 107 if($ItemType[0] != 'PointerOneToMany') 108 { 109 $Values[$Index] = $_POST[$Index]; 110 } 104 111 } 105 112 $Database->update($List['TableName'], 'Id='.$Id, $Values); … … 114 121 global $Database, $Types; 115 122 116 $Output = '<form action="?Action=Add Finish" method="post"><table class="WideTable">';123 $Output = '<form action="?Action=AddItemFinish" method="post"><table class="WideTable">'; 117 124 $Output .= '<tr><th>Jméno položky</th><th>Hodnota</th></tr>'; 118 125 119 126 foreach($List['Items'] as $Index => $Item) 120 127 { 121 $Type = $Types[$Item['Type']]; 122 if(is_callable($Type['EditHtml'])) $Value = $Type['EditHtml']($Type, $Type['InitValue'], $List['TableName'], 0); 123 else $Value = $Type['EditHtml']; 124 $Value = str_replace('%value%', $Type['InitValue'], $Value); 125 $Value = str_replace('%name%', $Index, $Value); 126 $Output .= '<tr><td>'.$Item['TextBefore'].':</td><td title="'.$Item['Help'].'">'.$Value.'</td></tr>'; 127 } 128 $Output .= '</table><input type="submit" value="Přidat"></form>'; 128 $ItemType = explode(':', $Item['Type']); 129 if($ItemType[0] != 'PointerOneToMany') 130 { 131 $Type = $Types[$ItemType[0]]; 132 if(count($ItemType) > 1) $Type['Parameter'] = $ItemType[1]; 133 if(is_callable($Type['EditHtml'])) $Value = $Type['EditHtml']($Type, $Type['InitValue'], $List['TableName'], 0); 134 else $Value = $Type['EditHtml']; 135 $Value = str_replace('%value%', $Type['InitValue'], $Value); 136 $Value = str_replace('%name%', $Index, $Value); 137 if($Item['Required'] == 1) $Required = ' *'; else $Required = ''; 138 $Output .= '<tr><td>'.$Item['TextBefore'].':'.$Required.'</td><td title="'.$Item['Help'].'">'.$Value.'</td></tr>'; 139 } 140 } 141 $Output .= '</table><input type="submit" value="Přidat"></form><a href="?">Zpět</a>'; 129 142 return($Output); 130 143 } … … 137 150 foreach($List['Items'] as $Index => $Item) 138 151 { 139 $Values[$Index] = $_POST[$Index]; 152 $ItemType = explode(':', $Item['Type']); 153 if($ItemType[0] != 'PointerOneToMany') 154 { 155 $Values[$Index] = $_POST[$Index]; 156 } 140 157 } 141 158 $Database->insert($List['TableName'], $Values); … … 148 165 function ShowViewItem($List, $Id) 149 166 { 150 global $Database, $Types; 151 152 $Output = '<table class="WideTable">'; 153 $Output .= '<tr><th>Jméno položky</th><th>Hodnota</th></tr>'; 154 167 global $Database, $Types, $Lists; 168 169 $Output = ''; 155 170 $DbResult = $Database->select($List['TableName'], '*', 'Id='.$Id); 156 171 while($DbRow = $DbResult->fetch_array()) 157 172 { 158 foreach($List['Items'] as $Index => $Item) 159 { 160 $Type = $Types[$Item['Type']]; 161 if(is_callable($Type['ViewHtml'])) $Value = $Type['ViewHtml']($Type, $DbRow[$Index], $List['TableName'], $DbRow['Id']); 162 else $Value = $Type['ViewHtml']; 163 $Value = str_replace('%value%', $DbRow[$Index], $Value); 164 $Output .= '<tr><td>'.$Item['TextBefore'].':</td><td title="'.$Item['Help'].'">'.$Value.'</td></tr>'; 165 } 166 } 167 $Output .= '</table>'; 173 $Output = '<table class="WideTable">'; 174 $Output .= '<tr><th>Jméno položky</th><th>Hodnota</th></tr>'; 175 foreach($List['Items'] as $Index => $Item) 176 { 177 $ItemType = explode(':', $Item['Type']); 178 if($ItemType[0] != 'PointerOneToMany') 179 { 180 $Type = $Types[$ItemType[0]]; 181 if(count($ItemType) > 1) $Type['Parameter'] = $ItemType[1]; 182 if(is_callable($Type['ViewHtml'])) $Value = $Type['ViewHtml']($Type, $DbRow[$Index], $List['TableName'], $DbRow['Id']); 183 else $Value = $Type['ViewHtml']; 184 $Value = str_replace('%value%', $DbRow[$Index], $Value); 185 $Output .= '<tr><td>'.$Item['TextBefore'].':</td><td title="'.$Item['Help'].'">'.$Value.'</td></tr>'; 186 } 187 } 188 $Output .= '</table>'; 189 $Output .= '<a href="?Action=EditItem&ItemId='.$DbRow['Id'].'">Editovat</a>'; 190 $Output .= ' <a href="?Action=ShowList&ItemId='.$DbRow['Id'].'">Seznam</a>'; 191 $Output .= '<div class="line"></div>'; 192 193 foreach($List['Items'] as $Index => $Item) 194 { 195 $ItemType = explode(':', $Item['Type']); 196 if($ItemType[0] == 'PointerOneToMany') 197 { 198 $SubList = $Lists[$ItemType[1]]; 199 $Output .= ShowList($SubList, $ItemType[2], $DbRow['Id']).'<br /><br />'; 200 } 201 } 202 } 168 203 return($Output); 169 204 } … … 186 221 foreach($Lists as $Index => $List) 187 222 { 188 if( $List['System'] == $System)189 $Output .= '<a href="?Action=S electList&Id='.$Index.'">'.$List['Title'].'</a><br />';223 if(($List['System'] == $System) and ($List['VisibleInMenu'] == 1)) 224 $Output .= '<a href="?Action=ShowList&TableId='.$Index.'">'.$List['Title'].'</a><br />'; 190 225 } 191 226 $Output .= '<br />'; … … 197 232 global $Lists; 198 233 234 $PermanentVar = array('TableId', 'ItemId', 'ParentTable', 'ParentColumn', 'Action'); 235 foreach($PermanentVar as $Var) 236 { 237 if(array_key_exists($Var, $_GET)) $_SESSION[$Var] = $_GET[$Var]; 238 } 239 199 240 $Output = ''; 200 if(array_key_exists('Action', $_GET)) 201 { 202 if($_GET['Action'] == 'SelectList') 203 $_SESSION['ListId'] = $_GET['Id']; 204 } 205 206 if(array_key_exists('ListId', $_SESSION) and array_key_exists($_SESSION['ListId'], $Lists)) 207 { 208 $List = $Lists[$_SESSION['ListId']]; 209 if(array_key_exists('Action', $_GET)) 210 { 211 switch($_GET['Action']) 212 { 213 case 'Edit': 214 $Output = ShowEditItem($List, $_GET['Id']); 215 break; 216 case 'EditFinish': 217 $Output = ShowEditItemFinish($List, $_GET['Id']); 218 break; 219 case 'Delete': 220 $Output = ShowDeleteItem($List, $_GET['Id']); 221 break; 222 case 'View': 223 $Output = ShowViewItem($List, $_GET['Id']); 224 break; 225 case 'Add': 241 if(array_key_exists('TableId', $_SESSION) and array_key_exists($_SESSION['TableId'], $Lists)) 242 { 243 $List = $Lists[$_SESSION['TableId']]; 244 if(array_key_exists('Action', $_SESSION)) 245 { 246 switch($_SESSION['Action']) 247 { 248 case 'EditItem': 249 $Output = ShowEditItem($List, $_SESSION['ItemId']); 250 break; 251 case 'EditItemFinish': 252 $Output = ShowEditItemFinish($List, $_SESSION['ItemId']); 253 break; 254 case 'DeleteItem': 255 $Output = ShowDeleteItem($List, $_SESSION['ItemId']); 256 break; 257 case 'ViewItem': 258 $Output = ShowViewItem($List, $_SESSION['ItemId']); 259 break; 260 case 'AddItem': 226 261 $Output = ShowAddItem($List); 227 262 break; 228 case 'Add Finish':263 case 'AddItemFinish': 229 264 $Output = ShowAddItemFinish($List); 230 265 break; 266 case 'ShowList': 231 267 default: 232 268 $Output = ShowList($List); … … 241 277 global $Database, $Lists; 242 278 243 $DbResult = $Database->select(' List', '*');279 $DbResult = $Database->select('SystemList', '*'); 244 280 while($DbRow = $DbResult->fetch_assoc()) 245 281 { 246 282 $Items = array(); 247 $DbResult2 = $Database->select(' ListItem', '`Name`, `TextBefore`, `TextAfter`, `Type`, `Default`, `Help`, `Required`, `Editable`, `VisibleInList`', 'List='.$DbRow['Id']);283 $DbResult2 = $Database->select('SystemListItem', '`Name`, `TextBefore`, `TextAfter`, `Type`, `Default`, `Help`, `Required`, `Editable`, `VisibleInList`, `VisibleInPointer`', 'List='.$DbRow['Id']); 248 284 while($DbRow2 = $DbResult2->fetch_assoc()) 249 285 { … … 254 290 'Title' => $DbRow['Title'], 255 291 'System' => $DbRow['System'], 292 'VisibleInMenu' => $DbRow['VisibleInMenu'], 256 293 'Items' => $Items, 257 294 ); 258 $Lists[] = $List; 259 } 260 } 295 $Lists[$List['TableName']] = $List; 296 } 297 } 298 261 299 ?>
Note:
See TracChangeset
for help on using the changeset viewer.