Changeset 56


Ignore:
Timestamp:
Apr 7, 2020, 9:13:33 PM (5 years ago)
Author:
chronos
Message:
  • Modified: Updated Common package.
Location:
trunk
Files:
1 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Event/EventPage.php

    r55 r56  
    4949    $this->Title = 'Události - '.$this->Title;
    5050    if (array_key_exists('lvm', $_GET) and ($_GET['lvm'] == 'seznam'))
    51       $this->ClearPage = true;
     51      $this->RawPage = true;
    5252      else $Output .= '<div class="title">Události</div>';
    5353
     
    191191    global $Config;
    192192
    193     $this->ClearPage = true;
     193    $this->RawPage = true;
    194194    $RSS = new RSS();
    195195    $RSS->Title = 'Taneční události';
  • trunk/Modules/Meet/MeetPage.php

    r55 r56  
    5252    $this->Title = 'Seznamka - '.$this->Title;
    5353    if (array_key_exists('lvm', $_GET) and ($_GET['lvm'] == 'seznam'))
    54       $this->ClearPage = true;
     54      $this->RawPage = true;
    5555      else $Output .= '<div class="title">Inzeráty</div>';
    5656
     
    203203    global $Config;
    204204
    205     $this->ClearPage = true;
     205    $this->RawPage = true;
    206206    $RSS = new RSS();
    207207    $RSS->Title = 'Taneční seznamka';
  • trunk/Modules/Movie/Movie.php

    r55 r56  
    3636    $this->Title = 'Filmy - '.$this->Title;
    3737    if (array_key_exists('lvm', $_GET) and ($_GET['lvm'] == 'seznam'))
    38       $this->ClearPage = true;
     38      $this->RawPage = true;
    3939      else $Output .= '<div class="title">Filmy</div>';
    4040
  • trunk/Modules/RSS/RSS.php

    r55 r56  
    5656  function Show()
    5757  {
    58     $this->ClearPage = true;
     58    $this->RawPage = true;
    5959
    6060    if (array_key_exists('channel', $_GET)) $ChannelName = $_GET['channel'];
  • trunk/Packages/Common/Application.php

    r37 r56  
    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/Base.php

    r37 r56  
    1414class Base
    1515{
    16   /* @var Application */
     16  /** @var Application */
    1717  var $System;
    1818  /* @var Database */
  • trunk/Packages/Common/Common.php

    r55 r56  
    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('2019-02-28');
     35    $this->Version = '1.4';
     36    $this->ReleaseDate = strtotime('2020-04-07');
    3637    $this->Creator = 'Chronos';
    3738    $this->License = 'GNU/GPL';
    38     $this->Homepage = 'http://svn.zdechov.net/PHPlib/Common/';
     39    $this->Homepage = 'https://svn.zdechov.net/PHPlib/Common/';
    3940  }
    4041}
     
    4849  var $Page;
    4950
    50   function __construct()
     51  function __construct($System)
    5152  {
    52     global $System;
    53 
    5453    $this->ItemPerPage = $System->Config['Web']['ItemsPerPage'];
    5554    $this->Around = $System->Config['Web']['VisiblePagingItems'];
  • trunk/Packages/Common/Database.php

    r55 r56  
    22
    33// Extended database class
    4 // Date: 2016-01-11
     4// Date: 2020-04-07
     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();
    88     $this->LastQuery = $Query;
     94    if (($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true)) $QueryStartTime = microtime_float();
     95    $this->LastQuery = $Query;   
    8996    if (($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true))
    90       $Duration = ' ; '.round(microtime() - $QueryStartTime, 4). ' s';
     97      $Duration = ' ; '.round(microtime_float() - $QueryStartTime, 4). ' s';
    9198    if ($this->LogSQLQuery == true)
    9299      file_put_contents($this->LogFile, $Query.$Duration."\n", FILE_APPEND);
     
    101108      $this->insert_id = $this->PDO->lastInsertId();
    102109    } else
    103     {
     110    {     
    104111      $this->Error = $this->PDO->errorInfo();
    105112      $this->Error = $this->Error[2];
     
    123130  function insert($Table, $Data)
    124131  {
     132    $this->query($this->GetInsert($Table, $Data));
     133    $this->insert_id = $this->PDO->lastInsertId();
     134  }
     135 
     136  function GetInsert($Table, $Data)
     137  {
    125138    $Name = '';
    126139    $Values = '';
     
    137150    $Name = substr($Name, 1);
    138151    $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.')';
    141153  }
    142154
    143155  function update($Table, $Condition, $Data)
     156  {
     157    $this->query($this->GetUpdate($Table, $Condition, $Data));
     158  }
     159 
     160  function GetUpdate($Table, $Condition, $Data)
    144161  {
    145162    $Values = '';
     
    154171    }
    155172    $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.')';
    157174  }
    158175
     
    200217  public function __wakeup()
    201218  {
     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();
    202230  }
    203231}
  • trunk/Packages/Common/Image.php

    r55 r56  
    8989    if ($this->Type == IMAGETYPE_GIF)
    9090    {
    91       $this->Image = imagecreatefromgif ($FileName);
     91      $this->Image = imagecreatefromgif($FileName);
    9292    } else
    9393    if ( $this->Type == IMAGETYPE_PNG)
  • trunk/Packages/Common/Page.php

    r55 r56  
    77  var $RawPage;
    88  var $OnSystemMessage;
    9   var $ClearPage;
    109
    1110  function __construct(System $System)
  • trunk/Packages/Common/Setup.php

    r55 r56  
    207207    $Output = '';
    208208
    209     $Pageing = new Paging();
     209    $Pageing = new Paging($this->System);
    210210    $Pageing->TotalCount = count($this->System->ModuleManager->Modules);
    211     $Table = new VisualTable();
     211    $Table = new VisualTable($this->System);
    212212    $Table->SetColumns(array(
    213213      array('Name' => 'Name', 'Title' => 'Jméno'),
     
    402402  function CheckState()
    403403  {
    404     $this->Database->Connected() and $this->UpdateManager->IsInstalled() and
     404    return $this->Database->Connected() and $this->UpdateManager->IsInstalled() and
    405405      $this->UpdateManager->IsUpToDate();
    406406  }
     
    415415  PRIMARY KEY (`Id`)
    416416) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
    417     $this->Database->query("INSERT INTO `'.$this->UpdateManager->VersionTable.'` (`Id`, `Revision`) VALUES
    418       (1, '.$DatabaseRevision.');");
     417    $this->Database->query('INSERT INTO `'.$this->UpdateManager->VersionTable.'` (`Id`, `Revision`) VALUES
     418      (1, '.$DatabaseRevision.');');
    419419    $this->Database->query("CREATE TABLE IF NOT EXISTS `Module` (
    420420  `Id` int(11) NOT NULL AUTO_INCREMENT,
     
    428428  {
    429429    $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.'`');
    432432  }
    433433
  • trunk/Packages/Common/Table.php

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

    r55 r56  
    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/>';
  • trunk/View.php

    r55 r56  
    99  var $ShowRuntimeInfo = false;
    1010  var $ShowNavigation = false;
    11   var $ClearPage = false;
    1211  var $BasicHTML = false;
    1312  var $ParentClass = '';
     
    123122    $Output = '';
    124123    if ($this->BasicHTML == false)
    125     {           
     124    {
    126125      $Output .= '<div class="Footer">'.
    127126      '<i>';
     
    129128      $Output .= ' <a href="https://app.zdechov.net/tanec/">Zdrojový kód</a> ';
    130129      //$Output .= ' Verze: '.$Revision.' ('.HumanDate($ReleaseTime).') ';
    131       if ($this->ShowRuntimeInfo == true) 
     130      if ($this->ShowRuntimeInfo == true)
    132131      {
    133132        $Output .= ' Doba generování: '.$Time.' s / '.ini_get('max_execution_time').' s '.
     
    145144
    146145    $Output = $Page->Show();
    147     if ($Page->ClearPage == false)
     146    if ($Page->RawPage == false)
    148147    {
    149148      $Output = $this->ShowHeader($Page).$Output.$this->ShowFooter();
  • trunk/index.php

    r55 r56  
    204204  function Show()
    205205  {
    206     $this->ClearPage = true;
     206    $this->RawPage = true;
    207207    $Result = 'User-agent: *'."\n".
    208208      'Disallow: /*?'."\n".
     
    216216  function Show()
    217217  {
    218     $this->ClearPage = true;
     218    $this->RawPage = true;
    219219    $Urls = array(
    220220      '/seznamka/',
Note: See TracChangeset for help on using the changeset viewer.