|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Ajax\semantic\html\collections; |
|
4
|
|
|
|
|
5
|
|
|
use Ajax\common\html\html5\HtmlCollection; |
|
6
|
|
|
use Ajax\semantic\html\content\HtmlGridRow; |
|
7
|
|
|
use Ajax\semantic\html\base\Wide; |
|
8
|
|
|
|
|
9
|
|
|
class HtmlGrid extends HtmlCollection{ |
|
10
|
|
|
|
|
11
|
|
|
private $_createCols; |
|
12
|
|
|
private $_colSizing=true; |
|
13
|
|
|
public function __construct( $identifier,$numRows=1,$numCols=NULL,$createCols=true){ |
|
14
|
|
|
parent::__construct( $identifier, "div"); |
|
15
|
|
|
$this->_createCols=$createCols; |
|
16
|
|
|
if(isset($numCols)){ |
|
17
|
|
|
if($this->_createCols){ |
|
18
|
|
|
$this->_colSizing=false; |
|
19
|
|
|
} |
|
20
|
|
|
$cols=Wide::getConstants()["W".$numCols]; |
|
21
|
|
|
$this->setClass($cols." column"); |
|
22
|
|
|
} |
|
23
|
|
|
$this->addToProperty("class","ui grid"); |
|
24
|
|
|
$this->setNumRows($numRows,$numCols); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Create $numRows rows |
|
29
|
|
|
* @param int $numRows |
|
30
|
|
|
* @param int $numCols |
|
31
|
|
|
* @return \Ajax\semantic\html\collections\HtmlGrid |
|
32
|
|
|
*/ |
|
33
|
|
|
public function setNumRows($numRows,$numCols=NULL){ |
|
34
|
|
|
$count=$this->count(); |
|
35
|
|
|
for($i=$count;$i<$numRows;$i++){ |
|
36
|
|
|
$this->addItem($numCols); |
|
37
|
|
|
} |
|
38
|
|
|
return $this; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* return the row at $index |
|
43
|
|
|
* @param int $index |
|
44
|
|
|
* @return \Ajax\semantic\html\collections\HtmlGridRow |
|
45
|
|
|
*/ |
|
46
|
|
|
public function getRow($index){ |
|
47
|
|
|
return $this->getItem($index); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @param int $row |
|
52
|
|
|
* @param int $col |
|
53
|
|
|
* @return \Ajax\semantic\html\collections\HtmlGridCol |
|
54
|
|
|
*/ |
|
55
|
|
|
public function getCell($row,$col){ |
|
56
|
|
|
$row=$this->getItem($row); |
|
57
|
|
|
if(isset($row)){ |
|
58
|
|
|
$col=$row->getItem($col); |
|
59
|
|
|
} |
|
60
|
|
|
return $col; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
protected function createItem($value){ |
|
64
|
|
|
if($this->_createCols===false) |
|
65
|
|
|
$value=null; |
|
66
|
|
|
$item=new HtmlGridRow($this->identifier."-row-".($this->count()+1),$value,$this->_colSizing); |
|
67
|
|
|
return $item; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
} |