Changeset 92 for trunk/Packages/Common/Table.php
- Timestamp:
- Apr 7, 2020, 11:53:58 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/Table.php
r90 r92 7 7 function Show() 8 8 { 9 return ('');9 return ''; 10 10 } 11 11 } … … 15 15 function GetCell($Y, $X) 16 16 { 17 return ('');17 return ''; 18 18 } 19 19 … … 28 28 function RowsCount() 29 29 { 30 return (0);30 return 0; 31 31 } 32 32 } … … 38 38 function GetCell($Y, $X) 39 39 { 40 return ($this->Cells[$Y][$X]);40 return $this->Cells[$Y][$X]; 41 41 } 42 42 43 43 function RowsCount() 44 44 { 45 return (count($this->Cells));45 return count($this->Cells); 46 46 } 47 47 } … … 55 55 function GetCell($Y, $X) 56 56 { 57 return ($this->Cells[$Y][$X]);57 return $this->Cells[$Y][$X]; 58 58 } 59 59 … … 62 62 $this->Cells = array(); 63 63 $DbResult = $this->Database->query($this->Query); 64 while ($DbRow = $DbResult->fetch_row())64 while ($DbRow = $DbResult->fetch_row()) 65 65 { 66 66 $this->Cells[] = $DbRow; … … 75 75 function RowsCount() 76 76 { 77 return (count($this->Cells));77 return count($this->Cells); 78 78 } 79 79 } … … 114 114 { 115 115 $this->Columns = array(); 116 foreach ($Columns as $Column)116 foreach ($Columns as $Column) 117 117 { 118 118 $NewCol = new TableColumn(); … … 121 121 $this->Columns[] = $NewCol; 122 122 } 123 if (count($this->Columns) > 0)123 if (count($this->Columns) > 0) 124 124 $this->DefaultColumn = $this->Columns[0]->Name; 125 125 else $this->DefaultColumn = ''; … … 131 131 $Output .= $this->GetOrderHeader(); 132 132 $this->Table->BeginRead(); 133 for ($Y = 0; $Y < $this->Table->RowsCount(); $Y++)133 for ($Y = 0; $Y < $this->Table->RowsCount(); $Y++) 134 134 { 135 135 $Output .= '<tr>'; 136 136 137 for ($X = 0; $X < count($this->Columns); $X++)137 for ($X = 0; $X < count($this->Columns); $X++) 138 138 { 139 139 $Cell = $this->Table->GetCell($Y, $X); 140 if ($Cell == '') $Output .= '<td> </td>';140 if ($Cell == '') $Output .= '<td> </td>'; 141 141 else $Output .= '<td>'.$Cell.'</td>'; 142 142 } … … 145 145 $this->Table->EndRead(); 146 146 $Output .= '</table>'; 147 return ($Output);147 return $Output; 148 148 } 149 149 150 150 function GetOrderHeader() 151 151 { 152 if (array_key_exists('OrderCol', $_GET)) $_SESSION['OrderCol'] = $_GET['OrderCol'];153 if (array_key_exists('OrderDir', $_GET)) $_SESSION['OrderDir'] = $_GET['OrderDir'];154 if (!array_key_exists('OrderCol', $_SESSION)) $_SESSION['OrderCol'] = $this->DefaultColumn;155 if (!array_key_exists('OrderDir', $_SESSION)) $_SESSION['OrderDir'] = $this->DefaultOrder;152 if (array_key_exists('OrderCol', $_GET)) $_SESSION['OrderCol'] = $_GET['OrderCol']; 153 if (array_key_exists('OrderDir', $_GET)) $_SESSION['OrderDir'] = $_GET['OrderDir']; 154 if (!array_key_exists('OrderCol', $_SESSION)) $_SESSION['OrderCol'] = $this->DefaultColumn; 155 if (!array_key_exists('OrderDir', $_SESSION)) $_SESSION['OrderDir'] = $this->DefaultOrder; 156 156 157 157 // Check OrderCol 158 158 $Found = false; 159 foreach ($this->Columns as $Column)159 foreach ($this->Columns as $Column) 160 160 { 161 if ($Column->Name == $_SESSION['OrderCol'])161 if ($Column->Name == $_SESSION['OrderCol']) 162 162 { 163 163 $Found = true; … … 165 165 } 166 166 } 167 if ($Found == false)167 if ($Found == false) 168 168 { 169 169 $_SESSION['OrderCol'] = $this->DefaultColumn; … … 171 171 } 172 172 // Check OrderDir 173 if (($_SESSION['OrderDir'] != 0) and ($_SESSION['OrderDir'] != 1))173 if (($_SESSION['OrderDir'] != 0) and ($_SESSION['OrderDir'] != 1)) 174 174 $_SESSION['OrderDir'] = 0; 175 175 176 176 $Result = ''; 177 177 $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']); 178 foreach ($this->Columns as $Index => $Column)178 foreach ($this->Columns as $Index => $Column) 179 179 { 180 180 $QueryItems['OrderCol'] = $Column->Name; 181 181 $QueryItems['OrderDir'] = 1 - $_SESSION['OrderDir']; 182 if ($Column->Name == $_SESSION['OrderCol'])182 if ($Column->Name == $_SESSION['OrderCol']) 183 183 $ArrowImage = '<img style="vertical-align: middle; border: 0px;" src="'.$this->OrderArrowImage[$_SESSION['OrderDir']].'" alt="order arrow">'; 184 184 else $ArrowImage = ''; 185 if ($Column->Name == '') $Result .= '<th>'.$Column->Title.'</th>';185 if ($Column->Name == '') $Result .= '<th>'.$Column->Title.'</th>'; 186 186 else $Result .= '<th><a href="?'.SetQueryStringArray($QueryItems).'">'.$Column->Title.$ArrowImage.'</a></th>'; 187 187 } … … 190 190 $this->OrderDirection = $_SESSION['OrderDir']; 191 191 192 return ('<tr>'.$Result.'</tr>');192 return '<tr>'.$Result.'</tr>'; 193 193 } 194 194 }
Note:
See TracChangeset
for help on using the changeset viewer.