Changeset 8 for trunk/Packages/Common/Common.php
- Timestamp:
- Jun 1, 2023, 12:18:18 AM (18 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/Common.php
r7 r8 11 11 include_once(dirname(__FILE__).'/Error.php'); 12 12 include_once(dirname(__FILE__).'/Base.php'); 13 include_once(dirname(__FILE__).'/Application.php'); 14 include_once(dirname(__FILE__).'/AppModule.php'); 13 include_once(dirname(__FILE__).'/View.php'); 14 include_once(dirname(__FILE__).'/Model.php'); 15 include_once(dirname(__FILE__).'/ModelDesc.php'); 16 include_once(dirname(__FILE__).'/Controller.php'); 17 include_once(dirname(__FILE__).'/System.php'); 18 include_once(dirname(__FILE__).'/Module.php'); 19 include_once(dirname(__FILE__).'/ModuleManager.php'); 20 include_once(dirname(__FILE__).'/ModelDef.php'); 15 21 include_once(dirname(__FILE__).'/Config.php'); 16 22 include_once(dirname(__FILE__).'/Page.php'); 17 23 include_once(dirname(__FILE__).'/Locale.php'); 18 24 include_once(dirname(__FILE__).'/Update.php'); 19 include_once(dirname(__FILE__).'/Setup.php');20 25 include_once(dirname(__FILE__).'/Table.php'); 21 include_once(dirname(__FILE__).'/Form/Form.php'); 26 include_once(dirname(__FILE__).'/Process.php'); 27 include_once(dirname(__FILE__).'/Generics.php'); 28 include_once(dirname(__FILE__).'/BigInt.php'); 29 include_once(dirname(__FILE__).'/Int128.php'); 30 include_once(dirname(__FILE__).'/Pdf.php'); 31 include_once(dirname(__FILE__).'/Paging.php'); 32 include_once(dirname(__FILE__).'/Modules/Setup.php'); 33 include_once(dirname(__FILE__).'/Modules/ModuleManager.php'); 22 34 23 35 class PackageCommon 24 36 { 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; 31 43 32 44 function __construct() … … 34 46 $this->Name = 'Common'; 35 47 $this->Version = '1.2'; 36 $this->ReleaseDate = strtotime('20 16-01-22');48 $this->ReleaseDate = strtotime('2023-05-31'); 37 49 $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/'; 40 52 } 41 53 } 42 43 class Paging44 {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 } else67 {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> 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).'"><<</a> ';88 $QueryItems['page'] = ($CurrentPage - 1);89 $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'"><</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).'">></a> ';112 $QueryItems['page'] = ($PageCount - 1);113 $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'">>></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.