Changeset 32 for trunk/Global.php
- Timestamp:
- Apr 7, 2020, 1:06:13 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Global.php
r4 r32 3 3 function HumanDate($Time) 4 4 { 5 return (date('j.n.Y', $Time));5 return date('j.n.Y', $Time); 6 6 } 7 7 8 8 function HumanDateTime($Time) 9 9 { 10 return (date('j.n.Y H:i:s', $Time));10 return date('j.n.Y H:i:s', $Time); 11 11 } 12 12 … … 22 22 $Result = array(); 23 23 $Parts = explode('&', $QueryString); 24 foreach ($Parts as $Part)24 foreach ($Parts as $Part) 25 25 { 26 if ($Part != '')26 if ($Part != '') 27 27 { 28 if (!strpos($Part, '=')) $Part .= '=';28 if (!strpos($Part, '=')) $Part .= '='; 29 29 $Item = explode('=', $Part); 30 30 $Result[$Item[0]] = $Item[1]; 31 31 } 32 32 } 33 return ($Result);33 return $Result; 34 34 } 35 35 … … 37 37 { 38 38 $Parts = array(); 39 foreach ($QueryStringArray as $Index => $Item)39 foreach ($QueryStringArray as $Index => $Item) 40 40 { 41 41 if ($Index != 'lvm') $Parts[] = $Index.'='.$Item; 42 42 } 43 return (implode('&', $Parts));43 return implode('&', $Parts); 44 44 } 45 45 … … 55 55 $PageCount = floor($TotalCount / $ItemPerPage) + 1; 56 56 57 if (!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0;58 if (array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1;59 if ($_SESSION['Page'] < 0) $_SESSION['Page'] = 0;60 if ($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1;57 if (!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0; 58 if (array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1; 59 if ($_SESSION['Page'] < 0) $_SESSION['Page'] = 0; 60 if ($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1; 61 61 $CurrentPage = $_SESSION['Page']; 62 62 … … 65 65 66 66 $Result = ''; 67 if ($PageCount > 1)67 if ($PageCount > 1) 68 68 { 69 if ($CurrentPage > 0)69 if ($CurrentPage > 0) 70 70 { 71 71 $QueryItems['page'] = 0; … … 76 76 $PagesMax = $PageCount - 1; 77 77 $PagesMin = 0; 78 if ($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around;79 if ($PagesMin < ($CurrentPage - $Around))78 if ($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around; 79 if ($PagesMin < ($CurrentPage - $Around)) 80 80 { 81 81 $Result.= ' ... '; 82 82 $PagesMin = $CurrentPage - $Around; 83 83 } 84 for ($i = $PagesMin; $i <= $PagesMax; $i++)84 for ($i = $PagesMin; $i <= $PagesMax; $i++) 85 85 { 86 if ($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> ';86 if ($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> '; 87 87 else { 88 88 $QueryItems['page'] = $i; … … 90 90 } 91 91 } 92 if ($PagesMax < ($PageCount - 1)) $Result .= ' ... ';93 if ($CurrentPage < ($PageCount - 1))92 if ($PagesMax < ($PageCount - 1)) $Result .= ' ... '; 93 if ($CurrentPage < ($PageCount - 1)) 94 94 { 95 95 $QueryItems['page'] = ($CurrentPage + 1); … … 100 100 } 101 101 $Result = '<div style="text-align: center">'.$Result.'</div>'; 102 return (array('SQLLimit' => ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage,102 return array('SQLLimit' => ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage, 103 103 'Page' => $CurrentPage, 104 104 'Output' => $Result, 105 ) );105 ); 106 106 } 107 107 … … 113 113 global $OrderDirSQL, $OrderArrowImage, $Config; 114 114 115 if (array_key_exists('OrderCol', $_GET)) $_SESSION['OrderCol'] = $_GET['OrderCol'];116 if (array_key_exists('OrderDir', $_GET) and (array_key_exists($_GET['OrderDir'], $OrderArrowImage)))115 if (array_key_exists('OrderCol', $_GET)) $_SESSION['OrderCol'] = $_GET['OrderCol']; 116 if (array_key_exists('OrderDir', $_GET) and (array_key_exists($_GET['OrderDir'], $OrderArrowImage))) 117 117 $_SESSION['OrderDir'] = $_GET['OrderDir']; 118 if (!array_key_exists('OrderCol', $_SESSION)) $_SESSION['OrderCol'] = $DefaultColumn;119 if (!array_key_exists('OrderDir', $_SESSION)) $_SESSION['OrderDir'] = $DefaultOrder;118 if (!array_key_exists('OrderCol', $_SESSION)) $_SESSION['OrderCol'] = $DefaultColumn; 119 if (!array_key_exists('OrderDir', $_SESSION)) $_SESSION['OrderDir'] = $DefaultOrder; 120 120 121 121 // Check OrderCol 122 122 $Found = false; 123 foreach ($Columns as $Column)123 foreach ($Columns as $Column) 124 124 { 125 if ($Column['Name'] == $_SESSION['OrderCol'])125 if ($Column['Name'] == $_SESSION['OrderCol']) 126 126 { 127 127 $Found = true; … … 129 129 } 130 130 } 131 if ($Found == false)131 if ($Found == false) 132 132 { 133 133 $_SESSION['OrderCol'] = $DefaultColumn; … … 135 135 } 136 136 // Check OrderDir 137 if (($_SESSION['OrderDir'] != 0) and ($_SESSION['OrderDir'] != 1)) $_SESSION['OrderDir'] = 0;137 if (($_SESSION['OrderDir'] != 0) and ($_SESSION['OrderDir'] != 1)) $_SESSION['OrderDir'] = 0; 138 138 139 139 $Result = ''; 140 140 $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']); 141 foreach ($Columns as $Index => $Column)141 foreach ($Columns as $Index => $Column) 142 142 { 143 143 $QueryItems['OrderCol'] = $Column['Name']; 144 144 $QueryItems['OrderDir'] = 1 - $_SESSION['OrderDir']; 145 if ($Column['Name'] == $_SESSION['OrderCol']) $ArrowImage = '<img style="vertical-align: middle; border: 0px;" src="'.145 if ($Column['Name'] == $_SESSION['OrderCol']) $ArrowImage = '<img style="vertical-align: middle; border: 0px;" src="'. 146 146 Link2('/images/'.$OrderArrowImage[$_SESSION['OrderDir']]).'" alt="order arrow"/>'; 147 147 else $ArrowImage = ''; 148 if ($Column['Name'] == '') $Result .= '<th>'.$Column['Title'].'</th>';148 if ($Column['Name'] == '') $Result .= '<th>'.$Column['Title'].'</th>'; 149 149 else $Result .= '<th><a href="?'.SetQueryStringArray($QueryItems).'">'.$Column['Title'].$ArrowImage.'</a></th>'; 150 150 } 151 return (array(151 return array( 152 152 'SQL' => ' ORDER BY `'.$_SESSION['OrderCol'].'` '.$OrderDirSQL[$_SESSION['OrderDir']], 153 153 'Output' => '<tr>'.$Result.'</tr>', 154 154 'Column' => $_SESSION['OrderCol'], 155 155 'Direction' => $_SESSION['OrderDir'], 156 ) );156 ); 157 157 }
Note:
See TracChangeset
for help on using the changeset viewer.