Changeset 791


Ignore:
Timestamp:
Jan 22, 2016, 5:31:05 PM (9 years ago)
Author:
chronos
Message:
  • Updated: Common package.
Location:
trunk
Files:
4 added
2 deleted
10 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Application/System.php

    r790 r791  
    1010include_once(dirname(__FILE__).'/UpdateTrace.php');
    1111include_once(dirname(__FILE__).'/View.php');
     12include_once(dirname(__FILE__).'/DefaultConfig.php');
    1213
    1314class Core extends Application
     
    2627  var $Setup;
    2728  var $CommandLine;
     29  var $PageHeaders;
    2830
    2931  function __construct()
     
    4042      $this->RootURLFolder = substr($this->RootURLFolder, 0, -10);
    4143    $this->CommandLine = array();
     44    $this->PageHeaders = array();
    4245  }
    4346
     
    228231    $this->Bars[$BarName][$ItemName] = $Callback;
    229232  }
     233
     234  function RegisterPageHeader($Name, $Callback)
     235  {
     236    $this->PageHeaders[$Name] = $Callback;
     237  }
    230238}
    231239
  • trunk/Application/Version.php

    r789 r791  
    11<?php
    22
    3 $Revision = 789; // Subversion revision
     3$Revision = 790; // Subversion revision
    44$DatabaseRevision = 785; // SQL structure revision
    5 $ReleaseTime = strtotime('2016-01-15');
     5$ReleaseTime = strtotime('2016-01-22');
  • trunk/Application/View.php

    r783 r791  
    8888    '<script type="text/javascript" src="'.$this->System->Link('/style/').$this->Style.'/global.js"></script>'.
    8989    '<title>'.$this->System->Config['Web']['Title'].' - '.$Path.'</title>';
    90     $Output .= $this->System->ModuleManager->Modules['RSS']->ShowRSSHeader();
     90
     91    // Show page headers
     92    $Bar = '';
     93    foreach($this->System->PageHeaders as $Item)
     94      $Output .= call_user_func($Item);
     95
    9196    $Output .= '</head><body'.$BodyParam.'>';
    9297    if($this->BasicHTML == false)
  • trunk/Common/Global.php

    r790 r791  
    88include_once(dirname(__FILE__).'/../Packages/Package.php');
    99include_once(dirname(__FILE__).'/../Packages/Common/Common.php');
    10 include_once(dirname(__FILE__).'/Table.php');
    1110include_once(dirname(__FILE__).'/Form/Form.php');
    12 include_once(dirname(__FILE__).'/Setup/Setup.php');
    1311include_once(dirname(__FILE__).'/VCL/General.php');
    1412include_once(dirname(__FILE__).'/VCL/Database.php');
     
    131129  }
    132130  return(implode('&amp;', $Parts));
    133 }
    134 
    135 class Paging
    136 {
    137   var $TotalCount;
    138   var $ItemPerPage;
    139   var $Around;
    140   var $SQLLimit;
    141   var $Page;
    142 
    143   function __construct()
    144   {
    145     global $System;
    146 
    147     $this->ItemPerPage = $System->Config['Web']['ItemsPerPage'];
    148     $this->Around = $System->Config['Web']['VisiblePagingItems'];
    149   }
    150 
    151   function Show()
    152   {
    153     $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']);
    154 
    155     $Result = '';
    156     if(array_key_exists('all', $QueryItems))
    157     {
    158       $PageCount = 1;
    159       $ItemPerPage = $this->TotalCount;
    160     } else
    161     {
    162       $ItemPerPage = $this->ItemPerPage;
    163       $Around = round($this->Around / 2);
    164       $PageCount = floor($this->TotalCount / $ItemPerPage) + 1;
    165     }
    166 
    167     if(!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0;
    168     if(array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1;
    169     if($_SESSION['Page'] < 0) $_SESSION['Page'] = 0;
    170     if($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1;
    171     $CurrentPage = $_SESSION['Page'];
    172 
    173     $Result .= 'Počet položek: <strong>'.$this->TotalCount.'</strong> &nbsp; Stránky: ';
    174 
    175     $Result = '';
    176     if($PageCount > 1)
    177     {
    178       if($CurrentPage > 0)
    179       {
    180         $QueryItems['page'] = 0;
    181         $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'">&lt;&lt;</a> ';
    182         $QueryItems['page'] = ($CurrentPage - 1);
    183         $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'">&lt;</a> ';
    184       }
    185       $PagesMax = $PageCount - 1;
    186       $PagesMin = 0;
    187       if($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around;
    188       if($PagesMin < ($CurrentPage - $Around))
    189       {
    190         $Result.= ' ... ';
    191         $PagesMin = $CurrentPage - $Around;
    192       }
    193       for($i = $PagesMin; $i <= $PagesMax; $i++)
    194       {
    195         if($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> ';
    196         else {
    197          $QueryItems['page'] = $i;
    198          $Result .= '<a href="?'.SetQueryStringArray($QueryItems).'">'.($i + 1).'</a> ';
    199         }
    200       }
    201       if($PagesMax < ($PageCount - 1)) $Result .= ' ... ';
    202       if($CurrentPage < ($PageCount - 1))
    203       {
    204         $QueryItems['page'] = ($CurrentPage + 1);
    205         $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'">&gt;</a> ';
    206         $QueryItems['page'] = ($PageCount - 1);
    207         $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'">&gt;&gt;</a>';
    208       }
    209     }
    210     $QueryItems['all'] = '1';
    211     if($PageCount > 1) $Result.= ' <a href="?'.SetQueryStringArray($QueryItems).'">Vše</a>';
    212 
    213     $Result = '<div style="text-align: center">'.$Result.'</div>';
    214     $this->SQLLimit = ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage;
    215     $this->Page = $CurrentPage;
    216     return($Result);
    217   }
    218131}
    219132
  • trunk/Modules/RSS/RSS.php

    r782 r791  
    2020  {
    2121    $this->System->RegisterPage('rss', 'PageRSS');
     22    $this->System->RegisterPageHeader('RSS', array($this, 'ShowRSSHeader'));
    2223  }
    2324
  • trunk/Packages/Common/AppModule.php

    r790 r791  
    197197    $this->Modules = array();
    198198    $this->System = &$System;
    199     $this->FileName = 'Config/Modules.php';
     199    $this->FileName = dirname(__FILE__).'/../../Config/ModulesConfig.php';
    200200    $this->ModulesDir = dirname(__FILE__).'/../../Modules';
    201201  }
     
    232232    {
    233233      if(!array_key_exists($Dependency, $this->Modules))
    234         throw new Exception('Module "'.$Module->Name.'" dependency "'.$Dependency.'" not found');
     234        throw new Exception(sprintf(T('Module "%s" dependency "%s" not found'), $Module->Name, $Dependency));
    235235      $DepModule = $this->Modules[$Dependency];
    236236      if(in_array(ModuleCondition::All, $Conditions) or
     
    318318  }
    319319
     320  function ModuleEnabled($Name)
     321  {
     322    return(array_key_exists($Name, $this->Modules) and $this->Modules[$Name]->Enabled);
     323  }
     324
     325  function ModuleRunning($Name)
     326  {
     327    return(array_key_exists($Name, $this->Modules) and $this->Modules[$Name]->Running);
     328  }
     329
    320330  /* @return Module */
    321331  function SearchModuleById($Id)
  • trunk/Packages/Common/Common.php

    r790 r791  
    1616include_once(dirname(__FILE__).'/Page.php');
    1717include_once(dirname(__FILE__).'/Locale.php');
     18include_once(dirname(__FILE__).'/Update.php');
     19include_once(dirname(__FILE__).'/Setup.php');
     20include_once(dirname(__FILE__).'/Table.php');
    1821
    1922class PackageCommon
     
    2124  var $Name;
    2225  var $Version;
     26  var $ReleaseDate;
    2327  var $License;
    2428  var $Creator;
     
    2832  {
    2933    $this->Name = 'Common';
    30     $this->Version = '1.1';
     34    $this->Version = '1.2';
     35    $this->ReleaseDate = strtotime('2016-01-22');
    3136    $this->Creator = 'Chronos';
    3237    $this->License = 'GNU/GPL';
     
    3439  }
    3540}
     41
     42class Paging
     43{
     44  var $TotalCount;
     45  var $ItemPerPage;
     46  var $Around;
     47  var $SQLLimit;
     48  var $Page;
     49
     50  function __construct()
     51  {
     52    global $System;
     53
     54    $this->ItemPerPage = $System->Config['Web']['ItemsPerPage'];
     55    $this->Around = $System->Config['Web']['VisiblePagingItems'];
     56  }
     57
     58  function Show()
     59  {
     60    $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']);
     61
     62    $Result = '';
     63    if(array_key_exists('all', $QueryItems))
     64    {
     65      $PageCount = 1;
     66      $ItemPerPage = $this->TotalCount;
     67    } else
     68    {
     69      $ItemPerPage = $this->ItemPerPage;
     70      $Around = round($this->Around / 2);
     71      $PageCount = floor($this->TotalCount / $ItemPerPage) + 1;
     72    }
     73
     74    if(!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0;
     75    if(array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1;
     76    if($_SESSION['Page'] < 0) $_SESSION['Page'] = 0;
     77    if($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1;
     78    $CurrentPage = $_SESSION['Page'];
     79
     80    $Result .= 'Počet položek: <strong>'.$this->TotalCount.'</strong> &nbsp; Stránky: ';
     81
     82    $Result = '';
     83    if($PageCount > 1)
     84    {
     85      if($CurrentPage > 0)
     86      {
     87        $QueryItems['page'] = 0;
     88        $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'">&lt;&lt;</a> ';
     89        $QueryItems['page'] = ($CurrentPage - 1);
     90        $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'">&lt;</a> ';
     91      }
     92      $PagesMax = $PageCount - 1;
     93      $PagesMin = 0;
     94      if($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around;
     95      if($PagesMin < ($CurrentPage - $Around))
     96      {
     97        $Result.= ' ... ';
     98        $PagesMin = $CurrentPage - $Around;
     99      }
     100      for($i = $PagesMin; $i <= $PagesMax; $i++)
     101      {
     102        if($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> ';
     103        else {
     104         $QueryItems['page'] = $i;
     105         $Result .= '<a href="?'.SetQueryStringArray($QueryItems).'">'.($i + 1).'</a> ';
     106        }
     107      }
     108      if($PagesMax < ($PageCount - 1)) $Result .= ' ... ';
     109      if($CurrentPage < ($PageCount - 1))
     110      {
     111        $QueryItems['page'] = ($CurrentPage + 1);
     112        $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'">&gt;</a> ';
     113        $QueryItems['page'] = ($PageCount - 1);
     114        $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'">&gt;&gt;</a>';
     115      }
     116    }
     117    $QueryItems['all'] = '1';
     118    if($PageCount > 1) $Result.= ' <a href="?'.SetQueryStringArray($QueryItems).'">Vše</a>';
     119
     120    $Result = '<div style="text-align: center">'.$Result.'</div>';
     121    $this->SQLLimit = ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage;
     122    $this->Page = $CurrentPage;
     123    return($Result);
     124  }
     125}
  • trunk/Packages/Common/Database.php

    r790 r791  
    8484  function query($Query)
    8585  {
    86     if(!$this->Connected()) throw new Exception('Not connected to database');
     86    if(!$this->Connected()) throw new Exception(T('Not connected to database'));
    8787    if(($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true)) $QueryStartTime = microtime();
    8888    $this->LastQuery = $Query;
  • trunk/Packages/Common/Mail.php

    r746 r791  
    9696  function Send()
    9797  {
    98     if(count($this->Bodies) == 0) throw new Exception('Mail: Need at least one text body');
     98    if(count($this->Bodies) == 0) throw new Exception(T('Mail message need at least one text body'));
    9999
    100100    $Body = $this->BuildAttachment($this->BuildBody());
     
    126126      }
    127127    }
    128     if($To == '') throw new Exception('Mail: Need at least one recipient address');
     128    if($To == '') throw new Exception(T('Mail message need at least one recipient address'));
    129129
    130130    $this->Headers['Mime-Version'] = '1.0';
     
    142142    $this->Subject = strtr($this->Subject, "\r\n", '  ');
    143143
    144     if($this->Subject == '') throw new Exception('Mail: Missing Subject');
     144    if($this->Subject == '') throw new Exception(T('Mail message missing Subject'));
    145145
    146146
     
    162162    {
    163163      if(!$this->ValidEmail($Address))
    164   throw new Exception('Mail: Invalid address '.$Address);
     164  throw new Exception(sprintf(T('Mail message invalid address %s'), $Address));
    165165    }
    166166  }
     
    190190        {
    191191          if(!file_exists($FileName))
    192             throw new Exception('Mail: Attached file '.$FileName.' can\'t be found');
     192            throw new Exception(sprintf(T('Mail message attached file %s can\'t be found'), $FileName));
    193193          $Data = file_get_contents($FileName);
    194194        } else
  • trunk/style/new/style.css

    r684 r791  
    440440  font-size: small;
    441441}
     442
     443.BaseTable
     444{
     445  margin: 2px auto 2px auto;
     446  border-width: 1px;
     447  border-color: black;
     448  border-style: solid;
     449  border-collapse: collapse;
     450}
     451
     452.BaseTable tr td
     453{
     454  border-width: 1px;
     455  border-color: black;
     456  border-style: solid;
     457  padding: 2px;
     458  text-align: center;
     459}
     460
     461.BaseTable tr th
     462{
     463  border-width: 1px;
     464  border-color: black;
     465  border-style: solid;
     466  padding: 2px;
     467  background-color: #F0F0F0;
     468  text-align: center;
     469}
Note: See TracChangeset for help on using the changeset viewer.