@@ -3,7 +3,6 @@ |
||
| 3 | 3 | namespace Ajax\bootstrap\html\base; |
| 4 | 4 | |
| 5 | 5 | use Ajax\service\JArray; |
| 6 | -use Ajax\service\AjaxCall; |
|
| 7 | 6 | |
| 8 | 7 | class PropertyWrapper { |
| 9 | 8 | |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | $value1=reset($input); |
| 18 | 18 | if (is_object($value1)) { |
| 19 | 19 | $output=PropertyWrapper::wrapObjects($input, $js, $separator=' '); |
| 20 | - } else |
|
| 20 | + }else |
|
| 21 | 21 | $output=PropertyWrapper::wrapStrings($input, $separator=' ', $valueQuote='"'); |
| 22 | 22 | } |
| 23 | 23 | } |
@@ -26,17 +26,17 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | public static function wrapStrings($input, $separator=' ', $valueQuote='"') { |
| 28 | 28 | if (JArray::isAssociative($input)===true) { |
| 29 | - $result=implode($separator, array_map(function ($v, $k) use($valueQuote) { |
|
| 29 | + $result=implode($separator, array_map(function($v, $k) use($valueQuote) { |
|
| 30 | 30 | return $k.'='.$valueQuote.$v.$valueQuote; |
| 31 | 31 | }, $input, array_keys($input))); |
| 32 | - } else { |
|
| 32 | + }else { |
|
| 33 | 33 | $result=implode($separator, array_values($input)); |
| 34 | 34 | } |
| 35 | 35 | return $result; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | public static function wrapObjects($input, $js=NULL, $separator=' ') { |
| 39 | - return implode($separator, array_map(function ($v) use($js) { |
|
| 39 | + return implode($separator, array_map(function($v) use($js) { |
|
| 40 | 40 | return $v->compile($js); |
| 41 | 41 | }, $input)); |
| 42 | 42 | } |
@@ -5,7 +5,6 @@ |
||
| 5 | 5 | use Phalcon\Mvc\View; |
| 6 | 6 | use Ajax\JsUtils; |
| 7 | 7 | use Ajax\bootstrap\html\base\BaseHtml; |
| 8 | -use Phalcon\Mvc\Dispatcher; |
|
| 9 | 8 | use Phalcon\Mvc\Controller; |
| 10 | 9 | |
| 11 | 10 | /** |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | class HtmlModal extends BaseHtml { |
| 17 | 17 | protected $title="Titre de ma boîte"; |
| 18 | 18 | protected $content=""; |
| 19 | - protected $buttons=array (); |
|
| 19 | + protected $buttons=array(); |
|
| 20 | 20 | protected $showOnStartup=false; |
| 21 | 21 | protected $draggable=false; |
| 22 | 22 | protected $validCondition=NULL; |
@@ -29,10 +29,10 @@ discard block |
||
| 29 | 29 | public function __construct($identifier, $title="", $content="", $buttonCaptions=array()) { |
| 30 | 30 | parent::__construct($identifier); |
| 31 | 31 | $this->_template=include 'templates/tplModal.php'; |
| 32 | - $this->buttons=array (); |
|
| 32 | + $this->buttons=array(); |
|
| 33 | 33 | $this->title=$title; |
| 34 | 34 | $this->content=$content; |
| 35 | - foreach ( $buttonCaptions as $button ) { |
|
| 35 | + foreach ($buttonCaptions as $button) { |
|
| 36 | 36 | $this->addButton($button); |
| 37 | 37 | } |
| 38 | 38 | } |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * @param string $value |
| 68 | 68 | * @return HtmlButton |
| 69 | 69 | */ |
| 70 | - public function addOkayButton($value="Okay",$jsCode="") { |
|
| 70 | + public function addOkayButton($value="Okay", $jsCode="") { |
|
| 71 | 71 | $btn=$this->addButton($value, "btn-primary"); |
| 72 | 72 | $btn->onClick("if(".$this->getValidCondition()."){ ".$jsCode."$('#".$this->identifier."').modal('hide');}"); |
| 73 | 73 | return $btn; |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | public function getValidCondition() { |
| 85 | 85 | if ($this->validCondition==NULL) { |
| 86 | 86 | return $this->getDefaultValidCondition(); |
| 87 | - } else { |
|
| 87 | + }else { |
|
| 88 | 88 | return $this->validCondition; |
| 89 | 89 | } |
| 90 | 90 | } |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | * @param $params The parameters to pass to the view |
| 118 | 118 | */ |
| 119 | 119 | public function renderContent($view, $controller, $action, $params=NULL) { |
| 120 | - $template=$view->getRender($controller, $action, $params, function ($view) { |
|
| 120 | + $template=$view->getRender($controller, $action, $params, function($view) { |
|
| 121 | 121 | $view->setRenderLevel(View::LEVEL_ACTION_VIEW); |
| 122 | 122 | }); |
| 123 | 123 | $this->content=$template; |
@@ -129,12 +129,12 @@ discard block |
||
| 129 | 129 | * @param string $controller a Phalcon controller |
| 130 | 130 | * @param string $action a Phalcon action |
| 131 | 131 | */ |
| 132 | - public function forward($initialController,$controller,$action){ |
|
| 133 | - $dispatcher = $initialController->dispatcher; |
|
| 132 | + public function forward($initialController, $controller, $action) { |
|
| 133 | + $dispatcher=$initialController->dispatcher; |
|
| 134 | 134 | $dispatcher->setControllerName($controller); |
| 135 | 135 | $dispatcher->setActionName($action); |
| 136 | 136 | $dispatcher->dispatch(); |
| 137 | - $template=$initialController->view->getRender($dispatcher->getControllerName(), $dispatcher->getActionName(),$dispatcher->getParams(), function ($view) { |
|
| 137 | + $template=$initialController->view->getRender($dispatcher->getControllerName(), $dispatcher->getActionName(), $dispatcher->getParams(), function($view) { |
|
| 138 | 138 | $view->setRenderLevel(View::LEVEL_ACTION_VIEW); |
| 139 | 139 | }); |
| 140 | 140 | $this->content=$template; |
@@ -145,10 +145,10 @@ discard block |
||
| 145 | 145 | * @see BaseHtml::run() |
| 146 | 146 | */ |
| 147 | 147 | public function run(JsUtils $js) { |
| 148 | - if($this->content instanceof BaseHtml){ |
|
| 148 | + if ($this->content instanceof BaseHtml) { |
|
| 149 | 149 | $this->content->run($js); |
| 150 | 150 | } |
| 151 | - $this->_bsComponent=$js->bootstrap()->modal("#".$this->identifier, array ( |
|
| 151 | + $this->_bsComponent=$js->bootstrap()->modal("#".$this->identifier, array( |
|
| 152 | 152 | "show" => $this->showOnStartup |
| 153 | 153 | )); |
| 154 | 154 | if ($this->draggable) |
@@ -4,7 +4,6 @@ |
||
| 4 | 4 | |
| 5 | 5 | use Ajax\bootstrap\html\phalcon\PhBsElement; |
| 6 | 6 | use Phalcon\Forms\Element\Select; |
| 7 | -use Ajax\bootstrap\html\base\HtmlDoubleElement; |
|
| 8 | 7 | use Ajax\bootstrap\html\html5\HtmlSelect; |
| 9 | 8 | |
| 10 | 9 | class PhBsSelect extends PhBsElement { |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | parent::__construct($name, $attributes); |
| 14 | 14 | $list=new HtmlSelect($name); |
| 15 | 15 | $list->setTagName("select"); |
| 16 | - $this->renderer=new PhBsRenderer(new Select($name, array (), $attributes), $list); |
|
| 16 | + $this->renderer=new PhBsRenderer(new Select($name, array(), $attributes), $list); |
|
| 17 | 17 | $this->setOptions($options); |
| 18 | 18 | } |
| 19 | 19 | |
@@ -267,8 +267,8 @@ discard block |
||
| 267 | 267 | * @param string $tagName container tagName |
| 268 | 268 | * @return HtmlListgroup |
| 269 | 269 | */ |
| 270 | - public function htmlListgroup($identifier,$items=array(),$tagName="ul"){ |
|
| 271 | - $listGroup=new HtmlListgroup($identifier,$tagName); |
|
| 270 | + public function htmlListgroup($identifier, $items=array(), $tagName="ul") { |
|
| 271 | + $listGroup=new HtmlListgroup($identifier, $tagName); |
|
| 272 | 272 | $listGroup->addItems($items); |
| 273 | 273 | return $this->addHtmlComponent($listGroup); |
| 274 | 274 | } |
@@ -293,8 +293,8 @@ discard block |
||
| 293 | 293 | * @param string $onClick |
| 294 | 294 | * @return HtmlSplitbutton |
| 295 | 295 | */ |
| 296 | - public function htmlSplitbutton($identifier,$value="", $items=array(), $cssStyle="btn-default", $onClick=NULL) { |
|
| 297 | - return $this->addHtmlComponent(new HtmlSplitbutton($identifier, $value, $items, $cssStyle,$onClick)); |
|
| 296 | + public function htmlSplitbutton($identifier, $value="", $items=array(), $cssStyle="btn-default", $onClick=NULL) { |
|
| 297 | + return $this->addHtmlComponent(new HtmlSplitbutton($identifier, $value, $items, $cssStyle, $onClick)); |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | /** |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | * @param string $identifier |
| 303 | 303 | * @return HtmlInputgroup |
| 304 | 304 | */ |
| 305 | - public function htmlInputgroup($identifier){ |
|
| 305 | + public function htmlInputgroup($identifier) { |
|
| 306 | 306 | return $this->addHtmlComponent(new HtmlInputgroup($identifier)); |
| 307 | 307 | } |
| 308 | 308 | |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | * @param function $hrefFunction the function who generates the href elements. default : function($e){return $e->getContent()} |
| 315 | 315 | * @return HtmlBreadcrumbs |
| 316 | 316 | */ |
| 317 | - public function htmlBreadcrumbs($identifier,$elements=array(),$autoActive=true,$hrefFunction=NULL){ |
|
| 318 | - return $this->addHtmlComponent(new HtmlBreadcrumbs($identifier,$elements,$autoActive,$hrefFunction)); |
|
| 317 | + public function htmlBreadcrumbs($identifier, $elements=array(), $autoActive=true, $hrefFunction=NULL) { |
|
| 318 | + return $this->addHtmlComponent(new HtmlBreadcrumbs($identifier, $elements, $autoActive, $hrefFunction)); |
|
| 319 | 319 | } |
| 320 | 320 | } |
| 321 | 321 | \ No newline at end of file |
@@ -21,14 +21,14 @@ discard block |
||
| 21 | 21 | protected $_bootstrap; |
| 22 | 22 | protected $libraryFile; |
| 23 | 23 | protected $_javascript_folder='js'; |
| 24 | - protected $jquery_code_for_load=array (); |
|
| 25 | - protected $jquery_code_for_compile=array (); |
|
| 24 | + protected $jquery_code_for_load=array(); |
|
| 25 | + protected $jquery_code_for_compile=array(); |
|
| 26 | 26 | protected $jquery_corner_active=FALSE; |
| 27 | 27 | protected $jquery_table_sorter_active=FALSE; |
| 28 | 28 | protected $jquery_table_sorter_pager_active=FALSE; |
| 29 | 29 | protected $ajaxLoader='<span></span><span></span><span></span><span></span><span></span>'; |
| 30 | - protected $jquery_events=array ( |
|
| 31 | - "bind","blur","change","click","dblclick","delegate","die","error","focus","focusin","focusout","hover","keydown","keypress","keyup","live","load","mousedown","mousseenter","mouseleave","mousemove","mouseout","mouseover","mouseup","off","on","one","ready","resize","scroll","select","submit","toggle","trigger","triggerHandler","undind","undelegate","unload" |
|
| 30 | + protected $jquery_events=array( |
|
| 31 | + "bind", "blur", "change", "click", "dblclick", "delegate", "die", "error", "focus", "focusin", "focusout", "hover", "keydown", "keypress", "keyup", "live", "load", "mousedown", "mousseenter", "mouseleave", "mousemove", "mouseout", "mouseover", "mouseup", "off", "on", "one", "ready", "resize", "scroll", "select", "submit", "toggle", "trigger", "triggerHandler", "undind", "undelegate", "unload" |
|
| 32 | 32 | ); |
| 33 | 33 | |
| 34 | 34 | public function setDi($di) { |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | */ |
| 162 | 162 | public function _click($element='this', $js=array(), $ret_false=TRUE) { |
| 163 | 163 | if (!is_array($js)) { |
| 164 | - $js=array ( |
|
| 164 | + $js=array( |
|
| 165 | 165 | $js |
| 166 | 166 | ); |
| 167 | 167 | } |
@@ -345,12 +345,12 @@ discard block |
||
| 345 | 345 | */ |
| 346 | 346 | public function _output($array_js='') { |
| 347 | 347 | if (!is_array($array_js)) { |
| 348 | - $array_js=array ( |
|
| 348 | + $array_js=array( |
|
| 349 | 349 | $array_js |
| 350 | 350 | ); |
| 351 | 351 | } |
| 352 | 352 | |
| 353 | - foreach ( $array_js as $js ) { |
|
| 353 | + foreach ($array_js as $js) { |
|
| 354 | 354 | $this->jquery_code_for_compile[]="\t$js\n"; |
| 355 | 355 | } |
| 356 | 356 | } |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | if (isset($value)) { |
| 427 | 427 | $value=$this->_prep_value($value); |
| 428 | 428 | $str="$({$element}).attr(\"$attributeName\",{$value});"; |
| 429 | - } else |
|
| 429 | + }else |
|
| 430 | 430 | $str="$({$element}).attr(\"$attributeName\");"; |
| 431 | 431 | if ($immediatly) |
| 432 | 432 | $this->jquery_code_for_compile[]=$str; |
@@ -444,7 +444,7 @@ discard block |
||
| 444 | 444 | if (isset($value)) { |
| 445 | 445 | $value=$this->_prep_value($value); |
| 446 | 446 | $str="$({$element}).html({$value});"; |
| 447 | - } else |
|
| 447 | + }else |
|
| 448 | 448 | $str="$({$element}).html();"; |
| 449 | 449 | if ($immediatly) |
| 450 | 450 | $this->jquery_code_for_compile[]=$str; |
@@ -469,7 +469,7 @@ discard block |
||
| 469 | 469 | |
| 470 | 470 | $animations="\t\t\t"; |
| 471 | 471 | if (is_array($params)) { |
| 472 | - foreach ( $params as $param => $value ) { |
|
| 472 | + foreach ($params as $param => $value) { |
|
| 473 | 473 | $animations.=$param.': \''.$value.'\', '; |
| 474 | 474 | } |
| 475 | 475 | } |
@@ -807,12 +807,12 @@ discard block |
||
| 807 | 807 | */ |
| 808 | 808 | public function sortable($element, $options=array()) { |
| 809 | 809 | if (count($options)>0) { |
| 810 | - $sort_options=array (); |
|
| 811 | - foreach ( $options as $k => $v ) { |
|
| 810 | + $sort_options=array(); |
|
| 811 | + foreach ($options as $k => $v) { |
|
| 812 | 812 | $sort_options[]="\n\t\t".$k.': '.$v.""; |
| 813 | 813 | } |
| 814 | 814 | $sort_options=implode(",", $sort_options); |
| 815 | - } else { |
|
| 815 | + }else { |
|
| 816 | 816 | $sort_options=''; |
| 817 | 817 | } |
| 818 | 818 | |
@@ -893,7 +893,7 @@ discard block |
||
| 893 | 893 | |
| 894 | 894 | // External references |
| 895 | 895 | $external_scripts=implode('', $this->jquery_code_for_load); |
| 896 | - extract(array ( |
|
| 896 | + extract(array( |
|
| 897 | 897 | 'library_src' => $external_scripts |
| 898 | 898 | )); |
| 899 | 899 | |
@@ -926,7 +926,7 @@ discard block |
||
| 926 | 926 | * @return void |
| 927 | 927 | */ |
| 928 | 928 | public function _clear_compile() { |
| 929 | - $this->jquery_code_for_compile=array (); |
|
| 929 | + $this->jquery_code_for_compile=array(); |
|
| 930 | 930 | } |
| 931 | 931 | |
| 932 | 932 | // -------------------------------------------------------------------- |
@@ -938,12 +938,12 @@ discard block |
||
| 938 | 938 | */ |
| 939 | 939 | public function _document_ready($js) { |
| 940 | 940 | if (!is_array($js)) { |
| 941 | - $js=array ( |
|
| 941 | + $js=array( |
|
| 942 | 942 | $js |
| 943 | 943 | ); |
| 944 | 944 | } |
| 945 | 945 | |
| 946 | - foreach ( $js as $script ) { |
|
| 946 | + foreach ($js as $script) { |
|
| 947 | 947 | $this->jquery_code_for_compile[]=$script; |
| 948 | 948 | } |
| 949 | 949 | } |
@@ -959,7 +959,7 @@ discard block |
||
| 959 | 959 | * @return string |
| 960 | 960 | */ |
| 961 | 961 | public function _prep_element($element) { |
| 962 | - if (strrpos($element, 'this')===false&&strrpos($element, 'event')===false) { |
|
| 962 | + if (strrpos($element, 'this')===false && strrpos($element, 'event')===false) { |
|
| 963 | 963 | $element='"'.$element.'"'; |
| 964 | 964 | } |
| 965 | 965 | return $element; |
@@ -977,7 +977,7 @@ discard block |
||
| 977 | 977 | if (is_array($value)) { |
| 978 | 978 | $value=implode(",", $value); |
| 979 | 979 | } |
| 980 | - if (strrpos($value, 'this')===false&&strrpos($value, 'event')===false) { |
|
| 980 | + if (strrpos($value, 'this')===false && strrpos($value, 'event')===false) { |
|
| 981 | 981 | $value='"'.$value.'"'; |
| 982 | 982 | } |
| 983 | 983 | return $value; |
@@ -992,8 +992,8 @@ discard block |
||
| 992 | 992 | * @return string |
| 993 | 993 | */ |
| 994 | 994 | private function _validate_speed($speed) { |
| 995 | - if (in_array($speed, array ( |
|
| 996 | - 'slow','normal','fast' |
|
| 995 | + if (in_array($speed, array( |
|
| 996 | + 'slow', 'normal', 'fast' |
|
| 997 | 997 | ))) { |
| 998 | 998 | $speed='"'.$speed.'"'; |
| 999 | 999 | } elseif (preg_match("/[^0-9]/", $speed)) { |
@@ -1007,7 +1007,7 @@ discard block |
||
| 1007 | 1007 | $loading_notifier='<div class="ajax-loader">'; |
| 1008 | 1008 | if ($this->ajaxLoader=='') { |
| 1009 | 1009 | $loading_notifier.="Loading..."; |
| 1010 | - } else { |
|
| 1010 | + }else { |
|
| 1011 | 1011 | $loading_notifier.=$this->ajaxLoader; |
| 1012 | 1012 | } |
| 1013 | 1013 | $loading_notifier.='</div>'; |
@@ -1015,18 +1015,18 @@ discard block |
||
| 1015 | 1015 | $retour.="\t\t$(\"{$responseElement}\").prepend('{$loading_notifier}');\n"; |
| 1016 | 1016 | } |
| 1017 | 1017 | |
| 1018 | - public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
| 1019 | - return $this->_ajax("get", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$immediatly); |
|
| 1018 | + public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
| 1019 | + return $this->_ajax("get", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $immediatly); |
|
| 1020 | 1020 | } |
| 1021 | - public function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
| 1022 | - return $this->_ajax("post", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$immediatly); |
|
| 1021 | + public function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
| 1022 | + return $this->_ajax("post", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $immediatly); |
|
| 1023 | 1023 | } |
| 1024 | 1024 | |
| 1025 | - protected function _ajax($method,$url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
| 1026 | - if(JString::isNull($params)){$params="{}";} |
|
| 1025 | + protected function _ajax($method, $url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
| 1026 | + if (JString::isNull($params)) {$params="{}"; } |
|
| 1027 | 1027 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
| 1028 | 1028 | $retour=$this->_getAjaxUrl($url, $attr); |
| 1029 | - if($hasLoader===true){ |
|
| 1029 | + if ($hasLoader===true) { |
|
| 1030 | 1030 | $this->addLoading($retour, $responseElement); |
| 1031 | 1031 | } |
| 1032 | 1032 | $retour.="$.".$method."(url,".$params.").done(function( data ) {\n"; |
@@ -1036,19 +1036,19 @@ discard block |
||
| 1036 | 1036 | return $retour; |
| 1037 | 1037 | } |
| 1038 | 1038 | |
| 1039 | - protected function _getAjaxUrl($url,$attr){ |
|
| 1039 | + protected function _getAjaxUrl($url, $attr) { |
|
| 1040 | 1040 | $url=$this->_correctAjaxUrl($url); |
| 1041 | 1041 | $retour="url='".$url."';\n"; |
| 1042 | - if(JString::isNotNull($attr)){ |
|
| 1042 | + if (JString::isNotNull($attr)) { |
|
| 1043 | 1043 | if ($attr=="value") |
| 1044 | 1044 | $retour.="url=url+'/'+$(this).val();\n"; |
| 1045 | - else if($attr!=null && $attr!=="") |
|
| 1045 | + else if ($attr!=null && $attr!=="") |
|
| 1046 | 1046 | $retour.="url=url+'/'+$(this).attr('".$attr."');\n"; |
| 1047 | 1047 | } |
| 1048 | 1048 | return $retour; |
| 1049 | 1049 | } |
| 1050 | 1050 | |
| 1051 | - protected function _getOnAjaxDone($responseElement,$jsCallback){ |
|
| 1051 | + protected function _getOnAjaxDone($responseElement, $jsCallback) { |
|
| 1052 | 1052 | $retour=""; |
| 1053 | 1053 | if ($responseElement!=="") { |
| 1054 | 1054 | $responseElement=$this->_prep_value($responseElement); |
@@ -1061,7 +1061,7 @@ discard block |
||
| 1061 | 1061 | protected function _correctAjaxUrl($url) { |
| 1062 | 1062 | if (PhalconUtils::endsWith($url, "/")) |
| 1063 | 1063 | $url=substr($url, 0, strlen($url)-1); |
| 1064 | - if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) { |
|
| 1064 | + if (strncmp($url, 'http://', 7)!=0 && strncmp($url, 'https://', 8)!=0) { |
|
| 1065 | 1065 | $url=$this->_di->get("url")->get($url); |
| 1066 | 1066 | } |
| 1067 | 1067 | return $url; |
@@ -1105,11 +1105,11 @@ discard block |
||
| 1105 | 1105 | return $retour; |
| 1106 | 1106 | } |
| 1107 | 1107 | |
| 1108 | - public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
| 1108 | + public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
| 1109 | 1109 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
| 1110 | 1110 | $retour=$this->_getAjaxUrl($url, $attr); |
| 1111 | 1111 | $retour.="\nvar params=$('#".$form."').serialize();\n"; |
| 1112 | - if($hasLoader===true){ |
|
| 1112 | + if ($hasLoader===true) { |
|
| 1113 | 1113 | $this->addLoading($retour, $responseElement); |
| 1114 | 1114 | } |
| 1115 | 1115 | $retour.="$.post(url,params).done(function( data ) {\n"; |
@@ -1136,14 +1136,14 @@ discard block |
||
| 1136 | 1136 | * @param string $responseElement |
| 1137 | 1137 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true) |
| 1138 | 1138 | */ |
| 1139 | - public function _getOn($event,$element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
| 1139 | + public function _getOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
| 1140 | 1140 | $preventDefault=true; |
| 1141 | 1141 | $stopPropagation=true; |
| 1142 | 1142 | $jsCallback=null; |
| 1143 | 1143 | $attr="id"; |
| 1144 | 1144 | $hasLoader=true; |
| 1145 | 1145 | extract($parameters); |
| 1146 | - return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr,$hasLoader), $event, $preventDefault, $stopPropagation); |
|
| 1146 | + return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr, $hasLoader), $event, $preventDefault, $stopPropagation); |
|
| 1147 | 1147 | } |
| 1148 | 1148 | |
| 1149 | 1149 | /** |
@@ -1156,14 +1156,14 @@ discard block |
||
| 1156 | 1156 | * @param string $responseElement |
| 1157 | 1157 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true) |
| 1158 | 1158 | */ |
| 1159 | - public function _postOn($event,$element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
| 1159 | + public function _postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
| 1160 | 1160 | $preventDefault=true; |
| 1161 | 1161 | $stopPropagation=true; |
| 1162 | 1162 | $jsCallback=null; |
| 1163 | 1163 | $attr="id"; |
| 1164 | 1164 | $hasLoader=true; |
| 1165 | 1165 | extract($parameters); |
| 1166 | - return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr,$hasLoader), $event, $preventDefault, $stopPropagation); |
|
| 1166 | + return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader), $event, $preventDefault, $stopPropagation); |
|
| 1167 | 1167 | } |
| 1168 | 1168 | |
| 1169 | 1169 | /** |
@@ -1176,7 +1176,7 @@ discard block |
||
| 1176 | 1176 | * @param string $responseElement |
| 1177 | 1177 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true) |
| 1178 | 1178 | */ |
| 1179 | - public function _postFormOn($event,$element, $url, $form, $responseElement="", $parameters=array()) { |
|
| 1179 | + public function _postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) { |
|
| 1180 | 1180 | $preventDefault=true; |
| 1181 | 1181 | $stopPropagation=true; |
| 1182 | 1182 | $validation=false; |
@@ -1184,7 +1184,7 @@ discard block |
||
| 1184 | 1184 | $attr="id"; |
| 1185 | 1185 | $hasLoader=true; |
| 1186 | 1186 | extract($parameters); |
| 1187 | - return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr,$hasLoader), $event, $preventDefault, $stopPropagation); |
|
| 1187 | + return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader), $event, $preventDefault, $stopPropagation); |
|
| 1188 | 1188 | } |
| 1189 | 1189 | |
| 1190 | 1190 | /** |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | protected function _setDi($di) { |
| 47 | 47 | $this->_di=$di; |
| 48 | - if ($this->js!=null&&$di!=null) |
|
| 48 | + if ($this->js!=null && $di!=null) |
|
| 49 | 49 | $this->js->setDi($di); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -120,17 +120,17 @@ discard block |
||
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | public function __construct($params=array()) { |
| 123 | - $defaults=array ( |
|
| 123 | + $defaults=array( |
|
| 124 | 124 | 'driver' => 'Jquery' |
| 125 | 125 | ); |
| 126 | - foreach ( $defaults as $key => $val ) { |
|
| 127 | - if (isset($params[$key])&&$params[$key]!=="") { |
|
| 126 | + foreach ($defaults as $key => $val) { |
|
| 127 | + if (isset($params[$key]) && $params[$key]!=="") { |
|
| 128 | 128 | $defaults[$key]=$params[$key]; |
| 129 | 129 | } |
| 130 | 130 | } |
| 131 | 131 | extract($defaults); |
| 132 | 132 | $this->js=new Jquery(); |
| 133 | - $this->cdns=array (); |
|
| 133 | + $this->cdns=array(); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | public function addToCompile($jsScript) { |
@@ -587,7 +587,7 @@ discard block |
||
| 587 | 587 | */ |
| 588 | 588 | public function compile($view=NULL, $view_var='script_foot', $script_tags=TRUE) { |
| 589 | 589 | $bs=$this->_bootstrap; |
| 590 | - if (isset($bs)&&isset($view)) { |
|
| 590 | + if (isset($bs) && isset($view)) { |
|
| 591 | 591 | $bs->compileHtml($this, $view); |
| 592 | 592 | } |
| 593 | 593 | return $this->js->_compile($view, $view_var, $script_tags); |
@@ -667,27 +667,27 @@ discard block |
||
| 667 | 667 | $json_result=$result->result_array(); |
| 668 | 668 | } elseif (is_array($result)) { |
| 669 | 669 | $json_result=$result; |
| 670 | - } else { |
|
| 670 | + }else { |
|
| 671 | 671 | return $this->_prep_args($result); |
| 672 | 672 | } |
| 673 | - } else { |
|
| 673 | + }else { |
|
| 674 | 674 | return 'null'; |
| 675 | 675 | } |
| 676 | 676 | return $this->_create_json($json_result, $match_array_type); |
| 677 | 677 | } |
| 678 | 678 | |
| 679 | 679 | private function _create_json($json_result, $match_array_type) { |
| 680 | - $json=array (); |
|
| 680 | + $json=array(); |
|
| 681 | 681 | $_is_assoc=TRUE; |
| 682 | - if (!is_array($json_result)&&empty($json_result)) { |
|
| 682 | + if (!is_array($json_result) && empty($json_result)) { |
|
| 683 | 683 | show_error("Generate JSON Failed - Illegal key, value pair."); |
| 684 | 684 | } elseif ($match_array_type) { |
| 685 | 685 | $_is_assoc=$this->_is_associative_array($json_result); |
| 686 | 686 | } |
| 687 | - foreach ( $json_result as $k => $v ) { |
|
| 687 | + foreach ($json_result as $k => $v) { |
|
| 688 | 688 | if ($_is_assoc) { |
| 689 | 689 | $json[]=$this->_prep_args($k, TRUE).':'.$this->generate_json($v, $match_array_type); |
| 690 | - } else { |
|
| 690 | + }else { |
|
| 691 | 691 | $json[]=$this->generate_json($v, $match_array_type); |
| 692 | 692 | } |
| 693 | 693 | } |
@@ -702,7 +702,7 @@ discard block |
||
| 702 | 702 | * @return type |
| 703 | 703 | */ |
| 704 | 704 | public function _is_associative_array($arr) { |
| 705 | - foreach ( array_keys($arr) as $key => $val ) { |
|
| 705 | + foreach (array_keys($arr) as $key => $val) { |
|
| 706 | 706 | if ($key!==$val) { |
| 707 | 707 | return TRUE; |
| 708 | 708 | } |
@@ -721,11 +721,11 @@ discard block |
||
| 721 | 721 | return 'null'; |
| 722 | 722 | } elseif (is_bool($result)) { |
| 723 | 723 | return ($result===TRUE) ? 'true' : 'false'; |
| 724 | - } elseif (is_string($result)||$is_key) { |
|
| 725 | - return '"'.str_replace(array ( |
|
| 726 | - '\\',"\t","\n","\r",'"','/' |
|
| 727 | - ), array ( |
|
| 728 | - '\\\\','\\t','\\n',"\\r",'\"','\/' |
|
| 724 | + } elseif (is_string($result) || $is_key) { |
|
| 725 | + return '"'.str_replace(array( |
|
| 726 | + '\\', "\t", "\n", "\r", '"', '/' |
|
| 727 | + ), array( |
|
| 728 | + '\\\\', '\\t', '\\n', "\\r", '\"', '\/' |
|
| 729 | 729 | ), $result).'"'; |
| 730 | 730 | } elseif (is_scalar($result)) { |
| 731 | 731 | return $result; |
@@ -740,8 +740,8 @@ discard block |
||
| 740 | 740 | * @param string $jsCallback javascript code to execute after the request |
| 741 | 741 | * @param boolean $hasLoader true for showing ajax loader. default : true |
| 742 | 742 | */ |
| 743 | - public function get($url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true) { |
|
| 744 | - return $this->js->_get($url, $params, $responseElement, $jsCallback, NULL, $hasLoader,true); |
|
| 743 | + public function get($url, $responseElement="", $params="{}", $jsCallback=NULL, $hasLoader=true) { |
|
| 744 | + return $this->js->_get($url, $params, $responseElement, $jsCallback, NULL, $hasLoader, true); |
|
| 745 | 745 | } |
| 746 | 746 | |
| 747 | 747 | /** |
@@ -797,7 +797,7 @@ discard block |
||
| 797 | 797 | * @param string $jsCallback javascript code to execute after the request |
| 798 | 798 | * @param string $attr the html attribute added to the request |
| 799 | 799 | */ |
| 800 | - public function getDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL,$attr="id") { |
|
| 800 | + public function getDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id") { |
|
| 801 | 801 | return $this->js->_get($url, $params, $responseElement, $jsCallback, $attr, false); |
| 802 | 802 | } |
| 803 | 803 | |
@@ -835,8 +835,8 @@ discard block |
||
| 835 | 835 | * @param string $jsCallback javascript code to execute after the request |
| 836 | 836 | * @param boolean $hasLoader true for showing ajax loader. default : true |
| 837 | 837 | */ |
| 838 | - public function post($url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true) { |
|
| 839 | - return $this->js->_post($url, $params, $responseElement, $jsCallback, NULL, $hasLoader,true); |
|
| 838 | + public function post($url, $responseElement="", $params="{}", $jsCallback=NULL, $hasLoader=true) { |
|
| 839 | + return $this->js->_post($url, $params, $responseElement, $jsCallback, NULL, $hasLoader, true); |
|
| 840 | 840 | } |
| 841 | 841 | |
| 842 | 842 | /** |
@@ -849,8 +849,8 @@ discard block |
||
| 849 | 849 | * @param string $jsCallback javascript code to execute after the request |
| 850 | 850 | * @param boolean $hasLoader true for showing ajax loader. default : true |
| 851 | 851 | */ |
| 852 | - public function postDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id",$hasLoader=true) { |
|
| 853 | - return $this->js->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader,false); |
|
| 852 | + public function postDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id", $hasLoader=true) { |
|
| 853 | + return $this->js->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, false); |
|
| 854 | 854 | } |
| 855 | 855 | |
| 856 | 856 | /** |
@@ -864,7 +864,7 @@ discard block |
||
| 864 | 864 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true) |
| 865 | 865 | */ |
| 866 | 866 | public function postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
| 867 | - return $this->js->_postOn($event, $element, $url, $params, $responseElement, $parameters); |
|
| 867 | + return $this->js->_postOn($event, $element, $url, $params, $responseElement, $parameters); |
|
| 868 | 868 | } |
| 869 | 869 | |
| 870 | 870 | /** |
@@ -888,8 +888,8 @@ discard block |
||
| 888 | 888 | * @param string $jsCallback javascript code to execute after the request |
| 889 | 889 | * @param boolean $hasLoader true for showing ajax loader. default : true |
| 890 | 890 | */ |
| 891 | - public function postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL,$hasLoader=true) { |
|
| 892 | - return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, NULL, $hasLoader,true); |
|
| 891 | + public function postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $hasLoader=true) { |
|
| 892 | + return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, NULL, $hasLoader, true); |
|
| 893 | 893 | } |
| 894 | 894 | |
| 895 | 895 | /** |
@@ -902,8 +902,8 @@ discard block |
||
| 902 | 902 | * @param string $attr the html attribute added to the request |
| 903 | 903 | * @param boolean $hasLoader true for showing ajax loader. default : true |
| 904 | 904 | */ |
| 905 | - public function postFormDeferred($url, $form, $responseElement, $validation=false, $jsCallback=NULL,$attr="id",$hasLoader=true) { |
|
| 906 | - return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader,false); |
|
| 905 | + public function postFormDeferred($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true) { |
|
| 906 | + return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader, false); |
|
| 907 | 907 | } |
| 908 | 908 | |
| 909 | 909 | /** |
@@ -917,7 +917,7 @@ discard block |
||
| 917 | 917 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true) |
| 918 | 918 | */ |
| 919 | 919 | public function postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) { |
| 920 | - return $this->js->_postFormOn($event,$element, $url, $form, $responseElement, $parameters); |
|
| 920 | + return $this->js->_postFormOn($event, $element, $url, $form, $responseElement, $parameters); |
|
| 921 | 921 | } |
| 922 | 922 | |
| 923 | 923 | /** |
@@ -1007,7 +1007,7 @@ discard block |
||
| 1007 | 1007 | |
| 1008 | 1008 | public function setCDNs($cdns) { |
| 1009 | 1009 | if (is_array($cdns)===false) { |
| 1010 | - $cdns=array ( |
|
| 1010 | + $cdns=array( |
|
| 1011 | 1011 | $cdns |
| 1012 | 1012 | ); |
| 1013 | 1013 | } |
@@ -1018,9 +1018,9 @@ discard block |
||
| 1018 | 1018 | $hasJQuery=false; |
| 1019 | 1019 | $hasJQueryUI=false; |
| 1020 | 1020 | $hasBootstrap=false; |
| 1021 | - $result=array (); |
|
| 1022 | - foreach ( $this->cdns as $cdn ) { |
|
| 1023 | - switch(get_class($cdn)) { |
|
| 1021 | + $result=array(); |
|
| 1022 | + foreach ($this->cdns as $cdn) { |
|
| 1023 | + switch (get_class($cdn)) { |
|
| 1024 | 1024 | case "Ajax\lib\CDNJQuery": |
| 1025 | 1025 | $hasJQuery=true; |
| 1026 | 1026 | $result[0]=$cdn; |
@@ -1038,10 +1038,10 @@ discard block |
||
| 1038 | 1038 | if ($hasJQuery===false) { |
| 1039 | 1039 | $result[0]=new CDNJQuery("x"); |
| 1040 | 1040 | } |
| 1041 | - if ($hasJQueryUI===false&&isset($this->_ui)) { |
|
| 1041 | + if ($hasJQueryUI===false && isset($this->_ui)) { |
|
| 1042 | 1042 | $result[1]=new CDNGuiGen("x", $template); |
| 1043 | 1043 | } |
| 1044 | - if ($hasBootstrap===false&&isset($this->_bootstrap)) { |
|
| 1044 | + if ($hasBootstrap===false && isset($this->_bootstrap)) { |
|
| 1045 | 1045 | $result[2]=new CDNBootstrap("x"); |
| 1046 | 1046 | } |
| 1047 | 1047 | ksort($result); |
@@ -1055,7 +1055,7 @@ discard block |
||
| 1055 | 1055 | $this->_setDi($di); |
| 1056 | 1056 | } |
| 1057 | 1057 | } |
| 1058 | -} else { |
|
| 1058 | +}else { |
|
| 1059 | 1059 | class JsUtils extends _JsUtils { |
| 1060 | 1060 | |
| 1061 | 1061 | public function setDi(DiInterface $di) { |
@@ -65,7 +65,7 @@ |
||
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | protected function compileEvents() { |
| 68 | - foreach ( $this->events as $event => $jsCode ) { |
|
| 68 | + foreach ($this->events as $event => $jsCode) { |
|
| 69 | 69 | $this->jquery_code_for_compile []="$( \"".$this->collapsed."\" ).on(\"".$event."\" , function (e) {".$jsCode."});"; |
| 70 | 70 | } |
| 71 | 71 | } |
@@ -9,9 +9,9 @@ |
||
| 9 | 9 | * @see \Ajax\bootstrap\components\SimpleBsComponent::getScript() |
| 10 | 10 | */ |
| 11 | 11 | public function getScript() { |
| 12 | - $this->jquery_code_for_compile=array (); |
|
| 13 | - foreach ( $this->jsCodes as $jsCode ) { |
|
| 14 | - $this->jquery_code_for_compile []=$jsCode->compile(array ( |
|
| 12 | + $this->jquery_code_for_compile=array(); |
|
| 13 | + foreach ($this->jsCodes as $jsCode) { |
|
| 14 | + $this->jquery_code_for_compile []=$jsCode->compile(array( |
|
| 15 | 15 | "identifier" => $this->attachTo |
| 16 | 16 | )); |
| 17 | 17 | } |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | if ($value) { |
| 58 | 58 | $this->jsCodes ["draggable"]=new Draggable(); |
| 59 | 59 | $this->setBackdrop(false); |
| 60 | - } else if (array_key_exists("draggable", $this->jsCodes)) { |
|
| 60 | + }else if (array_key_exists("draggable", $this->jsCodes)) { |
|
| 61 | 61 | unset($this->jsCodes ["draggable"]); |
| 62 | 62 | unset($this->params ["backdrop"]); |
| 63 | 63 | } |