Changeset 858 for trunk/Packages


Ignore:
Timestamp:
Jan 21, 2016, 9:54:58 AM (8 years ago)
Author:
chronos
Message:
  • Modified: Custom install script replaced by more sophisticated Setup class which also allows to configure system parameters and application modules.
Location:
trunk/Packages/Common
Files:
3 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/Common/AppModule.php

    r838 r858  
    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
  • trunk/Packages/Common/Common.php

    r856 r858  
    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
     
    3437  }
    3538}
     39
     40class Paging
     41{
     42  var $TotalCount;
     43  var $ItemPerPage;
     44  var $Around;
     45  var $SQLLimit;
     46  var $Page;
     47
     48  function __construct()
     49  {
     50    global $System;
     51
     52    $this->ItemPerPage = $System->Config['Web']['ItemsPerPage'];
     53    $this->Around = $System->Config['Web']['VisiblePagingItems'];
     54  }
     55
     56  function Show()
     57  {
     58    $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']);
     59
     60    $Result = '';
     61    if(array_key_exists('all', $QueryItems))
     62    {
     63      $PageCount = 1;
     64      $ItemPerPage = $this->TotalCount;
     65    } else
     66    {
     67      $ItemPerPage = $this->ItemPerPage;
     68      $Around = round($this->Around / 2);
     69      $PageCount = floor($this->TotalCount / $ItemPerPage) + 1;
     70    }
     71
     72    if(!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0;
     73    if(array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1;
     74    if($_SESSION['Page'] < 0) $_SESSION['Page'] = 0;
     75    if($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1;
     76    $CurrentPage = $_SESSION['Page'];
     77
     78    $Result .= 'Počet položek: <strong>'.$this->TotalCount.'</strong> &nbsp; Stránky: ';
     79
     80    $Result = '';
     81    if($PageCount > 1)
     82    {
     83      if($CurrentPage > 0)
     84      {
     85        $QueryItems['page'] = 0;
     86        $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'">&lt;&lt;</a> ';
     87        $QueryItems['page'] = ($CurrentPage - 1);
     88        $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'">&lt;</a> ';
     89      }
     90      $PagesMax = $PageCount - 1;
     91      $PagesMin = 0;
     92      if($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around;
     93      if($PagesMin < ($CurrentPage - $Around))
     94      {
     95        $Result.= ' ... ';
     96        $PagesMin = $CurrentPage - $Around;
     97      }
     98      for($i = $PagesMin; $i <= $PagesMax; $i++)
     99      {
     100        if($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> ';
     101        else {
     102         $QueryItems['page'] = $i;
     103         $Result .= '<a href="?'.SetQueryStringArray($QueryItems).'">'.($i + 1).'</a> ';
     104        }
     105      }
     106      if($PagesMax < ($PageCount - 1)) $Result .= ' ... ';
     107      if($CurrentPage < ($PageCount - 1))
     108      {
     109        $QueryItems['page'] = ($CurrentPage + 1);
     110        $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'">&gt;</a> ';
     111        $QueryItems['page'] = ($PageCount - 1);
     112        $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'">&gt;&gt;</a>';
     113      }
     114    }
     115    $QueryItems['all'] = '1';
     116    if($PageCount > 1) $Result.= ' <a href="?'.SetQueryStringArray($QueryItems).'">Vše</a>';
     117
     118    $Result = '<div style="text-align: center">'.$Result.'</div>';
     119    $this->SQLLimit = ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage;
     120    $this->Page = $CurrentPage;
     121    return($Result);
     122  }
     123}
  • trunk/Packages/Common/Database.php

    r838 r858  
    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/Locale.php

    r856 r858  
    5151      $ClassName = 'LocaleText'.$Language;
    5252      $this->Texts = new $ClassName();
    53     } else throw new Exception('Language file '.$FileName.' not found');
     53    } else throw new Exception(sprintf(T('Language file %s not found'), $FileName));
    5454    $this->Texts->Load();
    5555  }
     
    236236      $this->CurrentLocale->Dir = $this->Dir;
    237237      $this->CurrentLocale->Load($Code);
    238     } else throw new Exception('Unsupported locale code '.$Code);
     238    } else throw new Exception(sprintf(T('Unsupported locale code %s'), $Code));
    239239  }
    240240}
  • trunk/Packages/Common/Mail.php

    r838 r858  
    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
Note: See TracChangeset for help on using the changeset viewer.