phpMv  -UI toolkit 2.4.12
jQuery, jQuery UI, Twitter Bootstrap and Semantic-UI library for php & php MVC Frameworks
HtmlGridRow.php
Go to the documentation of this file.
1 <?php
2 
4 
7 use Ajax\JsUtils;
8 
11 
12 
21 
22  private $_colSize;
23  private $_implicite=false;
24 
25  public function __construct( $identifier,$numCols=NULL,$colSizing=false,$implicite=false){
26  parent::__construct( $identifier,"div","row");
27  $this->_implicite=$implicite;
28  $width=null;
29  if(isset($numCols)){
30  $numCols=min(16,$numCols);
31  $numCols=max(1,$numCols);
32  if($colSizing)
33  $width=(int)(16/$numCols);
34  else
35  $this->_colSize=16/$numCols;
36  for ($i=0;$i<$numCols;$i++){
37  $this->addItem($width);
38  }
39  }
40  }
41 
47  public function setWidth($width){
48  if(\is_int($width)){
49  $width=Wide::getConstants()["W".$width];
50  }
51  $this->addToPropertyCtrl("class", $width, Wide::getConstants());
52  return $this->addToPropertyCtrl("class", "column",array("column"));
53  }
54 
60  public function getCol($index){
61  return $this->getItem($index);
62  }
63 
64  public function setColsCount($colsCount,$toCreate=true){
65  $this->setWidth($colsCount);
66  if($toCreate===true){
67  $count=$this->count();
68  for($i=$count;$i<$colsCount;$i++){
69  $this->addItem(null);
70  }
71  }
72  return $this;
73  }
74 
75  public function addCols($colCount){
76  for($i=0;$i<$colCount;$i++){
77  $this->addItem(null);
78  }
79  return $this;
80  }
81 
82  public function addCol($width=NULL){
83  return $this->addItem($width);
84  }
85 
90  public function setStretched(){
91  return $this->addToProperty("class", "stretched");
92  }
93 
98  public function setColor($color){
99  return $this->addToPropertyCtrl("class", $color,Color::getConstants());
100  }
101 
102  public function setValues($values,$force=false){
103  $count=$this->count();
104  $valuesSize=\sizeof($values);
105  if($force===true){
106  for($i=$count;$i<$valuesSize;$i++){
107  $this->addItem(new HtmlGridCol($this->identifier."-col-".($this->count()+1),null));
108  }
109  }
110  $count=\min(array($this->count(),$valuesSize));
111  for($i=0;$i<$count;$i++){
112  $this->content[$i]->setValue($values[$i]);
113  }
114  return $this;
115  }
116 
121  protected function createItem($value){
122  $col=new HtmlGridCol($this->identifier."-col-".($this->count()+1),$value);
123  return $col;
124  }
125 
126  public function compile(JsUtils $js=NULL,&$view=NULL){
127  if($this->_implicite===true){
128  $this->_template="%wrapContentBefore%%content%%wrapContentAfter%";
129  }
130  return parent::compile($js,$view);
131  }
132 }
addToProperty($name, $value, $separator=" ")
setStretched()
stretch the row contents to take up the entire column height
Definition: HtmlGridRow.php:90
static getConstants()
Definition: BaseEnum.php:17
A row for the Semantic Grid component.
Definition: HtmlGridRow.php:19
addItem($item)
adds and returns an item
setColsCount($colsCount, $toCreate=true)
Definition: HtmlGridRow.php:64
setWidth($width)
Defines the row width.
Definition: HtmlGridRow.php:47
getItem($index)
Return the item at index.
A col in the Semantic Grid component.
Definition: HtmlGridCol.php:16
Base class for Semantic Html collections.
JQuery PHP library.
Definition: JsUtils.php:23
getCol($index)
return the col at $index
Definition: HtmlGridRow.php:60
__construct( $identifier, $numCols=NULL, $colSizing=false, $implicite=false)
Definition: HtmlGridRow.php:25
addToPropertyCtrl($name, $value, $typeCtrl)
compile(JsUtils $js=NULL, &$view=NULL)