@@ -12,8 +12,8 @@ discard block |
||
| 12 | 12 | $output=$input; |
| 13 | 13 | } |
| 14 | 14 | if (\is_array($input)) { |
| 15 | - if (sizeof($input) > 0) { |
|
| 16 | - if (self::containsElement($input) === false) { |
|
| 15 | + if (sizeof($input)>0) { |
|
| 16 | + if (self::containsElement($input)===false) { |
|
| 17 | 17 | $output=self::wrapStrings($input, $js, $separator=' ', $valueQuote='"'); |
| 18 | 18 | } else { |
| 19 | 19 | $output=self::wrapObjects($input, $js, $separator, $valueQuote); |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | private static function containsElement($input) { |
| 27 | - foreach ( $input as $v ) { |
|
| 27 | + foreach ($input as $v) { |
|
| 28 | 28 | if (\is_object($v) || \is_array($v)) |
| 29 | 29 | return true; |
| 30 | 30 | } |
@@ -32,9 +32,9 @@ discard block |
||
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | public static function wrapStrings($input, $js, $separator=' ', $valueQuote='"') { |
| 35 | - if (JArray::isAssociative($input) === true) { |
|
| 36 | - $result=implode($separator, array_map(function ($v, $k) use($valueQuote) { |
|
| 37 | - return $k . '=' . $valueQuote . $v . $valueQuote; |
|
| 35 | + if (JArray::isAssociative($input)===true) { |
|
| 36 | + $result=implode($separator, array_map(function($v, $k) use($valueQuote) { |
|
| 37 | + return $k.'='.$valueQuote.$v.$valueQuote; |
|
| 38 | 38 | }, $input, array_keys($input))); |
| 39 | 39 | } else { |
| 40 | 40 | $result=implode($separator, array_values($input)); |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | public static function wrapObjects($input, $js=NULL, $separator=' ', $valueQuote='"') { |
| 46 | - return implode($separator, array_map(function ($v) use($js, $separator, $valueQuote) { |
|
| 46 | + return implode($separator, array_map(function($v) use($js, $separator, $valueQuote) { |
|
| 47 | 47 | if (is_object($v)) |
| 48 | 48 | return $v->compile($js); |
| 49 | 49 | elseif (\is_array($v)) { |
@@ -25,8 +25,9 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | private static function containsElement($input) { |
| 27 | 27 | foreach ( $input as $v ) { |
| 28 | - if (\is_object($v) || \is_array($v)) |
|
| 29 | - return true; |
|
| 28 | + if (\is_object($v) || \is_array($v)) { |
|
| 29 | + return true; |
|
| 30 | + } |
|
| 30 | 31 | } |
| 31 | 32 | return false; |
| 32 | 33 | } |
@@ -44,12 +45,13 @@ discard block |
||
| 44 | 45 | |
| 45 | 46 | public static function wrapObjects($input, $js=NULL, $separator=' ', $valueQuote='"') { |
| 46 | 47 | return implode($separator, array_map(function ($v) use($js, $separator, $valueQuote) { |
| 47 | - if (is_object($v)) |
|
| 48 | - return $v->compile($js); |
|
| 49 | - elseif (\is_array($v)) { |
|
| 48 | + if (is_object($v)) { |
|
| 49 | + return $v->compile($js); |
|
| 50 | + } elseif (\is_array($v)) { |
|
| 50 | 51 | return self::wrap($v, $js, $separator, $valueQuote); |
| 51 | - } else |
|
| 52 | - return $v; |
|
| 52 | + } else { |
|
| 53 | + return $v; |
|
| 54 | + } |
|
| 53 | 55 | }, $input)); |
| 54 | 56 | } |
| 55 | 57 | } |
| 56 | 58 | \ No newline at end of file |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | public function setClass($classNames) { |
| 16 | - if(\is_array($classNames)){ |
|
| 16 | + if (\is_array($classNames)) { |
|
| 17 | 17 | $classNames=implode(" ", $classNames); |
| 18 | 18 | } |
| 19 | 19 | $this->setProperty("class", $classNames); |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | public function fromArray($array) { |
| 46 | 46 | $array=parent::fromArray($array); |
| 47 | - foreach ( $array as $key => $value ) { |
|
| 47 | + foreach ($array as $key => $value) { |
|
| 48 | 48 | $this->setProperty($key, $value); |
| 49 | 49 | } |
| 50 | 50 | return $array; |
@@ -41,8 +41,9 @@ discard block |
||
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | public function compile($internal=false) { |
| 44 | - if ($internal===false&&$this->autoCompile===true) |
|
| 45 | - throw new \Exception("Impossible to compile if autoCompile is set to 'true'"); |
|
| 44 | + if ($internal===false&&$this->autoCompile===true) { |
|
| 45 | + throw new \Exception("Impossible to compile if autoCompile is set to 'true'"); |
|
| 46 | + } |
|
| 46 | 47 | foreach ( $this->components as $component ) { |
| 47 | 48 | $component->compile(); |
| 48 | 49 | } |
@@ -53,13 +54,16 @@ discard block |
||
| 53 | 54 | } |
| 54 | 55 | |
| 55 | 56 | public function addComponent(SimpleComponent $component, $attachTo, $params) { |
| 56 | - if ($this->autoCompile) |
|
| 57 | - $this->components []=$component; |
|
| 58 | - if (isset($attachTo)) |
|
| 59 | - $component->attach($attachTo); |
|
| 60 | - if (isset($params)) |
|
| 61 | - if (\is_array($params)) |
|
| 57 | + if ($this->autoCompile) { |
|
| 58 | + $this->components []=$component; |
|
| 59 | + } |
|
| 60 | + if (isset($attachTo)) { |
|
| 61 | + $component->attach($attachTo); |
|
| 62 | + } |
|
| 63 | + if (isset($params)) { |
|
| 64 | + if (\is_array($params)) |
|
| 62 | 65 | $component->setParams($params); |
| 66 | + } |
|
| 63 | 67 | return $component; |
| 64 | 68 | } |
| 65 | 69 | |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | if (\is_array($elements)) { |
| 62 | 62 | foreach ( $elements as $key => $element ) { |
| 63 | 63 | $iid=$this->getElementsCount()+1; |
| 64 | - if ($element instanceof HtmlDropdownItem) |
|
| 65 | - $this->elements []=$element; |
|
| 66 | - else if (\is_array($element)) { |
|
| 64 | + if ($element instanceof HtmlDropdownItem) { |
|
| 65 | + $this->elements []=$element; |
|
| 66 | + } else if (\is_array($element)) { |
|
| 67 | 67 | if (is_string($key)===true) { |
| 68 | 68 | $dropdown=new HtmlDropdown($this->identifier."-dropdown-".$iid); |
| 69 | 69 | $dropdown->addItems($element); |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | $li=new HtmlBsDoubleElement($this->identifier."-li-".$iid, "li"); |
| 90 | 90 | if($caption instanceof HtmlLink){ |
| 91 | 91 | $link=$caption; |
| 92 | - }else{ |
|
| 92 | + } else{ |
|
| 93 | 93 | $link=new HtmlLink($this->identifier."-link-".$iid, $href, $caption); |
| 94 | 94 | } |
| 95 | 95 | $li->setContent($link); |
@@ -29,11 +29,11 @@ discard block |
||
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | public function setActive($value) { |
| 32 | - if(\is_array($this->content)){ |
|
| 33 | - foreach ($this->content as $pb){ |
|
| 32 | + if (\is_array($this->content)) { |
|
| 33 | + foreach ($this->content as $pb) { |
|
| 34 | 34 | $pb->setActive($value); |
| 35 | 35 | } |
| 36 | - }else{ |
|
| 36 | + } else { |
|
| 37 | 37 | if ($value===true) |
| 38 | 38 | $this->active="active"; |
| 39 | 39 | else |
@@ -43,11 +43,11 @@ discard block |
||
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | public function setStriped($value) { |
| 46 | - if(\is_array($this->content)){ |
|
| 47 | - foreach ($this->content as $pb){ |
|
| 46 | + if (\is_array($this->content)) { |
|
| 47 | + foreach ($this->content as $pb) { |
|
| 48 | 48 | $pb->setStriped($value); |
| 49 | 49 | } |
| 50 | - }else{ |
|
| 50 | + } else { |
|
| 51 | 51 | if ($value===true) |
| 52 | 52 | $this->striped="progress-bar-striped"; |
| 53 | 53 | else |
@@ -57,11 +57,11 @@ discard block |
||
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | public function showCaption($value) { |
| 60 | - if(\is_array($this->content)){ |
|
| 61 | - foreach ($this->content as $pb){ |
|
| 60 | + if (\is_array($this->content)) { |
|
| 61 | + foreach ($this->content as $pb) { |
|
| 62 | 62 | $pb->showCaption($value); |
| 63 | 63 | } |
| 64 | - }else{ |
|
| 64 | + } else { |
|
| 65 | 65 | if ($value===true) |
| 66 | 66 | $this->caption="%value%%"; |
| 67 | 67 | else |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | $progressBar->setStriped($this->striped!=="" || $progressBar->isStriped()); |
| 82 | 82 | $progressBar->setActive($this->active==="active" || $progressBar->isActive()); |
| 83 | 83 | if (!is_array($this->content)) { |
| 84 | - $this->content=array (); |
|
| 84 | + $this->content=array(); |
|
| 85 | 85 | } |
| 86 | 86 | $this->content []=$progressBar; |
| 87 | 87 | } |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | * @return \Ajax\bootstrap\html\HtmlProgressbar default : "" |
| 126 | 126 | */ |
| 127 | 127 | public function setStyle($cssStyle) { |
| 128 | - return $this->setMemberCtrl($this->style,CssRef::getStyle($cssStyle, "progress-bar"), CssRef::Styles("progress-bar")); |
|
| 128 | + return $this->setMemberCtrl($this->style, CssRef::getStyle($cssStyle, "progress-bar"), CssRef::Styles("progress-bar")); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /* |
@@ -134,10 +134,10 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
| 136 | 136 | $actualStyle=$this->style; |
| 137 | - if(isset($this->styleLimits)&& JArray::isAssociative($this->styleLimits)){ |
|
| 138 | - foreach ($this->styleLimits as $k=>$v){ |
|
| 137 | + if (isset($this->styleLimits) && JArray::isAssociative($this->styleLimits)) { |
|
| 138 | + foreach ($this->styleLimits as $k=>$v) { |
|
| 139 | 139 | $actualStyle=$k; |
| 140 | - if($v>$this->value) |
|
| 140 | + if ($v>$this->value) |
|
| 141 | 141 | break; |
| 142 | 142 | } |
| 143 | 143 | } |
@@ -16,12 +16,12 @@ discard block |
||
| 16 | 16 | * @version 1.001 |
| 17 | 17 | */ |
| 18 | 18 | class HtmlCarousel extends BaseHtml { |
| 19 | - protected $indicators=array (); |
|
| 20 | - protected $slides=array (); |
|
| 19 | + protected $indicators=array(); |
|
| 20 | + protected $slides=array(); |
|
| 21 | 21 | protected $leftControl=""; |
| 22 | 22 | protected $rightControl=""; |
| 23 | 23 | protected $_base=""; |
| 24 | - protected $_glyphs=array (); |
|
| 24 | + protected $_glyphs=array(); |
|
| 25 | 25 | |
| 26 | 26 | public function __construct($identifier, $images=NULL) { |
| 27 | 27 | parent::__construct($identifier); |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | public function setBase($_base) { |
| 41 | - foreach ($this->slides as $slide){ |
|
| 41 | + foreach ($this->slides as $slide) { |
|
| 42 | 42 | $imgSrc=$slide->getImageSrc(); |
| 43 | 43 | $slide->setImageSrc(str_replace($this->_base.$imgSrc, $_base.$imgSrc, $imgSrc)); |
| 44 | 44 | } |
@@ -93,9 +93,9 @@ discard block |
||
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | public function addImage($imageSrc, $imageAlt="", $caption=NULL, $description=NULL) { |
| 96 | - if(\is_array($imageSrc)){ |
|
| 97 | - $this->addImage($imageSrc[0],@$imageSrc[1],@$imageSrc[2],@$imageSrc[3]); |
|
| 98 | - }else{ |
|
| 96 | + if (\is_array($imageSrc)) { |
|
| 97 | + $this->addImage($imageSrc[0], @$imageSrc[1], @$imageSrc[2], @$imageSrc[3]); |
|
| 98 | + } else { |
|
| 99 | 99 | $image=new HtmlCarouselItem("item-".$this->identifier); |
| 100 | 100 | $image->setImageSrc($this->_base.$imageSrc); |
| 101 | 101 | $image->setImageAlt($imageAlt); |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | */ |
| 119 | 119 | public function fromArray($array) { |
| 120 | 120 | if (\is_array($array) && sizeof($array)>0) { |
| 121 | - foreach ( $array as $value ) { |
|
| 121 | + foreach ($array as $value) { |
|
| 122 | 122 | if (\is_array($value)) { |
| 123 | 123 | $this->addImage($value ["src"], @$value ["alt"], @$value ["caption"], @$value ["description"]); |
| 124 | 124 | } else { |
@@ -41,15 +41,15 @@ discard block |
||
| 41 | 41 | * @param boolean $autoActive sets the last element's class to <b>active</b> if true |
| 42 | 42 | * @param function $hrefFunction the function who generates the href elements. default : function($e){return $e->getContent()} |
| 43 | 43 | */ |
| 44 | - public function __construct($identifier,$elements=array(),$autoActive=true,$startIndex=0,$hrefFunction=NULL){ |
|
| 45 | - parent::__construct($identifier,"ol"); |
|
| 44 | + public function __construct($identifier, $elements=array(), $autoActive=true, $startIndex=0, $hrefFunction=NULL) { |
|
| 45 | + parent::__construct($identifier, "ol"); |
|
| 46 | 46 | $this->startIndex=$startIndex; |
| 47 | 47 | $this->setProperty("class", "breadcrumb"); |
| 48 | 48 | $this->content=array(); |
| 49 | 49 | $this->autoActive=$autoActive; |
| 50 | 50 | $this->absolutePaths; |
| 51 | - $this->_hrefFunction=function ($e){return $e->getContent();}; |
|
| 52 | - if(isset($hrefFunction)){ |
|
| 51 | + $this->_hrefFunction=function($e) {return $e->getContent(); }; |
|
| 52 | + if (isset($hrefFunction)) { |
|
| 53 | 53 | $this->_hrefFunction=$hrefFunction; |
| 54 | 54 | } |
| 55 | 55 | $this->addElements($elements); |
@@ -60,43 +60,43 @@ discard block |
||
| 60 | 60 | * @param string $href |
| 61 | 61 | * @return \Ajax\bootstrap\html\HtmlLink |
| 62 | 62 | */ |
| 63 | - public function addElement($element,$href="",$glyph=NULL){ |
|
| 63 | + public function addElement($element, $href="", $glyph=NULL) { |
|
| 64 | 64 | $size=sizeof($this->content); |
| 65 | - if(\is_array($element)){ |
|
| 65 | + if (\is_array($element)) { |
|
| 66 | 66 | $elm=new HtmlLink("lnk-".$this->identifier."-".$size); |
| 67 | 67 | $elm->fromArray($element); |
| 68 | - }else if($element instanceof HtmlLink){ |
|
| 68 | + } else if ($element instanceof HtmlLink) { |
|
| 69 | 69 | $elm=$element; |
| 70 | - }else{ |
|
| 71 | - $elm=new HtmlLink("lnk-".$this->identifier."-".$size,$href,$element); |
|
| 72 | - if(isset($glyph)){ |
|
| 70 | + } else { |
|
| 71 | + $elm=new HtmlLink("lnk-".$this->identifier."-".$size, $href, $element); |
|
| 72 | + if (isset($glyph)) { |
|
| 73 | 73 | $elm->wrapContentWithGlyph($glyph); |
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | - $elm->wrap("<li>","</li>"); |
|
| 76 | + $elm->wrap("<li>", "</li>"); |
|
| 77 | 77 | $this->content[]=$elm; |
| 78 | 78 | $elm->setProperty($this->attr, $this->getHref($size)); |
| 79 | 79 | return $elm; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - public function setActive($index=null){ |
|
| 83 | - if(!isset($index)){ |
|
| 82 | + public function setActive($index=null) { |
|
| 83 | + if (!isset($index)) { |
|
| 84 | 84 | $index=sizeof($this->content)-1; |
| 85 | 85 | } |
| 86 | - $li=new HtmlBsDoubleElement("","li"); |
|
| 86 | + $li=new HtmlBsDoubleElement("", "li"); |
|
| 87 | 87 | $li->setClass("active"); |
| 88 | 88 | $li->setContent($this->content[$index]->getContent()); |
| 89 | 89 | $this->content[$index]=$li; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - public function addElements($elements){ |
|
| 93 | - foreach ( $elements as $element ) { |
|
| 92 | + public function addElements($elements) { |
|
| 93 | + foreach ($elements as $element) { |
|
| 94 | 94 | $this->addElement($element); |
| 95 | 95 | } |
| 96 | 96 | return $this; |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - public function fromArray($array){ |
|
| 99 | + public function fromArray($array) { |
|
| 100 | 100 | $array=parent::fromArray($array); |
| 101 | 101 | $this->addElements($array); |
| 102 | 102 | return $array; |
@@ -108,14 +108,14 @@ discard block |
||
| 108 | 108 | * @param string $separator |
| 109 | 109 | * @return string |
| 110 | 110 | */ |
| 111 | - public function getHref($index=null,$separator="/"){ |
|
| 112 | - if(!isset($index)){ |
|
| 111 | + public function getHref($index=null, $separator="/") { |
|
| 112 | + if (!isset($index)) { |
|
| 113 | 113 | $index=sizeof($this->content); |
| 114 | 114 | } |
| 115 | - if($this->absolutePaths===true){ |
|
| 115 | + if ($this->absolutePaths===true) { |
|
| 116 | 116 | return $this->_hrefFunction($this->content[$index]); |
| 117 | - }else{ |
|
| 118 | - return $this->root.implode($separator, array_slice(array_map(function($e){return $this->_hrefFunction($e);}, $this->content),$this->startIndex,$index+1)); |
|
| 117 | + } else { |
|
| 118 | + return $this->root.implode($separator, array_slice(array_map(function($e) {return $this->_hrefFunction($e); }, $this->content), $this->startIndex, $index+1)); |
|
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | 121 | |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | * @see \Ajax\bootstrap\html\BaseHtml::compile() |
| 125 | 125 | */ |
| 126 | 126 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
| 127 | - if($this->autoActive){ |
|
| 127 | + if ($this->autoActive) { |
|
| 128 | 128 | $this->setActive(); |
| 129 | 129 | } |
| 130 | 130 | return parent::compile($js, $view); |
@@ -142,19 +142,19 @@ discard block |
||
| 142 | 142 | * @see \Ajax\bootstrap\html\base\BaseHtml::on() |
| 143 | 143 | */ |
| 144 | 144 | public function on($event, $jsCode, $stopPropagation=false, $preventDefault=false) { |
| 145 | - foreach ($this->content as $element){ |
|
| 146 | - $element->on($event,$jsCode,$stopPropagation,$preventDefault); |
|
| 145 | + foreach ($this->content as $element) { |
|
| 146 | + $element->on($event, $jsCode, $stopPropagation, $preventDefault); |
|
| 147 | 147 | } |
| 148 | 148 | return $this; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | public function setAutoActive($autoActive) { |
| 152 | - $this->autoActive = $autoActive; |
|
| 152 | + $this->autoActive=$autoActive; |
|
| 153 | 153 | return $this; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | public function _ajaxOn($operation, $event, $url, $responseElement="", $parameters=array()) { |
| 157 | - foreach ($this->content as $element){ |
|
| 157 | + foreach ($this->content as $element) { |
|
| 158 | 158 | $element->_ajaxOn($operation, $event, $url, $responseElement, $parameters); |
| 159 | 159 | } |
| 160 | 160 | return $this; |
@@ -166,18 +166,18 @@ discard block |
||
| 166 | 166 | * @param string $targetSelector the target of the get |
| 167 | 167 | * @return HtmlBreadcrumbs |
| 168 | 168 | */ |
| 169 | - public function autoGetOnClick($targetSelector){ |
|
| 170 | - return $this->getOnClick($this->root, $targetSelector,array("attr"=>$this->attr)); |
|
| 169 | + public function autoGetOnClick($targetSelector) { |
|
| 170 | + return $this->getOnClick($this->root, $targetSelector, array("attr"=>$this->attr)); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - public function contentAsString(){ |
|
| 174 | - if($this->autoActive){ |
|
| 173 | + public function contentAsString() { |
|
| 174 | + if ($this->autoActive) { |
|
| 175 | 175 | $this->setActive(); |
| 176 | 176 | } |
| 177 | 177 | return parent::contentAsString(); |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - public function getElement($index){ |
|
| 180 | + public function getElement($index) { |
|
| 181 | 181 | return $this->content[$index]; |
| 182 | 182 | } |
| 183 | 183 | |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | * @param mixed $glyph |
| 187 | 187 | * @param int $index |
| 188 | 188 | */ |
| 189 | - public function addGlyph($glyph,$index=0){ |
|
| 189 | + public function addGlyph($glyph, $index=0) { |
|
| 190 | 190 | $elm=$this->getElement($index); |
| 191 | 191 | return $elm->wrapContentWithGlyph($glyph); |
| 192 | 192 | } |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | * @param Dispatcher $dispatcher the request dispatcher |
| 198 | 198 | * @return \Ajax\bootstrap\html\HtmlBreadcrumbs |
| 199 | 199 | */ |
| 200 | - public function fromDispatcher(JsUtils $js,$dispatcher,$startIndex=0){ |
|
| 200 | + public function fromDispatcher(JsUtils $js, $dispatcher, $startIndex=0) { |
|
| 201 | 201 | $this->startIndex=$startIndex; |
| 202 | 202 | return $this->addElements($js->fromDispatcher($dispatcher)); |
| 203 | 203 | } |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | * @return \Ajax\bootstrap\html\HtmlBreadcrumbs |
| 210 | 210 | */ |
| 211 | 211 | public function setHrefFunction($_hrefFunction) { |
| 212 | - $this->_hrefFunction = $_hrefFunction; |
|
| 212 | + $this->_hrefFunction=$_hrefFunction; |
|
| 213 | 213 | return $this; |
| 214 | 214 | } |
| 215 | 215 | |
@@ -8,23 +8,23 @@ discard block |
||
| 8 | 8 | use Cake\Network\Response; |
| 9 | 9 | use Cake\Core\App; |
| 10 | 10 | |
| 11 | -class _JsUtils extends \Ajax\JsUtils{ |
|
| 12 | - public function getUrl($url){ |
|
| 11 | +class _JsUtils extends \Ajax\JsUtils { |
|
| 12 | + public function getUrl($url) { |
|
| 13 | 13 | return Router::url($url); |
| 14 | 14 | } |
| 15 | - public function addViewElement($identifier,$content,&$view){ |
|
| 15 | + public function addViewElement($identifier, $content, &$view) { |
|
| 16 | 16 | $viewVars=$view->viewVars; |
| 17 | - if (isset($viewVars["q"]) === false) { |
|
| 18 | - $controls=array (); |
|
| 19 | - }else{ |
|
| 17 | + if (isset($viewVars["q"])===false) { |
|
| 18 | + $controls=array(); |
|
| 19 | + } else { |
|
| 20 | 20 | $controls=$viewVars["q"]; |
| 21 | 21 | } |
| 22 | 22 | $controls[$identifier]=$content; |
| 23 | 23 | $view->set("q", $controls); |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - public function createScriptVariable(&$view,$view_var, $output){ |
|
| 27 | - $view->set($view_var,$output); |
|
| 26 | + public function createScriptVariable(&$view, $view_var, $output) { |
|
| 27 | + $view->set($view_var, $output); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** |
@@ -34,18 +34,18 @@ discard block |
||
| 34 | 34 | * @param array $params |
| 35 | 35 | * @see \Ajax\JsUtils::forward() |
| 36 | 36 | */ |
| 37 | - public function forward($initialControllerInstance,$controllerName,$actionName,$params=array()){ |
|
| 37 | + public function forward($initialControllerInstance, $controllerName, $actionName, $params=array()) { |
|
| 38 | 38 | \ob_start(); |
| 39 | - if(isset($params) && !\is_array($params)){ |
|
| 39 | + if (isset($params) && !\is_array($params)) { |
|
| 40 | 40 | $params=[$params]; |
| 41 | 41 | } |
| 42 | 42 | $url=h(Router::url(\array_merge([ |
| 43 | 43 | 'controller' => $controllerName, |
| 44 | - 'action' => $actionName],$params),false |
|
| 44 | + 'action' => $actionName], $params), false |
|
| 45 | 45 | )); |
| 46 | 46 | $base=Router::url("/"); |
| 47 | - if (substr($url, 0, strlen($base)) == $base) { |
|
| 48 | - $url = substr($url, strlen($base)); |
|
| 47 | + if (substr($url, 0, strlen($base))==$base) { |
|
| 48 | + $url=substr($url, strlen($base)); |
|
| 49 | 49 | } |
| 50 | 50 | $initialControllerInstance->requestAction($url); |
| 51 | 51 | $result=\ob_get_contents(); |
@@ -53,17 +53,17 @@ discard block |
||
| 53 | 53 | return $result; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - public function renderContent($initialControllerInstance,$viewName, $params=NULL) { |
|
| 57 | - $view = new View(Router::getRequest(true), new Response()); |
|
| 58 | - if(\is_array($params)){ |
|
| 59 | - foreach ($params as $k=>$v){ |
|
| 56 | + public function renderContent($initialControllerInstance, $viewName, $params=NULL) { |
|
| 57 | + $view=new View(Router::getRequest(true), new Response()); |
|
| 58 | + if (\is_array($params)) { |
|
| 59 | + foreach ($params as $k=>$v) { |
|
| 60 | 60 | $view->set($k, $v); |
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | return $view->render($viewName); |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - public function fromDispatcher($dispatcher){ |
|
| 66 | + public function fromDispatcher($dispatcher) { |
|
| 67 | 67 | return \explode("/", Router::getRequest(true)->url); |
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | 70 | \ No newline at end of file |
@@ -1,39 +1,39 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace Ajax\php\ci; |
| 3 | 3 | |
| 4 | -class JsUtils extends \Ajax\JsUtils{ |
|
| 4 | +class JsUtils extends \Ajax\JsUtils { |
|
| 5 | 5 | protected $ci; |
| 6 | - protected $_my_controller_paths= array(); |
|
| 7 | - protected $_my_controllers= array(); |
|
| 6 | + protected $_my_controller_paths=array(); |
|
| 7 | + protected $_my_controllers=array(); |
|
| 8 | 8 | |
| 9 | - public function __construct($params=array(),$injected=NULL){ |
|
| 10 | - parent::__construct($params,$injected); |
|
| 11 | - $this->_my_controller_paths = array(APPPATH); |
|
| 9 | + public function __construct($params=array(), $injected=NULL) { |
|
| 10 | + parent::__construct($params, $injected); |
|
| 11 | + $this->_my_controller_paths=array(APPPATH); |
|
| 12 | 12 | } |
| 13 | - public function getUrl($url){ |
|
| 13 | + public function getUrl($url) { |
|
| 14 | 14 | return site_url($url); |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | - public function getCi(){ |
|
| 18 | - if(isset($this->ci)===false){ |
|
| 19 | - $this->ci =& get_instance(); |
|
| 17 | + public function getCi() { |
|
| 18 | + if (isset($this->ci)===false) { |
|
| 19 | + $this->ci=& get_instance(); |
|
| 20 | 20 | $this->ci->load->helper('url'); |
| 21 | 21 | } |
| 22 | 22 | return $this->ci; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - public function addViewElement($identifier,$content,&$view){ |
|
| 26 | - if(\array_key_exists("q", $view)===false){ |
|
| 25 | + public function addViewElement($identifier, $content, &$view) { |
|
| 26 | + if (\array_key_exists("q", $view)===false) { |
|
| 27 | 27 | $view["q"]=array(); |
| 28 | 28 | } |
| 29 | 29 | $view["q"][$identifier]=$content; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - public function createScriptVariable(&$view,$view_var, $output){ |
|
| 32 | + public function createScriptVariable(&$view, $view_var, $output) { |
|
| 33 | 33 | $view[$view_var]=$output; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - public function forward($initialControllerInstance,$controllerName,$actionName,$params=NULL){ |
|
| 36 | + public function forward($initialControllerInstance, $controllerName, $actionName, $params=NULL) { |
|
| 37 | 37 | $ci=$this->getCi(); |
| 38 | 38 | $controllerName=strtolower($controllerName); |
| 39 | 39 | $this->controller($controllerName); |
@@ -44,64 +44,64 @@ discard block |
||
| 44 | 44 | return $result; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - public function renderContent($initialControllerInstance,$viewName, $params=NULL) { |
|
| 47 | + public function renderContent($initialControllerInstance, $viewName, $params=NULL) { |
|
| 48 | 48 | return $initialControllerInstance->load->view($viewName, $params, true); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - public function fromDispatcher($dispatcher){ |
|
| 51 | + public function fromDispatcher($dispatcher) { |
|
| 52 | 52 | return array_values($dispatcher->uri->segment_array()); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - public function controller($controller, $name = '', $db_conn = FALSE){ |
|
| 56 | - if (\is_array($controller)){ |
|
| 57 | - foreach ($controller as $babe){ |
|
| 55 | + public function controller($controller, $name='', $db_conn=FALSE) { |
|
| 56 | + if (\is_array($controller)) { |
|
| 57 | + foreach ($controller as $babe) { |
|
| 58 | 58 | $this->controller($babe); |
| 59 | 59 | } |
| 60 | 60 | return; |
| 61 | 61 | } |
| 62 | - if ($controller == ''){ |
|
| 62 | + if ($controller=='') { |
|
| 63 | 63 | return; |
| 64 | 64 | } |
| 65 | - $path = ''; |
|
| 65 | + $path=''; |
|
| 66 | 66 | // Is the controller in a sub-folder? If so, parse out the filename and path. |
| 67 | - if (($last_slash = strrpos($controller, '/')) !== FALSE){ |
|
| 67 | + if (($last_slash=strrpos($controller, '/'))!==FALSE) { |
|
| 68 | 68 | // The path is in front of the last slash |
| 69 | - $path = substr($controller, 0, $last_slash + 1); |
|
| 69 | + $path=substr($controller, 0, $last_slash+1); |
|
| 70 | 70 | // And the controller name behind it |
| 71 | - $controller = substr($controller, $last_slash + 1); |
|
| 71 | + $controller=substr($controller, $last_slash+1); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - if ($name == ''){ |
|
| 75 | - $name = $controller; |
|
| 74 | + if ($name=='') { |
|
| 75 | + $name=$controller; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - if (in_array($name, $this->_my_controllers, TRUE)){ |
|
| 78 | + if (in_array($name, $this->_my_controllers, TRUE)) { |
|
| 79 | 79 | return; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - $CI =$this->getCi(); |
|
| 83 | - if (isset($CI->$name)){ |
|
| 82 | + $CI=$this->getCi(); |
|
| 83 | + if (isset($CI->$name)) { |
|
| 84 | 84 | show_error('The controller name you are loading is the name of a resource that is already being used: '.$name); |
| 85 | 85 | } |
| 86 | - $controller = strtolower($controller); |
|
| 87 | - foreach ($this->_my_controller_paths as $mod_path){ |
|
| 88 | - if ( ! file_exists($mod_path.'controllers/'.$path.$controller.'.php')){ |
|
| 86 | + $controller=strtolower($controller); |
|
| 87 | + foreach ($this->_my_controller_paths as $mod_path) { |
|
| 88 | + if (!file_exists($mod_path.'controllers/'.$path.$controller.'.php')) { |
|
| 89 | 89 | continue; |
| 90 | 90 | } |
| 91 | - if ($db_conn !== FALSE AND ! class_exists('CI_DB')){ |
|
| 92 | - if ($db_conn === TRUE){ |
|
| 93 | - $db_conn = ''; |
|
| 91 | + if ($db_conn!==FALSE AND !class_exists('CI_DB')) { |
|
| 92 | + if ($db_conn===TRUE) { |
|
| 93 | + $db_conn=''; |
|
| 94 | 94 | } |
| 95 | 95 | $CI->load->database($db_conn, FALSE, TRUE); |
| 96 | 96 | } |
| 97 | - if ( ! class_exists('CI_Controller')){ |
|
| 97 | + if (!class_exists('CI_Controller')) { |
|
| 98 | 98 | load_class('Controller', 'core'); |
| 99 | 99 | } |
| 100 | 100 | require_once($mod_path.'controllers/'.$path.$controller.'.php'); |
| 101 | - $controller = ucfirst($controller); |
|
| 102 | - $CI->$name = new $controller(); |
|
| 101 | + $controller=ucfirst($controller); |
|
| 102 | + $CI->$name=new $controller(); |
|
| 103 | 103 | |
| 104 | - $this->_my_controllers[] = $name; |
|
| 104 | + $this->_my_controllers[]=$name; |
|
| 105 | 105 | return; |
| 106 | 106 | } |
| 107 | 107 | show_error('Unable to locate the controller you have specified: '.$controller); |