Changeset 7 for trunk/Packages/Common/Table.php
- Timestamp:
- Apr 14, 2020, 11:13:32 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/Table.php
r1 r7 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 } … … 112 112 { 113 113 $this->Columns = array(); 114 foreach ($Columns as $Column)114 foreach ($Columns as $Column) 115 115 { 116 116 $NewCol = new TableColumn(); … … 119 119 $this->Columns[] = $NewCol; 120 120 } 121 if (count($this->Columns) > 0)121 if (count($this->Columns) > 0) 122 122 $this->DefaultColumn = $this->Columns[0]->Name; 123 123 else $this->DefaultColumn = ''; … … 129 129 $Output .= $this->GetOrderHeader(); 130 130 $this->Table->BeginRead(); 131 for ($Y = 0; $Y < $this->Table->RowsCount(); $Y++)131 for ($Y = 0; $Y < $this->Table->RowsCount(); $Y++) 132 132 { 133 133 $Output .= '<tr>'; 134 134 135 for ($X = 0; $X < count($this->Columns); $X++)135 for ($X = 0; $X < count($this->Columns); $X++) 136 136 { 137 137 $Cell = $this->Table->GetCell($Y, $X); 138 if ($Cell == '') $Output .= '<td> </td>';138 if ($Cell == '') $Output .= '<td> </td>'; 139 139 else $Output .= '<td>'.$Cell.'</td>'; 140 140 } … … 143 143 $this->Table->EndRead(); 144 144 $Output .= '</table>'; 145 return ($Output);145 return $Output; 146 146 } 147 147 148 148 function GetOrderHeader() 149 149 { 150 if (array_key_exists('OrderCol', $_GET)) $_SESSION['OrderCol'] = $_GET['OrderCol'];151 if (array_key_exists('OrderDir', $_GET)) $_SESSION['OrderDir'] = $_GET['OrderDir'];152 if (!array_key_exists('OrderCol', $_SESSION)) $_SESSION['OrderCol'] = $this->DefaultColumn;153 if (!array_key_exists('OrderDir', $_SESSION)) $_SESSION['OrderDir'] = $this->DefaultOrder;150 if (array_key_exists('OrderCol', $_GET)) $_SESSION['OrderCol'] = $_GET['OrderCol']; 151 if (array_key_exists('OrderDir', $_GET)) $_SESSION['OrderDir'] = $_GET['OrderDir']; 152 if (!array_key_exists('OrderCol', $_SESSION)) $_SESSION['OrderCol'] = $this->DefaultColumn; 153 if (!array_key_exists('OrderDir', $_SESSION)) $_SESSION['OrderDir'] = $this->DefaultOrder; 154 154 155 155 // Check OrderCol 156 156 $Found = false; 157 foreach ($this->Columns as $Column)157 foreach ($this->Columns as $Column) 158 158 { 159 if ($Column->Name == $_SESSION['OrderCol'])159 if ($Column->Name == $_SESSION['OrderCol']) 160 160 { 161 161 $Found = true; … … 163 163 } 164 164 } 165 if ($Found == false)165 if ($Found == false) 166 166 { 167 167 $_SESSION['OrderCol'] = $this->DefaultColumn; … … 169 169 } 170 170 // Check OrderDir 171 if (($_SESSION['OrderDir'] != 0) and ($_SESSION['OrderDir'] != 1))171 if (($_SESSION['OrderDir'] != 0) and ($_SESSION['OrderDir'] != 1)) 172 172 $_SESSION['OrderDir'] = 0; 173 173 174 174 $Result = ''; 175 175 $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']); 176 foreach ($this->Columns as $Index => $Column)176 foreach ($this->Columns as $Index => $Column) 177 177 { 178 178 $QueryItems['OrderCol'] = $Column->Name; 179 179 $QueryItems['OrderDir'] = 1 - $_SESSION['OrderDir']; 180 if ($Column->Name == $_SESSION['OrderCol'])180 if ($Column->Name == $_SESSION['OrderCol']) 181 181 $ArrowImage = '<img style="vertical-align: middle; border: 0px;" src="'.$this->OrderArrowImage[$_SESSION['OrderDir']].'" alt="order arrow">'; 182 182 else $ArrowImage = ''; 183 if ($Column->Name == '') $Result .= '<th>'.$Column->Title.'</th>';183 if ($Column->Name == '') $Result .= '<th>'.$Column->Title.'</th>'; 184 184 else $Result .= '<th><a href="?'.SetQueryStringArray($QueryItems).'">'.$Column->Title.$ArrowImage.'</a></th>'; 185 185 } … … 188 188 $this->OrderDirection = $_SESSION['OrderDir']; 189 189 190 return ('<tr>'.$Result.'</tr>');190 return '<tr>'.$Result.'</tr>'; 191 191 } 192 192 }
Note:
See TracChangeset
for help on using the changeset viewer.