phpMv  -UI toolkit 2.4.12
jQuery, jQuery UI, Twitter Bootstrap and Semantic-UI library for php & php MVC Frameworks
HtmlGridCol.php
Go to the documentation of this file.
1 <?php
3 
5 use Ajax\JsUtils;
6 
8 
16  private $positions;
17  private $offsets;
18  public function __construct($identifier,$size=CssSize::SIZE_MD,$width=1){
19  parent::__construct($identifier,"div");
20  $this->positions=array();
21  $this->offsets=array();
22  $this->addPosition($size,$width);
23  }
24  public function addPosition($size=CssSize::SIZE_MD,$width=1){
25  $this->positions[$size]=$width;
26  return $this;
27  }
28  private function _generateClass(){
29  $result=array();
30  foreach ($this->positions as $size=>$width){
31  $result[]="col-".$size."-".$width;
32  }
33  foreach ($this->offsets as $size=>$offset){
34  $result[]="col-".$size."-offset-".$offset;
35  }
36  return implode(" ", $result);
37  }
38 
39  public function compile(JsUtils $js=NULL, &$view=NULL) {
40  $this->setProperty("class", $this->_generateClass());
41  return parent::compile($js,$view);
42  }
43 
44  public function setOffset($size,$offset){
45  $this->offsets[$size]=$offset;
46  return $this;
47  }
48 
49  public function setOffsetForAll($newOffset){
50  foreach ($this->offsets as &$value){
51  $value=$newOffset;
52  }
53  unset($value);
54  return $this;
55  }
56 
57  public function setWidthForAll($newWidth){
58  foreach ($this->positions as &$pos){
59  $pos=$newWidth;
60  }
61  unset($pos);
62  return $this;
63  }
64 
65  public function setWidth($size=CssSize::SIZE_MD,$width=1){
66  $this->positions[$size]=$width;
67  return $this;
68  }
69 
70  public function setPosition($size=CssSize::SIZE_MD,$width=1){
71  return $this->addPosition($size,$width);
72  }
73 
74  public function getWidth($size){
75  return @$this->positions[$size];
76  }
77 
78  public function getOffest($size){
79  return @$this->offsets[$size];
80  }
81 
82  public function addClear(){
83  $this->wrap("","<div class='clearfix'></div>");
84  }
85  public function setOffsets($offsets) {
86  $this->offsets = $offsets;
87  return $this;
88  }
89 
90  public function copy($identifier){
91  $result=new HtmlGridCol($identifier);
92  $result->setPositions($this->positions);
93  $result->setOffsets($this->offsets);
94  return $result;
95  }
96  public function setPositions($positions) {
97  $this->positions = $positions;
98  return $this;
99  }
100  public function getOffsets() {
101  return $this->offsets;
102  }
103 
104 
105 
106 }
addPosition($size=CssSize::SIZE_MD, $width=1)
Definition: HtmlGridCol.php:24
wrap($before, $after="")
Definition: BaseHtml.php:171
Inner element for Twitter Bootstrap Grid col.
Definition: HtmlGridCol.php:15
JQuery PHP library.
Definition: JsUtils.php:23
compile(JsUtils $js=NULL, &$view=NULL)
Definition: HtmlGridCol.php:39
setPosition($size=CssSize::SIZE_MD, $width=1)
Definition: HtmlGridCol.php:70
__construct($identifier, $size=CssSize::SIZE_MD, $width=1)
Definition: HtmlGridCol.php:18
setWidth($size=CssSize::SIZE_MD, $width=1)
Definition: HtmlGridCol.php:65