Changeset 56 for trunk/Packages/Common
- Timestamp:
- Apr 7, 2020, 9:13:33 PM (5 years ago)
- Location:
- trunk/Packages/Common
- Files:
-
- 1 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/Application.php
r37 r56 1 1 <?php 2 3 class ModelDef 4 { 5 var $OnChange; 6 7 function __construct() 8 { 9 $this->OnChange = array(); 10 } 11 12 function DoOnChange() 13 { 14 foreach ($this->OnChange as $Callback) 15 { 16 call_user_func($Callback); 17 } 18 } 19 20 function RegisterOnChange($SysName, $Callback) 21 { 22 $this->OnChange[$SysName] = $Callback; 23 } 24 25 function UnregisterOnChange($SysName) 26 { 27 unset($this->OnChange[$SysName]); 28 } 29 } 2 30 3 31 class Application extends System … … 7 35 var $ModuleManager; 8 36 var $Modules; 9 37 var $Models; 38 10 39 function __construct() 11 40 { … … 14 43 $this->ModuleManager = new AppModuleManager($this); 15 44 $this->Modules = array(); 45 $this->Models = array(); 46 } 47 48 function RegisterModel($SysName, $Model) 49 { 50 $NewModelDef = new ModelDef(); 51 $NewModelDef->Title = $Model['Title']; 52 $this->Models[$SysName] = $NewModelDef; 16 53 } 17 54 55 function UnregisterModel($SysName) 56 { 57 unset($this->Models[$SysName]); 58 } 59 18 60 function Run() 19 61 { -
trunk/Packages/Common/Base.php
r37 r56 14 14 class Base 15 15 { 16 /* @var Application */16 /** @var Application */ 17 17 var $System; 18 18 /* @var Database */ -
trunk/Packages/Common/Common.php
r55 r56 19 19 include_once(dirname(__FILE__).'/Setup.php'); 20 20 include_once(dirname(__FILE__).'/Table.php'); 21 include_once(dirname(__FILE__).'/Process.php'); 21 22 22 23 class PackageCommon … … 32 33 { 33 34 $this->Name = 'Common'; 34 $this->Version = '1. 2';35 $this->ReleaseDate = strtotime('20 19-02-28');35 $this->Version = '1.4'; 36 $this->ReleaseDate = strtotime('2020-04-07'); 36 37 $this->Creator = 'Chronos'; 37 38 $this->License = 'GNU/GPL'; 38 $this->Homepage = 'http ://svn.zdechov.net/PHPlib/Common/';39 $this->Homepage = 'https://svn.zdechov.net/PHPlib/Common/'; 39 40 } 40 41 } … … 48 49 var $Page; 49 50 50 function __construct( )51 function __construct($System) 51 52 { 52 global $System;53 54 53 $this->ItemPerPage = $System->Config['Web']['ItemsPerPage']; 55 54 $this->Around = $System->Config['Web']['VisiblePagingItems']; -
trunk/Packages/Common/Database.php
r55 r56 2 2 3 3 // Extended database class 4 // Date: 2016-01-11 4 // Date: 2020-04-07 5 6 function microtime_float() 7 { 8 list($usec, $sec) = explode(" ", microtime()); 9 return (float)$usec + (float)$sec; 10 } 5 11 6 12 class DatabaseResult … … 51 57 $this->LogFile = dirname(__FILE__).'/../../Query.log'; 52 58 } 59 53 60 54 61 function Connect($Host, $User, $Password, $Database) … … 85 92 { 86 93 if (!$this->Connected()) throw new Exception(T('Not connected to database')); 87 if (($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true)) $QueryStartTime = microtime ();88 $this->LastQuery = $Query; 94 if (($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true)) $QueryStartTime = microtime_float(); 95 $this->LastQuery = $Query; 89 96 if (($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true)) 90 $Duration = ' ; '.round(microtime () - $QueryStartTime, 4). ' s';97 $Duration = ' ; '.round(microtime_float() - $QueryStartTime, 4). ' s'; 91 98 if ($this->LogSQLQuery == true) 92 99 file_put_contents($this->LogFile, $Query.$Duration."\n", FILE_APPEND); … … 101 108 $this->insert_id = $this->PDO->lastInsertId(); 102 109 } else 103 { 110 { 104 111 $this->Error = $this->PDO->errorInfo(); 105 112 $this->Error = $this->Error[2]; … … 123 130 function insert($Table, $Data) 124 131 { 132 $this->query($this->GetInsert($Table, $Data)); 133 $this->insert_id = $this->PDO->lastInsertId(); 134 } 135 136 function GetInsert($Table, $Data) 137 { 125 138 $Name = ''; 126 139 $Values = ''; … … 137 150 $Name = substr($Name, 1); 138 151 $Values = substr($Values, 1); 139 $this->query('INSERT INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')'); 140 $this->insert_id = $this->PDO->lastInsertId(); 152 return 'INSERT INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')'; 141 153 } 142 154 143 155 function update($Table, $Condition, $Data) 156 { 157 $this->query($this->GetUpdate($Table, $Condition, $Data)); 158 } 159 160 function GetUpdate($Table, $Condition, $Data) 144 161 { 145 162 $Values = ''; … … 154 171 } 155 172 $Values = substr($Values, 2); 156 $this->query('UPDATE `'.$this->Prefix.$Table.'` SET '.$Values.' WHERE ('.$Condition.')');173 return 'UPDATE `'.$this->Prefix.$Table.'` SET '.$Values.' WHERE ('.$Condition.')'; 157 174 } 158 175 … … 200 217 public function __wakeup() 201 218 { 219 } 220 221 public function Transaction($Queries) 222 { 223 $this->PDO->beginTransaction(); 224 foreach ($Queries as $Query) 225 { 226 $Statement = $this->PDO->prepare($Query); 227 $Statement->execute(); 228 } 229 $this->PDO->commit(); 202 230 } 203 231 } -
trunk/Packages/Common/Image.php
r55 r56 89 89 if ($this->Type == IMAGETYPE_GIF) 90 90 { 91 $this->Image = imagecreatefromgif 91 $this->Image = imagecreatefromgif($FileName); 92 92 } else 93 93 if ( $this->Type == IMAGETYPE_PNG) -
trunk/Packages/Common/Page.php
r55 r56 7 7 var $RawPage; 8 8 var $OnSystemMessage; 9 var $ClearPage;10 9 11 10 function __construct(System $System) -
trunk/Packages/Common/Setup.php
r55 r56 207 207 $Output = ''; 208 208 209 $Pageing = new Paging( );209 $Pageing = new Paging($this->System); 210 210 $Pageing->TotalCount = count($this->System->ModuleManager->Modules); 211 $Table = new VisualTable( );211 $Table = new VisualTable($this->System); 212 212 $Table->SetColumns(array( 213 213 array('Name' => 'Name', 'Title' => 'Jméno'), … … 402 402 function CheckState() 403 403 { 404 $this->Database->Connected() and $this->UpdateManager->IsInstalled() and404 return $this->Database->Connected() and $this->UpdateManager->IsInstalled() and 405 405 $this->UpdateManager->IsUpToDate(); 406 406 } … … 415 415 PRIMARY KEY (`Id`) 416 416 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;'); 417 $this->Database->query( "INSERT INTO `'.$this->UpdateManager->VersionTable.'` (`Id`, `Revision`) VALUES418 (1, '.$DatabaseRevision.'); ");417 $this->Database->query('INSERT INTO `'.$this->UpdateManager->VersionTable.'` (`Id`, `Revision`) VALUES 418 (1, '.$DatabaseRevision.');'); 419 419 $this->Database->query("CREATE TABLE IF NOT EXISTS `Module` ( 420 420 `Id` int(11) NOT NULL AUTO_INCREMENT, … … 428 428 { 429 429 $this->System->ModuleManager->UninstallAll(); 430 $this->Database->query('DROP TABLE `Module`');431 $this->Database->query('DROP TABLE `'.$this->UpdateManager->VersionTable.'`');430 $this->Database->query('DROP TABLE IF EXISTS `Module`'); 431 $this->Database->query('DROP TABLE IF EXISTS `'.$this->UpdateManager->VersionTable.'`'); 432 432 } 433 433 -
trunk/Packages/Common/Table.php
r55 r56 98 98 var $Style; 99 99 100 function __construct( )100 function __construct($System) 101 101 { 102 global $System;103 104 102 $this->Columns = array(); 105 103 $this->Table = new TableMemory(); -
trunk/Packages/Common/Update.php
r55 r56 43 43 while ($this->Revision > $DbRevision) 44 44 { 45 if (!array_key_exists($DbRevision, $this->Trace)) 46 die('Missing upgrade trace for revision '.$DbRevision); 45 47 $TraceItem = $this->Trace[$DbRevision]; 46 48 $Output .= 'Aktualizace na verzi '.$TraceItem['Revision'].':<br/>';
Note:
See TracChangeset
for help on using the changeset viewer.