@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | private $default; |
| 14 | 14 | private $options; |
| 15 | 15 | |
| 16 | - public function __construct($identifier, $caption,$default=NULL) { |
|
| 16 | + public function __construct($identifier, $caption, $default=NULL) { |
|
| 17 | 17 | parent::__construct($identifier, "select"); |
| 18 | 18 | $this->setProperty("name", $identifier); |
| 19 | 19 | $this->setProperty("class", "form-control"); |
@@ -22,21 +22,21 @@ discard block |
||
| 22 | 22 | $this->options=array(); |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - public function addOption($element,$value="",$selected=false){ |
|
| 26 | - if($element instanceof HtmlOption){ |
|
| 25 | + public function addOption($element, $value="", $selected=false) { |
|
| 26 | + if ($element instanceof HtmlOption) { |
|
| 27 | 27 | $option=$element; |
| 28 | - }else{ |
|
| 29 | - $option=new HtmlOption($this->identifier."-".count($this->options), $element,$value); |
|
| 28 | + } else { |
|
| 29 | + $option=new HtmlOption($this->identifier."-".count($this->options), $element, $value); |
|
| 30 | 30 | } |
| 31 | - if($selected || $option->getValue()==$this->getProperty("value")){ |
|
| 31 | + if ($selected || $option->getValue()==$this->getProperty("value")) { |
|
| 32 | 32 | $option->select(); |
| 33 | 33 | } |
| 34 | 34 | $this->options[]=$option; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | public function setValue($value) { |
| 38 | - foreach ( $this->options as $option ) { |
|
| 39 | - if (strcasecmp($option->getValue(),$value)===0) { |
|
| 38 | + foreach ($this->options as $option) { |
|
| 39 | + if (strcasecmp($option->getValue(), $value)===0) { |
|
| 40 | 40 | $option->setProperty("selected", ""); |
| 41 | 41 | } |
| 42 | 42 | } |
@@ -49,23 +49,23 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
| 51 | 51 | $this->content=array(); |
| 52 | - if(isset($this->default)){ |
|
| 52 | + if (isset($this->default)) { |
|
| 53 | 53 | $default=new HtmlOption("", $this->default); |
| 54 | 54 | $this->content[]=$default; |
| 55 | 55 | } |
| 56 | - foreach ($this->options as $option){ |
|
| 56 | + foreach ($this->options as $option) { |
|
| 57 | 57 | $this->content[]=$option; |
| 58 | 58 | } |
| 59 | 59 | return parent::compile($js, $view); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - public function fromArray($array){ |
|
| 63 | - if(JArray::isAssociative($array)){ |
|
| 64 | - foreach ($array as $k=>$v){ |
|
| 62 | + public function fromArray($array) { |
|
| 63 | + if (JArray::isAssociative($array)) { |
|
| 64 | + foreach ($array as $k=>$v) { |
|
| 65 | 65 | $this->addOption($v, $k); |
| 66 | 66 | } |
| 67 | - }else{ |
|
| 68 | - foreach ($array as $v){ |
|
| 67 | + } else { |
|
| 68 | + foreach ($array as $v) { |
|
| 69 | 69 | $this->addOption($v, $v); |
| 70 | 70 | } |
| 71 | 71 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | $this->addOption($function($object)); |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - public function setSize($size){ |
|
| 101 | + public function setSize($size) { |
|
| 102 | 102 | return $this->setProperty("size", $size); |
| 103 | 103 | } |
| 104 | 104 | } |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | public function addOption($element,$value="",$selected=false){ |
| 26 | 26 | if($element instanceof HtmlOption){ |
| 27 | 27 | $option=$element; |
| 28 | - }else{ |
|
| 28 | + } else{ |
|
| 29 | 29 | $option=new HtmlOption($this->identifier."-".count($this->options), $element,$value); |
| 30 | 30 | } |
| 31 | 31 | if($selected || $option->getValue()==$this->getProperty("value")){ |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | foreach ($array as $k=>$v){ |
| 65 | 65 | $this->addOption($v, $k); |
| 66 | 66 | } |
| 67 | - }else{ |
|
| 67 | + } else{ |
|
| 68 | 68 | foreach ($array as $v){ |
| 69 | 69 | $this->addOption($v, $v); |
| 70 | 70 | } |
@@ -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,17 +24,17 @@ discard block |
||
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | private static function containsElement($input) { |
| 27 | - foreach ( $input as $v ) { |
|
| 28 | - if (\is_object($v) === true || \is_array($v)) |
|
| 27 | + foreach ($input as $v) { |
|
| 28 | + if (\is_object($v)===true || \is_array($v)) |
|
| 29 | 29 | return true; |
| 30 | 30 | } |
| 31 | 31 | return false; |
| 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) === true || \is_array($v)) |
|
| 29 | - return true; |
|
| 28 | + if (\is_object($v) === true || \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; |
@@ -27,15 +27,15 @@ discard block |
||
| 27 | 27 | return $this->content; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - public function addContent($content,$before=false) { |
|
| 30 | + public function addContent($content, $before=false) { |
|
| 31 | 31 | if (is_array($this->content)===false) { |
| 32 | - if(isset($this->content)) |
|
| 33 | - $this->content=array ($this->content); |
|
| 32 | + if (isset($this->content)) |
|
| 33 | + $this->content=array($this->content); |
|
| 34 | 34 | else |
| 35 | 35 | $this->content=array(); |
| 36 | 36 | } |
| 37 | - if($before) |
|
| 38 | - array_unshift($this->content,$content); |
|
| 37 | + if ($before) |
|
| 38 | + array_unshift($this->content, $content); |
|
| 39 | 39 | else |
| 40 | 40 | $this->content []=$content; |
| 41 | 41 | return $this; |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | if ($this->content instanceof HtmlDoubleElement) { |
| 51 | 51 | $this->content->run($js); |
| 52 | 52 | } else if (is_array($this->content)) { |
| 53 | - foreach ( $this->content as $itemContent ) { |
|
| 53 | + foreach ($this->content as $itemContent) { |
|
| 54 | 54 | if ($itemContent instanceof HtmlDoubleElement) { |
| 55 | 55 | $itemContent->run($js); |
| 56 | 56 | } |
@@ -29,15 +29,17 @@ |
||
| 29 | 29 | |
| 30 | 30 | public function addContent($content,$before=false) { |
| 31 | 31 | if (is_array($this->content)===false) { |
| 32 | - if(isset($this->content)) |
|
| 33 | - $this->content=array ($this->content); |
|
| 34 | - else |
|
| 35 | - $this->content=array(); |
|
| 32 | + if(isset($this->content)) { |
|
| 33 | + $this->content=array ($this->content); |
|
| 34 | + } else { |
|
| 35 | + $this->content=array(); |
|
| 36 | + } |
|
| 37 | + } |
|
| 38 | + if($before) { |
|
| 39 | + array_unshift($this->content,$content); |
|
| 40 | + } else { |
|
| 41 | + $this->content []=$content; |
|
| 36 | 42 | } |
| 37 | - if($before) |
|
| 38 | - array_unshift($this->content,$content); |
|
| 39 | - else |
|
| 40 | - $this->content []=$content; |
|
| 41 | 43 | return $this; |
| 42 | 44 | } |
| 43 | 45 | |
@@ -68,7 +68,7 @@ |
||
| 68 | 68 | public abstract function forward($initialController,$controller,$action,$params); |
| 69 | 69 | /** |
| 70 | 70 | * render the content of an existing view : $viewName and set the response to the modal content |
| 71 | - * @param Controller $initialControllerInstance |
|
| 71 | + * @param Controller $initialControllerInstance |
|
| 72 | 72 | * @param View $viewName |
| 73 | 73 | * @param $params The parameters to pass to the view |
| 74 | 74 | */ |
@@ -21,8 +21,8 @@ discard block |
||
| 21 | 21 | /** |
| 22 | 22 | * JsUtils Class : Service to be injected |
| 23 | 23 | */ |
| 24 | -abstract class JsUtils{ |
|
| 25 | - use JsUtilsEventsTrait,JsUtilsActionsTrait,JsUtilsAjaxTrait; |
|
| 24 | +abstract class JsUtils { |
|
| 25 | + use JsUtilsEventsTrait, JsUtilsActionsTrait, JsUtilsAjaxTrait; |
|
| 26 | 26 | |
| 27 | 27 | protected $js; |
| 28 | 28 | protected $cdns; |
@@ -51,13 +51,13 @@ discard block |
||
| 51 | 51 | protected $config; |
| 52 | 52 | |
| 53 | 53 | protected function _setDi($di) { |
| 54 | - if ($this->js!=null&&$di!=null) |
|
| 54 | + if ($this->js!=null && $di!=null) |
|
| 55 | 55 | $this->js->setDi($di); |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | public abstract function getUrl($url); |
| 59 | - public abstract function addViewElement($identifier,$content,&$view); |
|
| 60 | - public abstract function createScriptVariable(&$view,$view_var, $output); |
|
| 59 | + public abstract function addViewElement($identifier, $content, &$view); |
|
| 60 | + public abstract function createScriptVariable(&$view, $view_var, $output); |
|
| 61 | 61 | /** |
| 62 | 62 | * render the content of $controller::$action and set the response to the modal content |
| 63 | 63 | * @param Controller $initialController |
@@ -65,14 +65,14 @@ discard block |
||
| 65 | 65 | * @param string $action a Phalcon action |
| 66 | 66 | * @param array $params |
| 67 | 67 | */ |
| 68 | - public abstract function forward($initialController,$controller,$action,$params); |
|
| 68 | + public abstract function forward($initialController, $controller, $action, $params); |
|
| 69 | 69 | /** |
| 70 | 70 | * render the content of an existing view : $viewName and set the response to the modal content |
| 71 | 71 | * @param Controller $initialControllerInstance |
| 72 | 72 | * @param View $viewName |
| 73 | 73 | * @param $params The parameters to pass to the view |
| 74 | 74 | */ |
| 75 | - public abstract function renderContent($initialControllerInstance,$viewName, $params=NULL); |
|
| 75 | + public abstract function renderContent($initialControllerInstance, $viewName, $params=NULL); |
|
| 76 | 76 | |
| 77 | 77 | /** |
| 78 | 78 | * Collect url parts from the request dispatcher : controllerName, actionName, parameters |
@@ -163,28 +163,28 @@ discard block |
||
| 163 | 163 | return $this->config; |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - public function __construct($params=array(),$injected=NULL) { |
|
| 167 | - $defaults=array ( |
|
| 166 | + public function __construct($params=array(), $injected=NULL) { |
|
| 167 | + $defaults=array( |
|
| 168 | 168 | 'driver' => 'Jquery', |
| 169 | 169 | 'debug' => true |
| 170 | 170 | ); |
| 171 | - foreach ( $defaults as $key => $val ) { |
|
| 171 | + foreach ($defaults as $key => $val) { |
|
| 172 | 172 | if (isset($params[$key])===false || $params[$key]==="") { |
| 173 | 173 | $params[$key]=$defaults[$key]; |
| 174 | 174 | } |
| 175 | 175 | } |
| 176 | - $this->js=new Jquery($params,$this); |
|
| 176 | + $this->js=new Jquery($params, $this); |
|
| 177 | 177 | |
| 178 | - if(\array_key_exists("semantic", $params)){ |
|
| 178 | + if (\array_key_exists("semantic", $params)) { |
|
| 179 | 179 | $this->semantic(new Semantic()); |
| 180 | 180 | } |
| 181 | - $this->cdns=array (); |
|
| 181 | + $this->cdns=array(); |
|
| 182 | 182 | $this->params=$params; |
| 183 | 183 | $this->injected=$injected; |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - public function __set($property, $value){ |
|
| 187 | - switch ($property){ |
|
| 186 | + public function __set($property, $value) { |
|
| 187 | + switch ($property) { |
|
| 188 | 188 | case "bootstrap": |
| 189 | 189 | $this->bootstrap($value); |
| 190 | 190 | break; |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | } |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | - public function getParam($key){ |
|
| 202 | + public function getParam($key) { |
|
| 203 | 203 | return $this->params[$key]; |
| 204 | 204 | } |
| 205 | 205 | |
@@ -237,11 +237,11 @@ discard block |
||
| 237 | 237 | */ |
| 238 | 238 | public function compile(&$view=NULL, $view_var='script_foot', $script_tags=TRUE) { |
| 239 | 239 | $bs=$this->_bootstrap; |
| 240 | - if (isset($bs)&&isset($view)) { |
|
| 240 | + if (isset($bs) && isset($view)) { |
|
| 241 | 241 | $bs->compileHtml($this, $view); |
| 242 | 242 | } |
| 243 | 243 | $sem=$this->_semantic; |
| 244 | - if (isset($sem)&&isset($view)) { |
|
| 244 | + if (isset($sem) && isset($view)) { |
|
| 245 | 245 | $sem->compileHtml($this, $view); |
| 246 | 246 | } |
| 247 | 247 | return $this->js->_compile($view, $view_var, $script_tags); |
@@ -318,14 +318,14 @@ discard block |
||
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | private function _create_json($json_result, $match_array_type) { |
| 321 | - $json=array (); |
|
| 321 | + $json=array(); |
|
| 322 | 322 | $_is_assoc=TRUE; |
| 323 | - if (!is_array($json_result)&&empty($json_result)) { |
|
| 323 | + if (!is_array($json_result) && empty($json_result)) { |
|
| 324 | 324 | show_error("Generate JSON Failed - Illegal key, value pair."); |
| 325 | 325 | } elseif ($match_array_type) { |
| 326 | 326 | $_is_assoc=$this->_is_associative_array($json_result); |
| 327 | 327 | } |
| 328 | - foreach ( $json_result as $k => $v ) { |
|
| 328 | + foreach ($json_result as $k => $v) { |
|
| 329 | 329 | if ($_is_assoc) { |
| 330 | 330 | $json[]=$this->_prep_args($k, TRUE).':'.$this->generate_json($v, $match_array_type); |
| 331 | 331 | } else { |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | * @return type |
| 344 | 344 | */ |
| 345 | 345 | public function _is_associative_array($arr) { |
| 346 | - foreach ( array_keys($arr) as $key => $val ) { |
|
| 346 | + foreach (array_keys($arr) as $key => $val) { |
|
| 347 | 347 | if ($key!==$val) { |
| 348 | 348 | return TRUE; |
| 349 | 349 | } |
@@ -362,11 +362,11 @@ discard block |
||
| 362 | 362 | return 'null'; |
| 363 | 363 | } elseif (is_bool($result)) { |
| 364 | 364 | return ($result===TRUE) ? 'true' : 'false'; |
| 365 | - } elseif (is_string($result)||$is_key) { |
|
| 366 | - return '"'.str_replace(array ( |
|
| 367 | - '\\',"\t","\n","\r",'"','/' |
|
| 368 | - ), array ( |
|
| 369 | - '\\\\','\\t','\\n',"\\r",'\"','\/' |
|
| 365 | + } elseif (is_string($result) || $is_key) { |
|
| 366 | + return '"'.str_replace(array( |
|
| 367 | + '\\', "\t", "\n", "\r", '"', '/' |
|
| 368 | + ), array( |
|
| 369 | + '\\\\', '\\t', '\\n', "\\r", '\"', '\/' |
|
| 370 | 370 | ), $result).'"'; |
| 371 | 371 | } elseif (is_scalar($result)) { |
| 372 | 372 | return $result; |
@@ -379,7 +379,7 @@ discard block |
||
| 379 | 379 | |
| 380 | 380 | public function setCDNs($cdns) { |
| 381 | 381 | if (is_array($cdns)===false) { |
| 382 | - $cdns=array ( |
|
| 382 | + $cdns=array( |
|
| 383 | 383 | $cdns |
| 384 | 384 | ); |
| 385 | 385 | } |
@@ -391,9 +391,9 @@ discard block |
||
| 391 | 391 | $hasJQueryUI=false; |
| 392 | 392 | $hasBootstrap=false; |
| 393 | 393 | $hasSemantic=false; |
| 394 | - $result=array (); |
|
| 395 | - foreach ( $this->cdns as $cdn ) { |
|
| 396 | - switch(get_class($cdn)) { |
|
| 394 | + $result=array(); |
|
| 395 | + foreach ($this->cdns as $cdn) { |
|
| 396 | + switch (get_class($cdn)) { |
|
| 397 | 397 | case "Ajax\lib\CDNJQuery": |
| 398 | 398 | $hasJQuery=true; |
| 399 | 399 | $result[0]=$cdn; |
@@ -403,11 +403,11 @@ discard block |
||
| 403 | 403 | $result[1]=$cdn; |
| 404 | 404 | break; |
| 405 | 405 | case "Ajax\lib\CDNCoreCss": |
| 406 | - if($cdn->getFramework()==="Bootstrap") |
|
| 406 | + if ($cdn->getFramework()==="Bootstrap") |
|
| 407 | 407 | $hasBootstrap=true; |
| 408 | - elseif($cdn->getFramework()==="Semantic") |
|
| 408 | + elseif ($cdn->getFramework()==="Semantic") |
|
| 409 | 409 | $hasSemantic=true; |
| 410 | - if($hasSemantic || $hasBootstrap) |
|
| 410 | + if ($hasSemantic || $hasBootstrap) |
|
| 411 | 411 | $result[2]=$cdn; |
| 412 | 412 | break; |
| 413 | 413 | } |
@@ -415,14 +415,14 @@ discard block |
||
| 415 | 415 | if ($hasJQuery===false) { |
| 416 | 416 | $result[0]=new CDNJQuery("x"); |
| 417 | 417 | } |
| 418 | - if ($hasJQueryUI===false&&isset($this->_ui)) { |
|
| 418 | + if ($hasJQueryUI===false && isset($this->_ui)) { |
|
| 419 | 419 | $result[1]=new CDNGuiGen("x", $template); |
| 420 | 420 | } |
| 421 | - if ($hasBootstrap===false&&isset($this->_bootstrap)) { |
|
| 422 | - $result[2]=new CDNCoreCss("Bootstrap","x"); |
|
| 421 | + if ($hasBootstrap===false && isset($this->_bootstrap)) { |
|
| 422 | + $result[2]=new CDNCoreCss("Bootstrap", "x"); |
|
| 423 | 423 | } |
| 424 | - if ($hasSemantic===false&&isset($this->_semantic)) { |
|
| 425 | - $result[2]=new CDNCoreCss("Semantic","x"); |
|
| 424 | + if ($hasSemantic===false && isset($this->_semantic)) { |
|
| 425 | + $result[2]=new CDNCoreCss("Semantic", "x"); |
|
| 426 | 426 | } |
| 427 | 427 | ksort($result); |
| 428 | 428 | return implode("\n", $result); |
@@ -51,8 +51,9 @@ discard block |
||
| 51 | 51 | protected $config; |
| 52 | 52 | |
| 53 | 53 | protected function _setDi($di) { |
| 54 | - if ($this->js!=null&&$di!=null) |
|
| 55 | - $this->js->setDi($di); |
|
| 54 | + if ($this->js!=null&&$di!=null) { |
|
| 55 | + $this->js->setDi($di); |
|
| 56 | + } |
|
| 56 | 57 | } |
| 57 | 58 | |
| 58 | 59 | public abstract function getUrl($url); |
@@ -403,12 +404,14 @@ discard block |
||
| 403 | 404 | $result[1]=$cdn; |
| 404 | 405 | break; |
| 405 | 406 | case "Ajax\lib\CDNCoreCss": |
| 406 | - if($cdn->getFramework()==="Bootstrap") |
|
| 407 | - $hasBootstrap=true; |
|
| 408 | - elseif($cdn->getFramework()==="Semantic") |
|
| 409 | - $hasSemantic=true; |
|
| 410 | - if($hasSemantic || $hasBootstrap) |
|
| 411 | - $result[2]=$cdn; |
|
| 407 | + if($cdn->getFramework()==="Bootstrap") { |
|
| 408 | + $hasBootstrap=true; |
|
| 409 | + } elseif($cdn->getFramework()==="Semantic") { |
|
| 410 | + $hasSemantic=true; |
|
| 411 | + } |
|
| 412 | + if($hasSemantic || $hasBootstrap) { |
|
| 413 | + $result[2]=$cdn; |
|
| 414 | + } |
|
| 412 | 415 | break; |
| 413 | 416 | } |
| 414 | 417 | } |
@@ -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 |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | class JArray { |
| 6 | 6 | |
| 7 | 7 | public static function isAssociative($array) { |
| 8 | - return (array_values($array) !== $array); |
|
| 8 | + return (array_values($array)!==$array); |
|
| 9 | 9 | // return (array_keys($array)!==range(0, count($array)-1)); |
| 10 | 10 | } |
| 11 | 11 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | return $array[$key]; |
| 15 | 15 | } |
| 16 | 16 | $values=array_values($array); |
| 17 | - if ($pos < sizeof($values)) |
|
| 17 | + if ($pos<sizeof($values)) |
|
| 18 | 18 | return $values[$pos]; |
| 19 | 19 | } |
| 20 | 20 | |
@@ -22,12 +22,12 @@ discard block |
||
| 22 | 22 | $result=NULL; |
| 23 | 23 | if (array_key_exists($key, $array)) { |
| 24 | 24 | $result=$array[$key]; |
| 25 | - if ($condition($result) === true) |
|
| 25 | + if ($condition($result)===true) |
|
| 26 | 26 | return $result; |
| 27 | 27 | } |
| 28 | 28 | $values=array_values($array); |
| 29 | - foreach ( $values as $val ) { |
|
| 30 | - if ($condition($val) === true) |
|
| 29 | + foreach ($values as $val) { |
|
| 30 | + if ($condition($val)===true) |
|
| 31 | 31 | return $val; |
| 32 | 32 | } |
| 33 | 33 | return $result; |
@@ -44,11 +44,11 @@ discard block |
||
| 44 | 44 | $result=""; |
| 45 | 45 | if (\is_array($glue)) { |
| 46 | 46 | $size=\sizeof($pieces); |
| 47 | - if ($size > 0) { |
|
| 48 | - for($i=0; $i < $size - 1; $i++) { |
|
| 49 | - $result.=$pieces[$i] . @$glue[$i]; |
|
| 47 | + if ($size>0) { |
|
| 48 | + for ($i=0; $i<$size-1; $i++) { |
|
| 49 | + $result.=$pieces[$i].@$glue[$i]; |
|
| 50 | 50 | } |
| 51 | - $result.=$pieces[$size - 1]; |
|
| 51 | + $result.=$pieces[$size-1]; |
|
| 52 | 52 | } |
| 53 | 53 | } else { |
| 54 | 54 | $result=\implode($glue, $pieces); |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | public static function dimension($array) { |
| 60 | 60 | if (is_array(reset($array))) { |
| 61 | - $return=self::dimension(reset($array)) + 1; |
|
| 61 | + $return=self::dimension(reset($array))+1; |
|
| 62 | 62 | } else { |
| 63 | 63 | $return=1; |
| 64 | 64 | } |
@@ -66,8 +66,8 @@ discard block |
||
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | public static function sortAssociative($array, $sortedKeys=array()) { |
| 69 | - $newArray=array (); |
|
| 70 | - foreach ( $sortedKeys as $key ) { |
|
| 69 | + $newArray=array(); |
|
| 70 | + foreach ($sortedKeys as $key) { |
|
| 71 | 71 | if (\array_key_exists($key, $array)) { |
| 72 | 72 | $newArray[$key]=$array[$key]; |
| 73 | 73 | } |
@@ -14,21 +14,24 @@ discard block |
||
| 14 | 14 | return $array[$key]; |
| 15 | 15 | } |
| 16 | 16 | $values=array_values($array); |
| 17 | - if ($pos < sizeof($values)) |
|
| 18 | - return $values[$pos]; |
|
| 17 | + if ($pos < sizeof($values)) { |
|
| 18 | + return $values[$pos]; |
|
| 19 | + } |
|
| 19 | 20 | } |
| 20 | 21 | |
| 21 | 22 | public static function getConditionalValue($array, $key, $condition) { |
| 22 | 23 | $result=NULL; |
| 23 | 24 | if (array_key_exists($key, $array)) { |
| 24 | 25 | $result=$array[$key]; |
| 25 | - if ($condition($result) === true) |
|
| 26 | - return $result; |
|
| 26 | + if ($condition($result) === true) { |
|
| 27 | + return $result; |
|
| 28 | + } |
|
| 27 | 29 | } |
| 28 | 30 | $values=array_values($array); |
| 29 | 31 | foreach ( $values as $val ) { |
| 30 | - if ($condition($val) === true) |
|
| 31 | - return $val; |
|
| 32 | + if ($condition($val) === true) { |
|
| 33 | + return $val; |
|
| 34 | + } |
|
| 32 | 35 | } |
| 33 | 36 | return $result; |
| 34 | 37 | } |
@@ -36,8 +39,9 @@ discard block |
||
| 36 | 39 | public static function getDefaultValue($array, $key, $default=NULL) { |
| 37 | 40 | if (array_key_exists($key, $array)) { |
| 38 | 41 | return $array[$key]; |
| 39 | - } else |
|
| 40 | - return $default; |
|
| 42 | + } else { |
|
| 43 | + return $default; |
|
| 44 | + } |
|
| 41 | 45 | } |
| 42 | 46 | |
| 43 | 47 | public static function implode($glue, $pieces) { |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | if ($stopPropagation===true) { |
| 31 | 31 | $result.="event.stopPropagation();\n"; |
| 32 | 32 | } |
| 33 | - switch($this->method) { |
|
| 33 | + switch ($this->method) { |
|
| 34 | 34 | case "get": |
| 35 | 35 | $result.=$js->getDeferred($url, $responseElement, $params, $callback, $attr); |
| 36 | 36 | break; |
@@ -14,8 +14,9 @@ |
||
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | public function compile(JsUtils $js=null) { |
| 17 | - if ($js==null) |
|
| 18 | - return; |
|
| 17 | + if ($js==null) { |
|
| 18 | + return; |
|
| 19 | + } |
|
| 19 | 20 | $result=""; |
| 20 | 21 | $params="{}"; |
| 21 | 22 | $callback=NULL; |
@@ -4,24 +4,24 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | use Illuminate\Support\Facades\App; |
| 6 | 6 | |
| 7 | -class JsUtils extends \Ajax\JsUtils{ |
|
| 8 | - public function getUrl($url){ |
|
| 7 | +class JsUtils extends \Ajax\JsUtils { |
|
| 8 | + public function getUrl($url) { |
|
| 9 | 9 | return \url($url); |
| 10 | 10 | } |
| 11 | - public function addViewElement($identifier,$content,&$view){ |
|
| 11 | + public function addViewElement($identifier, $content, &$view) { |
|
| 12 | 12 | $controls=$view->__get("q"); |
| 13 | - if (isset($controls) === false) { |
|
| 14 | - $controls=array (); |
|
| 13 | + if (isset($controls)===false) { |
|
| 14 | + $controls=array(); |
|
| 15 | 15 | } |
| 16 | 16 | $controls[$identifier]=$content; |
| 17 | 17 | $view->__set("q", $controls); |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | - public function createScriptVariable(&$view,$view_var, $output){ |
|
| 21 | - $view->__set($view_var,$output); |
|
| 20 | + public function createScriptVariable(&$view, $view_var, $output) { |
|
| 21 | + $view->__set($view_var, $output); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - public function forward($initialControllerInstance,$controllerName,$actionName,$params=NULL){ |
|
| 24 | + public function forward($initialControllerInstance, $controllerName, $actionName, $params=NULL) { |
|
| 25 | 25 | \ob_start(); |
| 26 | 26 | App::make($controllerName)->{$actionName}($params); |
| 27 | 27 | $result=\ob_get_contents(); |
@@ -29,11 +29,11 @@ discard block |
||
| 29 | 29 | return $result; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - public function renderContent($initialControllerInstance,$viewName, $params=NULL) { |
|
| 33 | - return \view()->make($viewName,$params)->render(); |
|
| 32 | + public function renderContent($initialControllerInstance, $viewName, $params=NULL) { |
|
| 33 | + return \view()->make($viewName, $params)->render(); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - public function fromDispatcher($dispatcher){ |
|
| 36 | + public function fromDispatcher($dispatcher) { |
|
| 37 | 37 | return $dispatcher->segments(); |
| 38 | 38 | } |
| 39 | 39 | } |
| 40 | 40 | \ No newline at end of file |