Changeset 15 for trunk/www/table.php
- Timestamp:
- Jun 12, 2009, 8:09:48 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/www/table.php
r11 r15 8 8 var $Header; 9 9 var $OnRow; 10 var $QueryParameters; 10 11 11 12 function __construct($ClassName) … … 14 15 15 16 $this->Definition = &$FormClasses[$ClassName]; 17 $this->QueryParameters = array(); 16 18 } 17 19 18 20 function Show() 19 21 { 22 $Header = array(); 23 if(!array_key_exists('Order', $_GET)) $_GET['Order'] = 0; 24 if(!array_key_exists('Column', $_GET)) $_GET['Column'] = 0; 25 $QueryParts = explode('&', $_SERVER['QUERY_STRING']); 26 foreach($QueryParts as $Part) 27 { 28 $Part2 = explode('=', $Part); 29 $QueryItems[$Part2[0]] = $Part2[1]; 30 } 31 $QueryItems['Order'] = $_GET['Order']; 32 foreach($this->Definition['Items'] as $Index => $Item) 33 { 34 $QueryItems['Column'] = $Index; 35 if($_GET['Column'] == $Index) $QueryItems['Order'] = 1 - $_GET['Order']; 36 else $QueryItems['Order'] = $_GET['Order']; 37 $QueryParts = array(); 38 foreach($QueryItems as $Index2 => $Item2) 39 { 40 $QueryParts[] = $Index2.'='.$Item2; 41 } 42 $Header[] = '<a href="?'.implode('&', $QueryParts).'">'.$Item['Caption'].'</a>'; 43 } 20 44 $Table = array( 21 'Header' => $ this->Header,45 'Header' => $Header, 22 46 'Rows' => $this->Values, 23 47 ); … … 28 52 function LoadValuesFromDatabase($Database) 29 53 { 54 $OrderType = array('ASC', 'DESC'); 55 if(!array_key_exists('Order', $_GET)) $_GET['Order'] = 0; 56 else if($_GET['Order'] == 'Asc') $_GET['Order'] = 1; 57 if(!array_key_exists('Column', $_GET)) 58 { 59 $Keys = array_keys($this->Definition['Items']); 60 $_GET['Column'] = $Keys[0]; 61 } 30 62 $this->Header = array(); 31 63 foreach($this->Definition['Items'] as $Index => $Item) 32 64 { 33 65 $this->Header[] = $Item['Caption']; 34 35 66 } 36 67 $this->Values = array(); 37 $DbResult = $Database->query('SELECT * FROM '.$this->Definition['Table']); 68 $Table = $this->Definition['Table']; 69 foreach($this->QueryParameters as $Index => $Item) 70 $Table = str_replace('%'.$Index, $Item, $Table); 71 $DbResult = $Database->query('SELECT * FROM '.$Table.' ORDER BY T.'.$_GET['Column'].' '.$OrderType[$_GET['Order']]); 38 72 while($DbRow = $DbResult->fetch_assoc()) 39 73 {
Note:
See TracChangeset
for help on using the changeset viewer.