Changeset 90 for trunk


Ignore:
Timestamp:
Oct 4, 2019, 10:31:38 PM (5 years ago)
Author:
chronos
Message:
  • Modified: Updated Common package files.
  • Modified: Updated link to project website.
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/Version.php

    r85 r90  
    66// and system will need database update.
    77
    8 $Revision = 85;
     8$Revision = 88;
    99$DatabaseRevision = 79;
    10 $ReleaseTime = strtotime('2018-01-20');
     10$ReleaseTime = strtotime('2019-10-04');
  • trunk/Application/View.php

    r88 r90  
    2020    $Output .= $Content;
    2121    $Output .= '<br/><div style="text-align: center; font-size: small;">Verze: '.$Revision.' ('.HumanDate($ReleaseTime).')'.
    22       ' &nbsp; <a href="http://svn.zdechov.net/trac/estetistic/browser/trunk">Zdrojový kód</a> &nbsp; '.
    23       '<a href="http://svn.zdechov.net/trac/estetistic/log/trunk?verbose=on">Historie změn</a></div>';
     22      ' &nbsp; <a href="https://app.zdechov.net/estetistic/">Zdrojový kód</a></div>';
    2423    $Output .= '</body></html>';
    2524    echo($Output);
  • trunk/Packages/Common/Application.php

    r69 r90  
    11<?php
     2
     3class 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}
    230
    331class Application extends System
     
    735  var $ModuleManager;
    836  var $Modules;
    9 
     37  var $Models;
     38 
    1039  function __construct()
    1140  {
     
    1443    $this->ModuleManager = new AppModuleManager($this);
    1544    $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;
    1653  }
    1754
     55  function UnregisterModel($SysName)
     56  {
     57    unset($this->Models[$SysName]);
     58  }
     59 
    1860  function Run()
    1961  {
  • trunk/Packages/Common/Common.php

    r69 r90  
    1919include_once(dirname(__FILE__).'/Setup.php');
    2020include_once(dirname(__FILE__).'/Table.php');
     21include_once(dirname(__FILE__).'/Process.php');
    2122
    2223class PackageCommon
     
    3233  {
    3334    $this->Name = 'Common';
    34     $this->Version = '1.2';
    35     $this->ReleaseDate = strtotime('2016-01-22');
     35    $this->Version = '1.3';
     36    $this->ReleaseDate = strtotime('2019-10-04');
    3637    $this->Creator = 'Chronos';
    3738    $this->License = 'GNU/GPL';
    38     $this->Homepage = 'http://svn.zdechov.net/svn/PHPlib/Common/';
     39    $this->Homepage = 'https://svn.zdechov.net/PHPlib/Common/';
    3940  }
    4041}
     
    4849  var $Page;
    4950
    50   function __construct(System $System)
     51  function __construct()
    5152  {
     53    global $System;
     54
    5255    $this->ItemPerPage = $System->Config['Web']['ItemsPerPage'];
    5356    $this->Around = $System->Config['Web']['VisiblePagingItems'];
  • trunk/Packages/Common/Database.php

    r69 r90  
    33// Extended database class
    44// Date: 2016-01-11
     5
     6function microtime_float()
     7{
     8  list($usec, $sec) = explode(" ", microtime());
     9  return ((float)$usec + (float)$sec);
     10}
    511
    612class DatabaseResult
     
    5157    $this->LogFile = dirname(__FILE__).'/../../Query.log';
    5258  }
     59 
    5360
    5461  function Connect($Host, $User, $Password, $Database)
     
    8592  {
    8693    if(!$this->Connected()) throw new Exception(T('Not connected to database'));
    87     if(($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true)) $QueryStartTime = microtime();
     94    if(($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true)) $QueryStartTime = microtime_float();
    8895    $this->LastQuery = $Query;
     96    //echo('a'.$this->ShowSQLQuery.'<'.$QueryStartTime.', '.microtime_float());
    8997    if(($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true))
    90       $Duration = ' ; '.round(microtime() - $QueryStartTime, 4). ' s';
     98      $Duration = ' ; '.round(microtime_float() - $QueryStartTime, 4). ' s';
    9199    if($this->LogSQLQuery == true)
    92100      file_put_contents($this->LogFile, $Query.$Duration."\n", FILE_APPEND);
     
    101109      $this->insert_id = $this->PDO->lastInsertId();
    102110    } else
    103     {
     111    {     
    104112      $this->Error = $this->PDO->errorInfo();
    105113      $this->Error = $this->Error[2];
     
    123131  function insert($Table, $Data)
    124132  {
     133    $this->query($this->GetInsert($Table, $Data));
     134    $this->insert_id = $this->PDO->lastInsertId();
     135  }
     136 
     137  function GetInsert($Table, $Data)
     138  {
    125139    $Name = '';
    126140    $Values = '';
     
    137151    $Name = substr($Name, 1);
    138152    $Values = substr($Values, 1);
    139     $this->query('INSERT INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')');
    140     $this->insert_id = $this->PDO->lastInsertId();
     153    return('INSERT INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')');
    141154  }
    142155
    143156  function update($Table, $Condition, $Data)
     157  {
     158    $this->query($this->GetUpdate($Table, $Condition, $Data));
     159  }
     160 
     161  function GetUpdate($Table, $Condition, $Data)
    144162  {
    145163    $Values = '';
     
    154172    }
    155173    $Values = substr($Values, 2);
    156     $this->query('UPDATE `'.$this->Prefix.$Table.'` SET '.$Values.' WHERE ('.$Condition.')');
     174    return('UPDATE `'.$this->Prefix.$Table.'` SET '.$Values.' WHERE ('.$Condition.')');
    157175  }
    158176
     
    200218  public function __wakeup()
    201219  {
     220  }
     221 
     222  public function Transaction($Queries)
     223  {
     224      $this->PDO->beginTransaction();
     225      foreach ($Queries as $Query)
     226      {
     227        $Statement = $this->PDO->prepare($Query);
     228        $Statement->execute();
     229      }         
     230      $this->PDO->commit();
    202231  }
    203232}
  • trunk/Packages/Common/Table.php

    r69 r90  
    9898  var $Style;
    9999
    100   function __construct(System $System)
     100  function __construct()
    101101  {
     102    global $System;
     103
    102104    $this->Columns = array();
    103105    $this->Table = new TableMemory();
  • trunk/Packages/Common/Update.php

    r69 r90  
    4343    while($this->Revision > $DbRevision)
    4444    {
     45      if(!array_key_exists($DbRevision, $this->Trace))
     46        die('Missing upgrade trace for revision '.$DbRevision);
    4547      $TraceItem = $this->Trace[$DbRevision];
    4648      $Output .= 'Aktualizace na verzi '.$TraceItem['Revision'].':<br/>';
Note: See TracChangeset for help on using the changeset viewer.