Changeset 659 for trunk/Common/Form/Types
- Timestamp:
- May 29, 2014, 11:59:39 PM (11 years ago)
- Location:
- trunk/Common/Form/Types
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/Form/Types/DateTime.php
r616 r659 10 10 { 11 11 global $MonthNames; 12 12 13 13 if($Item['Value'] == 0) return(''); 14 14 if((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == '')) $Item['Value'] = time(); 15 15 $Parts = getdate($Item['Value']); 16 16 $Output = $Parts['mday'].'.'.$Parts['mon'].'.'.$Parts['year'].' '. 17 $Parts['hours'].':'.$Parts['minutes'].':'.$Parts['seconds'];17 sprintf('%02d', $Parts['hours']).':'.sprintf('%02d', $Parts['minutes']).':'.sprintf('%02d', $Parts['seconds']); 18 18 return($Output); 19 19 } … … 25 25 if(($Item['Value'] !== null) and ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == ''))) $Item['Value'] = time(); 26 26 $Parts = getdate($Item['Value']); 27 27 28 28 $Output = ''; 29 29 $Style = ''; … … 43 43 $Item['Name'].'-day\');toggle(\''.$Item['Name'].'-month\');toggle(\''.$Item['Name'].'-year\');"/>'; 44 44 } 45 45 46 46 // Hour 47 47 $Output .= '<select name="'.$Item['Name'].'-hour" id="'.$Item['Name'].'-hour" '.$Style.'>'; … … 106 106 return(MysqlDateTimeToTime($Item['Value'])); 107 107 } 108 108 109 109 function OnSaveDb($Item) 110 { 110 { 111 111 if($Item['Value'] == null) return(null); 112 112 else return(date('Y-m-d H:i:s', $Item['Value'])); -
trunk/Common/Form/Types/File.php
r577 r659 9 9 var $DirectoryId; 10 10 var $TempName; 11 11 12 12 function DetectMimeType() 13 13 { … … 18 18 return($Result); 19 19 } 20 20 21 21 function GetSize($Item) 22 22 { … … 24 24 if(file_exists($FileName)) $Result = filesize($FileName); 25 25 else $Result = 0; 26 return($Result); 26 return($Result); 27 27 } 28 28 29 29 function GetFullName() 30 30 { 31 31 $ParentId = $this->Directory; 32 while($Paren Id != null)32 while($ParentId != null) 33 33 { 34 34 $DbResult = $this->Database->select('FileDirectory', '*', 'Id='.$ParentId); … … 36 36 $Path .= $DbRow['Name'].'/'; 37 37 $ParentId = $DbRow['Parent']; 38 } 38 } 39 39 $Result = $this->UploadFileFolder.'/'.$Path.$File->Name; 40 40 return($Result); 41 41 } 42 42 43 43 function GetExt() 44 44 { 45 45 return(substr($this->Name, 0, strpos($this->Name, '.') - 1)); 46 46 } 47 47 48 48 function Delete() 49 49 { 50 50 if(file_exists($this->GetFullName())) unlink($this->GetFullName()); 51 51 } 52 52 53 53 function GetContent() 54 54 { … … 64 64 var $FileDownloadURL; 65 65 var $DirectoryId; 66 66 67 67 function __construct($FormManager) 68 68 { … … 71 71 $this->DirectoryId = null; 72 72 } 73 73 74 74 function OnView($Item) 75 75 { … … 99 99 { 100 100 $File->Name = $UploadFile['name']; 101 $File->Size = $UploadFile['size']; 101 $File->Size = $UploadFile['size']; 102 102 $File->TempName = $UploadFile['tmp_name']; 103 103 } … … 105 105 return($File); 106 106 } 107 107 108 108 function OnLoadDb($Item) 109 109 { … … 120 120 return($File); 121 121 } 122 122 123 123 function OnSaveDb($Item) 124 124 { 125 125 if(!is_object($Item['Value'])) $Item['Value'] = new DbFile(); 126 126 $File = &$Item['Value']; 127 $Properties = array('Name' => $File->Name, 127 $Properties = array('Name' => $File->Name, 128 128 'Size' => $File->GetSize(), 'Directory' => $File->Directory); 129 129 $DbResult = $this->Database->select('File', '*', 'Id='.$File->Id); … … 131 131 { 132 132 $DbRow = $DbResult->fetch_assoc(); 133 if($File->TempName != '') 133 if($File->TempName != '') 134 134 { 135 135 $FileName = $File->GetFullName(); … … 137 137 } 138 138 $this->Database->update('File', 'Id='.$File->Id, $Properties); 139 } else 139 } else 140 140 { 141 141 $this->Database->insert('File', $Properties); … … 145 145 SystemMessage('Nahrání souboru', 'Cílová složka není dostupná!'); 146 146 } 147 147 148 148 } -
trunk/Common/Form/Types/Time.php
r616 r659 13 13 $TimeParts = getdate($Item['Value']); 14 14 15 $Output = $TimeParts['hours'].':'.$TimeParts['minutes'].':'.$TimeParts['seconds'];15 $Output = sprintf('%02d', $TimeParts['hours']).':'.sprintf('%02d', $TimeParts['minutes']).':'.sprintf('%02d', $TimeParts['seconds']); 16 16 return($Output); 17 17 } … … 24 24 $Output = ''; 25 25 $Style = ''; 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) 28 if($Item['Value'] != null) 29 29 { 30 30 $Checked = ' checked="1"'; 31 31 $Style = 'style="display:inline;"'; 32 } else 32 } else 33 33 { 34 34 $Checked = ''; 35 $Style = 'style="display:none;"'; 35 $Style = 'style="display:none;"'; 36 36 } 37 37 $Output .= '<input type="checkbox" name="'.$Item['Name'].'-null"'.$Checked.' onclick="toggle(\''. 38 $Item['Name'].'-hour\');toggle(\''.$Item['Name'].'-minute\');toggle(\''.$Item['Name'].'-second\');"/>'; 38 $Item['Name'].'-hour\');toggle(\''.$Item['Name'].'-minute\');toggle(\''.$Item['Name'].'-second\');"/>'; 39 39 } 40 40 41 41 // Hour 42 42 $Output .= '<select name="'.$Item['Name'].'-hour" id="'.$Item['Name'].'-hour" '.$Style.'>'; … … 68 68 function OnLoad($Item) 69 69 { 70 if(!array_key_exists($Item['Name'].'-null', $_POST) and array_key_exists('Null', $Item) and ($Item['Null'] == true)) return(null); 70 if(!array_key_exists($Item['Name'].'-null', $_POST) and array_key_exists('Null', $Item) and ($Item['Null'] == true)) return(null); 71 71 return(mktime($_POST[$Item['Name'].'-hour'], $_POST[$Item['Name'].'-minute'], $_POST[$Item['Name'].'-second'])); 72 72 } -
trunk/Common/Form/Types/Type.php
r623 r659 24 24 include(dirname(__FILE__).'/MacAddress.php'); 25 25 include(dirname(__FILE__).'/Image.php'); 26 include(dirname(__FILE__).'/TimeDiff.php'); 26 27 27 28 class Type … … 58 59 'IPv6Address' => array('Name' => 'IPv6Address', 'Class' => 'IPv6Address', 'ParentType' => '', 'Parameters' => array()), 59 60 'Image' => array('Name' => 'Image', 'Class' => 'Image', 'ParentType' => '', 'Parameters' => array()), 61 'TimeDiff' => array('Name' => 'TimeDiff', 'Class' => 'TimeDiff', 'ParentType' => 'Integer', 'Parameters' => array()), 60 62 ); 61 63 } … … 72 74 } else return($TypeName); 73 75 } 74 76 75 77 function IsHidden($TypeName) 76 78 { … … 90 92 $Type = $this->TypeDefinitionList[$ParentType]; 91 93 } else $Type = array(); 92 94 93 95 $Type['Name'] = $Name; 94 96 $Type['Class'] = $Name; … … 104 106 // TODO: remove dependent types 105 107 } 106 108 107 109 function GetTypeDefinition($TypeName) 108 110 {
Note:
See TracChangeset
for help on using the changeset viewer.