@@ -25,8 +25,8 @@ discard block |
||
25 | 25 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
26 | 26 | * @param string|callable $ajaxTransition |
27 | 27 | */ |
28 | - public function get($url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
29 | - return $this->js->_get($url, $params, $responseElement, $jsCallback, NULL, $hasLoader,$jqueryDone,$ajaxTransition,true); |
|
28 | + public function get($url, $responseElement="", $params="{}", $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
29 | + return $this->js->_get($url, $params, $responseElement, $jsCallback, NULL, $hasLoader, $jqueryDone, $ajaxTransition, true); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | * @param string $jsCallback javascript code to execute after the request |
38 | 38 | * @param boolean $immediatly |
39 | 39 | */ |
40 | - public function json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document",$immediatly=false) { |
|
41 | - return $this->js->_json($url, $method, $params, $jsCallback, $attr, $context,$immediatly); |
|
40 | + public function json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document", $immediatly=false) { |
|
41 | + return $this->js->_json($url, $method, $params, $jsCallback, $attr, $context, $immediatly); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | * @param string $url the request address |
49 | 49 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true) |
50 | 50 | */ |
51 | - public function jsonOn($event,$element, $url,$parameters=array()) { |
|
52 | - return $this->js->_jsonOn($event, $element, $url,$parameters); |
|
51 | + public function jsonOn($event, $element, $url, $parameters=array()) { |
|
52 | + return $this->js->_jsonOn($event, $element, $url, $parameters); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * @param string $jsCallback javascript code to execute after the request |
72 | 72 | */ |
73 | 73 | public function jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL) { |
74 | - return $this->js->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, NULL,true); |
|
74 | + return $this->js->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, NULL, true); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | * @param string $url the request url |
94 | 94 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true) |
95 | 95 | */ |
96 | - public function jsonArrayOn($event,$element,$maskSelector, $url,$parameters=array()) { |
|
97 | - return $this->js->_jsonArrayOn($event,$element,$maskSelector, $url, $parameters); |
|
96 | + public function jsonArrayOn($event, $element, $maskSelector, $url, $parameters=array()) { |
|
97 | + return $this->js->_jsonArrayOn($event, $element, $maskSelector, $url, $parameters); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
109 | 109 | * @param string|callable $ajaxTransition |
110 | 110 | */ |
111 | - public function getDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL,$attr="id",$jqueryDone="html",$ajaxTransition=null) { |
|
112 | - return $this->js->_get($url, $params, $responseElement, $jsCallback, $attr, false,$jqueryDone,$ajaxTransition); |
|
111 | + public function getDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id", $jqueryDone="html", $ajaxTransition=null) { |
|
112 | + return $this->js->_get($url, $params, $responseElement, $jsCallback, $attr, false, $jqueryDone, $ajaxTransition); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -148,8 +148,8 @@ discard block |
||
148 | 148 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
149 | 149 | * @param string|callable $ajaxTransition |
150 | 150 | */ |
151 | - public function post($url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
152 | - return $this->js->_post($url, $params, $responseElement, $jsCallback, NULL, $hasLoader,$jqueryDone,$ajaxTransition,true); |
|
151 | + public function post($url, $responseElement="", $params="{}", $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
152 | + return $this->js->_post($url, $params, $responseElement, $jsCallback, NULL, $hasLoader, $jqueryDone, $ajaxTransition, true); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
165 | 165 | * @param string|callable $ajaxTransition |
166 | 166 | */ |
167 | - public function postDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id",$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
168 | - return $this->js->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader,$jqueryDone,$ajaxTransition,false); |
|
167 | + public function postDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
168 | + return $this->js->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, false); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null) |
180 | 180 | */ |
181 | 181 | public function postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
182 | - return $this->js->_postOn($event, $element, $url, $params, $responseElement, $parameters); |
|
182 | + return $this->js->_postOn($event, $element, $url, $params, $responseElement, $parameters); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | /** |
@@ -205,8 +205,8 @@ discard block |
||
205 | 205 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
206 | 206 | * @param string|callable $ajaxTransition |
207 | 207 | */ |
208 | - public function postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
209 | - return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, NULL, $hasLoader,$jqueryDone,$ajaxTransition,true); |
|
208 | + public function postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
209 | + return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, NULL, $hasLoader, $jqueryDone, $ajaxTransition, true); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | /** |
@@ -221,8 +221,8 @@ discard block |
||
221 | 221 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
222 | 222 | * @param string|callable $ajaxTransition |
223 | 223 | */ |
224 | - public function postFormDeferred($url, $form, $responseElement, $validation=false, $jsCallback=NULL,$attr="id",$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
225 | - return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader,$jqueryDone,$ajaxTransition,false); |
|
224 | + public function postFormDeferred($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
225 | + return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, false); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | /** |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null) |
237 | 237 | */ |
238 | 238 | public function postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) { |
239 | - return $this->js->_postFormOn($event,$element, $url, $form, $responseElement, $parameters); |
|
239 | + return $this->js->_postFormOn($event, $element, $url, $form, $responseElement, $parameters); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | /** |
@@ -3,26 +3,26 @@ |
||
3 | 3 | use Ajax\semantic\html\base\constants\Transition; |
4 | 4 | |
5 | 5 | class AjaxTransition { |
6 | - public static function none($responseElement,$jqueryDone="html"){ |
|
6 | + public static function none($responseElement, $jqueryDone="html") { |
|
7 | 7 | return "$({$responseElement}).{$jqueryDone}( data )"; |
8 | 8 | } |
9 | 9 | |
10 | - public static function jqFade($responseElement,$jqueryDone="html"){ |
|
10 | + public static function jqFade($responseElement, $jqueryDone="html") { |
|
11 | 11 | return "$({$responseElement}).hide().{$jqueryDone}( data ).fadeIn()"; |
12 | 12 | } |
13 | 13 | |
14 | - public static function jqSlide($responseElement,$jqueryDone="html"){ |
|
14 | + public static function jqSlide($responseElement, $jqueryDone="html") { |
|
15 | 15 | return "$({$responseElement}).hide().{$jqueryDone}( data ).slideDown()"; |
16 | 16 | } |
17 | 17 | |
18 | - public static function random($responseElement,$jqueryDone="html"){ |
|
18 | + public static function random($responseElement, $jqueryDone="html") { |
|
19 | 19 | $transitions=Transition::getConstantValues(); |
20 | - $transition=$transitions[\rand(0,\sizeof($transitions)-1)]; |
|
21 | - return self::__callStatic($transition, [$responseElement,$jqueryDone]); |
|
20 | + $transition=$transitions[\rand(0, \sizeof($transitions)-1)]; |
|
21 | + return self::__callStatic($transition, [$responseElement, $jqueryDone]); |
|
22 | 22 | } |
23 | 23 | |
24 | - public static function __callStatic($name, $arguments){ |
|
25 | - if(\sizeof($arguments)==2){ |
|
24 | + public static function __callStatic($name, $arguments) { |
|
25 | + if (\sizeof($arguments)==2) { |
|
26 | 26 | $responseElement=$arguments[0]; |
27 | 27 | $jqueryDone=$arguments[1]; |
28 | 28 | $name=JString::camelCaseToSeparated($name); |
@@ -3,12 +3,12 @@ |
||
3 | 3 | use Ajax\common\BaseEnum; |
4 | 4 | abstract class Transition extends BaseEnum { |
5 | 5 | const SCALE="scale", |
6 | - FADE="fade",FADE_UP="fadeUp",FADE_DOWN="fadeDown",FADE_LEFT="fadeLeft",FADE_RIGHT="fadeRight", |
|
7 | - HORIZONTAL_FLIP="horizontalFlip",VERTICAL_FLIP="verticalFlip", |
|
6 | + FADE="fade", FADE_UP="fadeUp", FADE_DOWN="fadeDown", FADE_LEFT="fadeLeft", FADE_RIGHT="fadeRight", |
|
7 | + HORIZONTAL_FLIP="horizontalFlip", VERTICAL_FLIP="verticalFlip", |
|
8 | 8 | DROP="drop", |
9 | - FLY_LEFT="flyLeft",FLY_RIGHT="flyRight",FLY_UP="flyUp",FLY_DOWN="flyDown", |
|
10 | - SWING_LEFT="swingLeft",SWING_RIGHT="swingRight",SWING_UP="swingUp",SWING_DOWN="swingDown", |
|
11 | - BROWSE="browse",BROWSE_RIGHT="browseRight", |
|
12 | - SLIDE_LEFT="slideLeft",SLIDE_RIGHT="slideRight",SLIDE_UP="slideUp",SLIDE_DOWN="slideDown", |
|
13 | - JIGGLE="jiggle",FLASH="flash",SHAKE="shake",PULSE="pulse",TADA="tada",BOUNCE="bounce"; |
|
9 | + FLY_LEFT="flyLeft", FLY_RIGHT="flyRight", FLY_UP="flyUp", FLY_DOWN="flyDown", |
|
10 | + SWING_LEFT="swingLeft", SWING_RIGHT="swingRight", SWING_UP="swingUp", SWING_DOWN="swingDown", |
|
11 | + BROWSE="browse", BROWSE_RIGHT="browseRight", |
|
12 | + SLIDE_LEFT="slideLeft", SLIDE_RIGHT="slideRight", SLIDE_UP="slideUp", SLIDE_DOWN="slideDown", |
|
13 | + JIGGLE="jiggle", FLASH="flash", SHAKE="shake", PULSE="pulse", TADA="tada", BOUNCE="bounce"; |
|
14 | 14 | } |
15 | 15 | \ No newline at end of file |
@@ -3,8 +3,8 @@ |
||
3 | 3 | namespace Ajax\service; |
4 | 4 | |
5 | 5 | class JReflection { |
6 | - public static function shortClassName($object){ |
|
7 | - $classNameWithNamespace = get_class($object); |
|
6 | + public static function shortClassName($object) { |
|
7 | + $classNameWithNamespace=get_class($object); |
|
8 | 8 | return substr($classNameWithNamespace, strrpos($classNameWithNamespace, '\\')+1); |
9 | 9 | } |
10 | 10 | } |
11 | 11 | \ 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 && ! class_exists('CI_DB')){ |
|
92 | - if ($db_conn === TRUE){ |
|
93 | - $db_conn = ''; |
|
91 | + if ($db_conn!==FALSE && !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); |
@@ -48,8 +48,9 @@ discard block |
||
48 | 48 | |
49 | 49 | public function setAttached($value=true){ |
50 | 50 | $form=$this->getForm(); |
51 | - if($value) |
|
52 | - $form->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
51 | + if($value) { |
|
52 | + $form->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
53 | + } |
|
53 | 54 | return $form; |
54 | 55 | } |
55 | 56 | |
@@ -91,8 +92,9 @@ discard block |
||
91 | 92 | if(isset($url) && isset($responseElement)){ |
92 | 93 | $button->addEvent($event, "$('#".$form->getIdentifier()."').form('validate form');",true,true); |
93 | 94 | $params=["form"=>$form->getIdentifier(),"responseElement"=>$responseElement,"url"=>$url,"stopPropagation"=>true]; |
94 | - if(\is_array($parameters)) |
|
95 | - $params=\array_merge($params,$parameters); |
|
95 | + if(\is_array($parameters)) { |
|
96 | + $params=\array_merge($params,$parameters); |
|
97 | + } |
|
96 | 98 | $form->addValidationParam("_ajaxSubmit", new AjaxCall("postForm", $params)); |
97 | 99 | } |
98 | 100 | return $button; |
@@ -12,28 +12,28 @@ discard block |
||
12 | 12 | * @author jc |
13 | 13 | * |
14 | 14 | */ |
15 | -trait FormTrait{ |
|
15 | +trait FormTrait { |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * @return HtmlForm |
19 | 19 | */ |
20 | 20 | abstract protected function getForm(); |
21 | 21 | |
22 | - protected function addCompoValidation($compo,$field){ |
|
22 | + protected function addCompoValidation($compo, $field) { |
|
23 | 23 | $validation=$field->getValidation(); |
24 | - if(isset($validation)){ |
|
24 | + if (isset($validation)) { |
|
25 | 25 | $validation->setIdentifier($field->getDataField()->getIdentifier()); |
26 | 26 | $compo->addFieldValidation($validation); |
27 | 27 | } |
28 | 28 | return $compo; |
29 | 29 | } |
30 | 30 | |
31 | - protected function _runValidationParams(&$compo,JsUtils $js=NULL){ |
|
31 | + protected function _runValidationParams(&$compo, JsUtils $js=NULL) { |
|
32 | 32 | $form=$this->getForm(); |
33 | 33 | $params=$form->getValidationParams(); |
34 | - if(isset($params["_ajaxSubmit"]) && $params["_ajaxSubmit"] instanceof AjaxCall){ |
|
34 | + if (isset($params["_ajaxSubmit"]) && $params["_ajaxSubmit"] instanceof AjaxCall) { |
|
35 | 35 | $compilation=$params["_ajaxSubmit"]->compile($js); |
36 | - $compilation=str_ireplace("\"","%quote%", $compilation); |
|
36 | + $compilation=str_ireplace("\"", "%quote%", $compilation); |
|
37 | 37 | $this->onSuccess($compilation); |
38 | 38 | $form->removeValidationParam("_ajaxSubmit"); |
39 | 39 | } |
@@ -51,14 +51,14 @@ discard block |
||
51 | 51 | return $this; |
52 | 52 | } |
53 | 53 | |
54 | - public function setAttached($value=true){ |
|
54 | + public function setAttached($value=true) { |
|
55 | 55 | $form=$this->getForm(); |
56 | - if($value) |
|
57 | - $form->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
56 | + if ($value) |
|
57 | + $form->addToPropertyCtrl("class", "attached", array("attached")); |
|
58 | 58 | return $form; |
59 | 59 | } |
60 | 60 | |
61 | - public function addErrorMessage(){ |
|
61 | + public function addErrorMessage() { |
|
62 | 62 | return $this->getForm()->addContent((new HtmlMessage(""))->setError()); |
63 | 63 | } |
64 | 64 | |
@@ -73,38 +73,38 @@ discard block |
||
73 | 73 | * @param string $responseElement |
74 | 74 | * @return \Ajax\semantic\html\collections\form\HtmlForm |
75 | 75 | */ |
76 | - public function submitOn($event,$identifier,$url,$responseElement){ |
|
76 | + public function submitOn($event, $identifier, $url, $responseElement) { |
|
77 | 77 | $form=$this->getForm(); |
78 | 78 | $elem=$form->getElementById($identifier, $form->getContent()); |
79 | - if(isset($elem)){ |
|
80 | - $this->_buttonAsSubmit($elem, $event,$url,$responseElement); |
|
79 | + if (isset($elem)) { |
|
80 | + $this->_buttonAsSubmit($elem, $event, $url, $responseElement); |
|
81 | 81 | } |
82 | 82 | return $form; |
83 | 83 | } |
84 | 84 | |
85 | - public function submitOnClick($identifier,$url,$responseElement){ |
|
85 | + public function submitOnClick($identifier, $url, $responseElement) { |
|
86 | 86 | return $this->submitOn("click", $identifier, $url, $responseElement); |
87 | 87 | } |
88 | 88 | |
89 | - public function addSubmit($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL){ |
|
90 | - $bt=$this->getForm()->addButton($identifier, $value,$cssStyle); |
|
91 | - return $this->_buttonAsSubmit($bt, "click",$url,$responseElement); |
|
89 | + public function addSubmit($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL) { |
|
90 | + $bt=$this->getForm()->addButton($identifier, $value, $cssStyle); |
|
91 | + return $this->_buttonAsSubmit($bt, "click", $url, $responseElement); |
|
92 | 92 | } |
93 | 93 | |
94 | - protected function _buttonAsSubmit(HtmlButton &$button,$event,$url,$responseElement=NULL,$parameters=NULL){ |
|
94 | + protected function _buttonAsSubmit(HtmlButton&$button, $event, $url, $responseElement=NULL, $parameters=NULL) { |
|
95 | 95 | $form=$this->getForm(); |
96 | - if(isset($url) && isset($responseElement)){ |
|
97 | - $button->addEvent($event, "$('#".$form->getIdentifier()."').form('validate form');",true,true); |
|
98 | - $params=["form"=>$form->getIdentifier(),"responseElement"=>$responseElement,"url"=>$url,"stopPropagation"=>true]; |
|
99 | - if(\is_array($parameters)) |
|
100 | - $params=\array_merge($params,$parameters); |
|
96 | + if (isset($url) && isset($responseElement)) { |
|
97 | + $button->addEvent($event, "$('#".$form->getIdentifier()."').form('validate form');", true, true); |
|
98 | + $params=["form"=>$form->getIdentifier(), "responseElement"=>$responseElement, "url"=>$url, "stopPropagation"=>true]; |
|
99 | + if (\is_array($parameters)) |
|
100 | + $params=\array_merge($params, $parameters); |
|
101 | 101 | $form->addValidationParam("_ajaxSubmit", new AjaxCall("postForm", $params)); |
102 | 102 | } |
103 | 103 | return $button; |
104 | 104 | } |
105 | 105 | |
106 | - public function addReset($identifier,$value,$cssStyle=NULL){ |
|
107 | - $bt=$this->getForm()->addButton($identifier, $value,$cssStyle); |
|
106 | + public function addReset($identifier, $value, $cssStyle=NULL) { |
|
107 | + $bt=$this->getForm()->addButton($identifier, $value, $cssStyle); |
|
108 | 108 | $bt->setProperty("type", "reset"); |
109 | 109 | return $bt; |
110 | 110 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * @param string $jsCode |
115 | 115 | * @return \Ajax\semantic\html\collections\form\HtmlForm |
116 | 116 | */ |
117 | - public function onValid($jsCode){ |
|
117 | + public function onValid($jsCode) { |
|
118 | 118 | $form=$this->getForm(); |
119 | 119 | $form->addValidationParam("onValid", "%function(){".$jsCode."}%"); |
120 | 120 | return $form; |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | * @param string $jsCode can use event and fields parameters |
126 | 126 | * @return HtmlForm |
127 | 127 | */ |
128 | - public function onSuccess($jsCode){ |
|
128 | + public function onSuccess($jsCode) { |
|
129 | 129 | $form=$this->getForm(); |
130 | - $form->addValidationParam("onSuccess", $jsCode,"%function(event,fields){","}%"); |
|
130 | + $form->addValidationParam("onSuccess", $jsCode, "%function(event,fields){", "}%"); |
|
131 | 131 | return $form; |
132 | 132 | } |
133 | 133 | } |
134 | 134 | \ No newline at end of file |
@@ -32,6 +32,10 @@ discard block |
||
32 | 32 | protected $_targetSelector; |
33 | 33 | |
34 | 34 | |
35 | + /** |
|
36 | + * @param string $identifier |
|
37 | + * @param string $model |
|
38 | + */ |
|
35 | 39 | public function __construct($identifier,$model,$modelInstance=NULL) { |
36 | 40 | parent::__construct($identifier, $model,$modelInstance); |
37 | 41 | $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false); |
@@ -55,6 +59,9 @@ discard block |
||
55 | 59 | |
56 | 60 | |
57 | 61 | |
62 | + /** |
|
63 | + * @param string $op |
|
64 | + */ |
|
58 | 65 | protected function _generateBehavior($op,$params,JsUtils $js){ |
59 | 66 | if(isset($this->_urls[$op])){ |
60 | 67 | $params=\array_merge($params,["attr"=>"data-ajax"]); |
@@ -184,6 +191,9 @@ discard block |
||
184 | 191 | return $this; |
185 | 192 | } |
186 | 193 | |
194 | + /** |
|
195 | + * @param PositionInTable $part |
|
196 | + */ |
|
187 | 197 | private function addToolbarRow($part,$table,$captions){ |
188 | 198 | $hasPart=$table->hasPart($part); |
189 | 199 | if($hasPart){ |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * |
22 | 22 | */ |
23 | 23 | class DataTable extends Widget { |
24 | - use TableTrait,DataTableFieldAsTrait,HasCheckboxesTrait; |
|
24 | + use TableTrait, DataTableFieldAsTrait, HasCheckboxesTrait; |
|
25 | 25 | protected $_searchField; |
26 | 26 | protected $_urls; |
27 | 27 | protected $_pagination; |
@@ -32,33 +32,33 @@ discard block |
||
32 | 32 | protected $_targetSelector; |
33 | 33 | |
34 | 34 | |
35 | - public function __construct($identifier,$model,$modelInstance=NULL) { |
|
36 | - parent::__construct($identifier, $model,$modelInstance); |
|
37 | - $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false); |
|
35 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
36 | + parent::__construct($identifier, $model, $modelInstance); |
|
37 | + $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 0), false); |
|
38 | 38 | $this->_urls=[]; |
39 | 39 | } |
40 | 40 | |
41 | - public function run(JsUtils $js){ |
|
42 | - if($this->_hasCheckboxes && isset($js)){ |
|
41 | + public function run(JsUtils $js) { |
|
42 | + if ($this->_hasCheckboxes && isset($js)) { |
|
43 | 43 | $this->_runCheckboxes($js); |
44 | 44 | } |
45 | - if($this->_visibleHover){ |
|
46 | - $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]); |
|
47 | - $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]); |
|
45 | + if ($this->_visibleHover) { |
|
46 | + $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');", ["preventDefault"=>false, "stopPropagation"=>true]); |
|
47 | + $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');", ["preventDefault"=>false, "stopPropagation"=>true]); |
|
48 | 48 | } |
49 | - if(\is_array($this->_deleteBehavior)) |
|
50 | - $this->_generateBehavior("delete",$this->_deleteBehavior, $js); |
|
51 | - if(\is_array($this->_editBehavior)) |
|
52 | - $this->_generateBehavior("edit",$this->_editBehavior,$js); |
|
49 | + if (\is_array($this->_deleteBehavior)) |
|
50 | + $this->_generateBehavior("delete", $this->_deleteBehavior, $js); |
|
51 | + if (\is_array($this->_editBehavior)) |
|
52 | + $this->_generateBehavior("edit", $this->_editBehavior, $js); |
|
53 | 53 | return parent::run($js); |
54 | 54 | } |
55 | 55 | |
56 | 56 | |
57 | 57 | |
58 | - protected function _generateBehavior($op,$params,JsUtils $js){ |
|
59 | - if(isset($this->_urls[$op])){ |
|
60 | - $params=\array_merge($params,["attr"=>"data-ajax"]); |
|
61 | - $js->getOnClick("#".$this->identifier." ._".$op, $this->_urls[$op],$this->getTargetSelector(),$params); |
|
58 | + protected function _generateBehavior($op, $params, JsUtils $js) { |
|
59 | + if (isset($this->_urls[$op])) { |
|
60 | + $params=\array_merge($params, ["attr"=>"data-ajax"]); |
|
61 | + $js->getOnClick("#".$this->identifier." ._".$op, $this->_urls[$op], $this->getTargetSelector(), $params); |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
@@ -71,62 +71,62 @@ discard block |
||
71 | 71 | } |
72 | 72 | |
73 | 73 | |
74 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
75 | - if(!$this->_generated){ |
|
74 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
75 | + if (!$this->_generated) { |
|
76 | 76 | $this->_instanceViewer->setInstance($this->_model); |
77 | 77 | $captions=$this->_instanceViewer->getCaptions(); |
78 | 78 | |
79 | 79 | $table=$this->content["table"]; |
80 | 80 | |
81 | - if($this->_hasCheckboxes){ |
|
81 | + if ($this->_hasCheckboxes) { |
|
82 | 82 | $this->_generateMainCheckbox($captions); |
83 | 83 | } |
84 | 84 | |
85 | 85 | $table->setRowCount(0, \sizeof($captions)); |
86 | 86 | $table->setHeaderValues($captions); |
87 | - if(isset($this->_compileParts)) |
|
87 | + if (isset($this->_compileParts)) |
|
88 | 88 | $table->setCompileParts($this->_compileParts); |
89 | 89 | |
90 | - if(isset($this->_searchField) && isset($js)){ |
|
91 | - if(isset($this->_urls["refresh"])) |
|
92 | - $this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
90 | + if (isset($this->_searchField) && isset($js)) { |
|
91 | + if (isset($this->_urls["refresh"])) |
|
92 | + $this->_searchField->postOn("change", $this->_urls["refresh"], "{'s':$(this).val()}", "#".$this->identifier." tbody", ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | $this->_generateContent($table); |
96 | 96 | |
97 | - if($this->_hasCheckboxes && $table->hasPart("thead")){ |
|
97 | + if ($this->_hasCheckboxes && $table->hasPart("thead")) { |
|
98 | 98 | $table->getHeader()->getCell(0, 0)->addClass("no-sort"); |
99 | 99 | } |
100 | 100 | |
101 | - if(isset($this->_pagination) && $this->_pagination->getVisible()){ |
|
101 | + if (isset($this->_pagination) && $this->_pagination->getVisible()) { |
|
102 | 102 | $this->_generatePagination($table); |
103 | 103 | } |
104 | - if(isset($this->_toolbar)){ |
|
104 | + if (isset($this->_toolbar)) { |
|
105 | 105 | $this->_setToolbarPosition($table, $captions); |
106 | 106 | } |
107 | - $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]); |
|
107 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]); |
|
108 | 108 | $this->_compileForm(); |
109 | 109 | $this->_generated=true; |
110 | 110 | } |
111 | - return parent::compile($js,$view); |
|
111 | + return parent::compile($js, $view); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | |
115 | 115 | |
116 | - protected function _generateContent($table){ |
|
116 | + protected function _generateContent($table) { |
|
117 | 117 | $objects=$this->_modelInstance; |
118 | - if(isset($this->_pagination)){ |
|
118 | + if (isset($this->_pagination)) { |
|
119 | 119 | $objects=$this->_pagination->getObjects($this->_modelInstance); |
120 | 120 | } |
121 | 121 | InstanceViewer::setIndex(0); |
122 | 122 | $table->fromDatabaseObjects($objects, function($instance) use($table){ |
123 | 123 | $this->_instanceViewer->setInstance($instance); |
124 | 124 | InstanceViewer::$index++; |
125 | - $values= $this->_instanceViewer->getValues(); |
|
126 | - if($this->_hasCheckboxes){ |
|
127 | - $ck=new HtmlCheckbox("ck-".$this->identifier,""); |
|
125 | + $values=$this->_instanceViewer->getValues(); |
|
126 | + if ($this->_hasCheckboxes) { |
|
127 | + $ck=new HtmlCheckbox("ck-".$this->identifier, ""); |
|
128 | 128 | $field=$ck->getField(); |
129 | - $field->setProperty("value",$this->_instanceViewer->getIdentifier()); |
|
129 | + $field->setProperty("value", $this->_instanceViewer->getIdentifier()); |
|
130 | 130 | $field->setProperty("name", "selection[]"); |
131 | 131 | \array_unshift($values, $ck); |
132 | 132 | } |
@@ -137,37 +137,37 @@ discard block |
||
137 | 137 | }); |
138 | 138 | } |
139 | 139 | |
140 | - private function _generatePagination($table){ |
|
140 | + private function _generatePagination($table) { |
|
141 | 141 | $footer=$table->getFooter(); |
142 | 142 | $footer->mergeCol(); |
143 | - $menu=new HtmlPaginationMenu("pagination-".$this->identifier,$this->_pagination->getPagesNumbers()); |
|
143 | + $menu=new HtmlPaginationMenu("pagination-".$this->identifier, $this->_pagination->getPagesNumbers()); |
|
144 | 144 | $menu->floatRight(); |
145 | 145 | $menu->setActiveItem($this->_pagination->getPage()-1); |
146 | 146 | $footer->setValues($menu); |
147 | - if(isset($this->_urls["refresh"])) |
|
148 | - $menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
147 | + if (isset($this->_urls["refresh"])) |
|
148 | + $menu->postOnClick($this->_urls["refresh"], "{'p':$(this).attr('data-page')}", "#".$this->identifier." tbody", ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]); |
|
149 | 149 | } |
150 | 150 | |
151 | - protected function _getFieldName($index){ |
|
151 | + protected function _getFieldName($index) { |
|
152 | 152 | return parent::_getFieldName($index)."[]"; |
153 | 153 | } |
154 | 154 | |
155 | - protected function _getFieldCaption($index){ |
|
155 | + protected function _getFieldCaption($index) { |
|
156 | 156 | return null; |
157 | 157 | } |
158 | 158 | |
159 | - protected function _setToolbarPosition($table,$captions=NULL){ |
|
160 | - switch ($this->_toolbarPosition){ |
|
159 | + protected function _setToolbarPosition($table, $captions=NULL) { |
|
160 | + switch ($this->_toolbarPosition) { |
|
161 | 161 | case PositionInTable::BEFORETABLE: |
162 | 162 | case PositionInTable::AFTERTABLE: |
163 | - if(isset($this->_compileParts)===false){ |
|
163 | + if (isset($this->_compileParts)===false) { |
|
164 | 164 | $this->content[$this->_toolbarPosition]=$this->_toolbar; |
165 | 165 | } |
166 | 166 | break; |
167 | 167 | case PositionInTable::HEADER: |
168 | 168 | case PositionInTable::FOOTER: |
169 | 169 | case PositionInTable::BODY: |
170 | - $this->addToolbarRow($this->_toolbarPosition,$table, $captions); |
|
170 | + $this->addToolbarRow($this->_toolbarPosition, $table, $captions); |
|
171 | 171 | break; |
172 | 172 | } |
173 | 173 | } |
@@ -179,23 +179,23 @@ discard block |
||
179 | 179 | * @param callable $callback function called after the field compilation |
180 | 180 | * @return \Ajax\semantic\widgets\datatable\DataTable |
181 | 181 | */ |
182 | - public function afterCompile($index,$callback){ |
|
183 | - $this->_instanceViewer->afterCompile($index,$callback); |
|
182 | + public function afterCompile($index, $callback) { |
|
183 | + $this->_instanceViewer->afterCompile($index, $callback); |
|
184 | 184 | return $this; |
185 | 185 | } |
186 | 186 | |
187 | - private function addToolbarRow($part,$table,$captions){ |
|
187 | + private function addToolbarRow($part, $table, $captions) { |
|
188 | 188 | $hasPart=$table->hasPart($part); |
189 | - if($hasPart){ |
|
189 | + if ($hasPart) { |
|
190 | 190 | $row=$table->getPart($part)->addRow(\sizeof($captions)); |
191 | - }else{ |
|
191 | + } else { |
|
192 | 192 | $row=$table->getPart($part)->getRow(0); |
193 | 193 | } |
194 | 194 | $row->mergeCol(); |
195 | 195 | $row->setValues([$this->_toolbar]); |
196 | 196 | } |
197 | 197 | |
198 | - public function getHtmlComponent(){ |
|
198 | + public function getHtmlComponent() { |
|
199 | 199 | return $this->content["table"]; |
200 | 200 | } |
201 | 201 | |
@@ -209,36 +209,36 @@ discard block |
||
209 | 209 | * @return \Ajax\semantic\widgets\datatable\DataTable |
210 | 210 | */ |
211 | 211 | public function setUrls($urls) { |
212 | - if(\is_array($urls)){ |
|
213 | - $this->_urls["refresh"]=JArray::getValue($urls, "refresh",0); |
|
214 | - $this->_urls["edit"]=JArray::getValue($urls, "edit",1); |
|
215 | - $this->_urls["delete"]=JArray::getValue($urls, "delete",2); |
|
216 | - }else{ |
|
217 | - $this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls]; |
|
212 | + if (\is_array($urls)) { |
|
213 | + $this->_urls["refresh"]=JArray::getValue($urls, "refresh", 0); |
|
214 | + $this->_urls["edit"]=JArray::getValue($urls, "edit", 1); |
|
215 | + $this->_urls["delete"]=JArray::getValue($urls, "delete", 2); |
|
216 | + } else { |
|
217 | + $this->_urls=["refresh"=>$urls, "edit"=>$urls, "delete"=>$urls]; |
|
218 | 218 | } |
219 | 219 | return $this; |
220 | 220 | } |
221 | 221 | |
222 | - public function paginate($items_per_page=10,$page=1){ |
|
223 | - $this->_pagination=new Pagination($items_per_page,4,$page); |
|
222 | + public function paginate($items_per_page=10, $page=1) { |
|
223 | + $this->_pagination=new Pagination($items_per_page, 4, $page); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | |
227 | 227 | |
228 | - public function refresh($compileParts=["tbody"]){ |
|
228 | + public function refresh($compileParts=["tbody"]) { |
|
229 | 229 | $this->_compileParts=$compileParts; |
230 | 230 | return $this; |
231 | 231 | } |
232 | 232 | |
233 | 233 | |
234 | - public function addSearchInToolbar($position=Direction::RIGHT){ |
|
234 | + public function addSearchInToolbar($position=Direction::RIGHT) { |
|
235 | 235 | return $this->addInToolbar($this->getSearchField())->setPosition($position); |
236 | 236 | } |
237 | 237 | |
238 | - public function getSearchField(){ |
|
239 | - if(isset($this->_searchField)===false){ |
|
240 | - $this->_searchField=new HtmlInput("search-".$this->identifier,"search","","Search..."); |
|
241 | - $this->_searchField->addIcon("search",Direction::RIGHT); |
|
238 | + public function getSearchField() { |
|
239 | + if (isset($this->_searchField)===false) { |
|
240 | + $this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search..."); |
|
241 | + $this->_searchField->addIcon("search", Direction::RIGHT); |
|
242 | 242 | } |
243 | 243 | return $this->_searchField; |
244 | 244 | } |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | return $this; |
255 | 255 | } |
256 | 256 | |
257 | - public function asForm(){ |
|
257 | + public function asForm() { |
|
258 | 258 | return $this->getForm(); |
259 | 259 | } |
260 | 260 | |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | |
263 | 263 | protected function getTargetSelector() { |
264 | 264 | $result=$this->_targetSelector; |
265 | - if(!isset($result)) |
|
265 | + if (!isset($result)) |
|
266 | 266 | $result="#".$this->identifier; |
267 | 267 | return $result; |
268 | 268 | } |
@@ -46,10 +46,12 @@ discard block |
||
46 | 46 | $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]); |
47 | 47 | $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]); |
48 | 48 | } |
49 | - if(\is_array($this->_deleteBehavior)) |
|
50 | - $this->_generateBehavior("delete",$this->_deleteBehavior, $js); |
|
51 | - if(\is_array($this->_editBehavior)) |
|
52 | - $this->_generateBehavior("edit",$this->_editBehavior,$js); |
|
49 | + if(\is_array($this->_deleteBehavior)) { |
|
50 | + $this->_generateBehavior("delete",$this->_deleteBehavior, $js); |
|
51 | + } |
|
52 | + if(\is_array($this->_editBehavior)) { |
|
53 | + $this->_generateBehavior("edit",$this->_editBehavior,$js); |
|
54 | + } |
|
53 | 55 | return parent::run($js); |
54 | 56 | } |
55 | 57 | |
@@ -84,12 +86,14 @@ discard block |
||
84 | 86 | |
85 | 87 | $table->setRowCount(0, \sizeof($captions)); |
86 | 88 | $table->setHeaderValues($captions); |
87 | - if(isset($this->_compileParts)) |
|
88 | - $table->setCompileParts($this->_compileParts); |
|
89 | + if(isset($this->_compileParts)) { |
|
90 | + $table->setCompileParts($this->_compileParts); |
|
91 | + } |
|
89 | 92 | |
90 | 93 | if(isset($this->_searchField) && isset($js)){ |
91 | - if(isset($this->_urls["refresh"])) |
|
92 | - $this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
94 | + if(isset($this->_urls["refresh"])) { |
|
95 | + $this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
96 | + } |
|
93 | 97 | } |
94 | 98 | |
95 | 99 | $this->_generateContent($table); |
@@ -144,8 +148,9 @@ discard block |
||
144 | 148 | $menu->floatRight(); |
145 | 149 | $menu->setActiveItem($this->_pagination->getPage()-1); |
146 | 150 | $footer->setValues($menu); |
147 | - if(isset($this->_urls["refresh"])) |
|
148 | - $menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
151 | + if(isset($this->_urls["refresh"])) { |
|
152 | + $menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
153 | + } |
|
149 | 154 | } |
150 | 155 | |
151 | 156 | protected function _getFieldName($index){ |
@@ -188,7 +193,7 @@ discard block |
||
188 | 193 | $hasPart=$table->hasPart($part); |
189 | 194 | if($hasPart){ |
190 | 195 | $row=$table->getPart($part)->addRow(\sizeof($captions)); |
191 | - }else{ |
|
196 | + } else{ |
|
192 | 197 | $row=$table->getPart($part)->getRow(0); |
193 | 198 | } |
194 | 199 | $row->mergeCol(); |
@@ -213,7 +218,7 @@ discard block |
||
213 | 218 | $this->_urls["refresh"]=JArray::getValue($urls, "refresh",0); |
214 | 219 | $this->_urls["edit"]=JArray::getValue($urls, "edit",1); |
215 | 220 | $this->_urls["delete"]=JArray::getValue($urls, "delete",2); |
216 | - }else{ |
|
221 | + } else{ |
|
217 | 222 | $this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls]; |
218 | 223 | } |
219 | 224 | return $this; |
@@ -262,8 +267,9 @@ discard block |
||
262 | 267 | |
263 | 268 | protected function getTargetSelector() { |
264 | 269 | $result=$this->_targetSelector; |
265 | - if(!isset($result)) |
|
266 | - $result="#".$this->identifier; |
|
270 | + if(!isset($result)) { |
|
271 | + $result="#".$this->identifier; |
|
272 | + } |
|
267 | 273 | return $result; |
268 | 274 | } |
269 | 275 |
@@ -10,17 +10,17 @@ discard block |
||
10 | 10 | * @author jc |
11 | 11 | * @property string identifier |
12 | 12 | */ |
13 | -trait HasCheckboxesTrait{ |
|
13 | +trait HasCheckboxesTrait { |
|
14 | 14 | protected $_hasCheckboxes; |
15 | 15 | protected $_hasCheckedMessage=false; |
16 | 16 | protected $_checkedMessage; |
17 | 17 | protected $_checkedClass; |
18 | 18 | |
19 | - abstract public function addInToolbar($element,$callback=NULL); |
|
19 | + abstract public function addInToolbar($element, $callback=NULL); |
|
20 | 20 | |
21 | - protected function _runCheckboxes(JsUtils $js){ |
|
21 | + protected function _runCheckboxes(JsUtils $js) { |
|
22 | 22 | $checkedMessageCall=""; |
23 | - if($this->_hasCheckedMessage){ |
|
23 | + if ($this->_hasCheckedMessage) { |
|
24 | 24 | $msg=$this->getCheckedMessage(); |
25 | 25 | $checkedMessageFunction="function updateChecked(){var msg='".$msg[0]."',count=\$('#{$this->identifier} [name=\"selection[]\"]:checked').length,all=\$('#{$this->identifier} [name=\"selection[]\"]').length; |
26 | 26 | if(count==1) msg='".$msg[1]."'; |
@@ -28,10 +28,10 @@ discard block |
||
28 | 28 | \$('#checked-count-".$this->identifier."').contents().filter(function() {return this.nodeType == 3;}).each(function(){this.textContent = msg.replace('{count}',count);}); |
29 | 29 | \$('#toolbar-{$this->identifier} .visibleOnChecked').toggle(count>0);}\$('#toolbar-".$this->identifier." .visibleOnChecked').hide();"; |
30 | 30 | $checkedMessageCall="updateChecked();"; |
31 | - if(isset($this->_checkedClass)){ |
|
31 | + if (isset($this->_checkedClass)) { |
|
32 | 32 | $checkedMessageCall.="$(this).closest('tr').toggleClass('".$this->_checkedClass."',$(this).prop('checked'));"; |
33 | 33 | } |
34 | - $js->exec($checkedMessageFunction,true); |
|
34 | + $js->exec($checkedMessageFunction, true); |
|
35 | 35 | } |
36 | 36 | $js->execOn("change", "#".$this->identifier." [name='selection[]']", " |
37 | 37 | var \$parentCheckbox=\$('#ck-main-ck-{$this->identifier}'),\$checkbox=\$('#{$this->identifier} [name=\"selection[]\"]'),allChecked=true,allUnchecked=true; |
@@ -39,10 +39,10 @@ discard block |
||
39 | 39 | if(allChecked) {\$parentCheckbox.checkbox('set checked');}else if(allUnchecked){\$parentCheckbox.checkbox('set unchecked');}else{\$parentCheckbox.checkbox('set indeterminate');};".$checkedMessageCall); |
40 | 40 | } |
41 | 41 | |
42 | - protected function _generateMainCheckbox(&$captions){ |
|
43 | - $ck=new HtmlCheckbox("main-ck-".$this->identifier,""); |
|
42 | + protected function _generateMainCheckbox(&$captions) { |
|
43 | + $ck=new HtmlCheckbox("main-ck-".$this->identifier, ""); |
|
44 | 44 | $checkedMessageCall=""; |
45 | - if($this->_hasCheckedMessage) |
|
45 | + if ($this->_hasCheckedMessage) |
|
46 | 46 | $checkedMessageCall="updateChecked();"; |
47 | 47 | |
48 | 48 | $ck->setOnChecked($this->_setAllChecked("true").$checkedMessageCall); |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | \array_unshift($captions, $ck); |
51 | 51 | } |
52 | 52 | |
53 | - protected function _setAllChecked($checked){ |
|
53 | + protected function _setAllChecked($checked) { |
|
54 | 54 | $result="$('#".$this->identifier." [name=%quote%selection[]%quote%]').prop('checked',".$checked.");"; |
55 | - if(isset($this->_checkedClass)){ |
|
55 | + if (isset($this->_checkedClass)) { |
|
56 | 56 | $result.="$('#".$this->identifier." tr').toggleClass('".$this->_checkedClass."',".$checked.");"; |
57 | 57 | } |
58 | 58 | return $result; |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | } |
69 | 69 | |
70 | 70 | protected function getCheckedMessage() { |
71 | - $result= $this->_checkedMessage; |
|
72 | - if(!isset($result)){ |
|
73 | - $result=[0=>"none selected",1=>"one item selected","other"=>"{count} items selected"]; |
|
71 | + $result=$this->_checkedMessage; |
|
72 | + if (!isset($result)) { |
|
73 | + $result=[0=>"none selected", 1=>"one item selected", "other"=>"{count} items selected"]; |
|
74 | 74 | } |
75 | 75 | return $result; |
76 | 76 | } |
@@ -90,14 +90,14 @@ discard block |
||
90 | 90 | * @param array $checkedMessage |
91 | 91 | * @param callable $callback |
92 | 92 | */ |
93 | - public function addCountCheckedInToolbar(array $checkedMessage=null,$callback=null){ |
|
94 | - if(isset($checkedMessage)) |
|
93 | + public function addCountCheckedInToolbar(array $checkedMessage=null, $callback=null) { |
|
94 | + if (isset($checkedMessage)) |
|
95 | 95 | $this->_checkedMessage=$checkedMessage; |
96 | 96 | $checkedMessage=$this->getCheckedMessage(); |
97 | 97 | $this->_hasCheckboxes=true; |
98 | 98 | $this->_hasCheckedMessage=true; |
99 | - $element=new HtmlLabel("checked-count-".$this->identifier,$checkedMessage[0]); |
|
100 | - $this->addInToolbar($element,$callback); |
|
99 | + $element=new HtmlLabel("checked-count-".$this->identifier, $checkedMessage[0]); |
|
100 | + $this->addInToolbar($element, $callback); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | public function setCheckedClass($_checkedClass) { |
@@ -42,8 +42,9 @@ discard block |
||
42 | 42 | protected function _generateMainCheckbox(&$captions){ |
43 | 43 | $ck=new HtmlCheckbox("main-ck-".$this->identifier,""); |
44 | 44 | $checkedMessageCall=""; |
45 | - if($this->_hasCheckedMessage) |
|
46 | - $checkedMessageCall="updateChecked();"; |
|
45 | + if($this->_hasCheckedMessage) { |
|
46 | + $checkedMessageCall="updateChecked();"; |
|
47 | + } |
|
47 | 48 | |
48 | 49 | $ck->setOnChecked($this->_setAllChecked("true").$checkedMessageCall); |
49 | 50 | $ck->setOnUnchecked($this->_setAllChecked("false").$checkedMessageCall); |
@@ -91,8 +92,9 @@ discard block |
||
91 | 92 | * @param callable $callback |
92 | 93 | */ |
93 | 94 | public function addCountCheckedInToolbar(array $checkedMessage=null,$callback=null){ |
94 | - if(isset($checkedMessage)) |
|
95 | - $this->_checkedMessage=$checkedMessage; |
|
95 | + if(isset($checkedMessage)) { |
|
96 | + $this->_checkedMessage=$checkedMessage; |
|
97 | + } |
|
96 | 98 | $checkedMessage=$this->getCheckedMessage(); |
97 | 99 | $this->_hasCheckboxes=true; |
98 | 100 | $this->_hasCheckedMessage=true; |
@@ -28,9 +28,17 @@ discard block |
||
28 | 28 | trait FieldAsTrait{ |
29 | 29 | |
30 | 30 | abstract protected function _getFieldIdentifier($prefix,$name=""); |
31 | + |
|
32 | + /** |
|
33 | + * @param \Closure $callback |
|
34 | + */ |
|
31 | 35 | abstract public function setValueFunction($index,$callback); |
32 | 36 | abstract protected function _getFieldName($index); |
33 | 37 | abstract protected function _getFieldCaption($index); |
38 | + |
|
39 | + /** |
|
40 | + * @param string $event |
|
41 | + */ |
|
34 | 42 | abstract protected function _buttonAsSubmit(HtmlButton &$button,$event,$url,$responseElement=NULL,$parameters=NULL); |
35 | 43 | |
36 | 44 | /** |
@@ -70,6 +78,9 @@ discard block |
||
70 | 78 | } |
71 | 79 | } |
72 | 80 | |
81 | + /** |
|
82 | + * @param HtmlFormInput $field |
|
83 | + */ |
|
73 | 84 | protected function _prepareFormFields(&$field,$name,&$attributes){ |
74 | 85 | $field->setName($name); |
75 | 86 | $this->_addRules($field, $attributes); |
@@ -235,6 +246,9 @@ discard block |
||
235 | 246 | } |
236 | 247 | } |
237 | 248 | |
249 | + /** |
|
250 | + * @param integer $index |
|
251 | + */ |
|
238 | 252 | public function fieldAs($index,$type,$attributes=NULL){ |
239 | 253 | $method="fieldAs".\ucfirst($type); |
240 | 254 | if(\method_exists($this, $method)){ |
@@ -25,23 +25,23 @@ discard block |
||
25 | 25 | * @property boolean $_edition |
26 | 26 | * @property mixed _modelInstance |
27 | 27 | */ |
28 | -trait FieldAsTrait{ |
|
28 | +trait FieldAsTrait { |
|
29 | 29 | |
30 | - abstract protected function _getFieldIdentifier($prefix,$name=""); |
|
31 | - abstract public function setValueFunction($index,$callback); |
|
30 | + abstract protected function _getFieldIdentifier($prefix, $name=""); |
|
31 | + abstract public function setValueFunction($index, $callback); |
|
32 | 32 | abstract protected function _getFieldName($index); |
33 | 33 | abstract protected function _getFieldCaption($index); |
34 | - abstract protected function _buttonAsSubmit(HtmlButton &$button,$event,$url,$responseElement=NULL,$parameters=NULL); |
|
34 | + abstract protected function _buttonAsSubmit(HtmlButton&$button, $event, $url, $responseElement=NULL, $parameters=NULL); |
|
35 | 35 | |
36 | 36 | /** |
37 | 37 | * @param HtmlFormField $element |
38 | 38 | * @param array $attributes |
39 | 39 | */ |
40 | - protected function _applyAttributes($element,&$attributes,$index){ |
|
41 | - if(isset($attributes["callback"])){ |
|
40 | + protected function _applyAttributes($element, &$attributes, $index) { |
|
41 | + if (isset($attributes["callback"])) { |
|
42 | 42 | $callback=$attributes["callback"]; |
43 | - if(\is_callable($callback)){ |
|
44 | - $callback($element,$this->_modelInstance,$index); |
|
43 | + if (\is_callable($callback)) { |
|
44 | + $callback($element, $this->_modelInstance, $index); |
|
45 | 45 | unset($attributes["callback"]); |
46 | 46 | } |
47 | 47 | } |
@@ -51,43 +51,43 @@ discard block |
||
51 | 51 | $element->fromArray($attributes); |
52 | 52 | } |
53 | 53 | |
54 | - private function _getLabelField($caption,$icon=NULL){ |
|
55 | - $label=new HtmlLabel($this->_getFieldIdentifier("lbl"),$caption,$icon); |
|
54 | + private function _getLabelField($caption, $icon=NULL) { |
|
55 | + $label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon); |
|
56 | 56 | return $label; |
57 | 57 | } |
58 | 58 | |
59 | 59 | |
60 | - protected function _addRules($element,&$attributes){ |
|
61 | - if(isset($attributes["rules"])){ |
|
60 | + protected function _addRules($element, &$attributes) { |
|
61 | + if (isset($attributes["rules"])) { |
|
62 | 62 | $rules=$attributes["rules"]; |
63 | - if(\is_array($rules)){ |
|
63 | + if (\is_array($rules)) { |
|
64 | 64 | $element->addRules($rules); |
65 | 65 | } |
66 | - else{ |
|
66 | + else { |
|
67 | 67 | $element->addRule($rules); |
68 | 68 | } |
69 | 69 | unset($attributes["rules"]); |
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
73 | - protected function _prepareFormFields(&$field,$name,&$attributes){ |
|
73 | + protected function _prepareFormFields(&$field, $name, &$attributes) { |
|
74 | 74 | $field->setName($name); |
75 | 75 | $this->_addRules($field, $attributes); |
76 | 76 | return $field; |
77 | 77 | } |
78 | 78 | |
79 | - protected function _fieldAs($elementCallback,&$index,$attributes=NULL,$prefix=null){ |
|
80 | - $this->setValueFunction($index,function($value,$instance,$index) use (&$attributes,$elementCallback,$prefix){ |
|
79 | + protected function _fieldAs($elementCallback, &$index, $attributes=NULL, $prefix=null) { |
|
80 | + $this->setValueFunction($index, function($value, $instance, $index) use (&$attributes, $elementCallback, $prefix){ |
|
81 | 81 | $caption=$this->_getFieldCaption($index); |
82 | 82 | $name=$this->_getFieldName($index); |
83 | - $id=$this->_getFieldIdentifier($prefix,$name); |
|
84 | - if(isset($attributes["name"])){ |
|
83 | + $id=$this->_getFieldIdentifier($prefix, $name); |
|
84 | + if (isset($attributes["name"])) { |
|
85 | 85 | $name=$attributes["name"]; |
86 | 86 | unset($attributes["name"]); |
87 | 87 | } |
88 | - $element=$elementCallback($id,$name,$value,$caption); |
|
89 | - if(\is_array($attributes)){ |
|
90 | - $this->_applyAttributes($element, $attributes,$index); |
|
88 | + $element=$elementCallback($id, $name, $value, $caption); |
|
89 | + if (\is_array($attributes)) { |
|
90 | + $this->_applyAttributes($element, $attributes, $index); |
|
91 | 91 | } |
92 | 92 | $element->setDisabled(!$this->_edition); |
93 | 93 | return $element; |
@@ -96,169 +96,169 @@ discard block |
||
96 | 96 | } |
97 | 97 | |
98 | 98 | |
99 | - public function fieldAsProgress($index,$label=NULL, $attributes=array()){ |
|
100 | - $this->setValueFunction($index,function($value) use($label,$attributes){ |
|
101 | - $pb=new HtmlProgress($this->_getFieldIdentifier("pb"),$value,$label,$attributes); |
|
99 | + public function fieldAsProgress($index, $label=NULL, $attributes=array()) { |
|
100 | + $this->setValueFunction($index, function($value) use($label, $attributes){ |
|
101 | + $pb=new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes); |
|
102 | 102 | return $pb; |
103 | 103 | }); |
104 | 104 | return $this; |
105 | 105 | } |
106 | 106 | |
107 | - public function fieldAsRating($index,$max=5, $icon=""){ |
|
108 | - $this->setValueFunction($index,function($value) use($max,$icon){ |
|
109 | - $rating=new HtmlRating($this->_getFieldIdentifier("rat"),$value,$max,$icon); |
|
107 | + public function fieldAsRating($index, $max=5, $icon="") { |
|
108 | + $this->setValueFunction($index, function($value) use($max, $icon){ |
|
109 | + $rating=new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon); |
|
110 | 110 | return $rating; |
111 | 111 | }); |
112 | 112 | return $this; |
113 | 113 | } |
114 | 114 | |
115 | - public function fieldAsLabel($index,$icon=NULL){ |
|
116 | - $this->setValueFunction($index,function($caption) use($icon){ |
|
117 | - $lbl=$this->_getLabelField($caption,$icon); |
|
115 | + public function fieldAsLabel($index, $icon=NULL) { |
|
116 | + $this->setValueFunction($index, function($caption) use($icon){ |
|
117 | + $lbl=$this->_getLabelField($caption, $icon); |
|
118 | 118 | return $lbl; |
119 | 119 | }); |
120 | 120 | return $this; |
121 | 121 | } |
122 | 122 | |
123 | - public function fieldAsHeader($index,$niveau=1,$icon=NULL,$attributes=NULL){ |
|
124 | - return $this->_fieldAs(function($id,$name,$value) use($niveau,$icon){ |
|
125 | - $header=new HtmlHeader($id,$niveau,$value); |
|
126 | - if(isset($icon)) |
|
123 | + public function fieldAsHeader($index, $niveau=1, $icon=NULL, $attributes=NULL) { |
|
124 | + return $this->_fieldAs(function($id, $name, $value) use($niveau, $icon){ |
|
125 | + $header=new HtmlHeader($id, $niveau, $value); |
|
126 | + if (isset($icon)) |
|
127 | 127 | $header->asIcon($icon, $value); |
128 | 128 | return $header; |
129 | - }, $index,$attributes,"header"); |
|
129 | + }, $index, $attributes, "header"); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | |
133 | - public function fieldAsImage($index,$size=Size::MINI,$circular=false){ |
|
134 | - $this->setValueFunction($index,function($img) use($size,$circular){ |
|
135 | - $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular(); |
|
133 | + public function fieldAsImage($index, $size=Size::MINI, $circular=false) { |
|
134 | + $this->setValueFunction($index, function($img) use($size, $circular){ |
|
135 | + $image=new HtmlImage($this->_getFieldIdentifier("image"), $img); $image->setSize($size); if ($circular)$image->setCircular(); |
|
136 | 136 | return $image; |
137 | 137 | }); |
138 | 138 | return $this; |
139 | 139 | } |
140 | 140 | |
141 | - public function fieldAsAvatar($index,$attributes=NULL){ |
|
142 | - return $this->_fieldAs(function($id,$name,$value){ |
|
143 | - $img=new HtmlImage($id,$value); |
|
141 | + public function fieldAsAvatar($index, $attributes=NULL) { |
|
142 | + return $this->_fieldAs(function($id, $name, $value) { |
|
143 | + $img=new HtmlImage($id, $value); |
|
144 | 144 | $img->asAvatar(); |
145 | 145 | return $img; |
146 | - }, $index,$attributes,"avatar"); |
|
146 | + }, $index, $attributes, "avatar"); |
|
147 | 147 | } |
148 | 148 | |
149 | - public function fieldAsRadio($index,$attributes=NULL){ |
|
150 | - return $this->_fieldAs(function($id,$name,$value){ |
|
151 | - $input= new HtmlRadio($id,$name,$value,$value); |
|
149 | + public function fieldAsRadio($index, $attributes=NULL) { |
|
150 | + return $this->_fieldAs(function($id, $name, $value) { |
|
151 | + $input=new HtmlRadio($id, $name, $value, $value); |
|
152 | 152 | return $input; |
153 | - }, $index,$attributes,"radio"); |
|
153 | + }, $index, $attributes, "radio"); |
|
154 | 154 | } |
155 | 155 | |
156 | - public function fieldAsRadios($index,$elements=[],$attributes=NULL){ |
|
157 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($elements){ |
|
158 | - return HtmlFormFields::radios($name,$elements,$caption,$value); |
|
159 | - }, $index,$attributes,"radios"); |
|
156 | + public function fieldAsRadios($index, $elements=[], $attributes=NULL) { |
|
157 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements){ |
|
158 | + return HtmlFormFields::radios($name, $elements, $caption, $value); |
|
159 | + }, $index, $attributes, "radios"); |
|
160 | 160 | } |
161 | 161 | |
162 | - public function fieldAsInput($index,$attributes=NULL){ |
|
163 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($attributes){ |
|
164 | - $input= new HtmlFormInput($id,$caption,"text",$value); |
|
162 | + public function fieldAsInput($index, $attributes=NULL) { |
|
163 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes){ |
|
164 | + $input=new HtmlFormInput($id, $caption, "text", $value); |
|
165 | 165 | return $this->_prepareFormFields($input, $name, $attributes); |
166 | - }, $index,$attributes,"input"); |
|
166 | + }, $index, $attributes, "input"); |
|
167 | 167 | } |
168 | 168 | |
169 | - public function fieldAsTextarea($index,$attributes=NULL){ |
|
170 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
171 | - $textarea=new HtmlFormTextarea($id,$caption,$value); |
|
169 | + public function fieldAsTextarea($index, $attributes=NULL) { |
|
170 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
171 | + $textarea=new HtmlFormTextarea($id, $caption, $value); |
|
172 | 172 | $textarea->setName($name); |
173 | 173 | return $textarea; |
174 | - }, $index,$attributes,"textarea"); |
|
174 | + }, $index, $attributes, "textarea"); |
|
175 | 175 | } |
176 | 176 | |
177 | - public function fieldAsHidden($index,$attributes=NULL){ |
|
178 | - if(!\is_array($attributes)){ |
|
177 | + public function fieldAsHidden($index, $attributes=NULL) { |
|
178 | + if (!\is_array($attributes)) { |
|
179 | 179 | $attributes=[]; |
180 | 180 | } |
181 | 181 | $attributes["imputType"]="hidden"; |
182 | - return $this->fieldAsInput($index,$attributes); |
|
182 | + return $this->fieldAsInput($index, $attributes); |
|
183 | 183 | } |
184 | 184 | |
185 | - public function fieldAsCheckbox($index,$attributes=NULL){ |
|
186 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
187 | - $input=new HtmlFormCheckbox($id,$caption,$this->_instanceViewer->getIdentifier()); |
|
185 | + public function fieldAsCheckbox($index, $attributes=NULL) { |
|
186 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
187 | + $input=new HtmlFormCheckbox($id, $caption, $this->_instanceViewer->getIdentifier()); |
|
188 | 188 | $input->setChecked(JString::isBooleanTrue($value)); |
189 | 189 | $input->setName($name); |
190 | 190 | return $input; |
191 | - }, $index,$attributes,"ck"); |
|
191 | + }, $index, $attributes, "ck"); |
|
192 | 192 | } |
193 | 193 | |
194 | - public function fieldAsDropDown($index,$elements=[],$multiple=false,$attributes=NULL){ |
|
195 | - return $this->_fieldAs(function($id,$name,$value,$caption) use($elements,$multiple){ |
|
196 | - $dd=new HtmlFormDropdown($id,$elements,$caption,$value); |
|
197 | - $dd->asSelect($name,$multiple); |
|
194 | + public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) { |
|
195 | + return $this->_fieldAs(function($id, $name, $value, $caption) use($elements, $multiple){ |
|
196 | + $dd=new HtmlFormDropdown($id, $elements, $caption, $value); |
|
197 | + $dd->asSelect($name, $multiple); |
|
198 | 198 | return $dd; |
199 | - }, $index,$attributes,"dd"); |
|
199 | + }, $index, $attributes, "dd"); |
|
200 | 200 | } |
201 | 201 | |
202 | - public function fieldAsMessage($index,$attributes=NULL){ |
|
203 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
204 | - $mess= new HtmlMessage("message-".$id,$caption); |
|
202 | + public function fieldAsMessage($index, $attributes=NULL) { |
|
203 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
204 | + $mess=new HtmlMessage("message-".$id, $caption); |
|
205 | 205 | $mess->addHeader($value); |
206 | 206 | return $mess; |
207 | - }, $index,$attributes,"message"); |
|
207 | + }, $index, $attributes, "message"); |
|
208 | 208 | } |
209 | 209 | |
210 | - public function fieldAsLink($index,$attributes=NULL){ |
|
211 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
212 | - $lnk= new HtmlLink("message-".$id,"#",$caption); |
|
210 | + public function fieldAsLink($index, $attributes=NULL) { |
|
211 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
212 | + $lnk=new HtmlLink("message-".$id, "#", $caption); |
|
213 | 213 | return $lnk; |
214 | - }, $index,$attributes,"link"); |
|
214 | + }, $index, $attributes, "link"); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | /**Change fields type |
218 | 218 | * @param array $types an array or associative array $type=>$attributes |
219 | 219 | */ |
220 | - public function fieldsAs(array $types){ |
|
220 | + public function fieldsAs(array $types) { |
|
221 | 221 | $i=0; |
222 | - if(JArray::isAssociative($types)){ |
|
223 | - foreach ($types as $type=>$attributes){ |
|
224 | - if(\is_int($type)) |
|
225 | - $this->fieldAs($i++,$attributes,[]); |
|
226 | - else{ |
|
227 | - $type=preg_replace('/\d/', '', $type ); |
|
228 | - $this->fieldAs($i++,$type,$attributes); |
|
222 | + if (JArray::isAssociative($types)) { |
|
223 | + foreach ($types as $type=>$attributes) { |
|
224 | + if (\is_int($type)) |
|
225 | + $this->fieldAs($i++, $attributes, []); |
|
226 | + else { |
|
227 | + $type=preg_replace('/\d/', '', $type); |
|
228 | + $this->fieldAs($i++, $type, $attributes); |
|
229 | 229 | } |
230 | 230 | } |
231 | - }else{ |
|
232 | - foreach ($types as $type){ |
|
233 | - $this->fieldAs($i++,$type); |
|
231 | + } else { |
|
232 | + foreach ($types as $type) { |
|
233 | + $this->fieldAs($i++, $type); |
|
234 | 234 | } |
235 | 235 | } |
236 | 236 | } |
237 | 237 | |
238 | - public function fieldAs($index,$type,$attributes=NULL){ |
|
238 | + public function fieldAs($index, $type, $attributes=NULL) { |
|
239 | 239 | $method="fieldAs".\ucfirst($type); |
240 | - if(\method_exists($this, $method)){ |
|
241 | - if(!\is_array($attributes)){ |
|
240 | + if (\method_exists($this, $method)) { |
|
241 | + if (!\is_array($attributes)) { |
|
242 | 242 | $attributes=[$index]; |
243 | - }else{ |
|
243 | + } else { |
|
244 | 244 | \array_unshift($attributes, $index); |
245 | 245 | } |
246 | - \call_user_func_array([$this,$method], $attributes); |
|
246 | + \call_user_func_array([$this, $method], $attributes); |
|
247 | 247 | } |
248 | 248 | } |
249 | 249 | |
250 | - public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){ |
|
251 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$attributes){ |
|
252 | - $button=new HtmlButton($id,$caption,$cssStyle); |
|
253 | - $this->_buttonAsSubmit($button,"click",$url,$responseElement,@$attributes["ajax"]); |
|
250 | + public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) { |
|
251 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $attributes){ |
|
252 | + $button=new HtmlButton($id, $caption, $cssStyle); |
|
253 | + $this->_buttonAsSubmit($button, "click", $url, $responseElement, @$attributes["ajax"]); |
|
254 | 254 | return $button; |
255 | - }, $index,$attributes,"submit"); |
|
255 | + }, $index, $attributes, "submit"); |
|
256 | 256 | } |
257 | 257 | |
258 | - public function fieldAsButton($index,$cssStyle=NULL,$attributes=NULL){ |
|
259 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($cssStyle){ |
|
260 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
258 | + public function fieldAsButton($index, $cssStyle=NULL, $attributes=NULL) { |
|
259 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle){ |
|
260 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
261 | 261 | return $button; |
262 | - }, $index,$attributes,"button"); |
|
262 | + }, $index, $attributes, "button"); |
|
263 | 263 | } |
264 | 264 | } |
265 | 265 | \ No newline at end of file |
@@ -62,8 +62,7 @@ discard block |
||
62 | 62 | $rules=$attributes["rules"]; |
63 | 63 | if(\is_array($rules)){ |
64 | 64 | $element->addRules($rules); |
65 | - } |
|
66 | - else{ |
|
65 | + } else{ |
|
67 | 66 | $element->addRule($rules); |
68 | 67 | } |
69 | 68 | unset($attributes["rules"]); |
@@ -123,8 +122,9 @@ discard block |
||
123 | 122 | public function fieldAsHeader($index,$niveau=1,$icon=NULL,$attributes=NULL){ |
124 | 123 | return $this->_fieldAs(function($id,$name,$value) use($niveau,$icon){ |
125 | 124 | $header=new HtmlHeader($id,$niveau,$value); |
126 | - if(isset($icon)) |
|
127 | - $header->asIcon($icon, $value); |
|
125 | + if(isset($icon)) { |
|
126 | + $header->asIcon($icon, $value); |
|
127 | + } |
|
128 | 128 | return $header; |
129 | 129 | }, $index,$attributes,"header"); |
130 | 130 | } |
@@ -132,7 +132,9 @@ discard block |
||
132 | 132 | |
133 | 133 | public function fieldAsImage($index,$size=Size::MINI,$circular=false){ |
134 | 134 | $this->setValueFunction($index,function($img) use($size,$circular){ |
135 | - $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular(); |
|
135 | + $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular) { |
|
136 | + $image->setCircular(); |
|
137 | + } |
|
136 | 138 | return $image; |
137 | 139 | }); |
138 | 140 | return $this; |
@@ -221,14 +223,14 @@ discard block |
||
221 | 223 | $i=0; |
222 | 224 | if(JArray::isAssociative($types)){ |
223 | 225 | foreach ($types as $type=>$attributes){ |
224 | - if(\is_int($type)) |
|
225 | - $this->fieldAs($i++,$attributes,[]); |
|
226 | - else{ |
|
226 | + if(\is_int($type)) { |
|
227 | + $this->fieldAs($i++,$attributes,[]); |
|
228 | + } else{ |
|
227 | 229 | $type=preg_replace('/\d/', '', $type ); |
228 | 230 | $this->fieldAs($i++,$type,$attributes); |
229 | 231 | } |
230 | 232 | } |
231 | - }else{ |
|
233 | + } else{ |
|
232 | 234 | foreach ($types as $type){ |
233 | 235 | $this->fieldAs($i++,$type); |
234 | 236 | } |
@@ -240,7 +242,7 @@ discard block |
||
240 | 242 | if(\method_exists($this, $method)){ |
241 | 243 | if(!\is_array($attributes)){ |
242 | 244 | $attributes=[$index]; |
243 | - }else{ |
|
245 | + } else{ |
|
244 | 246 | \array_unshift($attributes, $index); |
245 | 247 | } |
246 | 248 | \call_user_func_array([$this,$method], $attributes); |