Changeset 873 for trunk/Common
- Timestamp:
- Apr 6, 2020, 11:17:40 PM (5 years ago)
- Location:
- trunk/Common
- Files:
-
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/Form/Form.php
r872 r873 67 67 { 68 68 $Item = $this->Definition['Items'][$Index]; 69 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))70 { 71 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))69 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 70 { 71 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 72 72 $this->FormManager->Type->RegisterType($Item['Type'], '', $this->FormManager->FormTypes[$Item['Type']]); 73 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')73 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference') 74 74 $UseType = 'OneToMany'; 75 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')75 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration') 76 76 $UseType = 'Enumeration'; 77 77 } else $UseType = $Item['Type']; … … 88 88 'Rows' => array(), 89 89 ); 90 foreach ($this->Definition['Items'] as $Index => $Item)91 if (!array_key_exists('Hidden', $Item) or ($Item['Hidden'] == false))92 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or90 foreach ($this->Definition['Items'] as $Index => $Item) 91 if (!array_key_exists('Hidden', $Item) or ($Item['Hidden'] == false)) 92 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 93 93 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 94 94 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) 95 95 { 96 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))97 { 98 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))96 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 97 { 98 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 99 99 $this->FormManager->Type->RegisterType($Item['Type'], '', $this->FormManager->FormTypes[$Item['Type']]); 100 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')100 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference') 101 101 $UseType = 'OneToMany'; 102 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')102 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration') 103 103 $UseType = 'Enumeration'; 104 104 } else $UseType = $Item['Type']; … … 107 107 'Type' => $Item['Type'], 'Values' => $this->Values, 108 108 'Filter' => $this->ValuesFilter[$Index])); 109 if (array_key_exists('Suffix', $Item)) $Edit .= ' '.$Item['Suffix'];110 if (!$this->FormManager->Type->IsHidden($UseType))109 if (array_key_exists('Suffix', $Item)) $Edit .= ' '.$Item['Suffix']; 110 if (!$this->FormManager->Type->IsHidden($UseType)) 111 111 array_push($Table['Rows'], array($Item['Caption'].':', $Edit)); 112 112 } 113 113 $Output = '<fieldset><legend>'.$this->Definition['Title'].'</legend>'.Table($Table). 114 114 '</fieldset>'; 115 return ($Output);115 return ($Output); 116 116 } 117 117 118 118 function ShowEditForm() 119 119 { 120 if (!array_key_exists('SubmitText', $this->Definition)) $this->Definition['SubmitText'] = 'Uložit';120 if (!array_key_exists('SubmitText', $this->Definition)) $this->Definition['SubmitText'] = 'Uložit'; 121 121 $Output = '<form enctype="multipart/form-data" class="Form" action="'.$this->OnSubmit.'" method="post">'.$this->ShowEditBlock(). 122 122 '<div><input name="submit" type="submit" value="'.$this->Definition['SubmitText'].'" /> '. 123 123 '<input type="button" value="Zrušit" onclick="location.href=\'?\'"/></div></form>'; 124 return ($Output);124 return ($Output); 125 125 } 126 126 … … 184 184 function LoadValuesFromDatabase($Id) 185 185 { 186 foreach ($this->Definition['Items'] as $Index => $Item)187 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or186 foreach ($this->Definition['Items'] as $Index => $Item) 187 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 188 188 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 189 189 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) 190 190 { 191 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))192 { 193 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))191 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 192 { 193 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 194 194 $this->FormManager->Type->RegisterType($Item['Type'], '', 195 195 $this->FormManager->FormTypes[$Item['Type']]); 196 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')196 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference') 197 197 $UseType = 'OneToMany'; 198 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')198 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration') 199 199 $UseType = 'Enumeration'; 200 200 } else $UseType = $Item['Type']; 201 if (!array_key_exists('SQL', $Item)) $Item['SQL'] = '';201 if (!array_key_exists('SQL', $Item)) $Item['SQL'] = ''; 202 202 else $Item['SQL'] = str_replace('#Id', $Id, $Item['SQL']); 203 203 $Columns[] = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnFilterNameQuery', … … 205 205 } 206 206 $Columns = implode(',', $Columns); 207 if (array_key_exists('SQL', $this->Definition))207 if (array_key_exists('SQL', $this->Definition)) 208 208 $SourceTable = '('.$this->Definition['SQL'].') AS `TX`'; 209 209 else $SourceTable = '`'.$this->Definition['Table'].'` AS `TX`'; 210 210 $DbResult = $this->Database->query('SELECT '.$Columns.' FROM '.$SourceTable.' WHERE `TX`.`Id`='.$Id); 211 211 $DbRow = $DbResult->fetch_array(); 212 foreach ($this->Definition['Items'] as $Index => $Item)213 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or212 foreach ($this->Definition['Items'] as $Index => $Item) 213 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 214 214 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 215 215 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) 216 216 { 217 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))218 { 219 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))217 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 218 { 219 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 220 220 $this->FormManager->Type->RegisterType($Item['Type'], '', 221 221 $this->FormManager->FormTypes[$Item['Type']]); 222 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')222 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference') 223 223 $UseType = 'OneToMany'; 224 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')224 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration') 225 225 $UseType = 'Enumeration'; 226 226 } else $UseType = $Item['Type']; … … 235 235 { 236 236 $Values = array(); 237 foreach ($this->Definition['Items'] as $Index => $Item)238 { 239 if (array_key_exists($Index, $this->Values))240 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or237 foreach ($this->Definition['Items'] as $Index => $Item) 238 { 239 if (array_key_exists($Index, $this->Values)) 240 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 241 241 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 242 242 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) … … 245 245 'Type' => $Item['Type'], 'Values' => $this->Values); 246 246 247 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))248 { 249 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))247 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 248 { 249 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 250 250 $this->FormManager->Type->RegisterType($Item['Type'], '', 251 251 $this->FormManager->FormTypes[$Item['Type']]); 252 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')252 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference') 253 253 { 254 254 $UseType = 'OneToMany'; 255 255 } 256 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')256 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration') 257 257 $UseType = 'Enumeration'; 258 258 } else $UseType = $Item['Type']; 259 259 $Values[$Index] = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnSaveDb', $Parameters); 260 if (($Item['Type'] == 'Password') and ($Values[$Index] == '')) unset($Values[$Index]);261 } 262 } 263 if ($Id == 0)260 if (($Item['Type'] == 'Password') and ($Values[$Index] == '')) unset($Values[$Index]); 261 } 262 } 263 if ($Id == 0) 264 264 { 265 265 $Values['Id'] = $Id; … … 316 316 } 317 317 } 318 return ($Values);318 return ($Values); 319 319 } 320 320 … … 322 322 { 323 323 $Valid = true; 324 foreach ($this->Definition['Items'] as $Index => $Item)325 if ((!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or324 foreach ($this->Definition['Items'] as $Index => $Item) 325 if ((!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 326 326 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 327 327 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) and … … 330 330 ($Item['ReadOnly'] != true)))) 331 331 { 332 //if (array_key_exists($Context.$Index, $_POST))333 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))334 { 335 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))332 //if (array_key_exists($Context.$Index, $_POST)) 333 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 334 { 335 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 336 336 $this->FormManager->Type->RegisterType($Item['Type'], '', 337 337 $this->FormManager->FormTypes[$Item['Type']]); 338 338 $CustomType = $this->FormManager->FormTypes[$Item['Type']]['Type']; 339 if ($CustomType == 'Reference')339 if ($CustomType == 'Reference') 340 340 $UseType = 'OneToMany'; 341 else if ($CustomType == 'Enumeration')341 else if ($CustomType == 'Enumeration') 342 342 $UseType = 'Enumeration'; 343 343 } else $UseType = $Item['Type']; 344 344 345 345 $Parameters = array('Value' => $this->Values[$Index]); 346 if (array_key_exists('Null', $Item)) $Parameters['Null'] = $Item['Null'];346 if (array_key_exists('Null', $Item)) $Parameters['Null'] = $Item['Null']; 347 347 else $Parameters['Null'] = false; 348 if (!$this->FormManager->Type->ExecuteTypeEvent($UseType, 'Validate',348 if (!$this->FormManager->Type->ExecuteTypeEvent($UseType, 'Validate', 349 349 $Parameters)) { 350 350 $this->ValuesValidate[$Index] = true; … … 352 352 } 353 353 } 354 if ($Valid == false) throw new Exception('not validated');355 return ($Valid);354 if ($Valid == false) throw new Exception('not validated'); 355 return ($Valid); 356 356 } 357 357 } … … 360 360 function MakeLink($Target, $Title) 361 361 { 362 return ('<a href="'.$Target.'">'.$Title.'</a>');362 return ('<a href="'.$Target.'">'.$Title.'</a>'); 363 363 } 364 364 … … 366 366 { 367 367 $Result = '<table class="BasicTable">'; 368 if (array_key_exists('Header', $Table))368 if (array_key_exists('Header', $Table)) 369 369 { 370 370 $Result .= '<tr>'; 371 foreach ($Table['Header'] as $Item)371 foreach ($Table['Header'] as $Item) 372 372 $Result .= '<th>'.$Item.'</th>'; 373 373 $Result .= '</tr>'; 374 374 } 375 foreach ($Table['Rows'] as $Row)375 foreach ($Table['Rows'] as $Row) 376 376 { 377 377 $Result .= '<tr>'; 378 foreach ($Row as $Index => $Item)379 { 380 if ($Index == 0) $Class = ' class="Header"'; else $Class = '';378 foreach ($Row as $Index => $Item) 379 { 380 if ($Index == 0) $Class = ' class="Header"'; else $Class = ''; 381 381 $Result .= '<td'.$Class.' style="width: '.(floor(100 / count($Row))).'%">'.$Item.'</td>'; 382 382 } … … 384 384 } 385 385 $Result .= '</table>'; 386 return ($Result);386 return ($Result); 387 387 } 388 388 … … 432 432 $this->Database->query('DELETE FROM DataType'); 433 433 434 foreach ($this->Type->TypeDefinitionList as $Name => $Type)434 foreach ($this->Type->TypeDefinitionList as $Name => $Type) 435 435 { 436 436 $DbResult = $this->Database->select('DataType', 'Id', 'Name="'.$Name.'"'); 437 if ($DbResult->num_rows == 0)437 if ($DbResult->num_rows == 0) 438 438 { 439 439 $this->Database->insert('DataType', array('Name' => $Name, … … 447 447 } 448 448 449 foreach ($this->Classes as $Class)450 if (!array_key_exists('SQL', $Class) and ($Class['Table'] != ''))449 foreach ($this->Classes as $Class) 450 if (!array_key_exists('SQL', $Class) and ($Class['Table'] != '')) 451 451 { 452 452 $DbResult = $this->Database->query('SELECT * FROM information_schema.tables WHERE table_schema = "centrala_big" 453 453 AND table_name = "'.$Class['Table'].'" LIMIT 1'); 454 if ($DbResult->num_rows == 0) continue;454 if ($DbResult->num_rows == 0) continue; 455 455 456 456 echo($Class['Table'].'<br>'); 457 457 $Module = 1; 458 458 $DbResult = $this->Database->select('Model', 'Id', 'Name="'.$Class['Table'].'"'); 459 if ($DbResult->num_rows == 0)459 if ($DbResult->num_rows == 0) 460 460 { 461 461 $this->Database->insert('Model', array('Name' => $Class['Table'], 'Title' => $Class['Title'], 'Module' => $Module)); … … 469 469 } 470 470 471 foreach ($Class['Items'] as $Name => $Field)471 foreach ($Class['Items'] as $Name => $Field) 472 472 { 473 473 echo($Name.', '); 474 474 $DbResult = $this->Database->select('DataType', 'Id', 'Name="'.$Field['Type'].'"'); 475 if ($DbResult->num_rows > 0)475 if ($DbResult->num_rows > 0) 476 476 { 477 477 $DbRow = $DbResult->fetch_assoc(); … … 482 482 // Search parent type 483 483 $DbResult = $this->Database->select('DataType', 'Id', 'Name="'.$Type['Type'].'"'); 484 if ($DbResult->num_rows > 0)484 if ($DbResult->num_rows > 0) 485 485 { 486 486 $DbRow = $DbResult->fetch_assoc(); … … 494 494 495 495 $DbResult = $this->Database->select('ModelField', 'Id', '(Name="'.$Name.'") AND (Model='.$Model.')'); 496 if ($DbResult->num_rows == 0)496 if ($DbResult->num_rows == 0) 497 497 { 498 498 $this->Database->insert('ModelField', array('Name' => $Name, -
trunk/Common/Form/Types/Base.php
r738 r873 17 17 function OnView($Item) 18 18 { 19 return ('');19 return (''); 20 20 } 21 21 22 22 function OnEdit($Item) 23 23 { 24 return ('');24 return (''); 25 25 } 26 26 27 27 function OnLoad($Item) 28 28 { 29 return ('');29 return (''); 30 30 } 31 31 32 32 function OnLoadDb($Item) 33 33 { 34 return ($Item['Value']);34 return ($Item['Value']); 35 35 } 36 36 37 37 function OnSaveDb($Item) 38 38 { 39 return ($Item['Value']);39 return ($Item['Value']); 40 40 } 41 41 42 42 function DatabaseEscape($Value) 43 43 { 44 return (addslashes($Value));44 return (addslashes($Value)); 45 45 } 46 46 47 47 function OnFilterName($Item) 48 48 { 49 if (array_key_exists('SQL', $Item) and ($Item['SQL'] != ''))49 if (array_key_exists('SQL', $Item) and ($Item['SQL'] != '')) 50 50 $SQL = '('.$Item['SQL'].') AS '; 51 51 else $SQL = ''; 52 return ($SQL.'`'.$Item['Name'].'`');52 return ($SQL.'`'.$Item['Name'].'`'); 53 53 } 54 54 55 55 function OnFilterNameQuery($Item) 56 56 { 57 if (array_key_exists('SQL', $Item) and ($Item['SQL'] != ''))57 if (array_key_exists('SQL', $Item) and ($Item['SQL'] != '')) 58 58 $Output = '('.$Item['SQL'].') AS `'.$Item['Name'].'`, ('.$Item['SQL'].') AS `'.$Item['Name'].'_Filter`'; 59 59 else $Output = '`'.$Item['Name'].'`, `'.$Item['Name'].'` AS `'.$Item['Name'].'_Filter`'; 60 return ($Output);60 return ($Output); 61 61 } 62 62 63 63 function Validate($Item) 64 64 { 65 return (true);65 return (true); 66 66 } 67 67 68 68 function GetValidationFormat() 69 69 { 70 return ('');70 return (''); 71 71 } 72 72 } -
trunk/Common/Form/Types/Boolean.php
r738 r873 9 9 function OnView($Item) 10 10 { 11 if ($Item['Value'] == 1) $Checked = ' checked="1"'; else $Checked = '';12 return ('<input type="checkbox" name="'.$Item['Name'].'" disabled="1"'.$Checked.'/>');11 if ($Item['Value'] == 1) $Checked = ' checked="1"'; else $Checked = ''; 12 return ('<input type="checkbox" name="'.$Item['Name'].'" disabled="1"'.$Checked.'/>'); 13 13 } 14 14 15 15 function OnEdit($Item) 16 16 { 17 if ($Item['Value'] == 1) $Checked = ' checked="1"'; else $Checked = '';18 return ('<input type="checkbox" name="'.$Item['Name'].'"'.$Checked.'/>');17 if ($Item['Value'] == 1) $Checked = ' checked="1"'; else $Checked = ''; 18 return ('<input type="checkbox" name="'.$Item['Name'].'"'.$Checked.'/>'); 19 19 } 20 20 21 21 function OnLoad($Item) 22 22 { 23 if (array_key_exists($Item['Name'], $_POST)) return(1);24 else return (0);23 if (array_key_exists($Item['Name'], $_POST)) return (1); 24 else return (0); 25 25 } 26 26 } -
trunk/Common/Form/Types/Color.php
r548 r873 10 10 { 11 11 $Output = '<span style="background-color: #'.$Item['Value'].'"> </span>'; 12 return ($Output);12 return ($Output); 13 13 } 14 14 … … 16 16 { 17 17 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>'; 18 return ($Output);18 return ($Output); 19 19 } 20 20 21 21 function OnLoad($Item) 22 22 { 23 return ($_POST[$Item['Name']]);23 return ($_POST[$Item['Name']]); 24 24 } 25 25 } -
trunk/Common/Form/Types/Date.php
r872 r873 11 11 global $MonthNames; 12 12 13 if ($Item['Value'] == null) return('');14 if ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == '')) $Item['Value'] = time();13 if ($Item['Value'] == null) return (''); 14 if ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == '')) $Item['Value'] = time(); 15 15 $Parts = getdate($Item['Value']); 16 16 17 17 $Output = $Parts['mday'].'.'.$Parts['mon'].'.'.$Parts['year']; 18 return ($Output);18 return ($Output); 19 19 } 20 20 … … 32 32 $Output = ''; 33 33 $Style = ''; 34 if (array_key_exists('Null', $Item) and $Item['Null'])34 if (array_key_exists('Null', $Item) and $Item['Null']) 35 35 { 36 if (!$IsNull)36 if (!$IsNull) 37 37 { 38 38 $Checked = ' checked="1"'; … … 49 49 // Day 50 50 $Output .= '<select name="'.$Item['Name'].'-day" id="'.$Item['Name'].'-day" '.$Style.'>'; 51 for ($I = 1; $I <= 31; $I++)51 for ($I = 1; $I <= 31; $I++) 52 52 { 53 if ($Parts['mday'] == $I) $Selected = ' selected="1"'; else $Selected = '';53 if ($Parts['mday'] == $I) $Selected = ' selected="1"'; else $Selected = ''; 54 54 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 55 55 } … … 57 57 // Month 58 58 $Output .= '<select name="'.$Item['Name'].'-month" id="'.$Item['Name'].'-month" '.$Style.'>'; 59 for ($I = 1; $I <= 12; $I++)59 for ($I = 1; $I <= 12; $I++) 60 60 { 61 if ($Parts['mon'] == $I) $Selected = ' selected="1"'; else $Selected = '';61 if ($Parts['mon'] == $I) $Selected = ' selected="1"'; else $Selected = ''; 62 62 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$MonthNames[$I].'</option>'; 63 63 } … … 65 65 // Year 66 66 $Output .= '<select name="'.$Item['Name'].'-year" id="'.$Item['Name'].'-year" '.$Style.'>'; 67 for ($I = 1900; $I < 2100; $I++)67 for ($I = 1900; $I < 2100; $I++) 68 68 { 69 if ($Parts['year'] == $I) $Selected = ' selected="1"'; else $Selected = '';69 if ($Parts['year'] == $I) $Selected = ' selected="1"'; else $Selected = ''; 70 70 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 71 71 } 72 72 $Output .= '</select>'; 73 return ($Output);73 return ($Output); 74 74 } 75 75 76 76 function OnLoad($Item) 77 77 { 78 if (!array_key_exists($Item['Name'].'-null', $_POST) and array_key_exists('Null', $Item) and ($Item['Null'] == true)) return(null);79 else return (mktime(0, 0, 0, $_POST[$Item['Name'].'-month'], $_POST[$Item['Name'].'-day'], $_POST[$Item['Name'].'-year']));78 if (!array_key_exists($Item['Name'].'-null', $_POST) and array_key_exists('Null', $Item) and ($Item['Null'] == true)) return (null); 79 else return (mktime(0, 0, 0, $_POST[$Item['Name'].'-month'], $_POST[$Item['Name'].'-day'], $_POST[$Item['Name'].'-year'])); 80 80 } 81 81 82 82 function OnLoadDb($Item) 83 83 { 84 return (MysqlDateToTime($Item['Value']));84 return (MysqlDateToTime($Item['Value'])); 85 85 } 86 86 87 87 function OnSaveDb($Item) 88 88 { 89 if ($Item['Value'] == null) return(null);90 else return (date('Y-m-d', $Item['Value']));89 if ($Item['Value'] == null) return (null); 90 else return (date('Y-m-d', $Item['Value'])); 91 91 } 92 92 93 93 function DatabaseEscape($Value) 94 94 { 95 return ('"'.addslashes($Value).'"');95 return ('"'.addslashes($Value).'"'); 96 96 } 97 97 } -
trunk/Common/Form/Types/Enumeration.php
r738 r873 8 8 { 9 9 $Type = $this->FormManager->Type->GetTypeDefinition($Item['Type']); 10 if (array_key_exists($Item['Value'], $Type['Parameters']['States']))10 if (array_key_exists($Item['Value'], $Type['Parameters']['States'])) 11 11 $Output = $Type['Parameters']['States'][$Item['Value']]; 12 12 else $Output = $Item['Value']; 13 return ($Output);13 return ($Output); 14 14 } 15 15 … … 18 18 $Type = $this->FormManager->Type->GetTypeDefinition($Item['Type']); 19 19 $Output = '<select name="'.$Item['Name'].'">'; 20 if (array_key_exists('Null', $Item) and $Item['Null'])20 if (array_key_exists('Null', $Item) and $Item['Null']) 21 21 { 22 if ($Item['Value'] == NULL) $Selected = ' selected="1"'; else $Selected = '';22 if ($Item['Value'] == NULL) $Selected = ' selected="1"'; else $Selected = ''; 23 23 $Output .= '<option value=""'.$Selected.'></option>'; 24 24 } 25 foreach ($Type['Parameters']['States'] as $Index => $StateName)25 foreach ($Type['Parameters']['States'] as $Index => $StateName) 26 26 { 27 if ($Item['Value'] == $Index) $Selected = ' selected="1"'; else $Selected = '';27 if ($Item['Value'] == $Index) $Selected = ' selected="1"'; else $Selected = ''; 28 28 $Output .= '<option value="'.$Index.'"'.$Selected.'>'.$StateName.'</option>'; 29 29 } 30 30 $Output .= '</select>'; 31 return ($Output);31 return ($Output); 32 32 } 33 33 34 34 function OnLoad($Item) 35 35 { 36 if ($_POST[$Item['Name']] == '') return(NULL);37 return ($_POST[$Item['Name']]);36 if ($_POST[$Item['Name']] == '') return (NULL); 37 return ($_POST[$Item['Name']]); 38 38 } 39 39 40 40 function OnLoadDb($Item) 41 41 { 42 if ($Item['Value'] == '') return(NULL);43 else return ($Item['Value']);42 if ($Item['Value'] == '') return (NULL); 43 else return ($Item['Value']); 44 44 } 45 45 } -
trunk/Common/Form/Types/File.php
r738 r873 16 16 $Result = $FileInfo->file($this->FileName); 17 17 //$FileInfo->close(); 18 return ($Result);18 return ($Result); 19 19 } 20 20 … … 22 22 { 23 23 $FileName = $this->GetFullName($Item); 24 if (file_exists($FileName)) $Result = filesize($FileName);24 if (file_exists($FileName)) $Result = filesize($FileName); 25 25 else $Result = 0; 26 return ($Result);26 return ($Result); 27 27 } 28 28 … … 30 30 { 31 31 $ParentId = $this->Directory; 32 while ($ParentId != null)32 while ($ParentId != null) 33 33 { 34 34 $DbResult = $this->Database->select('FileDirectory', '*', 'Id='.$ParentId); … … 38 38 } 39 39 $Result = $this->UploadFileFolder.'/'.$Path.$File->Name; 40 return ($Result);40 return ($Result); 41 41 } 42 42 43 43 function GetExt() 44 44 { 45 return (substr($this->Name, 0, strpos($this->Name, '.') - 1));45 return (substr($this->Name, 0, strpos($this->Name, '.') - 1)); 46 46 } 47 47 48 48 function Delete() 49 49 { 50 if (file_exists($this->GetFullName())) unlink($this->GetFullName());50 if (file_exists($this->GetFullName())) unlink($this->GetFullName()); 51 51 } 52 52 53 53 function GetContent() 54 54 { 55 if ($this->TempName != '') $Content = file_get_contents($this->TempName);55 if ($this->TempName != '') $Content = file_get_contents($this->TempName); 56 56 else $Content = file_get_contents($this->GetFullName()); 57 return ($Content);57 return ($Content); 58 58 } 59 59 } … … 75 75 { 76 76 $File = &$Item['Value']; 77 return ('<a href="'.$this->FileDownloadURL.'?id='.$File->Id.'">'.77 return ('<a href="'.$this->FileDownloadURL.'?id='.$File->Id.'">'. 78 78 $File.'</a> ('.HumanSize($File->Size).')'); 79 79 } … … 86 86 $File = &$Item['Value']; 87 87 $Output = '<input type="file" name="'.$Item['Name'].'" value="'.$File->Name.'">'; 88 return ($Output);88 return ($Output); 89 89 } 90 90 91 91 function OnLoad($Item) 92 92 { 93 if (!is_object($Item['Value'])) $Item['Value'] = new DbFile();93 if (!is_object($Item['Value'])) $Item['Value'] = new DbFile(); 94 94 $File = &$Item['Value']; 95 if (array_key_exists($Item['Name'], $_FILES) and ($_FILES[$Item['Name']]['name'] != ''))95 if (array_key_exists($Item['Name'], $_FILES) and ($_FILES[$Item['Name']]['name'] != '')) 96 96 { 97 97 $UploadFile = $_FILES[$Item['Name']]; 98 if (file_exists($UploadFile['tmp_name']))98 if (file_exists($UploadFile['tmp_name'])) 99 99 { 100 100 $File->Name = $UploadFile['name']; … … 103 103 } 104 104 } 105 return ($File);105 return ($File); 106 106 } 107 107 108 108 function OnLoadDb($Item) 109 109 { 110 if (!is_object($Item['Value'])) $Item['Value'] = new DbFile();110 if (!is_object($Item['Value'])) $Item['Value'] = new DbFile(); 111 111 $File = &$Item['Value']; 112 112 $DbResult = $this->Database->select('File', '*', 'Id='.$File->Id); 113 if ($DbResult->num_rows() > 0)113 if ($DbResult->num_rows() > 0) 114 114 { 115 115 $DbRow = $DbResult->fetch_assoc(); … … 118 118 $File->Directory = $DbRow['Directory']; 119 119 } 120 return ($File);120 return ($File); 121 121 } 122 122 123 123 function OnSaveDb($Item) 124 124 { 125 if (!is_object($Item['Value'])) $Item['Value'] = new DbFile();125 if (!is_object($Item['Value'])) $Item['Value'] = new DbFile(); 126 126 $File = &$Item['Value']; 127 127 $Properties = array('Name' => $File->Name, 128 128 'Size' => $File->GetSize(), 'Directory' => $File->Directory); 129 129 $DbResult = $this->Database->select('File', '*', 'Id='.$File->Id); 130 if ($DbResult->num_rows() > 0)130 if ($DbResult->num_rows() > 0) 131 131 { 132 132 $DbRow = $DbResult->fetch_assoc(); 133 if ($File->TempName != '')133 if ($File->TempName != '') 134 134 { 135 135 $FileName = $File->GetFullName(); … … 142 142 $File->Id = $this->Database->insert_id; 143 143 } 144 if (!move_uploaded_file($File->TempName, $FileName))144 if (!move_uploaded_file($File->TempName, $FileName)) 145 145 SystemMessage('Nahrání souboru', 'Cílová složka není dostupná!'); 146 146 } -
trunk/Common/Form/Types/Float.php
r548 r873 10 10 { 11 11 $Output = $Item['Value']; 12 return ($Output);12 return ($Output); 13 13 } 14 14 … … 16 16 { 17 17 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>'; 18 return ($Output);18 return ($Output); 19 19 } 20 20 21 21 function OnLoad($Item) 22 22 { 23 return ($_POST[$Item['Name']]);23 return ($_POST[$Item['Name']]); 24 24 } 25 25 } -
trunk/Common/Form/Types/GPS.php
r548 r873 10 10 11 11 $DbResult = $Database->query('SELECT * FROM `SystemGPS` WHERE `Id`='.$Item['Value']); 12 if ($DbResult->num_rows > 0)12 if ($DbResult->num_rows > 0) 13 13 { 14 14 $DbRow = $DbResult->fetch_assoc(); … … 17 17 $Output = '<a href="http://www.mapy.cz/?st=search&fr=loc:'.$DbRow['Latitude'].' '.$DbRow['Longitude'].'">'.$Latitude[0].'°'.$Latitude[1]."'".$Latitude[2].'" '.$Longitude[0].'°'.$Longitude[1]."'".$Longitude[2].'"</a>'; 18 18 } 19 return ($Output);19 return ($Output); 20 20 } 21 21 … … 24 24 global $Database; 25 25 26 if ($Item['Value'] != '')26 if ($Item['Value'] != '') 27 27 { 28 28 $DbResult = $Database->query('SELECT * FROM `SystemGPS` WHERE `Id`='.$Item['Value']); 29 if ($DbResult->num_rows > 0)29 if ($DbResult->num_rows > 0) 30 30 { 31 31 $DbRow = $DbResult->fetch_assoc(); … … 40 40 $Output .= '<input type="text" size="3" name="'.$Item['Name'].'-lon-min" value="'.$Value[1].'"/>\''; 41 41 $Output .= '<input type="text" size="3" name="'.$Item['Name'].'-lon-sec" value="'.$Value[2].'"/>"'; 42 return ($Output);42 return ($Output); 43 43 } 44 44 … … 50 50 $Longitude = $this->Implode($_POST[$Item['Name'].'-lon-deg'], $_POST[$Item['Name'].'-lon-min'], $_POST[$Item['Name'].'-lon-sec']); 51 51 $Database->query('INSERT INTO SystemGPS (`Latitude`, `Longitude`) VALUES ("'.$Latitude.'", "'.$Longitude.'")'); 52 return ($Database->insert_id);52 return ($Database->insert_id); 53 53 } 54 54 … … 61 61 $Float = ($Float - intval($Float)) * 60; 62 62 $Seconds = round($Float, 3); 63 return (array($Degrees, $Minutes, $Seconds));63 return (array($Degrees, $Minutes, $Seconds)); 64 64 } 65 65 66 66 function Implode($Degrees, $Minutes, $Seconds) 67 67 { 68 if ($Degrees < 0) return(-(abs($Degrees) + ($Minutes + $Seconds / 60) / 60));69 else return ($Degrees + ($Minutes + $Seconds / 60) / 60);68 if ($Degrees < 0) return (-(abs($Degrees) + ($Minutes + $Seconds / 60) / 60)); 69 else return ($Degrees + ($Minutes + $Seconds / 60) / 60); 70 70 } 71 71 } -
trunk/Common/Form/Types/Hidden.php
r738 r873 14 14 { 15 15 $Output = $Item['Value']; 16 return ($Output);16 return ($Output); 17 17 } 18 18 … … 20 20 { 21 21 $Output = '<input type="hidden" name="'.$Item['Name'].'" value="'.$Item['Value'].'" />'; 22 return ($Output);22 return ($Output); 23 23 } 24 24 25 25 function OnLoad($Item) 26 26 { 27 return ($_POST[$Item['Name']]);27 return ($_POST[$Item['Name']]); 28 28 } 29 29 } -
trunk/Common/Form/Types/Hyperlink.php
r548 r873 8 8 { 9 9 $Output = '<a href="'.$Item['Value'].'">'.$Item['Value'].'</a>'; 10 return ($Output);10 return ($Output); 11 11 } 12 12 … … 14 14 { 15 15 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>'; 16 return ($Output);16 return ($Output); 17 17 } 18 18 19 19 function OnLoad($Item) 20 20 { 21 return ($_POST[$Item['Name']]);21 return ($_POST[$Item['Name']]); 22 22 } 23 23 } -
trunk/Common/Form/Types/IPv4Address.php
r738 r873 8 8 { 9 9 $Output = $Item['Value']; 10 return ($Output);10 return ($Output); 11 11 } 12 12 … … 14 14 { 15 15 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>'; 16 return ($Output);16 return ($Output); 17 17 } 18 18 19 19 function OnLoad($Item) 20 20 { 21 return ($_POST[$Item['Name']]);21 return ($_POST[$Item['Name']]); 22 22 } 23 23 24 24 function Validate($Item) 25 25 { 26 if ($Item['Null'] and ($Item['Value'] == '')) return(true);27 return (filter_var($Item['Value'], FILTER_VALIDATE_IP, array('flags' => FILTER_FLAG_IPV4)));26 if ($Item['Null'] and ($Item['Value'] == '')) return (true); 27 return (filter_var($Item['Value'], FILTER_VALIDATE_IP, array('flags' => FILTER_FLAG_IPV4))); 28 28 } 29 29 30 30 function GetValidationFormat() 31 31 { 32 return ('x.x.x.x kde x je hodnota 0..255');32 return ('x.x.x.x kde x je hodnota 0..255'); 33 33 } 34 34 } -
trunk/Common/Form/Types/IPv6Address.php
r738 r873 8 8 { 9 9 $Output = $Item['Value']; 10 return ($Output);10 return ($Output); 11 11 } 12 12 … … 14 14 { 15 15 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>'; 16 return ($Output);16 return ($Output); 17 17 } 18 18 19 19 function OnLoad($Item) 20 20 { 21 return ($_POST[$Item['Name']]);21 return ($_POST[$Item['Name']]); 22 22 } 23 23 24 24 function Validate($Item) 25 25 { 26 if ($Item['Null'] and ($Item['Value'] == '')) return(true);27 return (filter_var($Item['Value'], FILTER_VALIDATE_IP, array('flags' => FILTER_FLAG_IPV6)));26 if ($Item['Null'] and ($Item['Value'] == '')) return (true); 27 return (filter_var($Item['Value'], FILTER_VALIDATE_IP, array('flags' => FILTER_FLAG_IPV6))); 28 28 } 29 29 30 30 function GetValidationFormat() 31 31 { 32 return ('xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx kde x je hexa hodnota 0..f');32 return ('xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx kde x je hexa hodnota 0..f'); 33 33 } 34 34 } -
trunk/Common/Form/Types/Image.php
r738 r873 7 7 global $System; 8 8 9 return ('<img src="'.$System->Link('/images/favicons/'.$Item['Value']).'"/> '.$Item['Value']);9 return ('<img src="'.$System->Link('/images/favicons/'.$Item['Value']).'"/> '.$Item['Value']); 10 10 } 11 11 } -
trunk/Common/Form/Types/Integer.php
r738 r873 10 10 { 11 11 $Output = $Item['Value']; 12 return ($Output);12 return ($Output); 13 13 } 14 14 … … 16 16 { 17 17 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>'; 18 return ($Output);18 return ($Output); 19 19 } 20 20 21 21 function OnLoad($Item) 22 22 { 23 return ($_POST[$Item['Name']]);23 return ($_POST[$Item['Name']]); 24 24 } 25 25 26 26 function Validate($Item) 27 27 { 28 if ($Item['Null'] and ($Item['Value'] == '')) return(true);29 return (preg_match('/^\-*[0-9\.]+$/', $Item['Value']));28 if ($Item['Null'] and ($Item['Value'] == '')) return (true); 29 return (preg_match('/^\-*[0-9\.]+$/', $Item['Value'])); 30 30 } 31 31 32 32 function GetValidationFormat() 33 33 { 34 return ('číselná hodnota');34 return ('číselná hodnota'); 35 35 } 36 36 } -
trunk/Common/Form/Types/MacAddress.php
r738 r873 10 10 { 11 11 $Output = $Item['Value']; 12 return ($Output);12 return ($Output); 13 13 } 14 14 … … 16 16 { 17 17 $Output = '<input type="text" name="'.$Item['Name'].'" id="'.$Item['Name'].'" value="'.$Item['Value'].'"/>'; 18 return ($Output);18 return ($Output); 19 19 } 20 20 … … 22 22 { 23 23 //echo($Item['Name'].'='.$_POST[$Item['Name']].','.is_null(NULL).'<br>'); 24 return (strtoupper($_POST[$Item['Name']]));24 return (strtoupper($_POST[$Item['Name']])); 25 25 } 26 26 27 27 function DatabaseEscape($Value) 28 28 { 29 return ('"'.addslashes($Value).'"');29 return ('"'.addslashes($Value).'"'); 30 30 } 31 31 32 32 function Validate($Item) 33 33 { 34 if ($Item['Null'] and ($Item['Value'] == '')) return(true);35 return (preg_match('/^([0-9A-F]{2}[:]){5}([0-9A-F]{2})$/', $Item['Value']));34 if ($Item['Null'] and ($Item['Value'] == '')) return (true); 35 return (preg_match('/^([0-9A-F]{2}[:]){5}([0-9A-F]{2})$/', $Item['Value'])); 36 36 } 37 37 38 38 function GetValidationFormat() 39 39 { 40 return ('XX:XX:XX:XX:XX:XX kde X je hexa hodnota 0..F');40 return ('XX:XX:XX:XX:XX:XX kde X je hexa hodnota 0..F'); 41 41 } 42 42 } -
trunk/Common/Form/Types/OneToMany.php
r738 r873 10 10 { 11 11 $Type = $this->FormManager->Type->TypeDefinitionList[$Item['Type']]; 12 if ($Item['Value'] != '')12 if ($Item['Value'] != '') 13 13 { 14 14 $Output = '<a href="?t='.$Type['Parameters']['Table'].'&a='. 15 15 'view'.'&i='.$Item['Value'].'">'.$Item['Filter'].'</a>'; 16 16 } else $Output = ''; 17 return ($Output);17 return ($Output); 18 18 } 19 19 … … 22 22 $Output = '<select name="'.$Item['Name'].'" id="'.$Item['Name'].'">'; 23 23 $Type = $this->FormManager->Type->TypeDefinitionList[$Item['Type']]; 24 if (array_key_exists('Condition', $Type['Parameters'])) $Where = ' WHERE '.$Type['Parameters']['Condition'];24 if (array_key_exists('Condition', $Type['Parameters'])) $Where = ' WHERE '.$Type['Parameters']['Condition']; 25 25 else $Where = ''; 26 if (array_key_exists('Null', $Item) and $Item['Null'])26 if (array_key_exists('Null', $Item) and $Item['Null']) 27 27 { 28 if ($Item['Value'] == NULL) $Selected = ' selected="1"'; else $Selected = '';28 if ($Item['Value'] == NULL) $Selected = ' selected="1"'; else $Selected = ''; 29 29 $Output .= '<option value=""'.$Selected.'></option>'; 30 30 } 31 if (array_key_exists('View', $Type['Parameters'])) $Table = $Type['Parameters']['View'];31 if (array_key_exists('View', $Type['Parameters'])) $Table = $Type['Parameters']['View']; 32 32 else $Table = $Type['Parameters']['Table']; 33 33 $DbResult = $this->Database->query('SELECT '.$Type['Parameters']['Name'].' AS `Name`,'.$Type['Parameters']['Id'].' AS `Id` FROM '.$Table.''.$Where.' ORDER BY `Name`'); 34 while ($DbRow = $DbResult->fetch_assoc())34 while ($DbRow = $DbResult->fetch_assoc()) 35 35 { 36 if ($Item['Value'] == $DbRow['Id']) $Selected = ' selected="1"'; else $Selected = '';36 if ($Item['Value'] == $DbRow['Id']) $Selected = ' selected="1"'; else $Selected = ''; 37 37 $Output .= '<option value="'.$DbRow['Id'].'"'.$Selected.'>'.$DbRow['Name'].'</option>'; 38 38 } 39 39 $Output .= '</select>'; 40 if ($this->FormManager->ShowRelation)40 if ($this->FormManager->ShowRelation) 41 41 { 42 42 $URL = ''; 43 if (array_key_exists('OnPreset', $Item))43 if (array_key_exists('OnPreset', $Item)) 44 44 { 45 45 $Preset = call_user_func($Item['OnPreset'], $Item['Values']); … … 51 51 'onclick="return popupwindow("'.$this->FormManager->Root.'/is/?a=select&t='.$Table.'&r='.$Item['Name'].'","test");" style="cursor:hand;cursor:pointer"/>'; 52 52 } 53 return ($Output);53 return ($Output); 54 54 } 55 55 56 56 function OnLoad($Item) 57 57 { 58 if ($_POST[$Item['Name']] == '') return(NULL);59 else return ($_POST[$Item['Name']]);58 if ($_POST[$Item['Name']] == '') return (NULL); 59 else return ($_POST[$Item['Name']]); 60 60 } 61 61 62 62 function OnLoadDb($Item) 63 63 { 64 if ($Item['Value'] == '') return(NULL);65 else return ($Item['Value']);64 if ($Item['Value'] == '') return (NULL); 65 else return ($Item['Value']); 66 66 } 67 67 68 68 function OnFilterName($Item) 69 69 { 70 return ('`'.$Item['Name'].'_Filter`');70 return ('`'.$Item['Name'].'_Filter`'); 71 71 } 72 72 … … 74 74 { 75 75 $Type = $this->FormManager->Type->TypeDefinitionList[$Item['Type']]; 76 //if ($Item['Value'] != '')76 //if ($Item['Value'] != '') 77 77 //{ 78 if (array_key_exists('View', $Type['Parameters'])) $Table = $Type['Parameters']['View'];78 if (array_key_exists('View', $Type['Parameters'])) $Table = $Type['Parameters']['View']; 79 79 else $Table = $Type['Parameters']['Table']; 80 80 $Output = '`'.$Item['Name'].'`, (SELECT '.$Type['Parameters']['Name'].''. … … 82 82 $Type['Parameters']['Id'].'`=`TX`.`'.$Item['Name'].'`) AS `'.$Item['Name'].'_Filter`'; 83 83 //} else $Output = '`'.$Item['Name'].'`, `'.$Item['Name'].'` AS `'.$Item['Name'].'_Filter`'; 84 return ($Output);84 return ($Output); 85 85 } 86 86 } -
trunk/Common/Form/Types/OneToMany2.php
r548 r873 8 8 { 9 9 $Output = '<a href="?Action=ShowList&TableId='.$Item['TypeDefinition'].'&ParentTable='.$Item['SourceTable'].'&ParentColumn='.$Item['SourceItemId'].'">Seznam</a>'; 10 return ($Output);10 return ($Output); 11 11 } 12 12 … … 14 14 { 15 15 $Output = '<a href="?Action=ShowList&TableId='.$Item['TypeDefinition'].'&ParentTable='.$Item['SourceTable'].'&ParentColumn='.$Item['SourceItemId'].'">Seznam</a>'; 16 return ($Output);16 return ($Output); 17 17 } 18 18 19 19 function OnLoad($Item) 20 20 { 21 return ($_POST[$Item['Name']]);21 return ($_POST[$Item['Name']]); 22 22 } 23 23 } -
trunk/Common/Form/Types/Password.php
r738 r873 10 10 { 11 11 $Output = ''; 12 for ($I = 0; $I < 6; $I++)12 for ($I = 0; $I < 6; $I++) 13 13 $Output .= '*'; 14 return ($Output);14 return ($Output); 15 15 } 16 16 … … 18 18 { 19 19 $Output = '<input type="password" name="'.$Item['Name'].'" value=""/>'; 20 return ($Output);20 return ($Output); 21 21 } 22 22 … … 27 27 $Result = $_POST[$Item['Name']]; 28 28 /* 29 if (!array_key_exists('SourceItemId', $Item)) $Result = sha1($_POST[$Item['Name']]);29 if (!array_key_exists('SourceItemId', $Item)) $Result = sha1($_POST[$Item['Name']]); 30 30 else 31 31 { 32 32 $DbRestult = $Database->query('SELECT '.$Item['Name'].' FROM '.$Item['SourceTable'].' WHERE Id='.$Item['SourceItemId']); 33 if ($DbResult->num_rows > 0)33 if ($DbResult->num_rows > 0) 34 34 { 35 35 $DbRow = $DbResult->fetch_assoc(); 36 if ($_POST[$Item['Name']] == '') $Result = $DbRow[$Item['Name']];36 if ($_POST[$Item['Name']] == '') $Result = $DbRow[$Item['Name']]; 37 37 else $Result = sha1($_POST[$Item['Name']]); 38 38 } else $Result = sha1($_POST[$Item['Name']]); 39 39 } 40 40 */ 41 return ($Result);41 return ($Result); 42 42 } 43 43 44 44 function OnSaveDb($Item) 45 45 { 46 if ($Item['Value'] == '') return('');46 if ($Item['Value'] == '') return (''); 47 47 else { 48 48 $PasswordHash = new PasswordHash(); 49 return ($PasswordHash->Hash($Item['Value'], $Item['Values']['Salt']));49 return ($PasswordHash->Hash($Item['Value'], $Item['Values']['Salt'])); 50 50 } 51 51 } … … 53 53 function OnLoadDb($Item) 54 54 { 55 return ('');55 return (''); 56 56 } 57 57 } -
trunk/Common/Form/Types/RandomHash.php
r738 r873 14 14 { 15 15 $Output = $Item['Value']; 16 return ($Output);16 return ($Output); 17 17 } 18 18 19 19 function OnEdit($Item) 20 20 { 21 if ($Item['Value'] == '')21 if ($Item['Value'] == '') 22 22 { 23 23 // Create only once … … 26 26 } 27 27 $Output = '<input type="hidden" name="'.$Item['Name'].'" value="'.$Item['Value'].'" />'; 28 return ($Output);28 return ($Output); 29 29 } 30 30 31 31 function OnLoad($Item) 32 32 { 33 return ($_POST[$Item['Name']]);33 return ($_POST[$Item['Name']]); 34 34 } 35 35 } -
trunk/Common/Form/Types/String.php
r574 r873 10 10 { 11 11 $Output = $Item['Value']; 12 return ($Output);12 return ($Output); 13 13 } 14 14 … … 16 16 { 17 17 $Output = '<input type="text" name="'.$Item['Name'].'" id="'.$Item['Name'].'" value="'.$Item['Value'].'"/>'; 18 return ($Output);18 return ($Output); 19 19 } 20 20 … … 22 22 { 23 23 //echo($Item['Name'].'='.$_POST[$Item['Name']].','.is_null(NULL).'<br>'); 24 return ($_POST[$Item['Name']]);24 return ($_POST[$Item['Name']]); 25 25 } 26 26 27 27 function DatabaseEscape($Value) 28 28 { 29 return ('"'.addslashes($Value).'"');29 return ('"'.addslashes($Value).'"'); 30 30 } 31 31 } -
trunk/Common/Form/Types/Text.php
r799 r873 10 10 { 11 11 $Output = str_replace("\n", '<br/>', strip_tags($Item['Value'])); 12 return ($Output);12 return ($Output); 13 13 } 14 14 … … 16 16 { 17 17 $Output = '<textarea name="'.$Item['Name'].'">'.$Item['Value'].'</textarea>'; 18 return ($Output);18 return ($Output); 19 19 } 20 20 21 21 function OnLoad($Item) 22 22 { 23 return ($_POST[$Item['Name']]);23 return ($_POST[$Item['Name']]); 24 24 } 25 25 26 26 function DatabaseEscape($Value) 27 27 { 28 return ('"'.addslashes($Value).'"');28 return ('"'.addslashes($Value).'"'); 29 29 } 30 30 } -
trunk/Common/Form/Types/Time.php
r872 r873 9 9 function OnView($Item) 10 10 { 11 if ($Item['Value'] == 0) return('');12 if ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == '')) $Item['Value'] = time();11 if ($Item['Value'] == 0) return (''); 12 if ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == '')) $Item['Value'] = time(); 13 13 $TimeParts = getdate($Item['Value']); 14 14 15 15 $Output = sprintf('%02d', $TimeParts['hours']).':'.sprintf('%02d', $TimeParts['minutes']).':'.sprintf('%02d', $TimeParts['seconds']); 16 return ($Output);16 return ($Output); 17 17 } 18 18 … … 28 28 $Output = ''; 29 29 $Style = ''; 30 if (array_key_exists('Null', $Item) and $Item['Null'])30 if (array_key_exists('Null', $Item) and $Item['Null']) 31 31 { 32 if ($IsNull)32 if ($IsNull) 33 33 { 34 34 $Checked = ' checked="1"'; … … 45 45 // Hour 46 46 $Output .= '<select name="'.$Item['Name'].'-hour" id="'.$Item['Name'].'-hour" '.$Style.'>'; 47 for ($I = 1; $I <= 24; $I++)47 for ($I = 1; $I <= 24; $I++) 48 48 { 49 if ($TimeParts['hours'] == $I) $Selected = ' selected="1"'; else $Selected = '';49 if ($TimeParts['hours'] == $I) $Selected = ' selected="1"'; else $Selected = ''; 50 50 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 51 51 } … … 53 53 // Minute 54 54 $Output .= '<select name="'.$Item['Name'].'-minute" id="'.$Item['Name'].'-minute" '.$Style.'>'; 55 for ($I = 1; $I <= 60; $I++)55 for ($I = 1; $I <= 60; $I++) 56 56 { 57 if ($TimeParts['month'] == $I) $Selected = ' selected="1"'; else $Selected = '';57 if ($TimeParts['month'] == $I) $Selected = ' selected="1"'; else $Selected = ''; 58 58 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 59 59 } … … 61 61 // Second 62 62 $Output .= '<select name="'.$Item['Name'].'-second" id="'.$Item['Name'].'-second" '.$Style.'>'; 63 for ($I = 1; $I <= 60; $I++)63 for ($I = 1; $I <= 60; $I++) 64 64 { 65 if ($TimeParts['seconds'] == $I) $Selected = ' selected="1"'; else $Selected = '';65 if ($TimeParts['seconds'] == $I) $Selected = ' selected="1"'; else $Selected = ''; 66 66 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 67 67 } 68 68 $Output .= '</select>'; 69 return ($Output);69 return ($Output); 70 70 } 71 71 72 72 function OnLoad($Item) 73 73 { 74 if (!array_key_exists($Item['Name'].'-null', $_POST) and array_key_exists('Null', $Item) and ($Item['Null'] == true)) return(null);75 return (mktime($_POST[$Item['Name'].'-hour'], $_POST[$Item['Name'].'-minute'], $_POST[$Item['Name'].'-second']));74 if (!array_key_exists($Item['Name'].'-null', $_POST) and array_key_exists('Null', $Item) and ($Item['Null'] == true)) return (null); 75 return (mktime($_POST[$Item['Name'].'-hour'], $_POST[$Item['Name'].'-minute'], $_POST[$Item['Name'].'-second'])); 76 76 } 77 77 78 78 function OnLoadDb($Item) 79 79 { 80 return (MysqlTimeToTime($Item['Value']));80 return (MysqlTimeToTime($Item['Value'])); 81 81 } 82 82 83 83 function OnSaveDb($Item) 84 84 { 85 if ($Item['Value'] == null) return(null);86 else return (date('H:i:s', $Item['Value']));85 if ($Item['Value'] == null) return (null); 86 else return (date('H:i:s', $Item['Value'])); 87 87 } 88 88 89 89 function DatabaseEscape($Value) 90 90 { 91 return ('"'.addslashes($Value).'"');91 return ('"'.addslashes($Value).'"'); 92 92 } 93 93 } -
trunk/Common/Form/Types/TimeDiff.php
r660 r873 7 7 function OnView($Item) 8 8 { 9 if ($Item['Value'] == null) $Output = '';9 if ($Item['Value'] == null) $Output = ''; 10 10 else { 11 11 $Output = sprintf('%02d', floor($Item['Value'] / 3600 % 24)).':'. … … 13 13 sprintf('%02d', floor($Item['Value'] % 60)); 14 14 $Days = floor($Item['Value'] / (60 * 60 * 24)); 15 if ($Days > 0) $Output = $Days.' dnů '.$Output;15 if ($Days > 0) $Output = $Days.' dnů '.$Output; 16 16 } 17 return ($Output);17 return ($Output); 18 18 } 19 19 } -
trunk/Common/Form/Types/Type.php
r738 r873 67 67 function ExecuteTypeEvent($TypeName, $Event, $Parameters = array()) 68 68 { 69 if (array_key_exists($TypeName, $this->TypeDefinitionList))69 if (array_key_exists($TypeName, $this->TypeDefinitionList)) 70 70 { 71 71 $Type = $this->TypeDefinitionList[$TypeName]; 72 72 $TypeClass = 'Type'.$Type['Class']; 73 73 $TypeObject = new $TypeClass($this->FormManager); 74 if (is_callable(array($TypeObject, $Event))) return($TypeObject->$Event($Parameters));75 else return ($TypeName.'->'.$Event.'('.serialize($Parameters).')');76 } else return ($TypeName);74 if (is_callable(array($TypeObject, $Event))) return ($TypeObject->$Event($Parameters)); 75 else return ($TypeName.'->'.$Event.'('.serialize($Parameters).')'); 76 } else return ($TypeName); 77 77 } 78 78 79 79 function IsHidden($TypeName) 80 80 { 81 if (array_key_exists($TypeName, $this->TypeDefinitionList))81 if (array_key_exists($TypeName, $this->TypeDefinitionList)) 82 82 { 83 83 $Type = $this->TypeDefinitionList[$TypeName]; 84 84 $TypeClass = 'Type'.$Type['Class']; 85 85 $TypeObject = new $TypeClass($this->FormManager); 86 return ($TypeObject->Hidden);87 } else return (false);86 return ($TypeObject->Hidden); 87 } else return (false); 88 88 } 89 89 90 90 function RegisterType($Name, $ParentType, $Parameters) 91 91 { 92 if ($ParentType != '')92 if ($ParentType != '') 93 93 { 94 94 $Type = $this->TypeDefinitionList[$ParentType]; … … 97 97 $Type['Name'] = $Name; 98 98 $Type['Class'] = $Name; 99 if (array_key_exists('Parameters', $Type))99 if (array_key_exists('Parameters', $Type)) 100 100 $Type['Parameters'] = array_merge($Type['Parameters'], $Parameters); 101 101 else $Type['Parameters'] = $Parameters; … … 111 111 function GetTypeDefinition($TypeName) 112 112 { 113 return ($this->TypeDefinitionList[$TypeName]);113 return ($this->TypeDefinitionList[$TypeName]); 114 114 } 115 115 } -
trunk/Common/Global.php
r869 r873 25 25 26 26 $UnitIndex = 0; 27 while ($Value > 1024)27 while ($Value > 1024) 28 28 { 29 29 $Value = round($Value / 1024, 3); 30 30 $UnitIndex++; 31 31 } 32 return ($Value.' '.$UnitNames[$UnitIndex]);32 return ($Value.' '.$UnitNames[$UnitIndex]); 33 33 } 34 34 … … 48 48 function HumanDate($Time) 49 49 { 50 if ($Time != '') {50 if ($Time != '') { 51 51 $Date = explode(' ', $Time); 52 52 $Parts = explode('-', $Date[0]); 53 if ($Date != '0000-00-00') return(($Parts[2]*1).'.'.($Parts[1]*1).'.'.$Parts[0]);54 else return (' ');55 } else return (' ');53 if ($Date != '0000-00-00') return (($Parts[2]*1).'.'.($Parts[1]*1).'.'.$Parts[0]); 54 else return (' '); 55 } else return (' '); 56 56 } 57 57 … … 62 62 $Around = 10; 63 63 $Result = ''; 64 if ($Count>1)65 { 66 if ($Page>0)64 if ($Count>1) 65 { 66 if ($Page>0) 67 67 { 68 68 $Result.= '<a href="'.$URL.'0"><<</a> '; … … 71 71 $PagesMax = $Count-1; 72 72 $PagesMin = 0; 73 if ($PagesMax>($Page+$Around)) $PagesMax = $Page+$Around;74 if ($PagesMin<($Page-$Around))73 if ($PagesMax>($Page+$Around)) $PagesMax = $Page+$Around; 74 if ($PagesMin<($Page-$Around)) 75 75 { 76 76 $Result.= ' .. '; 77 77 $PagesMin = $Page-$Around; 78 78 } 79 for ($i=$PagesMin;$i<=$PagesMax;$i++)80 { 81 if ($i==$Page) $Result.= '<strong>';79 for ($i=$PagesMin;$i<=$PagesMax;$i++) 80 { 81 if ($i==$Page) $Result.= '<strong>'; 82 82 $Result.= '<a href="'.$URL.$i.'">'.($i+1).'</a> '; 83 if ($i==$Page) $Result.= '</strong>';84 } 85 if ($PagesMax<($Count-1)) $Result .= ' .. ';86 if ($Page<($Count-1))83 if ($i==$Page) $Result.= '</strong>'; 84 } 85 if ($PagesMax<($Count-1)) $Result .= ' .. '; 86 if ($Page<($Count-1)) 87 87 { 88 88 $Result.= '<a href="'.$URL.($Page+1).'">></a> '; … … 90 90 } 91 91 } 92 return ($Result);92 return ($Result); 93 93 } 94 94 95 95 function ExtractTime($Time) 96 96 { 97 return (array(97 return (array( 98 98 'Year' => date('Y', $Time), 99 99 'Month' => date('n', $Time), … … 109 109 $Result = array(); 110 110 $Parts = explode('&', $QueryString); 111 foreach ($Parts as $Part)112 { 113 if ($Part != '')114 { 115 if (!strpos($Part, '=')) $Part .= '=';111 foreach ($Parts as $Part) 112 { 113 if ($Part != '') 114 { 115 if (!strpos($Part, '=')) $Part .= '='; 116 116 $Item = explode('=', $Part); 117 117 $Result[$Item[0]] = $Item[1]; 118 118 } 119 119 } 120 return ($Result);120 return ($Result); 121 121 } 122 122 … … 124 124 { 125 125 $Parts = array(); 126 foreach ($QueryStringArray as $Index => $Item)126 foreach ($QueryStringArray as $Index => $Item) 127 127 { 128 128 $Parts[] = $Index.'='.$Item; 129 129 } 130 return (implode('&', $Parts));130 return (implode('&', $Parts)); 131 131 } 132 132 … … 138 138 139 139 $Result = ''; 140 if (array_key_exists('all', $QueryItems))140 if (array_key_exists('all', $QueryItems)) 141 141 { 142 142 $PageCount = 1; … … 149 149 } 150 150 151 if (!array_key_exists($ObjectName.'Page', $_SESSION)) $_SESSION[$ObjectName.'Page'] = 0;152 if (array_key_exists('ObjectName', $_GET) and ($_GET['ObjectName'] == $ObjectName)) {153 if (array_key_exists('page', $_GET)) $_SESSION[$ObjectName.'Page'] = $_GET['page'] * 1;154 } 155 if ($_SESSION[$ObjectName.'Page'] < 0) $_SESSION[$ObjectName.'Page'] = 0;156 if ($_SESSION[$ObjectName.'Page'] >= $PageCount) $_SESSION[$ObjectName.'Page'] = $PageCount - 1;151 if (!array_key_exists($ObjectName.'Page', $_SESSION)) $_SESSION[$ObjectName.'Page'] = 0; 152 if (array_key_exists('ObjectName', $_GET) and ($_GET['ObjectName'] == $ObjectName)) { 153 if (array_key_exists('page', $_GET)) $_SESSION[$ObjectName.'Page'] = $_GET['page'] * 1; 154 } 155 if ($_SESSION[$ObjectName.'Page'] < 0) $_SESSION[$ObjectName.'Page'] = 0; 156 if ($_SESSION[$ObjectName.'Page'] >= $PageCount) $_SESSION[$ObjectName.'Page'] = $PageCount - 1; 157 157 $CurrentPage = $_SESSION[$ObjectName.'Page']; 158 158 … … 161 161 162 162 $Result = ''; 163 if ($PageCount > 1)164 { 165 if ($CurrentPage > 0)163 if ($PageCount > 1) 164 { 165 if ($CurrentPage > 0) 166 166 { 167 167 $QueryItems['page'] = 0; … … 172 172 $PagesMax = $PageCount - 1; 173 173 $PagesMin = 0; 174 if ($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around;175 if ($PagesMin < ($CurrentPage - $Around))174 if ($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around; 175 if ($PagesMin < ($CurrentPage - $Around)) 176 176 { 177 177 $Result.= ' ... '; 178 178 $PagesMin = $CurrentPage - $Around; 179 179 } 180 for ($i = $PagesMin; $i <= $PagesMax; $i++)181 { 182 if ($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> ';180 for ($i = $PagesMin; $i <= $PagesMax; $i++) 181 { 182 if ($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> '; 183 183 else { 184 184 $QueryItems['page'] = $i; … … 186 186 } 187 187 } 188 if ($PagesMax < ($PageCount - 1)) $Result .= ' ... ';189 if ($CurrentPage < ($PageCount - 1))188 if ($PagesMax < ($PageCount - 1)) $Result .= ' ... '; 189 if ($CurrentPage < ($PageCount - 1)) 190 190 { 191 191 $QueryItems['page'] = ($CurrentPage + 1); … … 196 196 } 197 197 $QueryItems['all'] = '1'; 198 if ($PageCount > 1) $Result.= ' <a href="?'.SetQueryStringArray($QueryItems).'">Vše</a>';198 if ($PageCount > 1) $Result.= ' <a href="?'.SetQueryStringArray($QueryItems).'">Vše</a>'; 199 199 200 200 $Result = '<div style="text-align: center">'.$Result.'</div>'; 201 return (array('SQLLimit' => ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage,201 return (array('SQLLimit' => ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage, 202 202 'Page' => $CurrentPage, 203 203 'Output' => $Result, … … 212 212 global $OrderDirSQL, $OrderArrowImage, $Config, $System; 213 213 214 if (array_key_exists('ObjectName', $_GET) and ($_GET['ObjectName'] == $ObjectName))215 { 216 if (array_key_exists('OrderCol', $_GET)) $_SESSION[$ObjectName.'OrderCol'] = $_GET['OrderCol'];217 if (array_key_exists('OrderDir', $_GET)) $_SESSION[$ObjectName.'OrderDir'] = $_GET['OrderDir'];218 } 219 if (!array_key_exists($ObjectName.'OrderCol', $_SESSION)) $_SESSION[$ObjectName.'OrderCol'] = $DefaultColumn;220 if (!array_key_exists($ObjectName.'OrderDir', $_SESSION) ) $_SESSION[$ObjectName.'OrderDir'] = $DefaultOrder;214 if (array_key_exists('ObjectName', $_GET) and ($_GET['ObjectName'] == $ObjectName)) 215 { 216 if (array_key_exists('OrderCol', $_GET)) $_SESSION[$ObjectName.'OrderCol'] = $_GET['OrderCol']; 217 if (array_key_exists('OrderDir', $_GET)) $_SESSION[$ObjectName.'OrderDir'] = $_GET['OrderDir']; 218 } 219 if (!array_key_exists($ObjectName.'OrderCol', $_SESSION)) $_SESSION[$ObjectName.'OrderCol'] = $DefaultColumn; 220 if (!array_key_exists($ObjectName.'OrderDir', $_SESSION) ) $_SESSION[$ObjectName.'OrderDir'] = $DefaultOrder; 221 221 222 222 // Check OrderCol 223 223 $Found = false; 224 foreach ($Columns as $Column)225 { 226 if ($Column['Name'] == $_SESSION[$ObjectName.'OrderCol'])224 foreach ($Columns as $Column) 225 { 226 if ($Column['Name'] == $_SESSION[$ObjectName.'OrderCol']) 227 227 { 228 228 $Found = true; … … 230 230 } 231 231 } 232 if (($_SESSION[$ObjectName.'OrderCol'] == '') or ($Found == false))232 if (($_SESSION[$ObjectName.'OrderCol'] == '') or ($Found == false)) 233 233 { 234 234 $_SESSION[$ObjectName.'OrderCol'] = $DefaultColumn; … … 236 236 } 237 237 // Check OrderDir 238 if (($_SESSION[$ObjectName.'OrderDir'] != 0) and ($_SESSION[$ObjectName.'OrderDir'] != 1))238 if (($_SESSION[$ObjectName.'OrderDir'] != 0) and ($_SESSION[$ObjectName.'OrderDir'] != 1)) 239 239 $_SESSION[$ObjectName.'OrderDir'] = 0; 240 240 241 241 $Result = ''; 242 242 $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']); 243 foreach ($Columns as $Index => $Column)243 foreach ($Columns as $Index => $Column) 244 244 { 245 245 $QueryItems['ObjectName'] = $ObjectName; 246 246 $QueryItems['OrderCol'] = $Column['Name']; 247 247 $QueryItems['OrderDir'] = 1 - $_SESSION[$ObjectName.'OrderDir']; 248 if ($Column['Name'] == $_SESSION[$ObjectName.'OrderCol'])248 if ($Column['Name'] == $_SESSION[$ObjectName.'OrderCol']) 249 249 $ArrowImage = '<img style="vertical-align: middle; border: 0px;" src="'. 250 250 $System->Link('/images/'.$OrderArrowImage[$_SESSION[$ObjectName.'OrderDir']]).'" alt="order arrow">'; 251 251 else $ArrowImage = ''; 252 if ($Column['Name'] == '') $Result .= '<th>'.$Column['Title'].'</th>';252 if ($Column['Name'] == '') $Result .= '<th>'.$Column['Title'].'</th>'; 253 253 else $Result .= '<th><a href="?'.SetQueryStringArray($QueryItems).'">'.$Column['Title'].$ArrowImage.'</a></th>'; 254 254 } 255 return (array(255 return (array( 256 256 'SQL' => ' ORDER BY `'.$_SESSION[$ObjectName.'OrderCol'].'` '.$OrderDirSQL[$_SESSION[$ObjectName.'OrderDir']], 257 257 'Output' => '<tr>'.$Result.'</tr>', … … 263 263 function GetRemoteAddress() 264 264 { 265 if (array_key_exists('REMOTE_ADDR', $_SERVER)) $IP = $_SERVER['REMOTE_ADDR'];265 if (array_key_exists('REMOTE_ADDR', $_SERVER)) $IP = $_SERVER['REMOTE_ADDR']; 266 266 else $IP = '0.0.0.0'; 267 return ($IP);267 return ($IP); 268 268 } 269 269 … … 274 274 $Result = true; 275 275 $RemoteAddr = GetRemoteAddress(); 276 foreach ($Config['Web']['IntranetSubnets'] as $Subnet)277 { 278 if (substr($RemoteAddr, 0, strlen($Subnet)) == $Subnet)276 foreach ($Config['Web']['IntranetSubnets'] as $Subnet) 277 { 278 if (substr($RemoteAddr, 0, strlen($Subnet)) == $Subnet) 279 279 { 280 280 $Result = false; … … 282 282 } 283 283 } 284 return ($Result);284 return ($Result); 285 285 } 286 286 … … 292 292 '(SELECT `Member` FROM `NetworkDevice` WHERE (SELECT `Device` FROM `NetworkInterface` '. 293 293 'WHERE `LocalIP` = "'.$IP.'") = `NetworkDevice`.`Id`) = `Member`.`Id`'); 294 if ($DbResult->num_rows > 0)294 if ($DbResult->num_rows > 0) 295 295 { 296 296 $DbRow = $DbResult->fetch_assoc(); 297 return ($DbRow['Id']);298 } else return ('');297 return ($DbRow['Id']); 298 } else return (''); 299 299 } 300 300 … … 302 302 { 303 303 $Result = shell_exec('which '.$Command); 304 return (!empty($Result));304 return (!empty($Result)); 305 305 } 306 306 307 307 function RemoveDiacritic($Text) 308 308 { 309 return (str_replace(309 return (str_replace( 310 310 array('á', 'č', 'ď', 'é', 'ě', 'í', 'ľ', 'ň', 'ó', 'ř', 'š', 'ť', 'ú', 'ů', 311 311 'ý', 'ž', 'Á', 'Č', 'Ď', 'É', 'Ě', 'Í', 'Ľ', 'Ň', 'Ó', 'Ř', 'Š', 'Ť', 'Ú', 'Ů', 'Ý', 'Ž'), … … 317 317 function RouterOSIdent($Name) 318 318 { 319 return (strtr(strtolower(trim($Name)), array(' ' => '-', '.' => '', '(' => '-', ')' => '-', ',' => '-',319 return (strtr(strtolower(trim($Name)), array(' ' => '-', '.' => '', '(' => '-', ')' => '-', ',' => '-', 320 320 'č' => 'c', 'š' => 's', 'ě' => 'e', 'ř' => 'r', 'ž' => 'z', 'ý' => 'y', 321 321 'á' => 'a', 'í' => 'i', 'é' => 'e', 'ů' => 'u', 'ú' => 'u', 'ď' => 'd', … … 329 329 function NotBlank($Text) 330 330 { 331 if ($Text == '') return(' ');332 else return ($Text);331 if ($Text == '') return (' '); 332 else return ($Text); 333 333 } 334 334 … … 352 352 function ProcessURL() 353 353 { 354 if (array_key_exists('REDIRECT_QUERY_STRING', $_SERVER))354 if (array_key_exists('REDIRECT_QUERY_STRING', $_SERVER)) 355 355 $PathString = $_SERVER['REDIRECT_QUERY_STRING']; 356 356 else $PathString = ''; 357 if (substr($PathString, -1, 1) == '/') $PathString = substr($PathString, 0, -1);357 if (substr($PathString, -1, 1) == '/') $PathString = substr($PathString, 0, -1); 358 358 $PathItems = explode('/', $PathString); 359 if (array_key_exists('REQUEST_URI', $_SERVER) and (strpos($_SERVER['REQUEST_URI'], '?') !== false))359 if (array_key_exists('REQUEST_URI', $_SERVER) and (strpos($_SERVER['REQUEST_URI'], '?') !== false)) 360 360 $_SERVER['QUERY_STRING'] = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], '?') + 1); 361 361 else $_SERVER['QUERY_STRING'] = ''; 362 362 parse_str($_SERVER['QUERY_STRING'], $_GET); 363 return ($PathItems);363 return ($PathItems); 364 364 } 365 365 366 366 function RepeatFunction($Period, $Callback) 367 367 { 368 while (1)368 while (1) 369 369 { 370 370 $StartTime = time(); … … 372 372 $EndTime = time(); 373 373 $Delay = $Period - ($EndTime - $StartTime); 374 if ($Delay < 0) $Delay = 0;374 if ($Delay < 0) $Delay = 0; 375 375 376 376 echo('Waiting remaining '.$Delay.' of '.$Period.' seconds period...'."\n"); -
trunk/Common/VCL/Database.php
r738 r873 28 28 29 29 $ColumnSQL = array(); 30 foreach ($this->Columns as $Column)30 foreach ($this->Columns as $Column) 31 31 { 32 32 $ColumnSQL[] = $Column->Name; … … 35 35 36 36 // Get total filtered item count in database 37 if ($this->Filter != '')37 if ($this->Filter != '') 38 38 { 39 39 $Query = 'SELECT COUNT(*) FROM (SELECT '.$ColumnSQL.' FROM '.$this->SQL.') AS `TS` '.$this->Filter; … … 46 46 $this->Rows = array(); 47 47 $VisibleItemCount = 0; 48 if (($this->SortOrder != 0) and ($this->SortOrder != 1)) $this->SortOrder = 0;49 //if ($this->SortColumn)48 if (($this->SortOrder != 0) and ($this->SortOrder != 1)) $this->SortOrder = 0; 49 //if ($this->SortColumn) 50 50 $this->SortColumn = $this->Columns[0]->Name; 51 51 $this->OrderSQL = ' ORDER BY `'.$this->SortColumn.'` '.$this->OrderDirSQL[$this->SortOrder]; … … 54 54 $this->Filter.' '.$this->OrderSQL.$SQLLimit; 55 55 $DbResult = $this->Database->query($Query); 56 while ($DbRow = $DbResult->fetch_assoc())56 while ($DbRow = $DbResult->fetch_assoc()) 57 57 { 58 if (method_exists($this->OnRowDraw[0], $this->OnRowDraw[1]))58 if (method_exists($this->OnRowDraw[0], $this->OnRowDraw[1])) 59 59 $DbRow = call_user_func($this->OnRowDraw, $DbRow); 60 60 $this->Rows[] = $DbRow; … … 62 62 } 63 63 $Row = '<td colspan="'.count($this->Columns).'" style="text-align: right;">Zobrazeno <strong>'.$VisibleItemCount.'</strong>'; 64 if ($this->Filter != '') $Row .= ' z filtrovaných <strong>'.$TotalFilteredCount.'</strong>';64 if ($this->Filter != '') $Row .= ' z filtrovaných <strong>'.$TotalFilteredCount.'</strong>'; 65 65 $Row .= ' z celkem <strong>'.$TotalCount.'</strong>'; 66 66 $ListView->Rows[] = $Row; 67 67 $Output = parent::Show(); 68 return ($Output);68 return ($Output); 69 69 } 70 70 } -
trunk/Common/VCL/General.php
r693 r873 8 8 //echo($Name.','); 9 9 $Result = ''; 10 if ($Persistent)11 if (array_key_exists($Name, $_SESSION)) $Result = $_SESSION[$Name];12 if (array_key_exists($Name, $_GET))10 if ($Persistent) 11 if (array_key_exists($Name, $_SESSION)) $Result = $_SESSION[$Name]; 12 if (array_key_exists($Name, $_GET)) 13 13 { 14 14 $Result = $_GET[$Name]; 15 if ($Persistent) $_SESSION[$Name] = $Result;16 } 17 return ($Result);15 if ($Persistent) $_SESSION[$Name] = $Result; 16 } 17 return ($Result); 18 18 } 19 19 … … 34 34 $Output = ''; 35 35 //$Output .= '#'.$this->Id; 36 return ($Output);36 return ($Output); 37 37 } 38 38 … … 48 48 function Show() 49 49 { 50 if ($this->Visible)50 if ($this->Visible) 51 51 { 52 52 $Output = parent::Show(); 53 foreach ($this->Items as $Item)53 foreach ($this->Items as $Item) 54 54 $Output .= $Item->Show(); 55 return ($Output);56 } 57 } 58 59 function Prepare() 60 { 61 foreach ($this->Items as $Item)55 return ($Output); 56 } 57 } 58 59 function Prepare() 60 { 61 foreach ($this->Items as $Item) 62 62 $Item->Prepare(); 63 63 } … … 70 70 function Show() 71 71 { 72 if ($this->Visible)73 { 74 return (parent::Show().'<button>'.$this->Caption.'</button>');72 if ($this->Visible) 73 { 74 return (parent::Show().'<button>'.$this->Caption.'</button>'); 75 75 } 76 76 } … … 83 83 function Show() 84 84 { 85 return (parent::Show().'<input type="text" name="'.$this->Id.'" value="'.$this->Text.'"/>');85 return (parent::Show().'<input type="text" name="'.$this->Id.'" value="'.$this->Text.'"/>'); 86 86 } 87 87 … … 108 108 function Show() 109 109 { 110 if (array_key_exists($this->Id.'_Page', $_GET))110 if (array_key_exists($this->Id.'_Page', $_GET)) 111 111 $this->Position = $_GET[$this->Id.'_Page']; 112 if ($this->Position >= $this->Count) $this->Position = $this->Count / $this->PageSize - 1;112 if ($this->Position >= $this->Count) $this->Position = $this->Count / $this->PageSize - 1; 113 113 $Output = ''; 114 for ($I = 0; $I < $this->Count / $this->PageSize; $I++)114 for ($I = 0; $I < $this->Count / $this->PageSize; $I++) 115 115 { 116 116 $Text = '<a href="?'.$this->Id.'_Page='.$I.'">'.$I.'</a> '; 117 if ($I == $this->Position) $Text = '<strong>'.$Text.'</strong>';117 if ($I == $this->Position) $Text = '<strong>'.$Text.'</strong>'; 118 118 $Output .= $Text; 119 119 } 120 120 $Output .= '<br/>'; 121 return ($Output);121 return ($Output); 122 122 } 123 123 … … 134 134 function Show() 135 135 { 136 return ($this->Name);136 return ($this->Name); 137 137 } 138 138 } … … 155 155 { 156 156 $Output = '<table class="WideTable" style="font-size: small;><tr>'; 157 foreach ($this->Columns as $Column)158 { 159 if ($this->OnColumnDraw != '') $Text = call_user_func($this->OnColumnDraw, $Column);157 foreach ($this->Columns as $Column) 158 { 159 if ($this->OnColumnDraw != '') $Text = call_user_func($this->OnColumnDraw, $Column); 160 160 else $Text = $Column->Show(); 161 161 $Output .= '<th>'.$Text.'</th>'; 162 162 } 163 163 $Output .= '</tr>'; 164 foreach ($this->Rows as $Row)164 foreach ($this->Rows as $Row) 165 165 { 166 166 $Output .= '<tr>'; 167 foreach ($Row as $Value)167 foreach ($Row as $Value) 168 168 $Output .= '<td>'.$Value.'</td>'; 169 169 $Output .= '</tr>'; 170 170 } 171 171 $Output .= '</table>'; 172 return ($Output);172 return ($Output); 173 173 } 174 174 } … … 192 192 function ColumnClick($Column) 193 193 { 194 return ('?'.$this->Id.'_SortColumn='.$Column->Id.'&'.$this->Id.'_SortOrder='.(1 - $this->SortOrder));194 return ('?'.$this->Id.'_SortColumn='.$Column->Id.'&'.$this->Id.'_SortOrder='.(1 - $this->SortOrder)); 195 195 } 196 196 … … 201 201 $Output = $Column->Show(); 202 202 203 if ($Column->Name == $this->SortColumn)203 if ($Column->Name == $this->SortColumn) 204 204 { 205 205 $Output .= '<img style="vertical-align: middle; border: 0px;" src="'. 206 206 $System->Link('/images/'.$this->OrderArrowImage[$this->SortOrder]).'" alt="order arrow">'; 207 207 } 208 if ($this->OnColumnClick != '')208 if ($this->OnColumnClick != '') 209 209 $Output = '<a href="'.call_user_func($this->OnColumnClick, $Column).'">'.$Output.'</a>'; 210 return ($Output);210 return ($Output); 211 211 } 212 212 … … 219 219 $Output .= parent::Show(); 220 220 $Output .= $this->PageSelect->Show(); 221 return ($Output);221 return ($Output); 222 222 } 223 223 … … 239 239 { 240 240 $Output .= '<table>'; 241 foreach ($this->Rows as $RowNum => $Row)241 foreach ($this->Rows as $RowNum => $Row) 242 242 { 243 243 $Output .= '<tr>'; 244 foreach ($Row as $ColNum => $Value)244 foreach ($Row as $ColNum => $Value) 245 245 { 246 if ($this->Span[$RowNum][$ColNum] != 1) $Span = ' colspan="'.$this->Span[$RowNum][$ColNum].'"';246 if ($this->Span[$RowNum][$ColNum] != 1) $Span = ' colspan="'.$this->Span[$RowNum][$ColNum].'"'; 247 247 else $Span = ''; 248 248 $Output .= '<td'.$Span.'>'.$Value->Show().'</td>'; … … 251 251 } 252 252 $Output .= '</table>'; 253 return ($Output);254 } 255 256 function Prepare() 257 { 258 foreach ($this->Rows as $RowNum => $Row)259 { 260 foreach ($Row as $ColNum => $Value)253 return ($Output); 254 } 255 256 function Prepare() 257 { 258 foreach ($this->Rows as $RowNum => $Row) 259 { 260 foreach ($Row as $ColNum => $Value) 261 261 { 262 262 $Value->Prepare(); … … 274 274 { 275 275 $Output = $this->Caption; 276 if (method_exists($this->OnExecute[0], $this->OnExecute[1]))276 if (method_exists($this->OnExecute[0], $this->OnExecute[1])) 277 277 { 278 278 $Link = 'O='.$this->Id.'&M=Execute'; 279 279 $Output = '<a href="?'.$Link.'">'.$Output.'</a>'; 280 280 }; 281 return ($Output);281 return ($Output); 282 282 } 283 283 … … 286 286 $Object = ReadSessionVar('O', false); 287 287 $Method = ReadSessionVar('M', false); 288 if (($Object == $this->Id) and ($Method == 'Execute'))288 if (($Object == $this->Id) and ($Method == 'Execute')) 289 289 call_user_func($this->OnExecute, $this); 290 290 } … … 298 298 { 299 299 $Output = '<!DOCTYPE html><html><head></head><body>'; 300 foreach ($this->Items as $Item)300 foreach ($this->Items as $Item) 301 301 $Output .= $Item->Show(); 302 302 $Output .= '</body></html>'; 303 return ($Output);304 } 305 306 function Prepare() 307 { 308 foreach ($this->Items as $Item)303 return ($Output); 304 } 305 306 function Prepare() 307 { 308 foreach ($this->Items as $Item) 309 309 $Item->Prepare(); 310 310 }
Note:
See TracChangeset
for help on using the changeset viewer.