@@ -16,11 +16,11 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | public function __construct(JsUtils $js) { |
| 18 | 18 | parent::__construct($js); |
| 19 | - $this->events=array (); |
|
| 19 | + $this->events=array(); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | protected function compileEvents() { |
| 23 | - foreach ( $this->events as $event => $jsCode ) { |
|
| 23 | + foreach ($this->events as $event => $jsCode) { |
|
| 24 | 24 | $this->jquery_code_for_compile []="$( \"".$this->attachTo."\" ).on(\"".$event."\" , function( event, data ) {".$jsCode."});"; |
| 25 | 25 | } |
| 26 | 26 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | $result=implode("\n", $this->jquery_code_for_compile); |
| 30 | 30 | $result=str_ireplace("\"%", "", $result); |
| 31 | 31 | $result=str_ireplace("%\"", "", $result); |
| 32 | - $result=str_replace(array ( |
|
| 32 | + $result=str_replace(array( |
|
| 33 | 33 | "\\n", |
| 34 | 34 | "\\r", |
| 35 | 35 | "\\t" |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | public function getScript() { |
| 41 | 41 | $allParams=$this->params; |
| 42 | - $this->jquery_code_for_compile=array (); |
|
| 42 | + $this->jquery_code_for_compile=array(); |
|
| 43 | 43 | $this->jquery_code_for_compile []="$( \"".$this->attachTo."\" ).{$this->uiName}(".$this->getParamsAsJSON($allParams).");"; |
| 44 | 44 | $this->compileEvents(); |
| 45 | 45 | return $this->compileJQueryCode(); |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | if (is_array($typeCtrl)) { |
| 67 | 67 | if (array_search($value, $typeCtrl)===false) |
| 68 | 68 | throw new \Exception("La valeur passée a propriété `".$key."` pour le composant `".$this->uiName."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}"); |
| 69 | - } else { |
|
| 69 | + }else { |
|
| 70 | 70 | if (!$typeCtrl($value)) { |
| 71 | 71 | throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$key." au composant ".$this->uiName); |
| 72 | 72 | } |
@@ -11,11 +11,11 @@ discard block |
||
| 11 | 11 | protected $variation; |
| 12 | 12 | protected $params; |
| 13 | 13 | protected $semElement; |
| 14 | - public function __construct($semElement,$title="",$content="",$variation=NULL,$params=array()){ |
|
| 14 | + public function __construct($semElement, $title="", $content="", $variation=NULL, $params=array()) { |
|
| 15 | 15 | $this->semElement=$semElement; |
| 16 | 16 | $this->title=$title; |
| 17 | 17 | $this->content=$content; |
| 18 | - $this->setAttributes($variation,$params); |
|
| 18 | + $this->setAttributes($variation, $params); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | public function setHtml($html) { |
@@ -23,32 +23,32 @@ discard block |
||
| 23 | 23 | return $this; |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - public function setAttributes($variation=NULL,$params=array()){ |
|
| 26 | + public function setAttributes($variation=NULL, $params=array()) { |
|
| 27 | 27 | $this->variation=$variation; |
| 28 | 28 | $this->params=$params; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - public function onShow($jsCode){ |
|
| 31 | + public function onShow($jsCode) { |
|
| 32 | 32 | $this->params["onShow"]=$jsCode; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - public function compile(){ |
|
| 36 | - if(JString::isNotNull($this->title)){ |
|
| 35 | + public function compile() { |
|
| 36 | + if (JString::isNotNull($this->title)) { |
|
| 37 | 37 | $this->semElement->addToProperty("data-title", $this->title); |
| 38 | 38 | } |
| 39 | - if(JString::isNotNull($this->content)){ |
|
| 39 | + if (JString::isNotNull($this->content)) { |
|
| 40 | 40 | $this->semElement->addToProperty("data-content", $this->content); |
| 41 | 41 | } |
| 42 | - if(JString::isNotNull($this->html)){ |
|
| 42 | + if (JString::isNotNull($this->html)) { |
|
| 43 | 43 | $this->semElement->addToProperty("data-html", $this->html); |
| 44 | 44 | } |
| 45 | - if(JString::isNotNull($this->variation)){ |
|
| 45 | + if (JString::isNotNull($this->variation)) { |
|
| 46 | 46 | $this->semElement->addToProperty("data-variation", $this->variation); |
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - public function run(JsUtils $js){ |
|
| 51 | - $js->semantic()->popup("#".$this->semElement->getIdentifier(),$this->params); |
|
| 50 | + public function run(JsUtils $js) { |
|
| 51 | + $js->semantic()->popup("#".$this->semElement->getIdentifier(), $this->params); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | } |
| 55 | 55 | \ No newline at end of file |
@@ -10,30 +10,30 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | class HtmlDropdownItem extends HtmlSemDoubleElement { |
| 12 | 12 | |
| 13 | - public function __construct($identifier, $content="",$value=NULL,$image=NULL) { |
|
| 13 | + public function __construct($identifier, $content="", $value=NULL, $image=NULL) { |
|
| 14 | 14 | parent::__construct($identifier, "div"); |
| 15 | 15 | $this->setClass("item"); |
| 16 | 16 | $this->setContent($content); |
| 17 | - if($value!==NULL) |
|
| 17 | + if ($value!==NULL) |
|
| 18 | 18 | $this->setData($value); |
| 19 | - if($image!==NULL) |
|
| 19 | + if ($image!==NULL) |
|
| 20 | 20 | $this->asMiniAvatar($image); |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - public function setDescription($description){ |
|
| 24 | - $descO=new HtmlDoubleElement("desc-".$this->identifier,"span"); |
|
| 23 | + public function setDescription($description) { |
|
| 24 | + $descO=new HtmlDoubleElement("desc-".$this->identifier, "span"); |
|
| 25 | 25 | $descO->setClass("description"); |
| 26 | 26 | $descO->setContent($description); |
| 27 | - return $this->addContent($descO,true); |
|
| 27 | + return $this->addContent($descO, true); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - public function setData($value){ |
|
| 30 | + public function setData($value) { |
|
| 31 | 31 | $this->setProperty("data-value", $value); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - public function asOption(){ |
|
| 34 | + public function asOption() { |
|
| 35 | 35 | $this->tagName="option"; |
| 36 | - if($this->getProperty("data-value")!==null) |
|
| 36 | + if ($this->getProperty("data-value")!==null) |
|
| 37 | 37 | $this->setProperty("value", $this->getProperty("data-value")); |
| 38 | 38 | } |
| 39 | 39 | |
@@ -41,58 +41,58 @@ discard block |
||
| 41 | 41 | * @param string $image the image src |
| 42 | 42 | * @return \Ajax\common\html\html5\HtmlImg |
| 43 | 43 | */ |
| 44 | - public function asMiniAvatar($image){ |
|
| 44 | + public function asMiniAvatar($image) { |
|
| 45 | 45 | $this->tagName="div"; |
| 46 | - $img=new HtmlImg("image-".$this->identifier,$image); |
|
| 46 | + $img=new HtmlImg("image-".$this->identifier, $image); |
|
| 47 | 47 | $img->setClass("ui mini avatar image"); |
| 48 | - $this->addContent($img,true); |
|
| 48 | + $this->addContent($img, true); |
|
| 49 | 49 | return $img; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - public function asSearchInput($placeholder=NULL,$icon=NULL){ |
|
| 52 | + public function asSearchInput($placeholder=NULL, $icon=NULL) { |
|
| 53 | 53 | $this->setClass("ui icon search input"); |
| 54 | 54 | $input=new HtmlInput("search-".$this->identifier); |
| 55 | - if(isset($placeholder)) |
|
| 55 | + if (isset($placeholder)) |
|
| 56 | 56 | $input->setProperty("placeholder", $placeholder); |
| 57 | 57 | $this->content=$input; |
| 58 | - if(isset($icon)) |
|
| 58 | + if (isset($icon)) |
|
| 59 | 59 | $this->addIcon($icon); |
| 60 | 60 | return $this; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - public function setContent($content){ |
|
| 64 | - if($content==="-"){ |
|
| 63 | + public function setContent($content) { |
|
| 64 | + if ($content==="-") { |
|
| 65 | 65 | $this->asDivider(); |
| 66 | - }elseif($content==="-search-"){ |
|
| 67 | - $values=\explode(",",$content,-1); |
|
| 68 | - $this->asSearchInput(JArray::getDefaultValue($values, 0, "Search..."),JArray::getDefaultValue($values, 1, "search")); |
|
| 66 | + }elseif ($content==="-search-") { |
|
| 67 | + $values=\explode(",", $content, -1); |
|
| 68 | + $this->asSearchInput(JArray::getDefaultValue($values, 0, "Search..."), JArray::getDefaultValue($values, 1, "search")); |
|
| 69 | 69 | }else |
| 70 | 70 | parent::setContent($content); |
| 71 | 71 | return $this; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - public function asDivider(){ |
|
| 74 | + public function asDivider() { |
|
| 75 | 75 | $this->content=NULL; |
| 76 | 76 | $this->setClass("divider"); |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - public function asHeader($caption=NULL,$icon=NULL){ |
|
| 79 | + public function asHeader($caption=NULL, $icon=NULL) { |
|
| 80 | 80 | $this->setClass("header"); |
| 81 | 81 | $this->content=$caption; |
| 82 | - if(isset($icon)) |
|
| 83 | - $this->addIcon($icon,true); |
|
| 82 | + if (isset($icon)) |
|
| 83 | + $this->addIcon($icon, true); |
|
| 84 | 84 | return $this; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - public static function searchInput($placeholder=NULL,$icon=NULL){ |
|
| 88 | - return (new HtmlDropdownItem(""))->asSearchInput($placeholder,$icon); |
|
| 87 | + public static function searchInput($placeholder=NULL, $icon=NULL) { |
|
| 88 | + return (new HtmlDropdownItem(""))->asSearchInput($placeholder, $icon); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - public static function divider($placeholder=NULL,$icon=NULL){ |
|
| 91 | + public static function divider($placeholder=NULL, $icon=NULL) { |
|
| 92 | 92 | return (new HtmlDropdownItem(""))->asDivider(); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - public static function header($caption=NULL,$icon=NULL){ |
|
| 96 | - return (new HtmlDropdownItem(""))->asHeader($caption,$icon); |
|
| 95 | + public static function header($caption=NULL, $icon=NULL) { |
|
| 96 | + return (new HtmlDropdownItem(""))->asHeader($caption, $icon); |
|
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | 99 | \ No newline at end of file |
@@ -2,21 +2,21 @@ |
||
| 2 | 2 | namespace Ajax\service; |
| 3 | 3 | class JString { |
| 4 | 4 | |
| 5 | - public static function contains($hay,$needle){ |
|
| 6 | - return strpos($hay, $needle) !== false; |
|
| 5 | + public static function contains($hay, $needle) { |
|
| 6 | + return strpos($hay, $needle)!==false; |
|
| 7 | 7 | } |
| 8 | 8 | public static function startswith($hay, $needle) { |
| 9 | - return substr($hay, 0, strlen($needle)) === $needle; |
|
| 9 | + return substr($hay, 0, strlen($needle))===$needle; |
|
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | public static function endswith($hay, $needle) { |
| 13 | - return substr($hay, -strlen($needle)) === $needle; |
|
| 13 | + return substr($hay, -strlen($needle))===$needle; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | - public static function isNull($s){ |
|
| 16 | + public static function isNull($s) { |
|
| 17 | 17 | return (!isset($s) || NULL===$s || ""===$s); |
| 18 | 18 | } |
| 19 | - public static function isNotNull($s){ |
|
| 19 | + public static function isNotNull($s) { |
|
| 20 | 20 | return (isset($s) && NULL!==$s && ""!==$s); |
| 21 | 21 | } |
| 22 | 22 | } |
| 23 | 23 | \ No newline at end of file |
@@ -24,38 +24,38 @@ discard block |
||
| 24 | 24 | $this->setContent($content); |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - public function addHeader($header){ |
|
| 27 | + public function addHeader($header) { |
|
| 28 | 28 | $headerO=$header; |
| 29 | - if(\is_string($header)){ |
|
| 30 | - $headerO=new HtmlSemDoubleElement("header-".$this->identifier,"div"); |
|
| 29 | + if (\is_string($header)) { |
|
| 30 | + $headerO=new HtmlSemDoubleElement("header-".$this->identifier, "div"); |
|
| 31 | 31 | $headerO->setClass("header"); |
| 32 | 32 | $headerO->setContent($header); |
| 33 | 33 | } |
| 34 | - return $this->addContent($headerO,true); |
|
| 34 | + return $this->addContent($headerO, true); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - public function addList($elements,$ordered=false){ |
|
| 38 | - $list=new HtmlList("list-".$this->identifier,$elements); |
|
| 37 | + public function addList($elements, $ordered=false) { |
|
| 38 | + $list=new HtmlList("list-".$this->identifier, $elements); |
|
| 39 | 39 | $list->setOrdered($ordered); |
| 40 | 40 | $list->setClass("ui list"); |
| 41 | 41 | $this->addContent($list); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - public function setIcon($icon){ |
|
| 44 | + public function setIcon($icon) { |
|
| 45 | 45 | $this->addToProperty("class", "icon"); |
| 46 | - $this->wrapContent("<div class='content'>","</div>"); |
|
| 46 | + $this->wrapContent("<div class='content'>", "</div>"); |
|
| 47 | 47 | $this->icon=new HtmlIcon("icon-".$this->identifier, $icon); |
| 48 | 48 | return $this; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - public function addLoader($loaderIcon="notched circle"){ |
|
| 51 | + public function addLoader($loaderIcon="notched circle") { |
|
| 52 | 52 | $this->setIcon($loaderIcon); |
| 53 | 53 | $this->icon->addToIcon("loading"); |
| 54 | 54 | return $this; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - public function setDismissable($dismiss=true){ |
|
| 58 | - if($dismiss===true) |
|
| 57 | + public function setDismissable($dismiss=true) { |
|
| 58 | + if ($dismiss===true) |
|
| 59 | 59 | $this->close=new HtmlIcon("close-".$this->identifier, "close"); |
| 60 | 60 | else |
| 61 | 61 | $this->close=NULL; |
@@ -66,28 +66,28 @@ discard block |
||
| 66 | 66 | * {@inheritDoc} |
| 67 | 67 | * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::run() |
| 68 | 68 | */ |
| 69 | - public function run(JsUtils $js){ |
|
| 69 | + public function run(JsUtils $js) { |
|
| 70 | 70 | parent::run($js); |
| 71 | - if(isset($this->close)){ |
|
| 71 | + if (isset($this->close)) { |
|
| 72 | 72 | $js->execOn("click", "#".$this->identifier." .close", "$(this).closest('.message').transition('fade')"); |
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - public function setState($visible=true){ |
|
| 77 | - $visible=($visible===true)?"visible":"hidden"; |
|
| 78 | - return $this->addToPropertyCtrl("class", $visible, array("visible","hidden")); |
|
| 76 | + public function setState($visible=true) { |
|
| 77 | + $visible=($visible===true) ? "visible" : "hidden"; |
|
| 78 | + return $this->addToPropertyCtrl("class", $visible, array("visible", "hidden")); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - public function setVariation($value="floating"){ |
|
| 82 | - return $this->addToPropertyCtrl("class", $value, array("floating","compact")); |
|
| 81 | + public function setVariation($value="floating") { |
|
| 82 | + return $this->addToPropertyCtrl("class", $value, array("floating", "compact")); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - public function setStyle($style){ |
|
| 85 | + public function setStyle($style) { |
|
| 86 | 86 | return $this->addToPropertyCtrl("class", $style, Style::getConstants()); |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - public function setAttached(HtmlDoubleElement $toElement=NULL){ |
|
| 90 | - if(isset($toElement)){ |
|
| 89 | + public function setAttached(HtmlDoubleElement $toElement=NULL) { |
|
| 90 | + if (isset($toElement)) { |
|
| 91 | 91 | $toElement->addToProperty("class", "attached"); |
| 92 | 92 | } |
| 93 | 93 | return $this->addToProperty("class", "attached"); |
@@ -13,8 +13,8 @@ |
||
| 13 | 13 | parent::__construct($identifier, "ul"); |
| 14 | 14 | $this->addItems($items); |
| 15 | 15 | } |
| 16 | - public function setOrdered($ordered=true){ |
|
| 17 | - $this->tagName=($ordered===true)?"ol":"ul"; |
|
| 16 | + public function setOrdered($ordered=true) { |
|
| 17 | + $this->tagName=($ordered===true) ? "ol" : "ul"; |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | /** |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | return $this->setParam("onShow", "%function(){".$jsCode."}%"); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - public function setExclusive($value){ |
|
| 33 | + public function setExclusive($value) { |
|
| 34 | 34 | return $this->setParam("exclusive", $value); |
| 35 | 35 | } |
| 36 | 36 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * @param string $popup the css selector of the popup |
| 40 | 40 | * @return \Ajax\semantic\components\Popup |
| 41 | 41 | */ |
| 42 | - public function setPopup($popup){ |
|
| 42 | + public function setPopup($popup) { |
|
| 43 | 43 | return $this->setParam("popup", $popup); |
| 44 | 44 | } |
| 45 | 45 | //TODO other events implementation |
@@ -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 |
@@ -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 | } |