Ignore:
Timestamp:
Jun 1, 2023, 12:18:18 AM (12 months ago)
Author:
chronos
Message:
  • Modified: Updated Common package.
  • Modified: Form types made as separate FormManager package.
  • Fixed: PHP 8.1 support.
File:
1 edited

Legend:

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

    r7 r8  
    1111include_once(dirname(__FILE__).'/Error.php');
    1212include_once(dirname(__FILE__).'/Base.php');
    13 include_once(dirname(__FILE__).'/Application.php');
    14 include_once(dirname(__FILE__).'/AppModule.php');
     13include_once(dirname(__FILE__).'/View.php');
     14include_once(dirname(__FILE__).'/Model.php');
     15include_once(dirname(__FILE__).'/ModelDesc.php');
     16include_once(dirname(__FILE__).'/Controller.php');
     17include_once(dirname(__FILE__).'/System.php');
     18include_once(dirname(__FILE__).'/Module.php');
     19include_once(dirname(__FILE__).'/ModuleManager.php');
     20include_once(dirname(__FILE__).'/ModelDef.php');
    1521include_once(dirname(__FILE__).'/Config.php');
    1622include_once(dirname(__FILE__).'/Page.php');
    1723include_once(dirname(__FILE__).'/Locale.php');
    1824include_once(dirname(__FILE__).'/Update.php');
    19 include_once(dirname(__FILE__).'/Setup.php');
    2025include_once(dirname(__FILE__).'/Table.php');
    21 include_once(dirname(__FILE__).'/Form/Form.php');
     26include_once(dirname(__FILE__).'/Process.php');
     27include_once(dirname(__FILE__).'/Generics.php');
     28include_once(dirname(__FILE__).'/BigInt.php');
     29include_once(dirname(__FILE__).'/Int128.php');
     30include_once(dirname(__FILE__).'/Pdf.php');
     31include_once(dirname(__FILE__).'/Paging.php');
     32include_once(dirname(__FILE__).'/Modules/Setup.php');
     33include_once(dirname(__FILE__).'/Modules/ModuleManager.php');
    2234
    2335class PackageCommon
    2436{
    25   var $Name;
    26   var $Version;
    27   var $ReleaseDate;
    28   var $License;
    29   var $Creator;
    30   var $Homepage;
     37  public string $Name;
     38  public string $Version;
     39  public int $ReleaseDate;
     40  public string $License;
     41  public string $Creator;
     42  public string $Homepage;
    3143
    3244  function __construct()
     
    3446    $this->Name = 'Common';
    3547    $this->Version = '1.2';
    36     $this->ReleaseDate = strtotime('2016-01-22');
     48    $this->ReleaseDate = strtotime('2023-05-31');
    3749    $this->Creator = 'Chronos';
    38     $this->License = 'GNU/GPL';
    39     $this->Homepage = 'http://svn.zdechov.net/svn/PHPlib/Common/';
     50    $this->License = 'GNU/GPLv3';
     51    $this->Homepage = 'https://svn.zdechov.net/PHPlib/Common/';
    4052  }
    4153}
    42 
    43 class Paging
    44 {
    45   var $TotalCount;
    46   var $ItemPerPage;
    47   var $Around;
    48   var $SQLLimit;
    49   var $Page;
    50 
    51   function __construct(Application $System)
    52   {
    53     $this->ItemPerPage = $System->Config['Web']['ItemsPerPage'];
    54     $this->Around = $System->Config['Web']['VisiblePagingItems'];
    55   }
    56 
    57   function Show()
    58   {
    59     $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']);
    60 
    61     $Result = '';
    62     if (array_key_exists('all', $QueryItems))
    63     {
    64       $PageCount = 1;
    65       $ItemPerPage = $this->TotalCount;
    66     } else
    67     {
    68       $ItemPerPage = $this->ItemPerPage;
    69       $Around = round($this->Around / 2);
    70       $PageCount = floor($this->TotalCount / $ItemPerPage) + 1;
    71     }
    72 
    73     if (!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0;
    74     if (array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1;
    75     if ($_SESSION['Page'] < 0) $_SESSION['Page'] = 0;
    76     if ($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1;
    77     $CurrentPage = $_SESSION['Page'];
    78 
    79     $Result .= 'Počet položek: <strong>'.$this->TotalCount.'</strong> &nbsp; Stránky: ';
    80 
    81     $Result = '';
    82     if ($PageCount > 1)
    83     {
    84       if ($CurrentPage > 0)
    85       {
    86         $QueryItems['page'] = 0;
    87         $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'">&lt;&lt;</a> ';
    88         $QueryItems['page'] = ($CurrentPage - 1);
    89         $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'">&lt;</a> ';
    90       }
    91       $PagesMax = $PageCount - 1;
    92       $PagesMin = 0;
    93       if ($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around;
    94       if ($PagesMin < ($CurrentPage - $Around))
    95       {
    96         $Result.= ' ... ';
    97         $PagesMin = $CurrentPage - $Around;
    98       }
    99       for ($i = $PagesMin; $i <= $PagesMax; $i++)
    100       {
    101         if ($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> ';
    102         else {
    103          $QueryItems['page'] = $i;
    104          $Result .= '<a href="?'.SetQueryStringArray($QueryItems).'">'.($i + 1).'</a> ';
    105         }
    106       }
    107       if ($PagesMax < ($PageCount - 1)) $Result .= ' ... ';
    108       if ($CurrentPage < ($PageCount - 1))
    109       {
    110         $QueryItems['page'] = ($CurrentPage + 1);
    111         $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'">&gt;</a> ';
    112         $QueryItems['page'] = ($PageCount - 1);
    113         $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'">&gt;&gt;</a>';
    114       }
    115     }
    116     $QueryItems['all'] = '1';
    117     if ($PageCount > 1) $Result.= ' <a href="?'.SetQueryStringArray($QueryItems).'">Vše</a>';
    118 
    119     $Result = '<div style="text-align: center">'.$Result.'</div>';
    120     $this->SQLLimit = ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage;
    121     $this->Page = $CurrentPage;
    122     return $Result;
    123   }
    124 }
Note: See TracChangeset for help on using the changeset viewer.