Changeset 5 for Common


Ignore:
Timestamp:
Jan 10, 2016, 12:16:44 AM (9 years ago)
Author:
chronos
Message:
  • Added: Logging support to Database class.
  • Modified: Page class use just $Title field instead two Short and Long titles.
  • Modified: Page class use RawPage instead ClearPage field.
Location:
Common
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • Common/AppModule.php

    r4 r5  
    231231    foreach($Module->Dependencies as $Dependency)
    232232    {
     233      if(!array_key_exists($Dependency, $this->Modules))
     234        throw new Exception('Module "'.$Module->Name.'" dependency "'.$Dependency.'" not found');
    233235      $DepModule = $this->Modules[$Dependency];
    234236      if(in_array(ModuleCondition::All, $Conditions) or
     
    287289  }
    288290
     291  function InstallAll()
     292  {
     293    $this->Perform($this->Modules, array(ModuleAction::Install));
     294    $this->SaveState();
     295  }
     296
    289297  function UninstallAll()
    290298  {
    291299    $this->Perform($this->Modules, array(ModuleAction::Uninstall));
     300    $this->SaveState();
     301  }
     302
     303  function EnableAll()
     304  {
     305    $this->Perform($this->Modules, array(ModuleAction::Enable));
     306    $this->SaveState();
     307  }
     308
     309  function DisableAll()
     310  {
     311    $this->Perform($this->Modules, array(ModuleAction::Disable));
    292312    $this->SaveState();
    293313  }
  • Common/Database.php

    r4 r5  
    22
    33// Extended database class
    4 // Date: 2011-11-25
     4// Date: 2016-01-11
    55
    66class DatabaseResult
     
    2727class Database
    2828{
    29   var $Prefix = '';
     29  var $Prefix;
    3030  var $Functions;
    3131  var $Type;
    3232  var $PDO;
    33   var $Error = '';
     33  var $Error;
    3434  var $insert_id;
    35   var $LastQuery = '';
     35  var $LastQuery;
    3636  var $ShowSQLError;
    3737  var $ShowSQLQuery;
     38  var $LogSQLQuery;
     39  var $LogFile;
    3840
    3941  function __construct()
    4042  {
     43    $this->Prefix = '';
     44    $this->Functions = array('NOW()', 'CURDATE()', 'CURTIME()', 'UUID()');
    4145    $this->Type = 'mysql';  // mysql, pgsql
     46    $this->Error = '';
     47    $this->LastQuery = '';
    4248    $this->ShowSQLError = false;
    4349    $this->ShowSQLQuery = false;
    44     $this->Functions = array('NOW()', 'CURDATE()', 'CURTIME()', 'UUID()');
     50    $this->LogSQLQuery = false;
     51    $this->LogFile = dirname(__FILE__).'/../../Query.log';
    4552  }
    4653
     
    7885  {
    7986    if(!$this->Connected()) throw new Exception('Not connected to database');
     87    if(($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true)) $QueryStartTime = microtime();
    8088    $this->LastQuery = $Query;
     89    if(($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true))
     90      $Duration = ' ; '.round(microtime() - $QueryStartTime, 4). ' s';
     91    if($this->LogSQLQuery == true)
     92      file_put_contents($this->LogFile, $Query.$Duration."\n", FILE_APPEND);
    8193    if($this->ShowSQLQuery == true)
    82       echo('<div style="border-bottom-width: 1px; border-bottom-style: solid; padding-bottom: 3px; padding-top: 3px; font-size: 12px; font-family: Arial;">'.$Query.'</div>'."\n");
     94      echo('<div style="border-bottom-width: 1px; border-bottom-style: solid; '.
     95      'padding-bottom: 3px; padding-top: 3px; font-size: 12px; font-family: Arial;">'.$Query.$Duration.'</div>'."\n");
    8396    $Result = new DatabaseResult();
    8497    $Result->PDOStatement = $this->PDO->query($Query);
     
    175188  }
    176189
     190  function quote($Text)
     191  {
     192    return($this->PDO->quote($Text));
     193  }
     194
    177195  public function __sleep()
    178196  {
  • Common/Error.php

    r3 r5  
    7474    die();
    7575  }
    76  
     76
    7777  function ShowDefaultError($Message)
    7878  {
     
    112112
    113113    foreach($this->OnError as $OnError)
    114       $OnError[0]->$OnError[1]($Error);
     114      call_user_func($OnError, $Error);
    115115  }
    116116}
  • Common/Page.php

    r4 r5  
    33class Page extends View
    44{
    5   var $FullTitle;
    6   var $ShortTitle;
     5  var $Title;
    76  var $ParentClass;
    8   var $ClearPage;
     7  var $RawPage;
    98  var $OnSystemMessage;
    109
    11   function __construct($System)
     10  function __construct(System $System)
    1211  {
    1312    parent::__construct($System);
    14     $this->ClearPage = false;
     13    $this->RawPage = false;
    1514    $this->OnSystemMessage = array();
    1615  }
Note: See TracChangeset for help on using the changeset viewer.