Changeset 636 for trunk/Common/Table.php
- Timestamp:
- Jan 21, 2014, 12:02:53 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/Table.php
r635 r636 11 11 } 12 12 13 class Table 14 { 15 function GetCell($Y, $X) 16 { 17 return(''); 18 } 19 20 function BeginRead() 21 { 22 } 23 24 function EndRead() 25 { 26 } 27 28 function RowsCount() 29 { 30 return(0); 31 } 32 } 33 34 class TableMemory extends Table 35 { 36 var $Cells; 37 38 function GetCell($Y, $X) 39 { 40 return($this->Cells[$Y][$X]); 41 } 42 43 function RowsCount() 44 { 45 return(count($this->Cells)); 46 } 47 } 48 49 class TableSQL extends Table 50 { 51 var $Query; 52 var $Database; 53 var $Cells; 54 55 function GetCell($Y, $X) 56 { 57 return($this->Cells[$Y][$X]); 58 } 59 60 function BeginRead() 61 { 62 $this->Cells = array(); 63 $DbResult = $this->Database->query($this->Query); 64 while($DbRow = $DbResult->fetch_row()) 65 { 66 $this->Cells[] = $DbRow; 67 } 68 } 69 70 function EndRead() 71 { 72 $this->Cells = array(); 73 } 74 75 function RowsCount() 76 { 77 return(count($this->Cells)); 78 } 79 } 80 13 81 class TableColumn 14 82 { … … 17 85 } 18 86 19 class Table extends Control87 class VisualTable extends Control 20 88 { 21 89 var $Cells; 22 90 var $Columns; 23 var $OrderDirSQL; 91 var $OrderSQL; 92 var $OrderColumn; 93 var $OrderDirection; 24 94 var $OrderArrowImage; 25 95 var $DefaultColumn; 26 96 var $DefaultOrder; 97 var $Table; 27 98 28 99 function __construct() … … 31 102 32 103 $this->Columns = array(); 33 $this-> Cells = array();104 $this->Table = new TableMemory(); 34 105 $this->OrderDirSQL = array('ASC', 'DESC'); 35 106 $this->OrderArrowImage = array($System->Link('/images/sort_asc.png'), … … 57 128 $Output = '<table class="WideTable">'; 58 129 $Output .= $this->GetOrderHeader(); 59 foreach($this->Cells as $Row) 130 $this->Table->BeginRead(); 131 for($Y = 0; $Y < $this->Table->RowsCount(); $Y++) 60 132 { 61 133 $Output .= '<tr>'; 62 foreach($Row as $Cell) 134 135 for($X = 0; $X < count($this->Columns); $X++) 63 136 { 137 $Cell = $this->Table->GetCell($Y, $X); 64 138 if($Cell == '') $Output .= '<td> </td>'; 65 139 else $Output .= '<td>'.$Cell.'</td>'; 66 } 140 } 67 141 $Output .= '</tr>'; 68 142 } 143 $this->Table->EndRead(); 69 144 $Output .= '</table>'; 70 145 return($Output); … … 109 184 else $Result .= '<th><a href="?'.SetQueryStringArray($QueryItems).'">'.$Column->Title.$ArrowImage.'</a></th>'; 110 185 } 111 $this-> SQL = ' ORDER BY `'.$_SESSION['OrderCol'].'` '.$this->OrderDirSQL[$_SESSION['OrderDir']];112 $this-> Column = $_SESSION['OrderCol'];113 $this-> Direction = $_SESSION['OrderDir'];186 $this->OrderSQL = ' ORDER BY `'.$_SESSION['OrderCol'].'` '.$this->OrderDirSQL[$_SESSION['OrderDir']]; 187 $this->OrderColumn = $_SESSION['OrderCol']; 188 $this->OrderDirection = $_SESSION['OrderDir']; 114 189 115 190 return($Result);
Note:
See TracChangeset
for help on using the changeset viewer.