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
3 
5 use Ajax\JsUtils;
6 
8 
16  private $cols;
17  public function __construct($identifier,$numCols=NULL){
18  parent::__construct($identifier,"div");
19  $this->setProperty("class", "row");
20  $this->cols=array();
21  if(isset($numCols)){
22  $numCols=min(12,$numCols);
23  $numCols=max(1,$numCols);
24  $width=12/$numCols;
25  for ($i=0;$i<$numCols;$i++){
26  $this->addCol(CssSize::SIZE_MD,$width);
27  }
28  }
29  }
30 
31  public function addCol($size=CssSize::SIZE_MD,$width=1){
32  $col=new HtmlGridCol($this->identifier."-col-".(sizeof($this->cols)+1),$size,$width);
33  $this->cols[]=$col;
34  return $col;
35  }
36 
37  public function addColAt($size=CssSize::SIZE_MD,$width=1,$offset=1){
38  $col=$this->addCol($size,$width);
39  return $col->setOffset($size, max($offset,sizeof($this->cols)+1));
40  }
41 
42  public function getCol($index,$force=true){
43  $result=null;
44  if($index<sizeof($this->cols)+1){
45  $result=$this->cols[$index-1];
46  }else if ($force){
47  $result=$this->addColAt(CssSize::SIZE_MD,1,$index);
48  }
49  return $result;
50  }
51 
52  public function getColAt($offset,$force=true){
53  $result=null;
54  foreach ($this->cols as $col){
55  $offsets=$col->getOffsets();
56  if($result=array_search($offset, $offsets)){
57  break;
58  }
59  }
60  if(!$result || isset($result)===false){
61  $result=$this->getCol($offset,$force);
62  }
63  return $result;
64  }
65 
66  public function compile(JsUtils $js=NULL, &$view=NULL) {
67 
68  foreach ($this->cols as $col){
69  $this->addContent($col);
70  }
71  return parent::compile($js,$view);
72  }
73  public function getCols() {
74  return $this->cols;
75  }
76 
77  public function setContentForAll($content){
78  foreach ($this->cols as $col){
79  $col->setContent($content);
80  }
81  }
82  public function merge($size=CssSize::SIZE_MD,$start,$width){
83  $col=$this->getColAt($start,false);
84  if(isset($col)){
85  $col->setWidth($size,$width+1);
86  $this->delete($size,$start+1, $width);
87  }
88  }
89  public function delete($size=CssSize::SIZE_MD,$start,$width){
90  while($start<sizeof($this->cols)+1 && $width>0){
91  $col=$this->getColAt($start,false);
92  if(isset($col)){
93  $widthCol=$col->getWidth($size);
94  if($widthCol<=$width){
95  unset($this->cols[$start-1]);
96  $this->cols = array_values($this->cols);
97  $width=$width-$widthCol;
98  }
99  }else{
100  $width=0;
101  }
102  }
103  }
104 }
merge($size=CssSize::SIZE_MD, $start, $width)
Definition: HtmlGridRow.php:82
addColAt($size=CssSize::SIZE_MD, $width=1, $offset=1)
Definition: HtmlGridRow.php:37
addContent($content, $before=false)
addCol($size=CssSize::SIZE_MD, $width=1)
Definition: HtmlGridRow.php:31
__construct($identifier, $numCols=NULL)
Definition: HtmlGridRow.php:17
Inner element for Twitter Bootstrap Grid col.
Definition: HtmlGridCol.php:15
JQuery PHP library.
Definition: JsUtils.php:23
Inner element for Twitter Bootstrap Grid row.
Definition: HtmlGridRow.php:15
compile(JsUtils $js=NULL, &$view=NULL)
Definition: HtmlGridRow.php:66