Changeset 21 for trunk/www/table.php
- Timestamp:
- Jun 12, 2009, 7:26:20 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/www/table.php
r20 r21 9 9 var $OnRow; 10 10 var $QueryParameters; 11 var $TotalRowCount; 11 12 12 13 function __construct($ClassName) … … 20 21 function Show() 21 22 { 23 global $Config; 24 22 25 $Header = array(); 23 26 if(!array_key_exists('Order', $_GET)) $_GET['Order'] = 0; 24 27 if(!array_key_exists('Column', $_GET)) $_GET['Column'] = 0; 25 $QueryParts = explode('&', $_SERVER['QUERY_STRING']); 26 foreach($QueryParts as $Part) 27 { 28 if($Part != '') 29 { 30 $Part2 = explode('=', $Part); 31 $QueryItems[$Part2[0]] = $Part2[1]; 32 } 33 } 34 $QueryItems['Order'] = $_GET['Order']; 28 $QueryStringArray = GetQueryStringArray(); 29 $QueryStringArray['Order'] = $_GET['Order']; 35 30 foreach($this->Definition['Items'] as $Index => $Item) 36 31 { 37 $QueryItems['Column'] = $Index; 38 if($_GET['Column'] == $Index) $QueryItems['Order'] = 1 - $_GET['Order']; 39 else $QueryItems['Order'] = $_GET['Order']; 40 $QueryParts = array(); 41 foreach($QueryItems as $Index2 => $Item2) 42 { 43 $QueryParts[] = $Index2.'='.$Item2; 44 } 45 $Header[] = '<a href="?'.implode('&', $QueryParts).'">'.$Item['Caption'].'</a>'; 32 $QueryStringArray['Column'] = $Index; 33 if($_GET['Column'] == $Index) $QueryStringArray['Order'] = 1 - $_GET['Order']; 34 else $QueryStringArray['Order'] = $_GET['Order']; 35 $Header[] = '<a href="?'.SetQueryStringArray($QueryStringArray).'">'.$Item['Caption'].'</a>'; 46 36 } 47 37 $Table = array( … … 50 40 ); 51 41 $Output = Table($Table, 'WideTable'); 42 $Output .= '<div class="Pager">'.PageList('Page', $this->Page, $this->TotalRowCount, $Config['Web']['TableRowPerPage']).'</div>'; 52 43 return($Output); 53 44 } … … 55 46 function LoadValuesFromDatabase($Database) 56 47 { 48 global $Config; 49 57 50 $OrderType = array('ASC', 'DESC'); 58 51 if(!array_key_exists('Order', $_GET)) $_GET['Order'] = 0; … … 72 65 foreach($this->QueryParameters as $Index => $Item) 73 66 $Table = str_replace('%'.$Index, $Item, $Table); 74 $DbResult = $Database->query('SELECT * FROM '.$Table.' ORDER BY T.'.$_GET['Column'].' '.$OrderType[$_GET['Order']]); 67 $DbResult = $Database->query('SELECT COUNT(*) FROM '.$Table.' ORDER BY T.'.$_GET['Column'].' '.$OrderType[$_GET['Order']]); 68 $DbRow = $DbResult->fetch_row(); 69 $this->TotalRowCount = $DbRow[0]; 70 if(array_key_exists('Page', $_GET)) $this->Page = $_GET['Page']; else $this->Page = 0; 71 if($this->Page > ($this->TotalRowCount / $Config['Web']['TableRowPerPage'])) $this->Page = 0; 72 $DbResult = $Database->query('SELECT * FROM '.$Table.' ORDER BY T.'.$_GET['Column'].' '.$OrderType[$_GET['Order']].' LIMIT '.($this->Page * $Config['Web']['TableRowPerPage']).', '.$Config['Web']['TableRowPerPage']); 75 73 while($DbRow = $DbResult->fetch_assoc()) 76 74 { … … 90 88 $this->Values[] = $Row; 91 89 } 92 } 90 } 93 91 } 94 92
Note:
See TracChangeset
for help on using the changeset viewer.