3 class SimpleGridCell {
\r
7 function __construct() {
\r
11 function __destruct() {
\r
15 function HeadingCell() {
\r
18 if (array_key_exists("colspan",$this->attr)) {
\r
19 $span=$this->attr["colspan"];
\r
20 $s.=" colspan='".$span."'";
\r
22 return array($s."><div class='ricoLG_col'>".$this->DataCell("")."</div></td>", $span);
\r
25 function DataCell($rowclass) {
\r
27 $this->attr["class"]=trim("ricoLG_cell ".$this->GetAttr("class")." ".$rowclass);
\r
28 foreach ($this->attr as $k => $v) {
\r
29 if ($k != "colspan") {
\r
30 $s.=" ".$k."='".$v."'";
\r
33 $s.=">".$this->content."</div>";
\r
37 function HtmlCell() {
\r
39 foreach ($this->attr as $k => $v) {
\r
40 $s.=" ".$k."='".$v."'";
\r
42 $s.=">".$this->content."</td>";
\r
46 function GetAttr($name) {
\r
47 return (array_key_exists($name,$this->attr)) ? $this->attr[$name] : "";
\r
50 function SetAttr($name, $value) {
\r
51 $this->attr[$name]=$value;
\r
55 class SimpleGridRow {
\r
60 function __construct() {
\r
61 $this->cells=array();
\r
62 $this->attr=array();
\r
65 function __destruct() {
\r
69 function AddCell($content) {
\r
70 array_push($this->cells, new SimpleGridCell());
\r
71 $this->CurrentCell=&$this->cells[count($this->cells)-1];
\r
72 $this->CurrentCell->content=$content;
\r
75 function HeadingRow($c1, $c2) {
\r
79 while ($colidx < $c1 && $cellidx < count($this->cells)) {
\r
80 $a=$this->cells[$cellidx]->HeadingCell();
\r
81 $colidx+=intval($a[1]);
\r
84 while (($colidx <= $c2) && $cellidx <= count($this->cells)-1) {
\r
85 $a=$this->cells[$cellidx]->HeadingCell();
\r
87 $colidx+=intval($a[1]);
\r
93 function HeadingClass() {
\r
95 if (array_key_exists("class",$this->attr)) $s.=" ".$this->attr["class"];
\r
99 function CellCount() {
\r
100 return count($this->cells);
\r
103 function GetRowAttr($name) {
\r
104 return (array_key_exists($name,$this->attr)) ? $this->attr[$name] : "";
\r
107 function SetRowAttr($name, $value) {
\r
108 $this->attr[$name]=$value;
\r
111 function SetCellAttr($name, $value) {
\r
112 $this->CurrentCell->SetAttr($name, $value);
\r
119 var $LastHeadingRow;
\r
120 var $ResizeRowIdx=-1;
\r
122 function __construct() {
\r
123 $this->rows=array();
\r
126 function AddHeadingRow($ResizeRowFlag) {
\r
127 $this->LastHeadingRow=$this->AddDataRow();
\r
128 if ($ResizeRowFlag) {
\r
129 $this->ResizeRowIdx=$this->LastHeadingRow;
\r
131 return $this->LastHeadingRow;
\r
134 function AddDataRow() {
\r
135 array_push($this->rows, new SimpleGridRow());
\r
136 $this->LastRow=count($this->rows)-1;
\r
137 return $this->LastRow;
\r
140 function HeadingRowCount() {
\r
141 return empty($this->LastHeadingRow) ? 0 : $this->LastHeadingRow+1;
\r
144 function DataRowCount() {
\r
145 return empty($this->LastRow) ? 0 : $this->LastRow+1-$this->HeadingRowCount();
\r
148 // returns # of cells in the current row
\r
149 function CellCount() {
\r
150 return $this->rows[$this->LastRow]->CellCount();
\r
153 function AddCell($content) {
\r
154 $this->rows[$this->LastRow]->AddCell($content);
\r
157 function AddCellToRow($RowIdx, $content) {
\r
158 $this->LastRow=$RowIdx;
\r
159 $this->AddCell($content);
\r
162 function SetRowAttr($name, $value) {
\r
163 $this->rows[$this->LastRow]->SetRowAttr($name, $value);
\r
166 function SetCellAttr($name, $value) {
\r
167 $this->rows[$this->LastRow]->SetCellAttr($name, $value);
\r
170 function RenderColumns($c1, $c2) {
\r
171 for ($c=$c1; $c<=$c2; $c++) {
\r
172 echo "\n<td><div class='ricoLG_col'>";
\r
173 for ($r=$this->LastHeadingRow + 1; $r<count($this->rows); $r++) {
\r
174 echo $this->rows[$r]->cells[$c]->DataCell($this->rows[$r]->GetRowAttr("class"));
\r
176 echo "</div></td>";
\r
180 // output buffering must be enabled
\r
181 function RenderExcel($fileName) {
\r
183 if ($fileName != "") {
\r
184 header("content-disposition: attachment; filename=" . $fileName);
\r
186 header("Content-type: application/ms-excel");
\r
189 for ($r=0; $r<count($this->rows); $r++) {
\r
191 $colcnt=count($this->rows[$r]->cells);
\r
192 for ($c=0; $c<$colcnt; $c++) {
\r
193 echo $this->rows[$r]->cells[$c]->HtmlCell();
\r
202 // output buffering must be enabled
\r
203 function RenderDelimited($fileName, $delim, $SubstituteChar) {
\r
205 if ($fileName != "") {
\r
206 header("content-disposition: attachment; filename=" . $fileName);
\r
208 header("Content-type: text/csv");
\r
210 for ($r=0; $r<count($this->rows); $r++) {
\r
211 $colcnt=count($this->rows[$r]->cells);
\r
212 for ($c=0; $c<$colcnt; $c++) {
\r
216 echo str_replace($delim, $SubstituteChar, $this->rows[$r]->cells[$c]->content);
\r
224 function Render($id, $FrozenCols) {
\r
225 if ($this->ResizeRowIdx < 0) {
\r
228 $colcnt=$this->rows[$this->ResizeRowIdx]->CellCount();
\r
229 echo "\n<div id='".$id."_outerDiv'>";
\r
230 //-------------------
\r
232 //-------------------
\r
233 echo "\n<div id='".$id."_frozenTabsDiv'>";
\r
235 echo "\n<table id='".$id."_tab0h' class='ricoLG_table ricoLG_left' cellspacing='0' cellpadding='0'><thead class='ricoLG_top'>";
\r
236 for ($r=0; $r<=$this->LastHeadingRow; $r++) {
\r
237 echo "\n<tr class='".$this->rows[$r]->HeadingClass()."'";
\r
238 if ($r == $this->ResizeRowIdx) {
\r
239 echo " id='".$id."_tab0h_main'";
\r
242 echo $this->rows[$r]->HeadingRow(0, $FrozenCols-1);
\r
245 echo "\n</thead></table>";
\r
247 echo "\n<table id='".$id."_tab0' class='ricoLG_table ricoLG_bottom ricoLG_left' cellspacing='0' cellpadding='0'>";
\r
249 $this->RenderColumns(0, $FrozenCols-1);
\r
253 //-------------------
\r
254 // scrolling columns
\r
255 //-------------------
\r
257 echo "\n<div id='".$id."_innerDiv'>";
\r
258 echo "\n<table id='".$id."_tab1h' class='ricoLG_table ricoLG_right' cellspacing='0' cellpadding='0'><thead class='ricoLG_top'>";
\r
259 for ($r=0; $r<=$this->LastHeadingRow; $r++) {
\r
260 echo "\n<tr class='".$this->rows[$r]->HeadingClass()."'";
\r
261 if ($r == $this->ResizeRowIdx) {
\r
262 echo " id='".$id."_tab1h_main'";
\r
265 echo $this->rows[$r]->HeadingRow($FrozenCols, $colcnt-1);
\r
268 echo "\n</thead></table>";
\r
271 echo "\n<div id='".$id."_scrollDiv'>";
\r
272 echo "\n<table id='".$id."_tab1' class='ricoLG_table ricoLG_bottom ricoLG_right' cellspacing='0' cellpadding='0'>";
\r
274 $this->RenderColumns($FrozenCols, $colcnt-1);
\r