@@ -12,11 +12,11 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | class Dialog extends SimpleComponent { |
| 14 | 14 | protected $attachTo; |
| 15 | - protected $buttons=array (); |
|
| 15 | + protected $buttons=array(); |
|
| 16 | 16 | |
| 17 | 17 | public function __construct(JsUtils $js) { |
| 18 | 18 | parent::__construct($js); |
| 19 | - $this->params=array ( |
|
| 19 | + $this->params=array( |
|
| 20 | 20 | "dialogClass" => "no-close" |
| 21 | 21 | ); |
| 22 | 22 | $this->addCancelBtn("Annuler"); |
@@ -24,12 +24,12 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | public function getScript() { |
| 26 | 26 | $allParams=$this->params; |
| 27 | - $jsonButtons=array (); |
|
| 28 | - foreach ( $this->buttons as $button ) { |
|
| 27 | + $jsonButtons=array(); |
|
| 28 | + foreach ($this->buttons as $button) { |
|
| 29 | 29 | $jsonButtons []=$button->getParams(); |
| 30 | 30 | } |
| 31 | 31 | $allParams ["buttons"]=$jsonButtons; |
| 32 | - $this->jquery_code_for_compile []="$( '" . $this->attachTo . "' ).dialog(" . $this->getParamsAsJSON($allParams) . ");"; |
|
| 32 | + $this->jquery_code_for_compile []="$( '".$this->attachTo."' ).dialog(".$this->getParamsAsJSON($allParams).");"; |
|
| 33 | 33 | $result=implode("", $this->jquery_code_for_compile); |
| 34 | 34 | $result=str_ireplace("\"%", "", $result); |
| 35 | 35 | $result=str_ireplace("%\"", "", $result); |
@@ -59,9 +59,9 @@ discard block |
||
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | private function insertBtn($insert, $position=NULL) { |
| 62 | - if ($position != NULL) { |
|
| 62 | + if ($position!=NULL) { |
|
| 63 | 63 | $this->buttons=array_splice($this->buttons, $position, 0, $insert); |
| 64 | - } else { |
|
| 64 | + }else { |
|
| 65 | 65 | $this->buttons []=$insert; |
| 66 | 66 | } |
| 67 | 67 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | private function addFunction($jsCode) { |
| 18 | 18 | if (!Text::startsWith($jsCode, "function")) |
| 19 | - $jsCode="%function(){" . $jsCode . "}%"; |
|
| 19 | + $jsCode="%function(){".$jsCode."}%"; |
|
| 20 | 20 | return $jsCode; |
| 21 | 21 | } |
| 22 | 22 | |
@@ -43,6 +43,6 @@ discard block |
||
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | public static function submitButton(JsUtils $js, $url, $form, $responseElement, $caption="Okay") { |
| 46 | - return new DialogButton($caption, $js->postForm($url, $form, $responseElement) . ";$( this ).dialog( 'close' );"); |
|
| 46 | + return new DialogButton($caption, $js->postForm($url, $form, $responseElement).";$( this ).dialog( 'close' );"); |
|
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | \ No newline at end of file |
@@ -15,8 +15,9 @@ |
||
| 15 | 15 | class DialogButton extends BaseComponent { |
| 16 | 16 | |
| 17 | 17 | private function addFunction($jsCode) { |
| 18 | - if (!Text::startsWith($jsCode, "function")) |
|
| 19 | - $jsCode="%function(){" . $jsCode . "}%"; |
|
| 18 | + if (!Text::startsWith($jsCode, "function")) { |
|
| 19 | + $jsCode="%function(){" . $jsCode . "}%"; |
|
| 20 | + } |
|
| 20 | 21 | return $jsCode; |
| 21 | 22 | } |
| 22 | 23 | |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | |
| 15 | 15 | public function __construct(JsUtils $js) { |
| 16 | 16 | parent::__construct($js); |
| 17 | - $this->params=array ( |
|
| 17 | + $this->params=array( |
|
| 18 | 18 | "value" => 50 |
| 19 | 19 | ); |
| 20 | 20 | $this->uiName="progressbar"; |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | * @param string $value default : swing |
| 31 | 31 | */ |
| 32 | 32 | public function setEasing($value) { |
| 33 | - $this->setParamCtrl("easing", $value, array ( |
|
| 33 | + $this->setParamCtrl("easing", $value, array( |
|
| 34 | 34 | "linear", |
| 35 | 35 | "swing", |
| 36 | 36 | "easeInQuad", |
@@ -74,7 +74,7 @@ |
||
| 74 | 74 | protected function setParamCtrl($key, $value, $typeCtrl) { |
| 75 | 75 | if (!$typeCtrl($value)) { |
| 76 | 76 | throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$key." à la position"); |
| 77 | - } else |
|
| 77 | + }else |
|
| 78 | 78 | $this->setParam($key, $value); |
| 79 | 79 | } |
| 80 | 80 | |
@@ -74,8 +74,9 @@ |
||
| 74 | 74 | protected function setParamCtrl($key, $value, $typeCtrl) { |
| 75 | 75 | if (!$typeCtrl($value)) { |
| 76 | 76 | throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$key." à la position"); |
| 77 | - } else |
|
| 78 | - $this->setParam($key, $value); |
|
| 77 | + } else { |
|
| 78 | + $this->setParam($key, $value); |
|
| 79 | + } |
|
| 79 | 80 | } |
| 80 | 81 | |
| 81 | 82 | /* |
@@ -20,6 +20,10 @@ discard block |
||
| 20 | 20 | protected $attr; |
| 21 | 21 | |
| 22 | 22 | |
| 23 | + /** |
|
| 24 | + * @param string $identifier |
|
| 25 | + * @param string $tagName |
|
| 26 | + */ |
|
| 23 | 27 | public function __construct($identifier,$tagName){ |
| 24 | 28 | parent::__construct($identifier,$tagName); |
| 25 | 29 | $this->root=""; |
@@ -30,7 +34,6 @@ discard block |
||
| 30 | 34 | * Associate an ajax get to the elements, displayed in $targetSelector |
| 31 | 35 | * $attr member is used to build each element url |
| 32 | 36 | * @param string $targetSelector the target of the get |
| 33 | - * @param string $attr the html attribute used to build the elements url |
|
| 34 | 37 | * @return HtmlNavElement |
| 35 | 38 | */ |
| 36 | 39 | public function autoGetOnClick($targetSelector){ |
@@ -19,8 +19,8 @@ discard block |
||
| 19 | 19 | protected $attr; |
| 20 | 20 | |
| 21 | 21 | |
| 22 | - public function __construct($identifier,$tagName){ |
|
| 23 | - parent::__construct($identifier,$tagName); |
|
| 22 | + public function __construct($identifier, $tagName) { |
|
| 23 | + parent::__construct($identifier, $tagName); |
|
| 24 | 24 | $this->root=""; |
| 25 | 25 | $this->attr="data-ajax"; |
| 26 | 26 | } |
@@ -32,11 +32,11 @@ discard block |
||
| 32 | 32 | * @param string $attr the html attribute used to build the elements url |
| 33 | 33 | * @return HtmlNavElement |
| 34 | 34 | */ |
| 35 | - public function autoGetOnClick($targetSelector){ |
|
| 36 | - return $this->getOnClick($this->root, $targetSelector,array("attr"=>$this->attr)); |
|
| 35 | + public function autoGetOnClick($targetSelector) { |
|
| 36 | + return $this->getOnClick($this->root, $targetSelector, array("attr"=>$this->attr)); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - public function contentAsString(){ |
|
| 39 | + public function contentAsString() { |
|
| 40 | 40 | return implode("", $this->content); |
| 41 | 41 | } |
| 42 | 42 | |
@@ -44,15 +44,15 @@ discard block |
||
| 44 | 44 | * Generate the jquery script to set the elements to the HtmlNavElement |
| 45 | 45 | * @param JsUtils $jsUtils |
| 46 | 46 | */ |
| 47 | - public function jsSetContent(JsUtils $jsUtils){ |
|
| 48 | - $jsUtils->html("#".$this->identifier,str_replace("\"","'", $this->contentAsString()),true); |
|
| 47 | + public function jsSetContent(JsUtils $jsUtils) { |
|
| 48 | + $jsUtils->html("#".$this->identifier, str_replace("\"", "'", $this->contentAsString()), true); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | public function getRoot() { |
| 52 | 52 | return $this->root; |
| 53 | 53 | } |
| 54 | 54 | public function setRoot($root) { |
| 55 | - $this->root = $root; |
|
| 55 | + $this->root=$root; |
|
| 56 | 56 | return $this; |
| 57 | 57 | } |
| 58 | 58 | public function getAttr() { |
@@ -65,12 +65,12 @@ discard block |
||
| 65 | 65 | * @return HtmlNavElement |
| 66 | 66 | */ |
| 67 | 67 | public function setAttr($attr) { |
| 68 | - $this->attr = $attr; |
|
| 68 | + $this->attr=$attr; |
|
| 69 | 69 | return $this; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | public function __call($method, $args) { |
| 73 | - if(isset($this->$method) && is_callable($this->$method)) { |
|
| 73 | + if (isset($this->$method) && is_callable($this->$method)) { |
|
| 74 | 74 | return call_user_func_array( |
| 75 | 75 | $this->$method, |
| 76 | 76 | $args |
@@ -78,6 +78,6 @@ discard block |
||
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - public abstract function fromDispatcher($dispatcher,$startIndex=0); |
|
| 81 | + public abstract function fromDispatcher($dispatcher, $startIndex=0); |
|
| 82 | 82 | |
| 83 | 83 | } |
| 84 | 84 | \ No newline at end of file |
@@ -149,7 +149,7 @@ |
||
| 149 | 149 | $glyph->setGlyphicon($glyphicon); |
| 150 | 150 | if ($left) { |
| 151 | 151 | $this->content=$glyph->compile().$separator.$this->content; |
| 152 | - } else { |
|
| 152 | + }else { |
|
| 153 | 153 | $this->content.=$separator.$glyph->compile(); |
| 154 | 154 | } |
| 155 | 155 | return $this; |
@@ -52,10 +52,11 @@ discard block |
||
| 52 | 52 | $this->from=$from; |
| 53 | 53 | $this->to=$to; |
| 54 | 54 | $this->urlMask="%page%"; |
| 55 | - if(!isset($countVisible)) |
|
| 56 | - $this->countVisible=$to-$from+1; |
|
| 57 | - else |
|
| 58 | - $this->countVisible=$countVisible; |
|
| 55 | + if(!isset($countVisible)) { |
|
| 56 | + $this->countVisible=$to-$from+1; |
|
| 57 | + } else { |
|
| 58 | + $this->countVisible=$countVisible; |
|
| 59 | + } |
|
| 59 | 60 | $this->createContent(); |
| 60 | 61 | } |
| 61 | 62 | |
@@ -74,7 +75,7 @@ discard block |
||
| 74 | 75 | $href=new HtmlLink("a-".$this->identifier."-".$count,$url,$content); |
| 75 | 76 | $href->setProperty($this->attr, $url); |
| 76 | 77 | $elem->setContent($href); |
| 77 | - }else{ |
|
| 78 | + } else{ |
|
| 78 | 79 | $elem->setContent($content); |
| 79 | 80 | } |
| 80 | 81 | $this->content[]=$elem; |
@@ -107,8 +108,9 @@ discard block |
||
| 107 | 108 | public function _addEvent($event, $jsCode) { |
| 108 | 109 | foreach ($this->content as $li){ |
| 109 | 110 | $content=$li->getContent(); |
| 110 | - if($content instanceof BaseHtml) |
|
| 111 | - $content->_addEvent($event,$jsCode); |
|
| 111 | + if($content instanceof BaseHtml) { |
|
| 112 | + $content->_addEvent($event,$jsCode); |
|
| 113 | + } |
|
| 112 | 114 | } |
| 113 | 115 | } |
| 114 | 116 | /** |
@@ -146,8 +148,9 @@ discard block |
||
| 146 | 148 | if (is_int($size)) { |
| 147 | 149 | return $this->addToPropertyUnique("class", CssRef::sizes("pagination")[$size], CssRef::sizes("pagination")); |
| 148 | 150 | } |
| 149 | - if(!PhalconUtils::startsWith($size, "pagination-") && $size!=="") |
|
| 150 | - $size="pagination-".$size; |
|
| 151 | + if(!PhalconUtils::startsWith($size, "pagination-") && $size!=="") { |
|
| 152 | + $size="pagination-".$size; |
|
| 153 | + } |
|
| 151 | 154 | return $this->addToPropertyCtrl("class", $size, CssRef::sizes("pagination")); |
| 152 | 155 | } |
| 153 | 156 | |
@@ -44,70 +44,70 @@ discard block |
||
| 44 | 44 | /** |
| 45 | 45 | * @param string $identifier |
| 46 | 46 | */ |
| 47 | - public function __construct($identifier,$from=1,$to=1,$active=NULL,$countVisible=NULL){ |
|
| 48 | - parent::__construct($identifier,"ul"); |
|
| 47 | + public function __construct($identifier, $from=1, $to=1, $active=NULL, $countVisible=NULL) { |
|
| 48 | + parent::__construct($identifier, "ul"); |
|
| 49 | 49 | $this->setProperty("class", "pagination"); |
| 50 | 50 | $this->active=$active; |
| 51 | 51 | $this->from=$from; |
| 52 | 52 | $this->to=$to; |
| 53 | 53 | $this->urlMask="%page%"; |
| 54 | - if(!isset($countVisible)) |
|
| 54 | + if (!isset($countVisible)) |
|
| 55 | 55 | $this->countVisible=$to-$from+1; |
| 56 | 56 | else |
| 57 | 57 | $this->countVisible=$countVisible; |
| 58 | 58 | $this->createContent(); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - private function createElement($num,$content,$disabled=false,$current=false){ |
|
| 61 | + private function createElement($num, $content, $disabled=false, $current=false) { |
|
| 62 | 62 | $count=sizeof($this->content)+1; |
| 63 | - $elem=new HtmlBsDoubleElement("li-".$this->identifier."-".$count,"li"); |
|
| 64 | - if($disabled){ |
|
| 63 | + $elem=new HtmlBsDoubleElement("li-".$this->identifier."-".$count, "li"); |
|
| 64 | + if ($disabled) { |
|
| 65 | 65 | $elem->setProperty("class", "disabled"); |
| 66 | 66 | } |
| 67 | - if($current){ |
|
| 67 | + if ($current) { |
|
| 68 | 68 | $content.="<span class='sr-only'>(current)</span>"; |
| 69 | 69 | $elem->setProperty("class", "active"); |
| 70 | 70 | } |
| 71 | - if(!$disabled){ |
|
| 71 | + if (!$disabled) { |
|
| 72 | 72 | $url=$this->getUrl($num); |
| 73 | - $href=new HtmlLink("a-".$this->identifier."-".$count,$url,$content); |
|
| 73 | + $href=new HtmlLink("a-".$this->identifier."-".$count, $url, $content); |
|
| 74 | 74 | $href->setProperty($this->attr, $url); |
| 75 | 75 | $elem->setContent($href); |
| 76 | - }else{ |
|
| 76 | + }else { |
|
| 77 | 77 | $elem->setContent($content); |
| 78 | 78 | } |
| 79 | 79 | $this->content[]=$elem; |
| 80 | 80 | return $this; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - protected function createContent(){ |
|
| 83 | + protected function createContent() { |
|
| 84 | 84 | $this->content=array(); |
| 85 | - $this->createElement($this->active-1,"<span aria-hidden='true'>«</span>",$this->active===1); |
|
| 85 | + $this->createElement($this->active-1, "<span aria-hidden='true'>«</span>", $this->active===1); |
|
| 86 | 86 | $start=$this->getStart(); |
| 87 | - $end=min($start+$this->countVisible-1,$this->to); |
|
| 88 | - for($index=$start;$index<=$end;$index++){ |
|
| 89 | - $this->createElement($index,$index,false,$index===$this->active); |
|
| 87 | + $end=min($start+$this->countVisible-1, $this->to); |
|
| 88 | + for ($index=$start; $index<=$end; $index++) { |
|
| 89 | + $this->createElement($index, $index, false, $index===$this->active); |
|
| 90 | 90 | } |
| 91 | - $this->createElement($this->active+1,"<span aria-hidden='true'>»</span>",$this->active===$this->to); |
|
| 91 | + $this->createElement($this->active+1, "<span aria-hidden='true'>»</span>", $this->active===$this->to); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - protected function half(){ |
|
| 95 | - return (int)($this->countVisible/2); |
|
| 94 | + protected function half() { |
|
| 95 | + return (int) ($this->countVisible / 2); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - protected function getStart(){ |
|
| 98 | + protected function getStart() { |
|
| 99 | 99 | $result=1; |
| 100 | - if($this->countVisible!==$this->to-$this->from+1){ |
|
| 101 | - $result=max($this->active-$this->half(),$result); |
|
| 100 | + if ($this->countVisible!==$this->to-$this->from+1) { |
|
| 101 | + $result=max($this->active-$this->half(), $result); |
|
| 102 | 102 | } |
| 103 | 103 | return $result; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | public function _addEvent($event, $jsCode) { |
| 107 | - foreach ($this->content as $li){ |
|
| 107 | + foreach ($this->content as $li) { |
|
| 108 | 108 | $content=$li->getContent(); |
| 109 | - if($content instanceof BaseHtml) |
|
| 110 | - $content->_addEvent($event,$jsCode); |
|
| 109 | + if ($content instanceof BaseHtml) |
|
| 110 | + $content->_addEvent($event, $jsCode); |
|
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | 113 | /** |
@@ -115,15 +115,15 @@ discard block |
||
| 115 | 115 | * @param Dispatcher $dispatcher the request dispatcher |
| 116 | 116 | * @return \Ajax\bootstrap\html\HtmlPagination |
| 117 | 117 | */ |
| 118 | - public function fromDispatcher($dispatcher,$startIndex=0){ |
|
| 119 | - $items=array($dispatcher->getControllerName(),$dispatcher->getActionName()); |
|
| 120 | - $items=array_merge($items,$dispatcher->getParams()); |
|
| 118 | + public function fromDispatcher($dispatcher, $startIndex=0) { |
|
| 119 | + $items=array($dispatcher->getControllerName(), $dispatcher->getActionName()); |
|
| 120 | + $items=array_merge($items, $dispatcher->getParams()); |
|
| 121 | 121 | $url=implode("/", $items); |
| 122 | - if($this->urlMask==="%page%"){ |
|
| 122 | + if ($this->urlMask==="%page%") { |
|
| 123 | 123 | $this->urlMask=preg_replace("/[0-9]/", "%page%", $url); |
| 124 | 124 | } |
| 125 | - for($index=$this->from;$index<=$this->to;$index++){ |
|
| 126 | - if($this->getUrl($index)==$url){ |
|
| 125 | + for ($index=$this->from; $index<=$this->to; $index++) { |
|
| 126 | + if ($this->getUrl($index)==$url) { |
|
| 127 | 127 | $this->setActive($index); |
| 128 | 128 | break; |
| 129 | 129 | } |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | return $this; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - public function getUrl($index){ |
|
| 134 | + public function getUrl($index) { |
|
| 135 | 135 | return str_ireplace("%page%", $index, $this->urlMask); |
| 136 | 136 | } |
| 137 | 137 | |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | if (is_int($size)) { |
| 146 | 146 | return $this->addToPropertyUnique("class", CssRef::sizes("pagination")[$size], CssRef::sizes("pagination")); |
| 147 | 147 | } |
| 148 | - if(!PhalconUtils::startsWith($size, "pagination-") && $size!=="") |
|
| 148 | + if (!PhalconUtils::startsWith($size, "pagination-") && $size!=="") |
|
| 149 | 149 | $size="pagination-".$size; |
| 150 | 150 | return $this->addToPropertyCtrl("class", $size, CssRef::sizes("pagination")); |
| 151 | 151 | } |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | return $this->from; |
| 155 | 155 | } |
| 156 | 156 | public function setFrom($from) { |
| 157 | - $this->from = $from; |
|
| 157 | + $this->from=$from; |
|
| 158 | 158 | $this->createContent(); |
| 159 | 159 | return $this; |
| 160 | 160 | } |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | return $this->to; |
| 163 | 163 | } |
| 164 | 164 | public function setTo($to) { |
| 165 | - $this->to = $to; |
|
| 165 | + $this->to=$to; |
|
| 166 | 166 | $this->createContent(); |
| 167 | 167 | return $this; |
| 168 | 168 | } |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | return $this->active; |
| 171 | 171 | } |
| 172 | 172 | public function setActive($active) { |
| 173 | - $this->active = $active; |
|
| 173 | + $this->active=$active; |
|
| 174 | 174 | $this->createContent(); |
| 175 | 175 | return $this; |
| 176 | 176 | } |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | return $this->urlMask; |
| 179 | 179 | } |
| 180 | 180 | public function setUrlMask($urlMask) { |
| 181 | - $this->urlMask = $urlMask; |
|
| 181 | + $this->urlMask=$urlMask; |
|
| 182 | 182 | $this->createContent(); |
| 183 | 183 | return $this; |
| 184 | 184 | } |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | return $this->countVisible; |
| 187 | 187 | } |
| 188 | 188 | public function setCountVisible($countVisible) { |
| 189 | - $this->countVisible = $countVisible; |
|
| 189 | + $this->countVisible=$countVisible; |
|
| 190 | 190 | $this->createContent(); |
| 191 | 191 | return $this; |
| 192 | 192 | } |
@@ -14,6 +14,11 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | class HtmlGridRow extends HtmlDoubleElement { |
| 16 | 16 | private $cols; |
| 17 | + |
|
| 18 | + /** |
|
| 19 | + * @param string $identifier |
|
| 20 | + * @param integer $numCols |
|
| 21 | + */ |
|
| 17 | 22 | public function __construct($identifier,$numCols=NULL){ |
| 18 | 23 | parent::__construct($identifier,"div"); |
| 19 | 24 | $this->setProperty("class", "row"); |
@@ -85,6 +90,11 @@ discard block |
||
| 85 | 90 | $this->delete($size,$start+1, $width); |
| 86 | 91 | } |
| 87 | 92 | } |
| 93 | + |
|
| 94 | + /** |
|
| 95 | + * @param integer $start |
|
| 96 | + * @param integer $width |
|
| 97 | + */ |
|
| 88 | 98 | public function delete($size=CssSize::SIZE_MD,$start,$width){ |
| 89 | 99 | while($start<sizeof($this->cols)+1 && $width>0){ |
| 90 | 100 | $col=$this->getColAt($start,false); |
@@ -14,88 +14,88 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class HtmlGridRow extends HtmlDoubleElement { |
| 16 | 16 | private $cols; |
| 17 | - public function __construct($identifier,$numCols=NULL){ |
|
| 18 | - parent::__construct($identifier,"div"); |
|
| 17 | + public function __construct($identifier, $numCols=NULL) { |
|
| 18 | + parent::__construct($identifier, "div"); |
|
| 19 | 19 | $this->setProperty("class", "row"); |
| 20 | 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); |
|
| 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 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - public function addCol($size=CssSize::SIZE_MD,$width=1){ |
|
| 32 | - $col=new HtmlGridCol($this->identifier."-col-".(sizeof($this->cols)+1),$size,$width); |
|
| 31 | + public function addCol($size=CssSize::SIZE_MD, $width=1) { |
|
| 32 | + $col=new HtmlGridCol($this->identifier."-col-".(sizeof($this->cols)+1), $size, $width); |
|
| 33 | 33 | $this->cols[]=$col; |
| 34 | 34 | return $col; |
| 35 | 35 | } |
| 36 | 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)); |
|
| 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 | 40 | } |
| 41 | 41 | |
| 42 | - public function getCol($index,$force=true){ |
|
| 43 | - if($index<sizeof($this->cols)+1){ |
|
| 42 | + public function getCol($index, $force=true) { |
|
| 43 | + if ($index<sizeof($this->cols)+1) { |
|
| 44 | 44 | $result=$this->cols[$index-1]; |
| 45 | - }else if ($force){ |
|
| 46 | - $result=$this->addColAt(CssSize::SIZE_MD,1,$index); |
|
| 45 | + }else if ($force) { |
|
| 46 | + $result=$this->addColAt(CssSize::SIZE_MD, 1, $index); |
|
| 47 | 47 | } |
| 48 | 48 | return $result; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - public function getColAt($offset,$force=true){ |
|
| 51 | + public function getColAt($offset, $force=true) { |
|
| 52 | 52 | $result=null; |
| 53 | - foreach ($this->cols as $col){ |
|
| 53 | + foreach ($this->cols as $col) { |
|
| 54 | 54 | $offsets=$col->getOffsets(); |
| 55 | - if($result=array_search($offset, $offsets)){ |
|
| 55 | + if ($result=array_search($offset, $offsets)) { |
|
| 56 | 56 | break; |
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | - if(!$result || isset($result)==false){ |
|
| 60 | - $result=$this->getCol($offset,$force); |
|
| 59 | + if (!$result || isset($result)==false) { |
|
| 60 | + $result=$this->getCol($offset, $force); |
|
| 61 | 61 | } |
| 62 | 62 | return $result; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | public function compile(JsUtils $js=NULL, View $view=NULL) { |
| 66 | 66 | |
| 67 | - foreach ($this->cols as $col){ |
|
| 67 | + foreach ($this->cols as $col) { |
|
| 68 | 68 | $this->addContent($col); |
| 69 | 69 | } |
| 70 | - return parent::compile($js,$view); |
|
| 70 | + return parent::compile($js, $view); |
|
| 71 | 71 | } |
| 72 | 72 | public function getCols() { |
| 73 | 73 | return $this->cols; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - public function setContentForAll($content){ |
|
| 77 | - foreach ($this->cols as $col){ |
|
| 76 | + public function setContentForAll($content) { |
|
| 77 | + foreach ($this->cols as $col) { |
|
| 78 | 78 | $col->setContent($content); |
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | - public function merge($size=CssSize::SIZE_MD,$start,$width){ |
|
| 82 | - $col=$this->getColAt($start,false); |
|
| 83 | - if(isset($col)){ |
|
| 84 | - $col->setWidth($size,$width+1); |
|
| 85 | - $this->delete($size,$start+1, $width); |
|
| 81 | + public function merge($size=CssSize::SIZE_MD, $start, $width) { |
|
| 82 | + $col=$this->getColAt($start, false); |
|
| 83 | + if (isset($col)) { |
|
| 84 | + $col->setWidth($size, $width+1); |
|
| 85 | + $this->delete($size, $start+1, $width); |
|
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | - public function delete($size=CssSize::SIZE_MD,$start,$width){ |
|
| 89 | - while($start<sizeof($this->cols)+1 && $width>0){ |
|
| 90 | - $col=$this->getColAt($start,false); |
|
| 91 | - if(isset($col)){ |
|
| 88 | + public function delete($size=CssSize::SIZE_MD, $start, $width) { |
|
| 89 | + while ($start<sizeof($this->cols)+1 && $width>0) { |
|
| 90 | + $col=$this->getColAt($start, false); |
|
| 91 | + if (isset($col)) { |
|
| 92 | 92 | $widthCol=$col->getWidth($size); |
| 93 | - if($widthCol<=$width){ |
|
| 93 | + if ($widthCol<=$width) { |
|
| 94 | 94 | unset($this->cols[$start-1]); |
| 95 | - $this->cols = array_values($this->cols); |
|
| 95 | + $this->cols=array_values($this->cols); |
|
| 96 | 96 | $width=$width-$widthCol; |
| 97 | 97 | } |
| 98 | - }else{ |
|
| 98 | + }else { |
|
| 99 | 99 | $width=0; |
| 100 | 100 | } |
| 101 | 101 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | public function getCol($index,$force=true){ |
| 43 | 43 | if($index<sizeof($this->cols)+1){ |
| 44 | 44 | $result=$this->cols[$index-1]; |
| 45 | - }else if ($force){ |
|
| 45 | + } else if ($force){ |
|
| 46 | 46 | $result=$this->addColAt(CssSize::SIZE_MD,1,$index); |
| 47 | 47 | } |
| 48 | 48 | return $result; |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | $this->cols = array_values($this->cols); |
| 96 | 96 | $width=$width-$widthCol; |
| 97 | 97 | } |
| 98 | - }else{ |
|
| 98 | + } else{ |
|
| 99 | 99 | $width=0; |
| 100 | 100 | } |
| 101 | 101 | } |