Changeset 873 for trunk/Common/Form
- Timestamp:
- Apr 6, 2020, 11:17:40 PM (5 years ago)
- Location:
- trunk/Common/Form
- Files:
-
- 25 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 }
Note:
See TracChangeset
for help on using the changeset viewer.