Changeset 501 for trunk/Common
- Timestamp:
- Mar 10, 2013, 8:15:46 PM (12 years ago)
- Location:
- trunk/Common
- Files:
-
- 2 added
- 1 deleted
- 11 edited
- 2 copied
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/Database.php
r486 r501 38 38 var $ShowSQLQuery = false; 39 39 40 function __construct($Host, $User, $Password, $Database) 40 function __construct() 41 { 42 } 43 44 function Connect($Host, $User, $Password, $Database) 41 45 { 42 46 if($this->Type == 'mysql') $ConnectionString = 'mysql:host='.$Host.';dbname='.$Database; … … 66 70 $this->Error = $this->Error[2]; 67 71 if(($this->Error != '') and ($this->ShowSQLError == true)) 68 echo('<div><strong>SQL Error: </strong>'.$this->Error.'<br />'.$Query.'</div>'); 72 //echo('<div><strong>SQL Error: </strong>'.$this->Error.'<br />'.$Query.'</div>'); 73 throw new Exception('SQL Error: </strong>'.$this->Error.', Query: '.$Query); 69 74 } 70 75 return($Result); -
trunk/Common/Error.php
r476 r501 4 4 { 5 5 var $Encoding; 6 var $ShowError; 7 var $UserErrors; 6 8 7 9 function __construct() 8 10 { 9 11 $this->Encoding = 'utf-8'; 12 $this->ShowError = false; 13 $this->UserErrors = E_ALL; //E_ERROR | E_WARNING | E_PARSE; 10 14 } 11 15 … … 17 21 function Handle($Number, $Message, $FileName, $LineNumber, $Variables) 18 22 { 19 global $Config; 23 $Date = date('Y-m-d H:i:s'); // časové razítko položky 24 $ErrorType = array 25 ( 26 1 => 'Error', 27 2 => 'Warning', 28 4 => 'Parsing Error', 29 8 => 'Notice', 30 16 => 'Core Error', 31 32 => 'Core Warning', 32 64 => 'Compile Error', 33 128 => 'Compile Warning', 34 256 => 'User Error', 35 512 => 'User Warning', 36 1024 => 'User Notice' 37 ); 20 38 21 $Date = date('Y-m-d H:i:s'); // časové razítko položky 22 $ErrorType = array 23 ( 24 1 => 'Error', 25 2 => 'Warning', 26 4 => 'Parsing Error', 27 8 => 'Notice', 28 16 => 'Core Error', 29 32 => 'Core Warning', 30 64 => 'Compile Error', 31 128 => 'Compile Warning', 32 256 => 'User Error', 33 512 => 'User Warning', 34 1024 => 'User Notice' 35 ); 36 $UserErrors = E_ALL; //E_ERROR | E_WARNING | E_PARSE; 37 38 if(($UserErrors & $Number)) 39 { 40 $Error = '# '.$Date."\n"; 41 $Backtrace = debug_backtrace(); 42 $Backtrace[0]['function'] = $Message; 43 $Backtrace[0]['args'] = ''; 44 $Backtrace[0]['file'] = $FileName; 45 $Backtrace[0]['line'] = $LineNumber; 46 //$First = array_shift($Backtrace); 47 //print_r($Backtrace); 39 if(($this->UserErrors & $Number)) 40 { 41 $Error = '# '.$Date."\n"; 42 $Backtrace = debug_backtrace(); 43 $Backtrace[0]['function'] = $Message; 44 $Backtrace[0]['args'] = ''; 45 $Backtrace[0]['file'] = $FileName; 46 $Backtrace[0]['line'] = $LineNumber; 47 //$First = array_shift($Backtrace); 48 48 49 //array_unshift($Backtrace, $First); 50 //array_shift($Backtrace); 51 //print_r($Backtrace); 52 foreach($Backtrace as $Item) 53 { 54 $Error .= ' '.$Item['file'].'('.$Item['line'].")\t".$Item['function']; 55 $Arguments = ''; 56 if(array_key_exists('args', $Item) and is_array($Item['args'])) 49 //array_unshift($Backtrace, $First); 50 //array_shift($Backtrace); 51 foreach($Backtrace as $Item) 52 { 53 $Error .= ' '.$Item['file'].'('.$Item['line'].")\t".$Item['function']; 54 $Arguments = ''; 55 if(array_key_exists('args', $Item) and is_array($Item['args'])) 57 56 foreach($Item['args'] as $Item) 58 57 { … … 61 60 else $Arguments .= "'".$Item."',"; 62 61 } 63 if(strlen($Arguments) > 0) $Error .= '('.substr($Arguments, 0, -1).')'; 62 if(strlen($Arguments) > 0) $Error .= '('.substr($Arguments, 0, -1).')'; 63 $Error .= "\n"; 64 } 64 65 $Error .= "\n"; 65 66 67 $this->System->Modules['Log']->NewRecord('Error', 'Log', $Error); 68 69 //if($Config['Web']['ErrorLogFile'] != '') 70 // error_log($Error, 3, $Config['Web']['ErrorLogFile']); 71 // Pošli mi zprávu (pokud je to kritická chyba) 72 //mail($Config['Web']['AdminEmail'], $Config['Web']['Title'].' - Chybové hlášení', $Error); 73 // Show error message 74 if($this->ShowError == true) 75 { 76 echo('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>'."\n". 77 '<meta http-equiv="Content-Language" content="cs">'."\n". 78 '<meta http-equiv="Content-Type" content="text/html; charset='.$this->Encoding.'"></head><body>'."\n". 79 'Došlo k vnitřní chybě!<br/> O chybě byl uvědoměn správce webu a chybu brzy odstraní.<br/><br/>'); 80 echo('<pre>'.$Error.'</pre><br/>'); // V případě ladění chybu i zobraz 81 echo('</body></html>'); 82 } 83 if((E_ERROR | E_PARSE) & $Number) die(); 66 84 } 67 $Error .= "\n";68 69 $this->System->Modules['Log']->NewRecord('Error', 'Log', $Error);70 71 //if($Config['Web']['ErrorLogFile'] != '')72 //error_log($Error, 3, $Config['Web']['ErrorLogFile']);73 // Pošli mi zprávu (pokud je to kritická chyba)74 //mail($Config['Web']['AdminEmail'], $Config['Web']['Title'].' - Chybové hlášení', $Error);75 // Show error message76 if($Config['Web']['ShowPHPError'] == true)77 {78 echo('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>'."\n".79 '<meta http-equiv="Content-Language" content="cs">'."\n".80 '<meta http-equiv="Content-Type" content="text/html; charset='.$this->Encoding.'"></head><body>'."\n".81 'Došlo k vnitřní chybě!<br/> O chybě byl uvědoměn správce webu a chybu brzy odstraní.<br/><br/>');82 echo('<pre>'.$Error.'</pre><br/>'); // V případě ladění chybu i zobraz83 echo('</body></html>');84 }85 if((E_ERROR | E_PARSE) & $Number) die();86 }87 85 } 88 86 } -
trunk/Common/Form/Form.php
r500 r501 1 1 <?php 2 2 3 include_once(dirname(__FILE__).'/../ form_classes.php');4 include_once(dirname(__FILE__).'/ Database.php');3 include_once(dirname(__FILE__).'/../Database.php'); 4 include_once(dirname(__FILE__).'/Types/Type.php'); 5 5 6 6 class Form 7 7 { 8 var $Definition = array(); 9 var $Values = array(); 10 var $OnSubmit = ''; 11 12 function __construct($ClassName) 13 { 14 global $FormClasses; 15 16 $this->Definition = &$FormClasses[$ClassName]; 17 } 8 var $FormManager; 9 var $Definition; 10 var $Values; 11 var $OnSubmit; 12 var $Database; 13 14 function __construct($FormManager) 15 { 16 $this->FormManager = &$FormManager; 17 $this->Database = $FormManager->Database; 18 $this->Definition = array(); 19 $this->Values = array(); 20 $this->OnSubmit = ''; 21 } 22 23 function SetClass($Name) 24 { 25 $this->Definition = &$this->FormManager->Classes[$Name]; 26 } 18 27 19 28 function ShowViewForm() 20 29 { 21 global $Database, $FormTypes, $System;22 23 30 $Table = array( 24 31 //'Header' => array('Položka', 'Hodnota'), … … 26 33 ); 27 34 foreach($this->Definition['Items'] as $Index => $Item) 28 if(!array_key_exists($Item['Type'], $FormTypes) or 29 (array_key_exists($Item['Type'], $FormTypes) and ($FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) 30 { 31 if(!array_key_exists($Index, $this->Values) and isset($Item['Default'])) $this->Values[$Index] = $Item['Default']; 32 if(array_key_exists($Item['Type'], $FormTypes)) 33 { 34 if(!array_key_exists($Item['Type'], $System->Type->TypeDefinitionList)) 35 $System->Type->RegisterType($Item['Type'], '', $FormTypes[$Item['Type']]); 36 if($FormTypes[$Item['Type']]['Type'] == 'Reference') 37 $UseType = 'OneToMany'; 38 else if($FormTypes[$Item['Type']]['Type'] == 'Enumeration') 35 if(!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 36 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 37 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) 38 { 39 if(!array_key_exists($Index, $this->Values) and isset($Item['Default'])) $this->Values[$Index] = $Item['Default']; 40 if(array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 41 { 42 if(!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 43 $this->FormManager->Type->RegisterType($Item['Type'], '', $this->FormManager->FormTypes[$Item['Type']]); 44 if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference') 45 $UseType = 'OneToMany'; 46 else if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration') 39 47 $UseType = 'Enumeration'; 40 48 } else $UseType = $Item['Type']; 41 $Edit = $ System->Type->ExecuteTypeEvent($UseType, 'OnView',49 $Edit = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnView', 42 50 array('Value' => $this->Values[$Index], 'Name' => $Index, 43 51 'Type' => $Item['Type'], 'Values' => $this->Values)); 44 52 if(array_key_exists('Suffix', $Item)) $Edit .= ' '.$Item['Suffix']; 45 if(!$ System->Type->IsHidden($UseType))53 if(!$this->FormManager->Type->IsHidden($UseType)) 46 54 array_push($Table['Rows'], array($Item['Caption'].':', $Edit)); 47 55 } … … 62 70 function ShowEditBlock($Context = '') 63 71 { 64 global $Database, $FormTypes, $System;65 66 72 $Hidden = ''; 67 73 $IsHidden = false; … … 75 81 if(!array_key_exists('ReadOnly', $Item)) $Item['ReadOnly'] = false; 76 82 if($Item['ReadOnly'] == false) 77 if(!array_key_exists($Item['Type'], $FormTypes) or 78 (array_key_exists($Item['Type'], $FormTypes) and ($FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) 83 if(!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 84 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 85 ($$this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) 79 86 { 80 87 if(!array_key_exists($Index, $this->Values) and isset($Item['Default'])) $this->Values[$Index] = $Item['Default']; … … 84 91 else unset($Parameters['Null']); 85 92 86 if(array_key_exists($Item['Type'], $ FormTypes))87 { 88 if(!array_key_exists($Item['Type'], $ System->Type->TypeDefinitionList))89 $ System->Type->RegisterType($Item['Type'], '',90 $ FormTypes[$Item['Type']]);91 if($ FormTypes[$Item['Type']]['Type'] == 'Reference')93 if(array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 94 { 95 if(!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 96 $this->FormManager->Type->RegisterType($Item['Type'], '', 97 $this->FormManager->FormTypes[$Item['Type']]); 98 if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference') 92 99 { 93 100 $UseType = 'OneToMany'; 94 } else if($ FormTypes[$Item['Type']]['Type'] == 'Enumeration')95 $UseType = 'Enumeration'; 96 } else $UseType = $Item['Type']; 97 $Edit = $ System->Type->ExecuteTypeEvent($UseType, 'OnEdit', $Parameters);101 } else if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration') 102 $UseType = 'Enumeration'; 103 } else $UseType = $Item['Type']; 104 $Edit = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnEdit', $Parameters); 98 105 if(array_key_exists('Suffix', $Item)) $Edit .= $Item['Suffix']; 99 106 100 if(!$ System->Type->IsHidden($UseType))107 if(!$this->FormManager->Type->IsHidden($UseType)) 101 108 array_push($Table['Rows'], array($Item['Caption'].':', $Edit)); 102 109 else $Hidden .= $Edit; … … 110 117 function LoadValuesFromDatabase($Id) 111 118 { 112 global $Database, $FormTypes, $System; 113 114 $DbResult = $Database->query('SELECT T.* FROM '.$this->Definition['Table'].' AS T WHERE T.Id='.$Id); 119 $DbResult = $this->Database->query('SELECT T.* FROM '.$this->Definition['Table'].' AS T WHERE T.Id='.$Id); 115 120 $DbRow = $DbResult->fetch_array(); 116 121 foreach($this->Definition['Items'] as $Index => $Item) 117 if(!array_key_exists($Item['Type'], $FormTypes) or 118 (array_key_exists($Item['Type'], $FormTypes) and ($FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) 119 { 120 if(!array_key_exists($Index, $this->Values) and isset($Item['Default'])) $this->Values[$Index] = $Item['Default']; 121 if(array_key_exists($Item['Type'], $FormTypes)) 122 { 123 if(!array_key_exists($Item['Type'], $System->Type->TypeDefinitionList)) 124 $System->Type->RegisterType($Item['Type'], '', 125 $FormTypes[$Item['Type']]); 126 if($FormTypes[$Item['Type']]['Type'] == 'Reference') 127 $UseType = 'OneToMany'; 128 else if($FormTypes[$Item['Type']]['Type'] == 'Enumeration') 129 $UseType = 'Enumeration'; 130 } else $UseType = $Item['Type']; 131 $this->Values[$Index] = $System->Type->ExecuteTypeEvent($UseType, 'OnLoadDb', 122 if(!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 123 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 124 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) 125 { 126 if(!array_key_exists($Index, $this->Values) and isset($Item['Default'])) $this->Values[$Index] = $Item['Default']; 127 if(array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 128 { 129 if(!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 130 $this->FormManager->Type->RegisterType($Item['Type'], '', 131 $this->FormManager->FormTypes[$Item['Type']]); 132 if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference') 133 $UseType = 'OneToMany'; 134 else if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration') 135 $UseType = 'Enumeration'; 136 } else $UseType = $Item['Type']; 137 $this->Values[$Index] = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnLoadDb', 132 138 array('Value' => $DbRow[$Index], 'Name' => $Index, 133 139 'Type' => $Item['Type'], 'Values' => $this->Values)); … … 139 145 function SaveValuesToDatabase($Id) 140 146 { 141 global $Database, $FormTypes, $System;142 143 147 $Values = array(); 144 148 foreach($this->Definition['Items'] as $Index => $Item) … … 146 150 if(!array_key_exists('ReadOnly', $Item)) $Item['ReadOnly'] = false; 147 151 if($Item['ReadOnly'] == false) 148 if(!array_key_exists($Item['Type'], $FormTypes) or 149 (array_key_exists($Item['Type'], $FormTypes) and ($FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) 152 if(!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 153 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 154 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) 150 155 { 151 156 if(!array_key_exists($Index, $this->Values) and isset($Item['Default'])) $this->Values[$Index] = $Item['Default']; … … 153 158 'Type' => $Item['Type'], 'Values' => $this->Values); 154 159 155 if(array_key_exists($Item['Type'], $ FormTypes))156 { 157 if(!array_key_exists($Item['Type'], $ System->Type->TypeDefinitionList))158 $ System->Type->RegisterType($Item['Type'], '',159 $ FormTypes[$Item['Type']]);160 if($ FormTypes[$Item['Type']]['Type'] == 'Reference')160 if(array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 161 { 162 if(!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 163 $this->FormManager->Type->RegisterType($Item['Type'], '', 164 $this->FormManager->FormTypes[$Item['Type']]); 165 if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference') 161 166 { 162 167 $UseType = 'OneToMany'; 163 168 } 164 else if($ FormTypes[$Item['Type']]['Type'] == 'Enumeration')165 $UseType = 'Enumeration'; 166 } else $UseType = $Item['Type']; 167 $Values[$Index] = $ System->Type->ExecuteTypeEvent($UseType, 'OnSaveDb', $Parameters);169 else if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration') 170 $UseType = 'Enumeration'; 171 } else $UseType = $Item['Type']; 172 $Values[$Index] = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnSaveDb', $Parameters); 168 173 if(($Item['Type'] == 'Password') and ($Values[$Index] == '')) unset($Values[$Index]); 169 174 … … 174 179 { 175 180 $Values['Id'] = $Id; 176 $DbResult = $ Database->insert($this->Definition['Table'], $Values);181 $DbResult = $this->Database->insert($this->Definition['Table'], $Values); 177 182 } else 178 $DbResult = $ Database->update($this->Definition['Table'], 'Id='.$Id, $Values);183 $DbResult = $this->Database->update($this->Definition['Table'], 'Id='.$Id, $Values); 179 184 //echo($Database->LastQuery); 180 185 } … … 187 192 function LoadValuesFromFormBlock($Context = '') 188 193 { 189 global $Database, $FormTypes, $System;190 191 194 if($Context != '') $Context = $Context.'-'; 192 195 $Values = array(); 193 196 foreach($this->Definition['Items'] as $Index => $Item) 194 if((!array_key_exists($Item['Type'], $ FormTypes) or195 (array_key_exists($Item['Type'], $ FormTypes) and196 ($ FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) and197 if((!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 198 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 199 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) and 197 200 (!array_key_exists('ReadOnly', $Item) or 198 201 (array_key_exists('ReadOnly', $Item) and … … 200 203 { 201 204 //if(array_key_exists($Context.$Index, $_POST)) 202 if(array_key_exists($Item['Type'], $ FormTypes))203 { 204 if(!array_key_exists($Item['Type'], $ System->Type->TypeDefinitionList))205 $ System->Type->RegisterType($Item['Type'], '',206 $ FormTypes[$Item['Type']]);207 if($ FormTypes[$Item['Type']]['Type'] == 'Reference')208 $UseType = 'OneToMany'; 209 else if($ FormTypes[$Item['Type']]['Type'] == 'Enumeration')210 $UseType = 'Enumeration'; 211 } else $UseType = $Item['Type']; 212 $Values[$Index] = $ System->Type->ExecuteTypeEvent($UseType, 'OnLoad',205 if(array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 206 { 207 if(!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 208 $this->FormManager->Type->RegisterType($Item['Type'], '', 209 $this->FormManager->FormTypes[$Item['Type']]); 210 if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference') 211 $UseType = 'OneToMany'; 212 else if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration') 213 $UseType = 'Enumeration'; 214 } else $UseType = $Item['Type']; 215 $Values[$Index] = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnLoad', 213 216 array('Name' => $Index, 'Type' => $Item['Type'], 'Values' => $this->Values)); 214 217 } … … 246 249 } 247 250 248 function ShowEditTable($ClassName, $Values) 249 { 251 class FormManager 252 { 253 var $Classes; 254 var $FormTypes; 255 var $Database; 256 var $Type; 257 258 function __construct($Database) 259 { 260 $this->Database = &$Database; 261 $this->Classes = array(); 262 $this->FormTypes = array(); 263 $this->Type = new Type($this); 264 } 265 266 function RegisterClass($Name, $Class) 267 { 268 $this->Classes[$Name] = $Class; 269 } 270 271 function UnregisterClass($Name) 272 { 273 unset($this->Classes[$Name]); 274 } 250 275 } 251 276 -
trunk/Common/Form/Types/Base.php
r484 r501 3 3 class TypeBase 4 4 { 5 var $System; 5 var $FormManager; 6 var $Database; 6 7 var $DatabaseCompareOperators = array(); 7 8 var $Hidden; 8 9 9 function __construct($ System)10 function __construct($FormManager) 10 11 { 11 $this->System = &$System; 12 $this->FormManager = &$FormManager; 13 $this->Database = &$FormManager->Database; 12 14 $this->Hidden = false; 13 15 } -
trunk/Common/Form/Types/Enumeration.php
r498 r501 7 7 function OnView($Item) 8 8 { 9 $Type = $this-> System->Type->GetTypeDefinition($Item['Type']);9 $Type = $this->FormManager->Type->GetTypeDefinition($Item['Type']); 10 10 if(array_key_exists($Item['Value'], $Type['Parameters']['States'])) 11 11 $Output = $Type['Parameters']['States'][$Item['Value']]; … … 16 16 function OnEdit($Item) 17 17 { 18 $Type = $this-> System->Type->GetTypeDefinition($Item['Type']);18 $Type = $this->FormManager->Type->GetTypeDefinition($Item['Type']); 19 19 $Output = '<select name="'.$Item['Name'].'">'; 20 20 if(array_key_exists('Null', $Item) and $Item['Null']) -
trunk/Common/Form/Types/Hidden.php
r484 r501 5 5 class TypeHidden extends TypeBase 6 6 { 7 function __construct($ System)7 function __construct($FormManager) 8 8 { 9 parent::__construct($ System);9 parent::__construct($FormManager); 10 10 $this->Hidden = true; 11 11 } -
trunk/Common/Form/Types/OneToMany.php
r483 r501 25 25 { 26 26 $Output = '<select name="'.$Item['Name'].'">'; 27 $Type = $this-> System->Type->TypeDefinitionList[$Item['Type']];27 $Type = $this->FormManager->Type->TypeDefinitionList[$Item['Type']]; 28 28 if(array_key_exists('Condition', $Type['Parameters'])) $Where = ' WHERE '.$Type['Parameters']['Condition']; 29 29 else $Where = ''; … … 35 35 if(array_key_exists('View', $Type['Parameters'])) $Table = $Type['Parameters']['View']; 36 36 else $Table = $Type['Parameters']['Table']; 37 $DbResult = $this-> System->Database->query('SELECT '.$Type['Parameters']['Name'].' AS `Name`,'.$Type['Parameters']['Id'].' AS `Id` FROM '.$Table.''.$Where.' ORDER BY `Name`');37 $DbResult = $this->Database->query('SELECT '.$Type['Parameters']['Name'].' AS `Name`,'.$Type['Parameters']['Id'].' AS `Id` FROM '.$Table.''.$Where.' ORDER BY `Name`'); 38 38 while($DbRow = $DbResult->fetch_assoc()) 39 39 { -
trunk/Common/Form/Types/RandomHash.php
r484 r501 5 5 class TypeRandomHash extends TypeBase 6 6 { 7 function __construct($ System)7 function __construct($FormManager) 8 8 { 9 parent::__construct($ System);9 parent::__construct($FormManager); 10 10 $this->Hidden = true; 11 11 } -
trunk/Common/Form/Types/Type.php
r500 r501 16 16 include(dirname(__FILE__).'/Hyperlink.php'); 17 17 include(dirname(__FILE__).'/Hidden.php'); 18 include(dirname(__FILE__).'/File/File.php'); 18 include(dirname(__FILE__).'/File.php'); 19 include(dirname(__FILE__).'/FileContent.php'); 19 20 include(dirname(__FILE__).'/GPS.php'); 20 21 include(dirname(__FILE__).'/IPv4Address.php'); … … 24 25 class Type 25 26 { 26 var $ System;27 var $FormManager; 27 28 var $TypeDefinitionList; 28 29 var $Values; 29 30 30 function __construct($ System)31 function __construct($FormManager) 31 32 { 32 $this-> System = $System;33 $this->FormManager = &$FormManager; 33 34 $this->TypeDefinitionList = array 34 35 ( … … 52 53 'Color' => array('Name' => 'Color', 'Class' => 'Color', 'ParentType' => '', 'Parameters' => array()), 53 54 'RandomHash' => array('Name' => 'RandomHash', 'Class' => 'RandomHash', 'ParentType' => '', 'Parameters' => array()), 55 'FileContent' => array('Name' => 'FileContent', 'Class' => 'FileContent', 'ParentType' => '', 'Parameters' => array()), 54 56 ); 55 57 } … … 61 63 $Type = $this->TypeDefinitionList[$TypeName]; 62 64 $TypeClass = 'Type'.$Type['Class']; 63 $TypeObject = new $TypeClass($this-> System);65 $TypeObject = new $TypeClass($this->FormManager); 64 66 if(is_callable(array($TypeObject, $Event))) return($TypeObject->$Event($Parameters)); 65 67 else return($TypeName.'->'.$Event.'('.serialize($Parameters).')'); … … 73 75 $Type = $this->TypeDefinitionList[$TypeName]; 74 76 $TypeClass = 'Type'.$Type['Class']; 75 $TypeObject = new $TypeClass($this-> System);77 $TypeObject = new $TypeClass($this->FormManager); 76 78 return($TypeObject->Hidden); 77 79 } else return(false); … … 92 94 } 93 95 96 function UnregisterType($Name) 97 { 98 unset($this->TypeDefinitionList[$Name]); 99 // TODO: remove dependent types 100 } 101 94 102 function GetTypeDefinition($TypeName) 95 103 { -
trunk/Common/Global.php
r500 r501 21 21 include_once(dirname(__FILE__).'/User.php'); 22 22 include_once(dirname(__FILE__).'/Page.php'); 23 include_once(dirname(__FILE__).'/Forms.php'); 24 include_once(dirname(__FILE__).'/Types/Type.php'); 23 include_once(dirname(__FILE__).'/Form/Form.php'); 25 24 include_once(dirname(__FILE__).'/File.php'); 26 25 include_once(dirname(__FILE__).'/../aktuality/news.php'); 27 26 include_once(dirname(__FILE__).'/../finance/bills.php'); 28 27 include_once(dirname(__FILE__).'/../finance/finance.php'); 28 include_once(dirname(__FILE__).'/../form_classes.php'); 29 29 30 30 31 // Application modules … … 57 58 parent::__construct(); 58 59 $this->Modules = array(); 59 $this->Type = new Type($this);60 60 $this->Pages = array(); 61 61 $this->ModuleManager = new AppModuleManager(); 62 62 $this->FilesDir = ''; 63 $this->Database = new Database(); 64 $this->FormManager = new FormManager($this->Database); 63 65 } 64 66 … … 101 103 function AddModule($Module) 102 104 { 103 global $Database;104 105 105 //echo('Přidávám modul '.get_class($Module).'<br />'); 106 106 $Module->System = &$this; 107 $Module->Database = &$ Database;107 $Module->Database = &$this->Database; 108 108 $this->Modules[get_class($Module)] = $Module; 109 109 } … … 166 166 167 167 if(!isset($Config)) die('Systém není nainstalován. Pokračujte v instalaci <a href="admin/install.php">zde</a>.'); 168 169 168 170 169 // SQL injection hack protection … … 174 173 if(isset($_SERVER['REMOTE_ADDR'])) session_start(); 175 174 176 $Database = new Database($Config['Database']['Host'], $Config['Database']['User'], $Config['Database']['Password'], $Config['Database']['Database']); 177 $Database->Prefix = $Config['Database']['Prefix']; 178 $Database->charset($Config['Database']['Charset']); 179 $Database->ShowSQLError = $Config['Web']['ShowSQLError']; 180 $Database->ShowSQLQuery = $Config['Web']['ShowSQLQuery']; 175 $System = new System(); 176 $System->Config = $Config; 177 $System->FilesDir = dirname(__FILE__).'/../'.$Config['Web']['UploadFileFolder'].'/'; 178 $System->Database->Connect($Config['Database']['Host'], $Config['Database']['User'], $Config['Database']['Password'], $Config['Database']['Database']); 179 $System->Database->Prefix = $Config['Database']['Prefix']; 180 $System->Database->charset($Config['Database']['Charset']); 181 $System->Database->ShowSQLError = $Config['Web']['ShowSQLError']; 182 $System->Database->ShowSQLQuery = $Config['Web']['ShowSQLQuery']; 181 183 182 184 // Check database persistence structure 183 185 $UpdateManager = new UpdateManager(); 184 $UpdateManager->Database = &$ Database;186 $UpdateManager->Database = &$System->Database; 185 187 $UpdateManager->Revision = $DatabaseRevision; 186 188 if(!$UpdateManager->IsInstalled()) die('Systém vyžaduje instalaci databáze.'); 187 189 if(!$UpdateManager->IsUpToDate()) die('Systém vyžaduje aktualizaci databáze.'); 188 190 189 $System = new System(); 190 $System->Config = $Config; 191 $System->FilesDir = dirname(__FILE__).'/../'.$Config['Web']['UploadFileFolder'].'/'; 192 $System->Database = &$Database; 191 // Init old modules 193 192 $System->AddModule(new Log()); 194 193 $System->AddModule(new ErrorHandler()); 194 $System->Modules['ErrorHandler']->ShowErrors = $Config['Web']['ShowPHPError']; 195 195 $System->Modules['ErrorHandler']->Init(); 196 196 $System->AddModule(new User()); … … 200 200 $System->AddModule(new Finance()); 201 201 $System->Modules['Finance']->LoadMonthParameters(0); 202 RegisterFormClasses($System->FormManager); 202 203 203 204 // Register new modules -
trunk/Common/Page.php
r494 r501 125 125 foreach($ScriptNameParts as $ScriptNamePart) 126 126 { 127 //echo($ScriptNamePart.'<br />');128 127 if(array_key_exists($ScriptNamePart, $PathTreeItem)) 129 128 { -
trunk/Common/Update.php
r493 r501 153 153 if(isset($_SERVER['REMOTE_ADDR'])) session_start(); 154 154 155 $Database = new Database($this->Config['Database']['Host'], $this->Config['Database']['User'], 155 $Database = new Database(); 156 $Database->Connect($this->Config['Database']['Host'], $this->Config['Database']['User'], 156 157 $this->Config['Database']['Password'], $this->Config['Database']['Database']); 157 158 $Database->Prefix = $this->Config['Database']['Prefix']; -
trunk/Common/Version.php
r500 r501 1 1 <?php 2 2 3 $Revision = 50 0; // Subversion revision4 $DatabaseRevision = 50 0;5 $ReleaseTime = '2013-03- 03';3 $Revision = 501; // Subversion revision 4 $DatabaseRevision = 501; 5 $ReleaseTime = '2013-03-10'; 6 6 7 7 ?>
Note:
See TracChangeset
for help on using the changeset viewer.