Changeset 19
- Timestamp:
- Oct 22, 2008, 9:12:20 AM (16 years ago)
- Files:
-
- 3 added
- 2 deleted
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
base.php
r18 r19 58 58 59 59 $DbResult = $Database->query('SELECT t1.* FROM `'.$List['TableName'].'` AS t1 LEFT JOIN `'.$List['TableName'].'` AS t2 ON t1.ItemId=t2.ItemId AND t1.Id < t2.Id WHERE (t2.ItemId IS NULL)'.$Where.' LIMIT '.($Page * $Config['Web']['ItemsPerPage']).', '.$Config['Web']['ItemsPerPage']); 60 //echo($Database->LastQuery); 60 61 while($DbRow = $DbResult->fetch_assoc()) 61 62 { … … 135 136 } 136 137 } 137 //print_r($TypeNames);138 //print_r($Types);139 138 $Item = array('Name' => 'Author', 'Type' => $TypeNames['PointerToUser']); 140 //print_r($Item);141 $ItemType = explode('|', $Types[$Item['Type']]['Parameters']);142 $Type = $Types[$ItemType[0]];143 139 $ItemDefinition = array('Name' => $Item['Name'], 'Value' => $DbRow[$Item['Name']], 'SourceTable' => $List['TableName'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']); 144 if(is_callable($Type['CallbackView'])) $Value = $Type['CallbackView']($Type, $ItemDefinition); 145 else $Value = $Type['CallbackView']; 146 $Output .= '<td>'.$Value.'</td>'; 140 $Output .= '<td>'.ExecuteTypeEvent($Item['Type'], 'OnView', $ItemDefinition).'</td>'; 147 141 148 142 $Output .= '<td>'.$DbRow['CreationTime'].'</td><td>'.$DbRow['DeletionTime'].'</td>'; … … 168 162 if($Types[$Item['Type']]['BaseType'] != 'PointerOneToMany') 169 163 { 170 $DefinitionItems[] = array('Name' => $Index, 'Caption' => $Item['TextBefore'].$Required, 'Value' => $DbRow[$Index], 'SourceTable' => $List['TableName'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']); 164 if($Item['Editable'] == 1) 165 { 166 $DefinitionItems[] = array('Name' => $Index, 'Caption' => $Item['TextBefore'].$Required, 'Value' => $DbRow[$Index], 'SourceTable' => $List['TableName'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']); 167 } else $DefinitionItems[] = array('Name' => $Index, 'Type' => 'Hidden', 'Caption' => '', 'Value' => $DbRow[$Index]); 171 168 } 172 169 } … … 241 238 { 242 239 if($Item['Required'] == 1) $Required = '*'; else $Required = ''; 243 $DefinitionItems[] = array('Name' => $Item['Name'], 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'].$Required, 'Value' => '', 'SourceTable' => $List['TableName'], 'SourceItemId' => 0); 240 if($Item['Editable'] == 1) 241 $DefinitionItems[] = array('Name' => $Item['Name'], 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'].$Required, 'Value' => '', 'SourceTable' => $List['TableName'], 'SourceItemId' => 0); 244 242 } else 245 243 if($Item['Name'] == $Column) … … 308 306 } 309 307 310 function ShowViewItem($List, $Id )308 function ShowViewItem($List, $Id, $Column = '', $ColumnValue = 0) 311 309 { 312 310 global $Database, $Types, $Lists; … … 318 316 { 319 317 $DefinitionItems = array(); 318 $Required = ''; 320 319 foreach($List['Items'] as $Index => $Item) 321 320 { … … 372 371 global $Lists, $Database; 373 372 373 $Output = ''; 374 374 $DbResult = $Database->query('SELECT t1.* FROM `SystemMenu` AS t1 LEFT JOIN `SystemMenu` AS t2 ON t1.ItemId=t2.ItemId AND t1.Id < t2.Id WHERE (t2.ItemId IS NULL) AND (t1.DeletionTime IS NULL)'); 375 375 while($DbRow = $DbResult->fetch_assoc()) … … 421 421 break; 422 422 case 'ViewItem': 423 $Output = ShowViewItem($List, $_SESSION['Item'] );423 $Output = ShowViewItem($List, $_SESSION['Item'], $_SESSION['Column'], $_SESSION['ColumnValue']); 424 424 break; 425 425 case 'AddItem': … … 434 434 case 'ShowList': 435 435 default: 436 $Output = ShowList($List );437 } 438 } else $Output = ShowList($List );436 $Output = ShowList($List, $_SESSION['Column'], $_SESSION['ColumnValue']); 437 } 438 } else $Output = ShowList($List, $_SESSION['Column'], $_SESSION['ColumnValue']); 439 439 } 440 440 return($Output); … … 505 505 function ExecuteTypeEvent($Type, $Event, $Parameters) 506 506 { 507 global $Types ;508 509 $ Callback = 'Type'.$Types[$Type]['BaseType'].$Event;507 global $Types, $TypeDefinitionList; 508 509 $TypeObject = $TypeDefinitionList[$Types[$Type]['BaseType']]; 510 510 //echo($Callback.','); 511 if(is_callable( $Callback)) return($Callback($Parameters));512 else return($ Callback.'('.$Type.')');511 if(is_callable(array($TypeObject, $Event))) return($TypeObject->$Event($Parameters)); 512 else return($Types[$Type]['BaseType'].'->'.$Event.'('.$Type.')'); 513 513 } 514 514 -
database_list.php
r15 r19 7 7 function AddItem($TableName, $Values) 8 8 { 9 $Values['Author'] = $this->System->Modules['User']->User['I d'];9 $Values['Author'] = $this->System->Modules['User']->User['ItemId']; 10 10 $Values['CreationTime'] = 'NOW()'; 11 11 $Values['ValidTimeFrom'] = 'NOW()'; … … 29 29 $this->DeleteItem($TableName, $Id); 30 30 $Values['ItemId'] = $Id; 31 $Values['Author'] = $this->System->Modules['User']->User['I d'];31 $Values['Author'] = $this->System->Modules['User']->User['ItemId']; 32 32 $Values['CreationTime'] = 'NOW()'; 33 33 $Values['ValidTimeFrom'] = 'NOW()'; -
forms.php
r14 r19 35 35 ); 36 36 if($Context != '') $Context = $Context.'-'; 37 foreach($this->Definition['Items'] as $I tem)37 foreach($this->Definition['Items'] as $Index => $Item) 38 38 { 39 39 if($Item['Type'] != $TypeNames['Hidden']) -
global.php
r15 r19 166 166 while($Value > 1024) 167 167 { 168 $Value = round($Value / 1024 );168 $Value = round($Value / 1024, 3); 169 169 $UnitIndex++; 170 170 } -
page.php
r15 r19 7 7 'index.php' => '', 8 8 ); 9 10 function __construct() 11 { 12 $this->TimeStart = GetMicrotime(); // Get script start time 13 } 9 14 10 15 function SystemMessage($Title, $Text) … … 17 22 function ShowHeader($Title, $Path, $BodyParam = '') 18 23 { 19 $this->Time_Start = GetMicrotime(); // Get script start time20 24 $ScriptName = $_SERVER['SCRIPT_NAME']; 21 25 while(strpos($ScriptName, '//') !== false) … … 28 32 array_shift($ScriptNameParts); 29 33 foreach($ScriptNameParts as $ScriptNamePart) 30 { 34 { 31 35 //echo($ScriptNamePart.'<br>'); 32 36 if(array_key_exists($ScriptNamePart, $PathTreeItem)) … … 59 63 function ShowFooter() 60 64 { 61 $Time = floor((GetMicrotime() - $this->Time _Start) * 100) / 100;65 $Time = floor((GetMicrotime() - $this->TimeStart) * 100) / 100; 62 66 $Output = '<div id="Footer"> 63 <i>| Správa webu: '.$this->System->Config['Web']['Admin'].' | e-mail: '.$this->System->Config['Web']['AdminEmail'].' | Vygenerováno za '.$Time.' s | Verze: 1.1 | Úprava skriptu: '.date('j.n.Y',filemtime($_SERVER['SCRIPT_FILENAME'])).' |</i></div></body></html>';67 <i>| Správa webu: '.$this->System->Config['Web']['Admin'].' | e-mail: '.$this->System->Config['Web']['AdminEmail'].' | Vygenerováno za '.$Time.' s | Použitá paměť: '.HumanSize(memory_get_peak_usage(FALSE)).' |</i></div></body></html>'; 64 68 return($Output); 65 69 } … … 69 73 $Output = $this->Show(); 70 74 $Output = $this->ShowHeader($this->FullTitle, $this->ShortTitle).$Output; 71 //$Output .= $this->ShowFooter();75 $Output .= $this->ShowFooter(); 72 76 //$Output = $this->FormatOutput($Output); 73 77 echo($Output); -
style.css
r15 r19 132 132 padding: 8px; 133 133 } 134 135 #Footer 136 { 137 border-style: solid; 138 border-top-color: gray; 139 border-width: 1px 0 0 0; 140 margin-top: 7px; 141 padding-top: 2px; 142 font-size: 10px; 143 text-align: center; 144 } -
types/Boolean.php
r11 r19 1 1 <?php 2 2 3 function TypeBooleanOnView($Item) 3 class TypeBoolean 4 4 { 5 if($Item['Value'] == 1) $Checked = ' checked="1"'; else $Checked = ''; 6 return('<input type="checkbox" name="'.$Item['Name'].'" disabled="1"'.$Checked.'>'); 5 function OnView($Item) 6 { 7 if($Item['Value'] == 1) $Checked = ' checked="1"'; else $Checked = ''; 8 return('<input type="checkbox" name="'.$Item['Name'].'" disabled="1"'.$Checked.'>'); 9 } 10 11 function OnEdit($Item) 12 { 13 if($Item['Value'] == 1) $Checked = ' checked="1"'; else $Checked = ''; 14 return('<input type="checkbox" name="'.$Item['Name'].'"'.$Checked.'>'); 15 } 16 17 function OnLoad($Item) 18 { 19 if(array_key_exists($Item['Name'], $_POST)) return(1); else return(0); 20 } 7 21 } 8 22 9 function TypeBooleanOnEdit($Item) 10 { 11 if($Item['Value'] == 1) $Checked = ' checked="1"'; else $Checked = ''; 12 return('<input type="checkbox" name="'.$Item['Name'].'"'.$Checked.'>'); 13 } 14 15 function TypeBooleanOnLoad($Item) 16 { 17 if(array_key_exists($Item['Name'], $_POST)) return(1); else return(0); 18 } 23 $TypeDefinitionList['Boolean'] = new TypeBoolean; 19 24 20 25 ?> -
types/Date.php
r14 r19 1 1 <?php 2 2 3 function TypeDateOnView($Item) 3 class TypeDate 4 4 { 5 global $MonthNames; 5 function OnView($Item) 6 { 7 global $MonthNames; 6 8 7 $Parts = explode('-', $Item['Value']);9 $Parts = explode('-', $Item['Value']); 8 10 9 $Output = ($Parts[2] * 1).'.'.$MonthNames[$Parts[1] * 1].' '.$Parts[0]; 10 return($Output); 11 $Output = ($Parts[2] * 1).'.'.$MonthNames[$Parts[1] * 1].' '.$Parts[0]; 12 return($Output); 13 } 14 15 function OnEdit($Item) 16 { 17 global $MonthNames; 18 19 $Parts = explode('-', $Item['Value']); 20 21 // Day 22 $Output = '<select name="'.$Item['Name'].'-day">'; 23 for($I = 1; $I <= 31; $I++) 24 { 25 if($Parts[2] == $I) $Selected = ' selected="1"'; else $Selected = ''; 26 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 27 } 28 $Output .= '</select>'; 29 // Month 30 $Output .= '<select name="'.$Item['Name'].'-month">'; 31 for($I = 1; $I <= 12; $I++) 32 { 33 if($Parts[1] == $I) $Selected = ' selected="1"'; else $Selected = ''; 34 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$MonthNames[$I].'</option>'; 35 } 36 $Output .= '</select>'; 37 // Year 38 $Output .= '<select name="'.$Item['Name'].'-year">'; 39 for($I = 1900; $I < 2100; $I++) 40 { 41 if($Parts[0] == $I) $Selected = ' selected="1"'; else $Selected = ''; 42 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 43 } 44 $Output .= '</select>'; 45 return($Output); 46 } 47 48 function OnLoad($Item) 49 { 50 return($_POST[$Item['Name'].'-year'].'-'.$_POST[$Item['Name'].'-month'].'-'.$_POST[$Item['Name'].'-day']); 51 } 11 52 } 12 53 13 function TypeDateOnEdit($Item) 14 { 15 global $MonthNames; 16 17 $Parts = explode('-', $Item['Value']); 18 19 // Day 20 $Output = '<select name="'.$Item['Name'].'-day">'; 21 for($I = 1; $I <= 31; $I++) 22 { 23 if($Parts[2] == $I) $Selected = ' selected="1"'; else $Selected = ''; 24 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 25 } 26 $Output .= '</select>'; 27 // Month 28 $Output .= '<select name="'.$Item['Name'].'-month">'; 29 for($I = 1; $I <= 12; $I++) 30 { 31 if($Parts[1] == $I) $Selected = ' selected="1"'; else $Selected = ''; 32 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$MonthNames[$I].'</option>'; 33 } 34 $Output .= '</select>'; 35 // Year 36 $Output .= '<select name="'.$Item['Name'].'-year">'; 37 for($I = 1900; $I < 2100; $I++) 38 { 39 if($Parts[0] == $I) $Selected = ' selected="1"'; else $Selected = ''; 40 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 41 } 42 $Output .= '</select>'; 43 return($Output); 44 } 45 46 function TypeDateOnLoad($Item) 47 { 48 return($_POST[$Item['Name'].'-year'].'-'.$_POST[$Item['Name'].'-month'].'-'.$_POST[$Item['Name'].'-day']); 49 } 54 $TypeDefinitionList['Date'] = new TypeDate; 50 55 51 56 ?> -
types/DateTime.php
r14 r19 1 1 <?php 2 2 3 function TypeDateTimeOnView($Item) 3 class TypeDateTime 4 4 { 5 global $MonthNames; 5 function OnView($Item) 6 { 7 global $MonthNames; 6 8 7 $ValueParts = explode(' ', $Item['Value']);8 $DateParts = explode('-', $ValueParts[0]);9 $TimeParts = explode(':', $ValueParts[1]);9 $ValueParts = explode(' ', $Item['Value']); 10 $DateParts = explode('-', $ValueParts[0]); 11 $TimeParts = explode(':', $ValueParts[1]); 10 12 11 $Output = $TimeParts[0].':'.$TimeParts[1].':'.$TimeParts[2].' '.($DateParts[2] * 1).'. '.$MonthNames[$DateParts[1] * 1].' '.$DateParts[0]; 12 return($Output); 13 $Output = $TimeParts[0].':'.$TimeParts[1].':'.$TimeParts[2].' '.($DateParts[2] * 1).'. '.$MonthNames[$DateParts[1] * 1].' '.$DateParts[0]; 14 return($Output); 15 } 16 17 function OnEdit($Item) 18 { 19 global $MonthNames; 20 21 $ValueParts = explode(' ', $Item['Value']); 22 $DateParts = explode('-', $ValueParts[0]); 23 $TimeParts = explode(':', $ValueParts[1]); 24 25 // Hour 26 $Output = '<select name="'.$Item['Name'].'-hour">'; 27 for($I = 1; $I <= 24; $I++) 28 { 29 if($TimeParts[2] == $I) $Selected = ' selected="1"'; else $Selected = ''; 30 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 31 } 32 $Output .= '</select>'; 33 // Minute 34 $Output .= '<select name="'.$Item['Name'].'-minute">'; 35 for($I = 1; $I <= 60; $I++) 36 { 37 if($TimeParts[1] == $I) $Selected = ' selected="1"'; else $Selected = ''; 38 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 39 } 40 $Output .= '</select>'; 41 // Second 42 $Output .= '<select name="'.$Item['Name'].'-second">'; 43 for($I = 1; $I <= 60; $I++) 44 { 45 if($TimeParts[0] == $I) $Selected = ' selected="1"'; else $Selected = ''; 46 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 47 } 48 $Output .= '</select>'; 49 // Day 50 $Output .= ' <select name="'.$Item['Name'].'-day">'; 51 for($I = 1; $I <= 31; $I++) 52 { 53 if($DateParts[2] == $I) $Selected = ' selected="1"'; else $Selected = ''; 54 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 55 } 56 $Output .= '</select>'; 57 // Month 58 $Output .= '<select name="'.$Item['Name'].'-month">'; 59 for($I = 1; $I <= 12; $I++) 60 { 61 if($DateParts[1] == $I) $Selected = ' selected="1"'; else $Selected = ''; 62 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$MonthNames[$I].'</option>'; 63 } 64 $Output .= '</select>'; 65 // Year 66 $Output .= '<select name="'.$Item['Name'].'-year">'; 67 for($I = 1900; $I < 2100; $I++) 68 { 69 if($DateParts[0] == $I) $Selected = ' selected="1"'; else $Selected = ''; 70 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 71 } 72 $Output .= '</select>'; 73 return($Output); 74 } 75 76 function OnLoad($Item) 77 { 78 return($_POST[$Item['Name'].'-year'].'-'.$_POST[$Item['Name'].'-month'].'-'.$_POST[$Item['Name'].'-day'].' '. 79 $_POST[$Item['Name'].'-hour'].':'.$_POST[$Item['Name'].'-minute'].':'.$_POST[$Item['Name'].'-second']); 80 } 13 81 } 14 82 15 function TypeDateTimeOnEdit($Item) 16 { 17 global $MonthNames; 18 19 $ValueParts = explode(' ', $Item['Value']); 20 $DateParts = explode('-', $ValueParts[0]); 21 $TimeParts = explode(':', $ValueParts[1]); 22 23 // Hour 24 $Output = '<select name="'.$Item['Name'].'-hour">'; 25 for($I = 1; $I <= 24; $I++) 26 { 27 if($TimeParts[2] == $I) $Selected = ' selected="1"'; else $Selected = ''; 28 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 29 } 30 $Output .= '</select>'; 31 // Minute 32 $Output .= '<select name="'.$Item['Name'].'-minute">'; 33 for($I = 1; $I <= 60; $I++) 34 { 35 if($TimeParts[1] == $I) $Selected = ' selected="1"'; else $Selected = ''; 36 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 37 } 38 $Output .= '</select>'; 39 // Second 40 $Output .= '<select name="'.$Item['Name'].'-second">'; 41 for($I = 1; $I <= 60; $I++) 42 { 43 if($TimeParts[0] == $I) $Selected = ' selected="1"'; else $Selected = ''; 44 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 45 } 46 $Output .= '</select>'; 47 // Day 48 $Output .= ' <select name="'.$Item['Name'].'-day">'; 49 for($I = 1; $I <= 31; $I++) 50 { 51 if($DateParts[2] == $I) $Selected = ' selected="1"'; else $Selected = ''; 52 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 53 } 54 $Output .= '</select>'; 55 // Month 56 $Output .= '<select name="'.$Item['Name'].'-month">'; 57 for($I = 1; $I <= 12; $I++) 58 { 59 if($DateParts[1] == $I) $Selected = ' selected="1"'; else $Selected = ''; 60 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$MonthNames[$I].'</option>'; 61 } 62 $Output .= '</select>'; 63 // Year 64 $Output .= '<select name="'.$Item['Name'].'-year">'; 65 for($I = 1900; $I < 2100; $I++) 66 { 67 if($DateParts[0] == $I) $Selected = ' selected="1"'; else $Selected = ''; 68 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 69 } 70 $Output .= '</select>'; 71 return($Output); 72 } 73 74 function TypeDateTimeOnLoad($Item) 75 { 76 return($_POST[$Item['Name'].'-year'].'-'.$_POST[$Item['Name'].'-month'].'-'.$_POST[$Item['Name'].'-day'].' '. 77 $_POST[$Item['Name'].'-hour'].':'.$_POST[$Item['Name'].'-minute'].':'.$_POST[$Item['Name'].'-second']); 78 } 83 $TypeDefinitionList['DateTime'] = new TypeDateTime; 79 84 80 85 ?> -
types/Enumeration.php
r11 r19 1 1 <?php 2 2 3 function TypeEnumerationOnView($Item) 3 class TypeEnumeration 4 4 { 5 global $Types; 5 function OnView($Item) 6 { 7 global $Types; 6 8 7 $Output = $Types[$Item['Type']]['Parameters'][$Item['Value']]; 8 return($Output); 9 $Output = $Types[$Item['Type']]['Parameters'][$Item['Value']]; 10 return($Output); 11 } 12 13 function OnEdit($Item) 14 { 15 global $Types; 16 17 $Output = '<select name="'.$Item['Name'].'">'; 18 foreach($Types[$Item['Type']]['Parameters'] as $Index => $StateName) 19 { 20 if($Item['Value'] == $Index) $Selected = ' selected="1"'; else $Selected = ''; 21 $Output .= '<option value="'.$Index.'"'.$Selected.'>'.$StateName.'</option>'; 22 } 23 $Output .= '</select>'; 24 return($Output); 25 } 26 27 function OnLoad($Item) 28 { 29 return($_POST[$Item['Name']]); 30 } 9 31 } 10 32 11 function TypeEnumerationOnEdit($Item) 12 { 13 global $Types; 14 15 $Output = '<select name="'.$Item['Name'].'">'; 16 foreach($Types[$Item['Type']]['Parameters'] as $Index => $StateName) 17 { 18 if($Item['Value'] == $Index) $Selected = ' selected="1"'; else $Selected = ''; 19 $Output .= '<option value="'.$Index.'"'.$Selected.'>'.$StateName.'</option>'; 20 } 21 $Output .= '</select>'; 22 return($Output); 23 } 24 25 function TypeEnumerationOnLoad($Item) 26 { 27 return($_POST[$Item['Name']]); 28 } 33 $TypeDefinitionList['Enumeration'] = new TypeEnumeration; 29 34 30 35 ?> -
types/Float.php
r14 r19 1 1 <?php 2 2 3 function TypeFloatOnView($Item) 3 class TypeFloat 4 4 { 5 $Output = $Item['Value']; 6 return($Output); 5 function OnView($Item) 6 { 7 $Output = $Item['Value']; 8 return($Output); 9 } 10 11 function OnEdit($Item) 12 { 13 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'">'; 14 return($Output); 15 } 16 17 function OnLoad($Item) 18 { 19 return($_POST[$Item['Name']]); 20 } 7 21 } 8 22 9 function TypeFloatOnEdit($Item) 10 { 11 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'">'; 12 return($Output); 13 } 14 15 function TypeFloatOnLoad($Item) 16 { 17 return($_POST[$Item['Name']]); 18 } 23 $TypeDefinitionList['Float'] = new TypeFloat; 19 24 20 25 ?> -
types/GPS.php
r18 r19 1 1 <?php 2 2 3 function TypeGPSOnView($Item) 3 class TypeGPS 4 4 { 5 global $Database; 5 function OnView($Item) 6 { 7 global $Database; 6 8 7 $DbResult = $Database->query('SELECT * FROM `SystemGPS` WHERE `Id`='.$Item['Value']);8 if($DbResult->num_rows > 0)9 {10 $DbRow = $DbResult->fetch_assoc();11 $Longitude = TypeGPSExplode($DbRow['Longitude']);12 $Latitude = TypeGPSExplode($DbRow['Latitude']);13 $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>';14 }15 return($Output);16 }17 18 function TypeGPSOnEdit($Item)19 {20 global $Database;21 22 if($Item['Value'] != '')23 {24 9 $DbResult = $Database->query('SELECT * FROM `SystemGPS` WHERE `Id`='.$Item['Value']); 25 10 if($DbResult->num_rows > 0) 26 11 { 27 12 $DbRow = $DbResult->fetch_assoc(); 13 $Longitude = $this->Explode($DbRow['Longitude']); 14 $Latitude = $this->Explode($DbRow['Latitude']); 15 $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>'; 16 } 17 return($Output); 18 } 19 20 function OnEdit($Item) 21 { 22 global $Database; 23 24 if($Item['Value'] != '') 25 { 26 $DbResult = $Database->query('SELECT * FROM `SystemGPS` WHERE `Id`='.$Item['Value']); 27 if($DbResult->num_rows > 0) 28 { 29 $DbRow = $DbResult->fetch_assoc(); 30 } else $DbRow = array('Longitude' => 0, 'Latitude' => 0); 28 31 } else $DbRow = array('Longitude' => 0, 'Latitude' => 0); 29 } else $DbRow = array('Longitude' => 0, 'Latitude' => 0); 30 $Value = TypeGPSExplode($DbRow['Latitude']); 31 $Output = '<input type="text" size="3" name="'.$Item['Name'].'-lat-deg" value="'.$Value[0].'">°'; 32 $Output .= '<input type="text" size="3" name="'.$Item['Name'].'-lat-min" value="'.$Value[1].'">\''; 33 $Output .= '<input type="text" size="3" name="'.$Item['Name'].'-lat-sec" value="'.$Value[2].'">"<br />'; 34 $Value = TypeGPSExplode($DbRow['Longitude']); 35 $Output .= '<input type="text" size="3" name="'.$Item['Name'].'-lon-deg" value="'.$Value[0].'">°'; 36 $Output .= '<input type="text" size="3" name="'.$Item['Name'].'-lon-min" value="'.$Value[1].'">\''; 37 $Output .= '<input type="text" size="3" name="'.$Item['Name'].'-lon-sec" value="'.$Value[2].'">"'; 38 return($Output); 32 $Value = $this->Explode($DbRow['Latitude']); 33 $Output = '<input type="text" size="3" name="'.$Item['Name'].'-lat-deg" value="'.$Value[0].'">°'; 34 $Output .= '<input type="text" size="3" name="'.$Item['Name'].'-lat-min" value="'.$Value[1].'">\''; 35 $Output .= '<input type="text" size="3" name="'.$Item['Name'].'-lat-sec" value="'.$Value[2].'">"<br />'; 36 $Value = $this->Explode($DbRow['Longitude']); 37 $Output .= '<input type="text" size="3" name="'.$Item['Name'].'-lon-deg" value="'.$Value[0].'">°'; 38 $Output .= '<input type="text" size="3" name="'.$Item['Name'].'-lon-min" value="'.$Value[1].'">\''; 39 $Output .= '<input type="text" size="3" name="'.$Item['Name'].'-lon-sec" value="'.$Value[2].'">"'; 40 return($Output); 41 } 42 43 function OnLoad($Item) 44 { 45 global $Database; 46 47 $Latitude = $this->Implode($_POST[$Item['Name'].'-lat-deg'], $_POST[$Item['Name'].'-lat-min'], $_POST[$Item['Name'].'-lat-sec']); 48 $Longitude = $this->Implode($_POST[$Item['Name'].'-lon-deg'], $_POST[$Item['Name'].'-lon-min'], $_POST[$Item['Name'].'-lon-sec']); 49 $Database->query('INSERT INTO SystemGPS (`Latitude`, `Longitude`) VALUES ("'.$Latitude.'", "'.$Longitude.'")'); 50 return($Database->insert_id); 51 } 52 53 function Explode($Float) 54 { 55 $Degrees = intval($Float); 56 $Float = abs($Float); 57 $Float = ($Float - intval($Float)) * 60; 58 $Minutes = intval($Float); 59 $Float = ($Float - intval($Float)) * 60; 60 $Seconds = round($Float, 3); 61 return(array($Degrees, $Minutes, $Seconds)); 62 } 63 64 function Implode($Degrees, $Minutes, $Seconds) 65 { 66 if($Degrees < 0) return(-(abs($Degrees) + ($Minutes + $Seconds / 60) / 60)); 67 else return($Degrees + ($Minutes + $Seconds / 60) / 60); 68 } 39 69 } 40 70 41 function TypeGPSOnLoad($Item) 42 { 43 global $Database; 44 45 $Latitude = TypeGPSImplode($_POST[$Item['Name'].'-lat-deg'], $_POST[$Item['Name'].'-lat-min'], $_POST[$Item['Name'].'-lat-sec']); 46 $Longitude = TypeGPSImplode($_POST[$Item['Name'].'-lon-deg'], $_POST[$Item['Name'].'-lon-min'], $_POST[$Item['Name'].'-lon-sec']); 47 $Database->query('INSERT INTO SystemGPS (`Latitude`, `Longitude`) VALUES ("'.$Latitude.'", "'.$Longitude.'")'); 48 return($Database->insert_id); 49 } 50 51 function TypeGPSExplode($Float) 52 { 53 $Degrees = intval($Float); 54 $Float = abs($Float); 55 $Float = ($Float - intval($Float)) * 60; 56 $Minutes = intval($Float); 57 $Float = ($Float - intval($Float)) * 60; 58 $Seconds = round($Float, 3); 59 return(array($Degrees, $Minutes, $Seconds)); 60 } 61 62 function TypeGPSImplode($Degrees, $Minutes, $Seconds) 63 { 64 if($Degrees < 0) return(-(abs($Degrees) + ($Minutes + $Seconds / 60) / 60)); 65 else return($Degrees + ($Minutes + $Seconds / 60) / 60); 66 } 71 $TypeDefinitionList['GPS'] = new TypeGPS; 67 72 68 73 ?> -
types/Hidden.php
r11 r19 1 1 <?php 2 2 3 function TypeHiddenOnView($Item) 3 class TypeHidden 4 4 { 5 $Output = $Item['Value']; 6 return($Output); 5 function OnView($Item) 6 { 7 $Output = $Item['Value']; 8 return($Output); 9 } 10 11 function OnEdit($Item) 12 { 13 $Output = '<input type="hidden" name="'.$Item['Name'].'" value="'.$Item['Value'].'">'; 14 return($Output); 15 } 16 17 function OnLoad($Item) 18 { 19 return($_POST[$Item['Name']]); 20 } 7 21 } 8 22 9 function TypeHiddenOnEdit($Item) 10 { 11 $Output = '<input type="hidden" name="'.$Item['Name'].'" value="'.$Item['Value'].'">'; 12 return($Output); 13 } 14 15 function TypeHiddenOnLoad($Item) 16 { 17 return($_POST[$Item['Name']]); 18 } 23 $TypeDefinitionList['Hidden'] = new TypeHidden; 19 24 20 25 ?> -
types/Hyperlink.php
r11 r19 1 1 <?php 2 2 3 function TypeHyperlinkOnView($Item) 3 class TypeHyperlink 4 4 { 5 $Output = '<a href="'.$Item['Value'].'">'.$Item['Value'].'</a>'; 6 return($Output); 5 function OnView($Item) 6 { 7 $Output = '<a href="'.$Item['Value'].'">'.$Item['Value'].'</a>'; 8 return($Output); 9 } 10 11 function OnEdit($Item) 12 { 13 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'">'; 14 return($Output); 15 } 16 17 function OnLoad($Item) 18 { 19 return($_POST[$Item['Name']]); 20 } 7 21 } 8 22 9 function TypeHyperlinkOnEdit($Item) 10 { 11 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'">'; 12 return($Output); 13 } 14 15 function TypeHyperlinkOnLoad($Item) 16 { 17 return($_POST[$Item['Name']]); 18 } 23 $TypeDefinitionList['Hyperlink'] = new TypeHyperlink; 19 24 20 25 ?> -
types/IPv4Address.php
r11 r19 1 1 <?php 2 2 3 function TypeIPv4AddressOnView($Item) 3 class TypeIPv4Address 4 4 { 5 $Output = $Item['Value']; 6 return($Output); 5 function OnView($Item) 6 { 7 $Output = $Item['Value']; 8 return($Output); 9 } 10 11 function OnEdit($Item) 12 { 13 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'">'; 14 return($Output); 15 } 16 17 function OnLoad($Item) 18 { 19 return($_POST[$Item['Name']]); 20 } 7 21 } 8 22 9 function TypeIPv4AddressOnEdit($Item) 10 { 11 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'">'; 12 return($Output); 13 } 23 $TypeDefinitionList['TypeIPv4Address'] = new TypeIPv4Address; 14 24 15 function TypeIPv4AddressOnCheck($Parameter, $Table, $Id)16 {17 return(true);18 }19 20 function TypeIPv4AddressOnLoad($Item)21 {22 return($_POST[$Item['Name']]);23 }24 25 ?> -
types/Integer.php
r11 r19 1 1 <?php 2 2 3 function TypeIntegerOnView($Item) 3 class TypeInteger 4 4 { 5 $Output = $Item['Value']; 6 return($Output); 5 function OnView($Item) 6 { 7 $Output = $Item['Value']; 8 return($Output); 9 } 10 11 function OnEdit($Item) 12 { 13 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'">'; 14 return($Output); 15 } 16 17 function OnLoad($Item) 18 { 19 return($_POST[$Item['Name']]); 20 } 7 21 } 8 22 9 function TypeIntegerOnEdit($Item) 10 { 11 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'">'; 12 return($Output); 13 } 14 15 function TypeIntegerOnLoad($Item) 16 { 17 return($_POST[$Item['Name']]); 18 } 23 $TypeDefinitionList['Integer'] = new TypeInteger; 19 24 20 25 ?> -
types/Password.php
r18 r19 3 3 // SHA1 hash used 4 4 5 function TypePasswordOnView($Item) 5 class TypePassword 6 6 { 7 $Output = ''; 8 for($I = 0; $I < 6; $I++) 9 $Output .= '*'; 10 return($Output); 7 function OnView($Item) 8 { 9 $Output = ''; 10 for($I = 0; $I < 6; $I++) 11 $Output .= '*'; 12 return($Output); 13 } 14 15 function OnEdit($Item) 16 { 17 $Output = '<input type="password" name="'.$Item['Name'].'" value="">'; 18 return($Output); 19 } 20 21 function OnLoad($Item) 22 { 23 global $Database; 24 25 if(!array_key_exists('SourceItemId', $Item)) $Result = sha1($_POST[$Item['Name']]); 26 else 27 { 28 $DbRestult = $Database->query('SELECT '.$Item['Name'].' FROM '.$Item['SourceTable'].' WHERE Id='.$Item['SourceItemId']); 29 if($DbResult->num_rows > 0) 30 { 31 $DbRow = $DbResult->fetch_assoc(); 32 if($_POST[$Item['Name']] == '') $Result = $DbRow[$Item['Name']]; 33 else $Result = sha1($_POST[$Item['Name']]); 34 } else $Result = sha1($_POST[$Item['Name']]); 35 } 36 return($Result); 37 } 11 38 } 12 39 13 function TypePasswordOnEdit($Item) 14 { 15 $Output = '<input type="password" name="'.$Item['Name'].'" value="">'; 16 return($Output); 17 } 18 19 function TypePasswordOnLoad($Item) 20 { 21 global $Database; 22 23 if(!array_key_exists('SourceItemId', $Item)) $Result = sha1($_POST[$Item['Name']]); 24 else 25 { 26 $DbRestult = $Database->query('SELECT '.$Item['Name'].' FROM '.$Item['SourceTable'].' WHERE Id='.$Item['SourceItemId']); 27 if($DbResult->num_rows > 0) 28 { 29 $DbRow = $DbResult->fetch_assoc(); 30 if($_POST[$Item['Name']] == '') $Result = $DbRow[$Item['Name']]; 31 else $Result = sha1($_POST[$Item['Name']]); 32 } else $Result = sha1($_POST[$Item['Name']]); 33 } 34 return($Result); 35 } 40 $TypeDefinitionList['Password'] = new TypePassword; 36 41 37 42 ?> -
types/PointerOneToMany.php
r11 r19 1 1 <?php 2 2 3 function TypePointerOneToManyOnView($Item) 3 class TypePointerOneToMany 4 4 { 5 $Output = '<a href="?Action=ShowList&TableId='.$Type['TypeDefinition'].'&ParentTable='.$Item['SourceTable'].'&ParentColumn='.$Item['SourceItemId'].'">Seznam</a>'; 6 return($Output); 5 function OnView($Item) 6 { 7 $Output = '<a href="?Action=ShowList&TableId='.$Type['TypeDefinition'].'&ParentTable='.$Item['SourceTable'].'&ParentColumn='.$Item['SourceItemId'].'">Seznam</a>'; 8 return($Output); 9 } 10 11 function OnEdit($Item) 12 { 13 $Output = '<a href="?Action=ShowList&TableId='.$Type['TypeDefinition'].'&ParentTable='.$Item['SourceTable'].'&ParentColumn='.$Item['SourceItemId'].'">Seznam</a>'; 14 return($Output); 15 } 16 17 function OnLoad($Item) 18 { 19 return($_POST[$Item['Name']]); 20 } 7 21 } 8 22 9 function TypePointerOneToManyOnEdit($Item) 10 { 11 $Output = '<a href="?Action=ShowList&TableId='.$Type['TypeDefinition'].'&ParentTable='.$Item['SourceTable'].'&ParentColumn='.$Item['SourceItemId'].'">Seznam</a>'; 12 return($Output); 13 } 14 15 function TypePointerOneToManyOnLoad($Item) 16 { 17 return($_POST[$Item['Name']]); 18 } 23 $TypeDefinitionList['PointerOneToMany'] = new TypePointerOneToMany; 19 24 20 25 ?> -
types/PointerOneToOne.php
r18 r19 1 1 <?php 2 2 3 function GetTablePointerName($Type, $Item) 3 class TypePointerOneToOne 4 4 { 5 global $Database, $Lists; 5 function GetTablePointerName($Type, $Item) 6 { 7 global $Database, $Lists; 6 8 7 //print_r($Item);8 $Columns = '';9 $TargetTable = $Type['Parameters'][0];9 //print_r($Item); 10 $Columns = ''; 11 $TargetTable = $Type['Parameters'][0]; 10 12 11 foreach($Lists[$TargetTable]['Items'] as $ListItem) 12 if($ListItem['VisibleInPointer'] == 1) $Columns .= '`'.$ListItem['Name'].'`," ",'; 13 $Columns = 'CONCAT('.substr($Columns, 0, -1).') AS Name, ItemId, Id'; 14 $DbResult = $Database->select($TargetTable, $Columns, 'ItemId='.$Item['Value'].' AND (DeletionTime IS NULL) ORDER BY Id DESC LIMIT 1'); 15 //echo($Database->LastQuery); 16 if($DbResult->num_rows > 0) 13 foreach($Lists[$TargetTable]['Items'] as $ListItem) 14 if($ListItem['VisibleInPointer'] == 1) $Columns .= '`'.$ListItem['Name'].'`," ",'; 15 $Columns = 'CONCAT('.substr($Columns, 0, -1).') AS Name, ItemId, Id'; 16 $DbResult = $Database->select($TargetTable, $Columns, 'ItemId='.$Item['Value'].' AND (DeletionTime IS NULL) ORDER BY Id DESC LIMIT 1'); 17 //echo($Database->LastQuery); 18 if($DbResult->num_rows > 0) 19 { 20 return($DbResult->fetch_assoc()); 21 } else return(''); 22 } 23 24 function GetTablePointerNameList($Type, $Item) 17 25 { 18 return($DbResult->fetch_assoc()); 19 } else return(''); 26 global $Database, $Lists; 27 28 $Columns = ''; 29 $TargetTable = $Type['Parameters'][0]; 30 31 foreach($Lists[$TargetTable]['Items'] as $ListItem) 32 if($ListItem['VisibleInPointer'] == 1) $Columns .= 't1.`'.$ListItem['Name'].'`," ",'; 33 $Columns = 'CONCAT('.substr($Columns, 0, -1).') AS Name, t1.Id, t1.ItemId, t1.DeletionTime'; 34 $DbResult = $Database->query('SELECT t3.* FROM (SELECT '.$Columns.' FROM `'.$TargetTable.'` AS t1 LEFT JOIN `'.$TargetTable.'` AS t2 ON t1.ItemId=t2.ItemId AND t1.Id < t2.Id WHERE (t2.ItemId IS NULL)) AS t3 WHERE t3.DeletionTime IS NULL'); 35 //echo($Database->LastQuery); 36 if($DbResult->num_rows > 0) 37 { 38 $Result = array(array('Name' => 'Žádný', 'Id' => 0, 'ItemId' => 0)); 39 while($DbRow = $DbResult->fetch_assoc()) 40 $Result[] = $DbRow; 41 return($Result); 42 } else return(array()); 43 } 44 45 function OnView($Item) 46 { 47 global $Database, $Lists, $Types; 48 49 $Type = $Types[$Item['Type']]; 50 $TargetTable = $Type['Parameters'][0]; 51 $TargetName = $this->GetTablePointerName($Type, $Item); 52 $Output = '<a href="?Action=ViewItem&Table='.$TargetTable.'&Item='.$TargetName['ItemId'].'">'.$TargetName['Name'].'</a>'; 53 return($Output); 54 } 55 56 function OnEdit($Item) 57 { 58 global $Database, $Lists, $Types; 59 60 $Type = $Types[$Item['Type']]; 61 $Output = '<select name="'.$Item['Name'].'">'; 62 $TargetNameList = $this->GetTablePointerNameList($Type, $Item); 63 //echo($Database->LastQuery); 64 foreach($TargetNameList as $TargetName) 65 { 66 if($Item['Value'] == $TargetName['ItemId']) $Selected = ' selected="1"'; else $Selected = ''; 67 $Output .= '<option value="'.$TargetName['ItemId'].'"'.$Selected.'>'.$TargetName['Name'].'</option>'; 68 } 69 $Output .= '</select>'; 70 return($Output); 71 } 72 73 function OnLoad($Item) 74 { 75 return($_POST[$Item['Name']]); 76 } 20 77 } 21 78 22 function GetTablePointerNameList($Type, $Item) 23 { 24 global $Database, $Lists; 25 26 $Columns = ''; 27 $TargetTable = $Type['Parameters'][0]; 28 29 foreach($Lists[$TargetTable]['Items'] as $ListItem) 30 if($ListItem['VisibleInPointer'] == 1) $Columns .= 't1.`'.$ListItem['Name'].'`," ",'; 31 $Columns = 'CONCAT('.substr($Columns, 0, -1).') AS Name, t1.Id, t1.ItemId, t1.DeletionTime'; 32 $DbResult = $Database->query('SELECT t3.* FROM (SELECT '.$Columns.' FROM `'.$TargetTable.'` AS t1 LEFT JOIN `'.$TargetTable.'` AS t2 ON t1.ItemId=t2.ItemId AND t1.Id < t2.Id WHERE (t2.ItemId IS NULL)) AS t3 WHERE t3.DeletionTime IS NULL'); 33 //echo($Database->LastQuery); 34 if($DbResult->num_rows > 0) 35 { 36 $Result = array(array('Name' => 'Žádný', 'Id' => 0, 'ItemId' => 0)); 37 while($DbRow = $DbResult->fetch_assoc()) 38 $Result[] = $DbRow; 39 return($Result); 40 } else return(array()); 41 } 42 43 function TypePointerOneToOneOnView($Item) 44 { 45 global $Database, $Lists, $Types; 46 47 $Type = $Types[$Item['Type']]; 48 $TargetTable = $Type['Parameters'][0]; 49 $TargetName = GetTablePointerName($Type, $Item); 50 $Output = '<a href="?Action=ViewItem&Table='.$TargetTable.'&Item='.$TargetName['ItemId'].'">'.$TargetName['Name'].'</a>'; 51 return($Output); 52 } 53 54 function TypePointerOneToOneOnEdit($Item) 55 { 56 global $Database, $Lists, $Types; 57 58 $Type = $Types[$Item['Type']]; 59 $Output = '<select name="'.$Item['Name'].'">'; 60 $TargetNameList = GetTablePointerNameList($Type, $Item); 61 //echo($Database->LastQuery); 62 foreach($TargetNameList as $TargetName) 63 { 64 if($Item['Value'] == $TargetName['ItemId']) $Selected = ' selected="1"'; else $Selected = ''; 65 $Output .= '<option value="'.$TargetName['ItemId'].'"'.$Selected.'>'.$TargetName['Name'].'</option>'; 66 } 67 $Output .= '</select>'; 68 return($Output); 69 } 70 71 function TypePointerOneToOneOnLoad($Item) 72 { 73 return($_POST[$Item['Name']]); 74 } 79 $TypeDefinitionList['PointerOneToOne'] = new TypePointerOneToOne; 75 80 76 81 ?> -
types/String.php
r11 r19 1 1 <?php 2 2 3 function TypeStringOnView($Item) 3 class TypeString 4 4 { 5 $Output = $Item['Value']; 6 return($Output); 5 function OnView($Item) 6 { 7 $Output = $Item['Value']; 8 return($Output); 9 } 10 11 function OnEdit($Item) 12 { 13 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'">'; 14 return($Output); 15 } 16 17 function OnLoad($Item) 18 { 19 return($_POST[$Item['Name']]); 20 } 7 21 } 8 22 9 function TypeStringOnEdit($Item) 10 { 11 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'">'; 12 return($Output); 13 } 14 15 function TypeStringOnLoad($Item) 16 { 17 return($_POST[$Item['Name']]); 18 } 23 $TypeDefinitionList['String'] = new TypeString; 19 24 20 25 ?> -
types/include.php
r17 r19 14 14 include('types/Hyperlink.php'); 15 15 include('types/Hidden.php'); 16 include('types/File .php');16 include('types/File/File.php'); 17 17 include('types/GPS.php'); 18 18
Note:
See TracChangeset
for help on using the changeset viewer.