@@ -55,6 +55,9 @@ discard block |
||
| 55 | 55 | return $this->_semantic; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | + /** |
|
| 59 | + * @param JsUtils $jsUtils |
|
| 60 | + */ |
|
| 58 | 61 | public function __construct($params,$jsUtils) { |
| 59 | 62 | $this->params=array(); |
| 60 | 63 | foreach ( $params as $key => $val ) { |
@@ -175,7 +178,7 @@ discard block |
||
| 175 | 178 | * |
| 176 | 179 | * @param string $element |
| 177 | 180 | * @param array $options |
| 178 | - * @return void |
|
| 181 | + * @return string |
|
| 179 | 182 | */ |
| 180 | 183 | public function sortable($element, $options=array()) { |
| 181 | 184 | if (count($options)>0) { |
@@ -307,6 +310,7 @@ discard block |
||
| 307 | 310 | |
| 308 | 311 | /** |
| 309 | 312 | * A wrapper for writing document.ready() |
| 313 | + * @param string $js |
|
| 310 | 314 | * @return string |
| 311 | 315 | */ |
| 312 | 316 | public function _document_ready($js) { |
@@ -354,6 +358,9 @@ discard block |
||
| 354 | 358 | return $value; |
| 355 | 359 | } |
| 356 | 360 | |
| 361 | + /** |
|
| 362 | + * @param string $input |
|
| 363 | + */ |
|
| 357 | 364 | private function minify($input) { |
| 358 | 365 | if(trim($input) === "") return $input; |
| 359 | 366 | return preg_replace( |
@@ -17,21 +17,21 @@ discard block |
||
| 17 | 17 | * jQuery Class |
| 18 | 18 | */ |
| 19 | 19 | class Jquery { |
| 20 | - use JqueryEventsTrait,JqueryAjaxTrait,JqueryActionsTrait; |
|
| 20 | + use JqueryEventsTrait, JqueryAjaxTrait, JqueryActionsTrait; |
|
| 21 | 21 | protected $_ui; |
| 22 | 22 | protected $_bootstrap; |
| 23 | 23 | protected $_semantic; |
| 24 | 24 | protected $libraryFile; |
| 25 | 25 | protected $_javascript_folder='js'; |
| 26 | - protected $jquery_code_for_load=array (); |
|
| 27 | - protected $jquery_code_for_compile=array (); |
|
| 26 | + protected $jquery_code_for_load=array(); |
|
| 27 | + protected $jquery_code_for_compile=array(); |
|
| 28 | 28 | protected $jquery_corner_active=FALSE; |
| 29 | 29 | protected $jquery_table_sorter_active=FALSE; |
| 30 | 30 | protected $jquery_table_sorter_pager_active=FALSE; |
| 31 | 31 | protected $jsUtils; |
| 32 | 32 | |
| 33 | - protected $jquery_events=array ( |
|
| 34 | - "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" |
|
| 33 | + protected $jquery_events=array( |
|
| 34 | + "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" |
|
| 35 | 35 | ); |
| 36 | 36 | |
| 37 | 37 | public function ui($ui=NULL) { |
@@ -55,9 +55,9 @@ discard block |
||
| 55 | 55 | return $this->_semantic; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - public function __construct($params,$jsUtils) { |
|
| 58 | + public function __construct($params, $jsUtils) { |
|
| 59 | 59 | $this->params=array(); |
| 60 | - foreach ( $params as $key => $val ) { |
|
| 60 | + foreach ($params as $key => $val) { |
|
| 61 | 61 | $this->params[$key]=$params[$key]; |
| 62 | 62 | } |
| 63 | 63 | $this->jsUtils=$jsUtils; |
@@ -125,12 +125,12 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | public function _output($array_js='') { |
| 127 | 127 | if (!is_array($array_js)) { |
| 128 | - $array_js=array ( |
|
| 128 | + $array_js=array( |
|
| 129 | 129 | $array_js |
| 130 | 130 | ); |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - foreach ( $array_js as $js ) { |
|
| 133 | + foreach ($array_js as $js) { |
|
| 134 | 134 | $this->jquery_code_for_compile[]="\t$js\n"; |
| 135 | 135 | } |
| 136 | 136 | } |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | * @param string $param |
| 143 | 143 | * @param boolean $immediatly delayed if false |
| 144 | 144 | */ |
| 145 | - public function _genericCallValue($jQueryCall,$element='this', $param="", $immediatly=false) { |
|
| 145 | + public function _genericCallValue($jQueryCall, $element='this', $param="", $immediatly=false) { |
|
| 146 | 146 | $element=$this->_prep_element($element); |
| 147 | 147 | if (isset($param)) { |
| 148 | 148 | $param=$this->_prep_value($param); |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | * @param boolean $immediatly delayed if false |
| 162 | 162 | * @return string |
| 163 | 163 | */ |
| 164 | - public function _genericCallElement($jQueryCall,$to='this', $element, $immediatly=false) { |
|
| 164 | + public function _genericCallElement($jQueryCall, $to='this', $element, $immediatly=false) { |
|
| 165 | 165 | $to=$this->_prep_element($to); |
| 166 | 166 | $element=$this->_prep_element($element); |
| 167 | 167 | $str="$({$to}).{$jQueryCall}({$element});"; |
@@ -179,8 +179,8 @@ discard block |
||
| 179 | 179 | */ |
| 180 | 180 | public function sortable($element, $options=array()) { |
| 181 | 181 | if (count($options)>0) { |
| 182 | - $sort_options=array (); |
|
| 183 | - foreach ( $options as $k => $v ) { |
|
| 182 | + $sort_options=array(); |
|
| 183 | + foreach ($options as $k => $v) { |
|
| 184 | 184 | $sort_options[]="\n\t\t".$k.': '.$v.""; |
| 185 | 185 | } |
| 186 | 186 | $sort_options=implode(",", $sort_options); |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | * @param boolean $stopPropagation Prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event. |
| 213 | 213 | * @return string |
| 214 | 214 | */ |
| 215 | - public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true) { |
|
| 215 | + public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true) { |
|
| 216 | 216 | if (is_array($js)) { |
| 217 | 217 | $js=implode("\n\t\t", $js); |
| 218 | 218 | } |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | $event="\n\t$(".$this->_prep_element($element).").bind('{$event}',function(event){\n\t\t{$js}\n\t});\n"; |
| 227 | 227 | else |
| 228 | 228 | $event="\n\t$(".$this->_prep_element($element).").{$event}(function(event){\n\t\t{$js}\n\t});\n"; |
| 229 | - if($immediatly) |
|
| 229 | + if ($immediatly) |
|
| 230 | 230 | $this->jquery_code_for_compile[]=$event; |
| 231 | 231 | return $event; |
| 232 | 232 | } |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | |
| 267 | 267 | // External references |
| 268 | 268 | $external_scripts=implode('', $this->jquery_code_for_load); |
| 269 | - extract(array ( |
|
| 269 | + extract(array( |
|
| 270 | 270 | 'library_src' => $external_scripts |
| 271 | 271 | )); |
| 272 | 272 | |
@@ -281,13 +281,13 @@ discard block |
||
| 281 | 281 | $script.='});'; |
| 282 | 282 | |
| 283 | 283 | $this->jquery_code_for_compile=array(); |
| 284 | - if($this->params["debug"]==false){ |
|
| 284 | + if ($this->params["debug"]==false) { |
|
| 285 | 285 | $script=$this->minify($script); |
| 286 | 286 | } |
| 287 | 287 | $output=($script_tags===FALSE) ? $script : $this->inline($script); |
| 288 | 288 | |
| 289 | - if ($view!==NULL){ |
|
| 290 | - $this->jsUtils->createScriptVariable($view,$view_var, $output); |
|
| 289 | + if ($view!==NULL) { |
|
| 290 | + $this->jsUtils->createScriptVariable($view, $view_var, $output); |
|
| 291 | 291 | } |
| 292 | 292 | return $output; |
| 293 | 293 | } |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | * @return void |
| 303 | 303 | */ |
| 304 | 304 | public function _clear_compile() { |
| 305 | - $this->jquery_code_for_compile=array (); |
|
| 305 | + $this->jquery_code_for_compile=array(); |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | /** |
@@ -311,12 +311,12 @@ discard block |
||
| 311 | 311 | */ |
| 312 | 312 | public function _document_ready($js) { |
| 313 | 313 | if (!is_array($js)) { |
| 314 | - $js=array ( |
|
| 314 | + $js=array( |
|
| 315 | 315 | $js |
| 316 | 316 | ); |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | - foreach ( $js as $script ) { |
|
| 319 | + foreach ($js as $script) { |
|
| 320 | 320 | $this->jquery_code_for_compile[]=$script; |
| 321 | 321 | } |
| 322 | 322 | } |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | * @return string |
| 331 | 331 | */ |
| 332 | 332 | public function _prep_element($element) { |
| 333 | - if (strrpos($element, 'this')===false&&strrpos($element, 'event')===false&&strrpos($element, 'self')===false) { |
|
| 333 | + if (strrpos($element, 'this')===false && strrpos($element, 'event')===false && strrpos($element, 'self')===false) { |
|
| 334 | 334 | $element='"'.addslashes($element).'"'; |
| 335 | 335 | } |
| 336 | 336 | return $element; |
@@ -348,14 +348,14 @@ discard block |
||
| 348 | 348 | if (is_array($value)) { |
| 349 | 349 | $value=implode(",", $value); |
| 350 | 350 | } |
| 351 | - if (strrpos($value, 'this')===false&&strrpos($value, 'event')===false&&strrpos($value, 'self')===false) { |
|
| 351 | + if (strrpos($value, 'this')===false && strrpos($value, 'event')===false && strrpos($value, 'self')===false) { |
|
| 352 | 352 | $value='"'.$value.'"'; |
| 353 | 353 | } |
| 354 | 354 | return $value; |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | private function minify($input) { |
| 358 | - if(trim($input) === "") return $input; |
|
| 358 | + if (trim($input)==="") return $input; |
|
| 359 | 359 | return preg_replace( |
| 360 | 360 | array( |
| 361 | 361 | // Remove comment(s) |
@@ -147,10 +147,12 @@ discard block |
||
| 147 | 147 | if (isset($param)) { |
| 148 | 148 | $param=$this->_prep_value($param); |
| 149 | 149 | $str="$({$element}).{$jQueryCall}({$param});"; |
| 150 | - } else |
|
| 151 | - $str="$({$element}).{$jQueryCall}();"; |
|
| 152 | - if ($immediatly) |
|
| 153 | - $this->jquery_code_for_compile[]=$str; |
|
| 150 | + } else { |
|
| 151 | + $str="$({$element}).{$jQueryCall}();"; |
|
| 152 | + } |
|
| 153 | + if ($immediatly) { |
|
| 154 | + $this->jquery_code_for_compile[]=$str; |
|
| 155 | + } |
|
| 154 | 156 | return $str; |
| 155 | 157 | } |
| 156 | 158 | /** |
@@ -165,8 +167,9 @@ discard block |
||
| 165 | 167 | $to=$this->_prep_element($to); |
| 166 | 168 | $element=$this->_prep_element($element); |
| 167 | 169 | $str="$({$to}).{$jQueryCall}({$element});"; |
| 168 | - if ($immediatly) |
|
| 169 | - $this->jquery_code_for_compile[]=$str; |
|
| 170 | + if ($immediatly) { |
|
| 171 | + $this->jquery_code_for_compile[]=$str; |
|
| 172 | + } |
|
| 170 | 173 | return $str; |
| 171 | 174 | } |
| 172 | 175 | |
@@ -222,12 +225,14 @@ discard block |
||
| 222 | 225 | if ($stopPropagation===true) { |
| 223 | 226 | $js="event.stopPropagation();\n".$js; |
| 224 | 227 | } |
| 225 | - if (array_search($event, $this->jquery_events)===false) |
|
| 226 | - $event="\n\t$(".$this->_prep_element($element).").bind('{$event}',function(event){\n\t\t{$js}\n\t});\n"; |
|
| 227 | - else |
|
| 228 | - $event="\n\t$(".$this->_prep_element($element).").{$event}(function(event){\n\t\t{$js}\n\t});\n"; |
|
| 229 | - if($immediatly) |
|
| 230 | - $this->jquery_code_for_compile[]=$event; |
|
| 228 | + if (array_search($event, $this->jquery_events)===false) { |
|
| 229 | + $event="\n\t$(".$this->_prep_element($element).").bind('{$event}',function(event){\n\t\t{$js}\n\t});\n"; |
|
| 230 | + } else { |
|
| 231 | + $event="\n\t$(".$this->_prep_element($element).").{$event}(function(event){\n\t\t{$js}\n\t});\n"; |
|
| 232 | + } |
|
| 233 | + if($immediatly) { |
|
| 234 | + $this->jquery_code_for_compile[]=$event; |
|
| 235 | + } |
|
| 231 | 236 | return $event; |
| 232 | 237 | } |
| 233 | 238 | |
@@ -355,7 +360,9 @@ discard block |
||
| 355 | 360 | } |
| 356 | 361 | |
| 357 | 362 | private function minify($input) { |
| 358 | - if(trim($input) === "") return $input; |
|
| 363 | + if(trim($input) === "") { |
|
| 364 | + return $input; |
|
| 365 | + } |
|
| 359 | 366 | return preg_replace( |
| 360 | 367 | array( |
| 361 | 368 | // Remove comment(s) |
@@ -429,7 +429,7 @@ |
||
| 429 | 429 | * |
| 430 | 430 | * @access public |
| 431 | 431 | * @param array an associative array of key/values |
| 432 | - * @return array |
|
| 432 | + * @return string |
|
| 433 | 433 | * |
| 434 | 434 | */ |
| 435 | 435 | function assoc_to_uri($array) { |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | * @access public |
| 11 | 11 | * |
| 12 | 12 | */ |
| 13 | - var $keyval=array (); |
|
| 13 | + var $keyval=array(); |
|
| 14 | 14 | /** |
| 15 | 15 | * Current uri string |
| 16 | 16 | * |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | * @access public |
| 27 | 27 | * |
| 28 | 28 | */ |
| 29 | - var $segments=array (); |
|
| 29 | + var $segments=array(); |
|
| 30 | 30 | /** |
| 31 | 31 | * Re-indexed list of uri segments |
| 32 | 32 | * Starts at 1 instead of 0 |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * @access public |
| 36 | 36 | * |
| 37 | 37 | */ |
| 38 | - var $rsegments=array (); |
|
| 38 | + var $rsegments=array(); |
|
| 39 | 39 | var $permitted_uri_chars="a-z 0-9~%.:_\-"; |
| 40 | 40 | var $enable_query_strings=false; |
| 41 | 41 | |
@@ -75,9 +75,9 @@ discard block |
||
| 75 | 75 | */ |
| 76 | 76 | function _fetch_uri_string() { |
| 77 | 77 | $uri=""; |
| 78 | - if ($this->uri_protocol == 'AUTO') { |
|
| 78 | + if ($this->uri_protocol=='AUTO') { |
|
| 79 | 79 | // Is the request coming from the command line? |
| 80 | - if (php_sapi_name() == 'cli' or defined('STDIN')) { |
|
| 80 | + if (php_sapi_name()=='cli' or defined('STDIN')) { |
|
| 81 | 81 | $this->_set_uri_string($this->_parse_cli_args()); |
| 82 | 82 | return; |
| 83 | 83 | } |
@@ -91,20 +91,20 @@ discard block |
||
| 91 | 91 | // Is there a PATH_INFO variable? |
| 92 | 92 | // Note: some servers seem to have trouble with getenv() so we'll test it two ways |
| 93 | 93 | $path=(isset($_SERVER['PATH_INFO'])) ? $_SERVER['PATH_INFO'] : @getenv('PATH_INFO'); |
| 94 | - if (trim($path, '/') != '' && $path != "/" . SELF) { |
|
| 94 | + if (trim($path, '/')!='' && $path!="/".SELF) { |
|
| 95 | 95 | $this->_set_uri_string($path); |
| 96 | 96 | return; |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | // No PATH_INFO?... What about QUERY_STRING? |
| 100 | 100 | $path=(isset($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : @getenv('QUERY_STRING'); |
| 101 | - if (trim($path, '/') != '') { |
|
| 101 | + if (trim($path, '/')!='') { |
|
| 102 | 102 | $this->_set_uri_string($path); |
| 103 | 103 | return; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | // As a last ditch effort lets try using the $_GET array |
| 107 | - if (is_array($_GET) && count($_GET) == 1 && trim(key($_GET), '/') != '') { |
|
| 107 | + if (is_array($_GET) && count($_GET)==1 && trim(key($_GET), '/')!='') { |
|
| 108 | 108 | $this->_set_uri_string(key($_GET)); |
| 109 | 109 | return; |
| 110 | 110 | } |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | return; |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - if ($uri == 'REQUEST_URI') { |
|
| 117 | + if ($uri=='REQUEST_URI') { |
|
| 118 | 118 | $this->_set_uri_string($this->_detect_uri()); |
| 119 | 119 | return; |
| 120 | 120 | } |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | // $str = remove_invisible_characters($str, FALSE); |
| 139 | 139 | |
| 140 | 140 | // If the URI contains only a slash we'll kill it |
| 141 | - $this->uri_string=($str == '/') ? '' : $str; |
|
| 141 | + $this->uri_string=($str=='/') ? '' : $str; |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | // -------------------------------------------------------------------- |
@@ -159,15 +159,15 @@ discard block |
||
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | $uri=$_SERVER['REQUEST_URI']; |
| 162 | - if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0) { |
|
| 162 | + if (strpos($uri, $_SERVER['SCRIPT_NAME'])===0) { |
|
| 163 | 163 | $uri=substr($uri, strlen($_SERVER['SCRIPT_NAME'])); |
| 164 | - } elseif (strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0) { |
|
| 164 | + } elseif (strpos($uri, dirname($_SERVER['SCRIPT_NAME']))===0) { |
|
| 165 | 165 | $uri=substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME']))); |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | // This section ensures that even on servers that require the URI to be in the query string (Nginx) a correct |
| 169 | 169 | // URI is found, and also fixes the QUERY_STRING server var and $_GET array. |
| 170 | - if (strncmp($uri, '?/', 2) === 0) { |
|
| 170 | + if (strncmp($uri, '?/', 2)===0) { |
|
| 171 | 171 | $uri=substr($uri, 2); |
| 172 | 172 | } |
| 173 | 173 | $parts=preg_split('#\?#i', $uri, 2); |
@@ -177,17 +177,17 @@ discard block |
||
| 177 | 177 | parse_str($_SERVER['QUERY_STRING'], $_GET); |
| 178 | 178 | } else { |
| 179 | 179 | $_SERVER['QUERY_STRING']=''; |
| 180 | - $_GET=array (); |
|
| 180 | + $_GET=array(); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - if ($uri == '/' || empty($uri)) { |
|
| 183 | + if ($uri=='/' || empty($uri)) { |
|
| 184 | 184 | return '/'; |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | $uri=parse_url($uri, PHP_URL_PATH); |
| 188 | 188 | |
| 189 | 189 | // Do some final cleaning of the URI and return it |
| 190 | - return str_replace(array ('//','../' ), '/', trim($uri, '/')); |
|
| 190 | + return str_replace(array('//', '../'), '/', trim($uri, '/')); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | // -------------------------------------------------------------------- |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | private function _parse_cli_args() { |
| 205 | 205 | $args=array_slice($_SERVER['argv'], 1); |
| 206 | 206 | |
| 207 | - return $args ? '/' . implode('/', $args) : ''; |
|
| 207 | + return $args ? '/'.implode('/', $args) : ''; |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | // -------------------------------------------------------------------- |
@@ -218,17 +218,17 @@ discard block |
||
| 218 | 218 | * |
| 219 | 219 | */ |
| 220 | 220 | function _filter_uri($str) { |
| 221 | - if ($str != '' && $this->permitted_uri_chars != '' && $this->enable_query_strings == FALSE) { |
|
| 221 | + if ($str!='' && $this->permitted_uri_chars!='' && $this->enable_query_strings==FALSE) { |
|
| 222 | 222 | // preg_quote() in PHP 5.3 escapes -, so the str_replace() and addition of - to preg_quote() is to maintain backwards |
| 223 | 223 | // compatibility as many are unaware of how characters in the permitted_uri_chars will be parsed as a regex pattern |
| 224 | - if (!preg_match("|^[" . str_replace(array ('\\-','\-' ), '-', preg_quote($this->permitted_uri_chars, '-')) . "]+$|i", $str)) { |
|
| 224 | + if (!preg_match("|^[".str_replace(array('\\-', '\-'), '-', preg_quote($this->permitted_uri_chars, '-'))."]+$|i", $str)) { |
|
| 225 | 225 | show_error('The URI you submitted has disallowed characters.', 400); |
| 226 | 226 | } |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | // Convert programatic characters to entities |
| 230 | - $bad=array ('$','(',')','%28','%29' ); |
|
| 231 | - $good=array ('$','(',')','(',')' ); |
|
| 230 | + $bad=array('$', '(', ')', '%28', '%29'); |
|
| 231 | + $good=array('$', '(', ')', '(', ')'); |
|
| 232 | 232 | |
| 233 | 233 | return str_replace($bad, $good, $str); |
| 234 | 234 | } |
@@ -243,11 +243,11 @@ discard block |
||
| 243 | 243 | * |
| 244 | 244 | */ |
| 245 | 245 | function _explode_segments() { |
| 246 | - foreach ( explode("/", preg_replace("|/*(.+?)/*$|", "\\1", $this->uri_string)) as $val ) { |
|
| 246 | + foreach (explode("/", preg_replace("|/*(.+?)/*$|", "\\1", $this->uri_string)) as $val) { |
|
| 247 | 247 | // Filter segments for security |
| 248 | 248 | $val=trim($this->_filter_uri($val)); |
| 249 | 249 | |
| 250 | - if ($val != '') { |
|
| 250 | + if ($val!='') { |
|
| 251 | 251 | $this->segments[]=$val; |
| 252 | 252 | } |
| 253 | 253 | } |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | * |
| 365 | 365 | */ |
| 366 | 366 | function _uri_to_assoc($n=3, $default=array(), $which='segment') { |
| 367 | - if ($which == 'segment') { |
|
| 367 | + if ($which=='segment') { |
|
| 368 | 368 | $total_segments='total_segments'; |
| 369 | 369 | $segment_array='segment_array'; |
| 370 | 370 | } else { |
@@ -380,25 +380,25 @@ discard block |
||
| 380 | 380 | return $this->keyval[$n]; |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | - if ($this->$total_segments() < $n) { |
|
| 384 | - if (count($default) == 0) { |
|
| 385 | - return array (); |
|
| 383 | + if ($this->$total_segments()<$n) { |
|
| 384 | + if (count($default)==0) { |
|
| 385 | + return array(); |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | - $retval=array (); |
|
| 389 | - foreach ( $default as $val ) { |
|
| 388 | + $retval=array(); |
|
| 389 | + foreach ($default as $val) { |
|
| 390 | 390 | $retval[$val]=FALSE; |
| 391 | 391 | } |
| 392 | 392 | return $retval; |
| 393 | 393 | } |
| 394 | 394 | |
| 395 | - $segments=array_slice($this->$segment_array(), ($n - 1)); |
|
| 395 | + $segments=array_slice($this->$segment_array(), ($n-1)); |
|
| 396 | 396 | |
| 397 | 397 | $i=0; |
| 398 | 398 | $lastval=''; |
| 399 | - $retval=array (); |
|
| 400 | - foreach ( $segments as $seg ) { |
|
| 401 | - if ($i % 2) { |
|
| 399 | + $retval=array(); |
|
| 400 | + foreach ($segments as $seg) { |
|
| 401 | + if ($i%2) { |
|
| 402 | 402 | $retval[$lastval]=$seg; |
| 403 | 403 | } else { |
| 404 | 404 | $retval[$seg]=FALSE; |
@@ -408,8 +408,8 @@ discard block |
||
| 408 | 408 | $i++; |
| 409 | 409 | } |
| 410 | 410 | |
| 411 | - if (count($default) > 0) { |
|
| 412 | - foreach ( $default as $val ) { |
|
| 411 | + if (count($default)>0) { |
|
| 412 | + foreach ($default as $val) { |
|
| 413 | 413 | if (!array_key_exists($val, $retval)) { |
| 414 | 414 | $retval[$val]=FALSE; |
| 415 | 415 | } |
@@ -433,8 +433,8 @@ discard block |
||
| 433 | 433 | * |
| 434 | 434 | */ |
| 435 | 435 | function assoc_to_uri($array) { |
| 436 | - $temp=array (); |
|
| 437 | - foreach ( ( array ) $array as $key => $val ) { |
|
| 436 | + $temp=array(); |
|
| 437 | + foreach ((array)$array as $key => $val) { |
|
| 438 | 438 | $temp[]=$key; |
| 439 | 439 | $temp[]=$val; |
| 440 | 440 | } |
@@ -488,13 +488,13 @@ discard block |
||
| 488 | 488 | $leading='/'; |
| 489 | 489 | $trailing='/'; |
| 490 | 490 | |
| 491 | - if ($where == 'trailing') { |
|
| 491 | + if ($where=='trailing') { |
|
| 492 | 492 | $leading=''; |
| 493 | - } elseif ($where == 'leading') { |
|
| 493 | + } elseif ($where=='leading') { |
|
| 494 | 494 | $trailing=''; |
| 495 | 495 | } |
| 496 | 496 | |
| 497 | - return $leading . $this->$which($n) . $trailing; |
|
| 497 | + return $leading.$this->$which($n).$trailing; |
|
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | // -------------------------------------------------------------------- |
@@ -572,7 +572,7 @@ discard block |
||
| 572 | 572 | * |
| 573 | 573 | */ |
| 574 | 574 | function ruri_string() { |
| 575 | - return '/' . implode('/', $this->rsegment_array()); |
|
| 575 | + return '/'.implode('/', $this->rsegment_array()); |
|
| 576 | 576 | } |
| 577 | 577 | } |
| 578 | 578 | // END URI Class |
| 579 | 579 | \ No newline at end of file |
@@ -22,6 +22,11 @@ discard block |
||
| 22 | 22 | protected $_contentSeparator=""; |
| 23 | 23 | |
| 24 | 24 | |
| 25 | + /** |
|
| 26 | + * @param string $identifier |
|
| 27 | + * @param string $tagName |
|
| 28 | + * @param string $baseClass |
|
| 29 | + */ |
|
| 25 | 30 | public function __construct($identifier,$tagName,$baseClass){ |
| 26 | 31 | parent::__construct($identifier,$tagName,$baseClass); |
| 27 | 32 | $this->root=""; |
@@ -31,7 +36,7 @@ discard block |
||
| 31 | 36 | /** |
| 32 | 37 | * Associate an ajax get to the elements, displayed in $targetSelector |
| 33 | 38 | * @param string $targetSelector the target of the get |
| 34 | - * @return HtmlNavElement |
|
| 39 | + * @return HtmlSemNavElement |
|
| 35 | 40 | */ |
| 36 | 41 | public function autoGetOnClick($targetSelector){ |
| 37 | 42 | return $this->getOnClick($this->root, $targetSelector,array("attr"=>$this->attr)); |
@@ -63,7 +68,7 @@ discard block |
||
| 63 | 68 | /** |
| 64 | 69 | * Define the html attribute for each element url in ajax |
| 65 | 70 | * @param string $attr html attribute |
| 66 | - * @return HtmlNavElement |
|
| 71 | + * @return HtmlSemNavElement |
|
| 67 | 72 | */ |
| 68 | 73 | public function setAttr($attr) { |
| 69 | 74 | $this->attr = $attr; |
@@ -103,6 +108,9 @@ discard block |
||
| 103 | 108 | return $this; |
| 104 | 109 | } |
| 105 | 110 | |
| 111 | + /** |
|
| 112 | + * @param integer $index |
|
| 113 | + */ |
|
| 106 | 114 | protected function getContentDivider($index){ |
| 107 | 115 | if(\is_array($this->_contentSeparator)===true){ |
| 108 | 116 | return @$this->_contentSeparator[$index]; |
@@ -22,8 +22,8 @@ discard block |
||
| 22 | 22 | protected $_contentSeparator=""; |
| 23 | 23 | |
| 24 | 24 | |
| 25 | - public function __construct($identifier,$tagName,$baseClass){ |
|
| 26 | - parent::__construct($identifier,$tagName,$baseClass); |
|
| 25 | + public function __construct($identifier, $tagName, $baseClass) { |
|
| 26 | + parent::__construct($identifier, $tagName, $baseClass); |
|
| 27 | 27 | $this->root=""; |
| 28 | 28 | $this->attr="data-ajax"; |
| 29 | 29 | } |
@@ -33,11 +33,11 @@ discard block |
||
| 33 | 33 | * @param string $targetSelector the target of the get |
| 34 | 34 | * @return HtmlNavElement |
| 35 | 35 | */ |
| 36 | - public function autoGetOnClick($targetSelector){ |
|
| 37 | - return $this->getOnClick($this->root, $targetSelector,array("attr"=>$this->attr)); |
|
| 36 | + public function autoGetOnClick($targetSelector) { |
|
| 37 | + return $this->getOnClick($this->root, $targetSelector, array("attr"=>$this->attr)); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - public function contentAsString(){ |
|
| 40 | + public function contentAsString() { |
|
| 41 | 41 | return JArray::implode($this->_contentSeparator, $this->content); |
| 42 | 42 | } |
| 43 | 43 | |
@@ -45,15 +45,15 @@ discard block |
||
| 45 | 45 | * Generate the jquery script to set the elements to the HtmlNavElement |
| 46 | 46 | * @param JsUtils $jsUtils |
| 47 | 47 | */ |
| 48 | - public function jsSetContent(JsUtils $jsUtils){ |
|
| 49 | - $jsUtils->html("#".$this->identifier,str_replace("\"","'", $this->contentAsString()),true); |
|
| 48 | + public function jsSetContent(JsUtils $jsUtils) { |
|
| 49 | + $jsUtils->html("#".$this->identifier, str_replace("\"", "'", $this->contentAsString()), true); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | public function getRoot() { |
| 53 | 53 | return $this->root; |
| 54 | 54 | } |
| 55 | 55 | public function setRoot($root) { |
| 56 | - $this->root = $root; |
|
| 56 | + $this->root=$root; |
|
| 57 | 57 | return $this; |
| 58 | 58 | } |
| 59 | 59 | public function getAttr() { |
@@ -66,12 +66,12 @@ discard block |
||
| 66 | 66 | * @return HtmlNavElement |
| 67 | 67 | */ |
| 68 | 68 | public function setAttr($attr) { |
| 69 | - $this->attr = $attr; |
|
| 69 | + $this->attr=$attr; |
|
| 70 | 70 | return $this; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | public function __call($method, $args) { |
| 74 | - if(isset($this->$method) && is_callable($this->$method)) { |
|
| 74 | + if (isset($this->$method) && is_callable($this->$method)) { |
|
| 75 | 75 | return call_user_func_array( |
| 76 | 76 | $this->$method, |
| 77 | 77 | $args |
@@ -79,32 +79,32 @@ discard block |
||
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - public abstract function fromDispatcher(JsUtils $js,$dispatcher, $startIndex=0); |
|
| 82 | + public abstract function fromDispatcher(JsUtils $js, $dispatcher, $startIndex=0); |
|
| 83 | 83 | |
| 84 | 84 | |
| 85 | - public function setContentDivider($divider,$index=NULL) { |
|
| 85 | + public function setContentDivider($divider, $index=NULL) { |
|
| 86 | 86 | $divider="<div class='divider'> {$divider} </div>"; |
| 87 | 87 | return $this->setDivider($divider, $index); |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - public function setIconContentDivider($iconContentDivider,$index=NULL) { |
|
| 90 | + public function setIconContentDivider($iconContentDivider, $index=NULL) { |
|
| 91 | 91 | $contentDivider="<i class='".$iconContentDivider." icon divider'></i>"; |
| 92 | 92 | return $this->setDivider($contentDivider, $index); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - protected function setDivider($divider,$index){ |
|
| 96 | - if(isset($index)){ |
|
| 97 | - if(\is_array($this->_contentSeparator)===false) |
|
| 98 | - $this->_contentSeparator=array_fill (0, $this->count()-1,$this->_contentSeparator); |
|
| 95 | + protected function setDivider($divider, $index) { |
|
| 96 | + if (isset($index)) { |
|
| 97 | + if (\is_array($this->_contentSeparator)===false) |
|
| 98 | + $this->_contentSeparator=array_fill(0, $this->count()-1, $this->_contentSeparator); |
|
| 99 | 99 | $this->_contentSeparator[$index]=$divider; |
| 100 | - }else{ |
|
| 100 | + } else { |
|
| 101 | 101 | $this->_contentSeparator=$divider; |
| 102 | 102 | } |
| 103 | 103 | return $this; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - protected function getContentDivider($index){ |
|
| 107 | - if(\is_array($this->_contentSeparator)===true){ |
|
| 106 | + protected function getContentDivider($index) { |
|
| 107 | + if (\is_array($this->_contentSeparator)===true) { |
|
| 108 | 108 | return @$this->_contentSeparator[$index]; |
| 109 | 109 | } |
| 110 | 110 | return $this->_contentSeparator; |
@@ -94,10 +94,11 @@ |
||
| 94 | 94 | |
| 95 | 95 | protected function setDivider($divider,$index){ |
| 96 | 96 | if(isset($index)){ |
| 97 | - if(\is_array($this->_contentSeparator)===false) |
|
| 98 | - $this->_contentSeparator=array_fill (0, $this->count()-1,$this->_contentSeparator); |
|
| 97 | + if(\is_array($this->_contentSeparator)===false) { |
|
| 98 | + $this->_contentSeparator=array_fill (0, $this->count()-1,$this->_contentSeparator); |
|
| 99 | + } |
|
| 99 | 100 | $this->_contentSeparator[$index]=$divider; |
| 100 | - }else{ |
|
| 101 | + } else{ |
|
| 101 | 102 | $this->_contentSeparator=$divider; |
| 102 | 103 | } |
| 103 | 104 | return $this; |
@@ -9,7 +9,6 @@ |
||
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * |
| 12 | - * @param string $side |
|
| 13 | 12 | * @return \Ajax\semantic\html\base\HtmlSemDoubleElement |
| 14 | 13 | */ |
| 15 | 14 | public function setAttachment(HtmlSemDoubleElement $toElement, $value=Side::BOTH) { |
@@ -14,8 +14,8 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | public function setAttachment(HtmlSemDoubleElement $toElement, $value=Side::BOTH) { |
| 16 | 16 | if (isset($toElement)) { |
| 17 | - $toElement->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
| 17 | + $toElement->addToPropertyCtrl("class", "attached", array("attached")); |
|
| 18 | 18 | } |
| 19 | - return $this->addToPropertyCtrl("class", $value . " attached", Side::getConstantValues("attached")); |
|
| 19 | + return $this->addToPropertyCtrl("class", $value." attached", Side::getConstantValues("attached")); |
|
| 20 | 20 | } |
| 21 | 21 | } |
| 22 | 22 | \ No newline at end of file |
@@ -12,12 +12,24 @@ |
||
| 12 | 12 | protected $_states=[ ]; |
| 13 | 13 | protected $_baseClass; |
| 14 | 14 | |
| 15 | + /** |
|
| 16 | + * @param string $name |
|
| 17 | + */ |
|
| 15 | 18 | protected abstract function setPropertyCtrl($name, $value, $typeCtrl); |
| 16 | 19 | |
| 20 | + /** |
|
| 21 | + * @param string $name |
|
| 22 | + */ |
|
| 17 | 23 | protected abstract function addToPropertyCtrl($name, $value, $typeCtrl); |
| 18 | 24 | |
| 25 | + /** |
|
| 26 | + * @param string $name |
|
| 27 | + */ |
|
| 19 | 28 | protected abstract function addToPropertyCtrlCheck($name, $value, $typeCtrl); |
| 20 | 29 | |
| 30 | + /** |
|
| 31 | + * @param string $name |
|
| 32 | + */ |
|
| 21 | 33 | public abstract function addToProperty($name, $value, $separator=" "); |
| 22 | 34 | |
| 23 | 35 | public function addVariation($variation) { |
@@ -8,8 +8,8 @@ discard block |
||
| 8 | 8 | use Ajax\semantic\html\elements\HtmlIcon; |
| 9 | 9 | |
| 10 | 10 | trait BaseTrait { |
| 11 | - protected $_variations=[ ]; |
|
| 12 | - protected $_states=[ ]; |
|
| 11 | + protected $_variations=[]; |
|
| 12 | + protected $_states=[]; |
|
| 13 | 13 | protected $_baseClass; |
| 14 | 14 | |
| 15 | 15 | protected abstract function setPropertyCtrl($name, $value, $typeCtrl); |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | $this->setProperty("class", $this->_baseClass); |
| 38 | 38 | if (\is_string($variations)) |
| 39 | 39 | $variations=\explode(" ", $variations); |
| 40 | - foreach ( $variations as $variation ) { |
|
| 40 | + foreach ($variations as $variation) { |
|
| 41 | 41 | $this->addVariation($variation); |
| 42 | 42 | } |
| 43 | 43 | return $this; |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | public function addVariations($variations=array()) { |
| 52 | 52 | if (\is_string($variations)) |
| 53 | 53 | $variations=\explode(" ", $variations); |
| 54 | - foreach ( $variations as $variation ) { |
|
| 54 | + foreach ($variations as $variation) { |
|
| 55 | 55 | $this->addVariation($variation); |
| 56 | 56 | } |
| 57 | 57 | return $this; |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | public function addStates($states=array()) { |
| 61 | 61 | if (\is_string($states)) |
| 62 | 62 | $states=\explode(" ", $states); |
| 63 | - foreach ( $states as $state ) { |
|
| 63 | + foreach ($states as $state) { |
|
| 64 | 64 | $this->addState($state); |
| 65 | 65 | } |
| 66 | 66 | return $this; |
@@ -70,14 +70,14 @@ discard block |
||
| 70 | 70 | $this->setProperty("class", $this->_baseClass); |
| 71 | 71 | if (\is_string($states)) |
| 72 | 72 | $states=\explode(" ", $states); |
| 73 | - foreach ( $states as $state ) { |
|
| 73 | + foreach ($states as $state) { |
|
| 74 | 74 | $this->addState($state); |
| 75 | 75 | } |
| 76 | 76 | return $this; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | public function addIcon($icon, $before=true) { |
| 80 | - return $this->addContent(new HtmlIcon("icon-" . $this->identifier, $icon), $before); |
|
| 80 | + return $this->addContent(new HtmlIcon("icon-".$this->identifier, $icon), $before); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | public function setFloated($direction="right") { |
| 130 | - return $this->addToPropertyCtrl("class", $direction . " floated", Direction::getConstantValues("floated")); |
|
| 130 | + return $this->addToPropertyCtrl("class", $direction." floated", Direction::getConstantValues("floated")); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | public function floatRight() { |
@@ -35,8 +35,9 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | public function setVariations($variations) { |
| 37 | 37 | $this->setProperty("class", $this->_baseClass); |
| 38 | - if (\is_string($variations)) |
|
| 39 | - $variations=\explode(" ", $variations); |
|
| 38 | + if (\is_string($variations)) { |
|
| 39 | + $variations=\explode(" ", $variations); |
|
| 40 | + } |
|
| 40 | 41 | foreach ( $variations as $variation ) { |
| 41 | 42 | $this->addVariation($variation); |
| 42 | 43 | } |
@@ -49,8 +50,9 @@ discard block |
||
| 49 | 50 | } |
| 50 | 51 | |
| 51 | 52 | public function addVariations($variations=array()) { |
| 52 | - if (\is_string($variations)) |
|
| 53 | - $variations=\explode(" ", $variations); |
|
| 53 | + if (\is_string($variations)) { |
|
| 54 | + $variations=\explode(" ", $variations); |
|
| 55 | + } |
|
| 54 | 56 | foreach ( $variations as $variation ) { |
| 55 | 57 | $this->addVariation($variation); |
| 56 | 58 | } |
@@ -58,8 +60,9 @@ discard block |
||
| 58 | 60 | } |
| 59 | 61 | |
| 60 | 62 | public function addStates($states=array()) { |
| 61 | - if (\is_string($states)) |
|
| 62 | - $states=\explode(" ", $states); |
|
| 63 | + if (\is_string($states)) { |
|
| 64 | + $states=\explode(" ", $states); |
|
| 65 | + } |
|
| 63 | 66 | foreach ( $states as $state ) { |
| 64 | 67 | $this->addState($state); |
| 65 | 68 | } |
@@ -68,8 +71,9 @@ discard block |
||
| 68 | 71 | |
| 69 | 72 | public function setStates($states) { |
| 70 | 73 | $this->setProperty("class", $this->_baseClass); |
| 71 | - if (\is_string($states)) |
|
| 72 | - $states=\explode(" ", $states); |
|
| 74 | + if (\is_string($states)) { |
|
| 75 | + $states=\explode(" ", $states); |
|
| 76 | + } |
|
| 73 | 77 | foreach ( $states as $state ) { |
| 74 | 78 | $this->addState($state); |
| 75 | 79 | } |
@@ -7,6 +7,10 @@ |
||
| 7 | 7 | trait IconTrait { |
| 8 | 8 | private $_hasIcon=false; |
| 9 | 9 | |
| 10 | + /** |
|
| 11 | + * @param string $name |
|
| 12 | + * @param string $value |
|
| 13 | + */ |
|
| 10 | 14 | protected abstract function addToPropertyCtrl($name, $value, $typeCtrl); |
| 11 | 15 | public abstract function addContent($content,$before=false); |
| 12 | 16 | |
@@ -8,18 +8,18 @@ discard block |
||
| 8 | 8 | private $_hasIcon=false; |
| 9 | 9 | |
| 10 | 10 | protected abstract function addToPropertyCtrl($name, $value, $typeCtrl); |
| 11 | - public abstract function addContent($content,$before=false); |
|
| 11 | + public abstract function addContent($content, $before=false); |
|
| 12 | 12 | |
| 13 | - public function addIcon($icon,$direction=Direction::LEFT){ |
|
| 14 | - if($this->_hasIcon===false){ |
|
| 13 | + public function addIcon($icon, $direction=Direction::LEFT) { |
|
| 14 | + if ($this->_hasIcon===false) { |
|
| 15 | 15 | $iconO=$icon; |
| 16 | - if(\is_string($icon)){ |
|
| 16 | + if (\is_string($icon)) { |
|
| 17 | 17 | $iconO=new HtmlIcon("icon-".$this->identifier, $icon); |
| 18 | 18 | } |
| 19 | 19 | $this->addToPropertyCtrl("class", $direction." icon", Direction::getConstantValues("icon")); |
| 20 | - $this->addContent($iconO,false); |
|
| 20 | + $this->addContent($iconO, false); |
|
| 21 | 21 | $this->_hasIcon=true; |
| 22 | - }else{ |
|
| 22 | + } else { |
|
| 23 | 23 | $iconO=$this->getIcon(); |
| 24 | 24 | $iconO->setIcon($icon); |
| 25 | 25 | $this->addToPropertyCtrl("class", $direction." icon", Direction::getConstantValues("icon")); |
@@ -27,10 +27,10 @@ discard block |
||
| 27 | 27 | return $iconO; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - public function getIcon(){ |
|
| 31 | - if(\is_array($this->content)){ |
|
| 32 | - foreach ($this->content as $item){ |
|
| 33 | - if($item instanceof HtmlIcon) |
|
| 30 | + public function getIcon() { |
|
| 31 | + if (\is_array($this->content)) { |
|
| 32 | + foreach ($this->content as $item) { |
|
| 33 | + if ($item instanceof HtmlIcon) |
|
| 34 | 34 | return $item; |
| 35 | 35 | } |
| 36 | 36 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | $this->addToPropertyCtrl("class", $direction." icon", Direction::getConstantValues("icon")); |
| 20 | 20 | $this->addContent($iconO,false); |
| 21 | 21 | $this->_hasIcon=true; |
| 22 | - }else{ |
|
| 22 | + } else{ |
|
| 23 | 23 | $iconO=$this->getIcon(); |
| 24 | 24 | $iconO->setIcon($icon); |
| 25 | 25 | $this->addToPropertyCtrl("class", $direction." icon", Direction::getConstantValues("icon")); |
@@ -30,8 +30,9 @@ discard block |
||
| 30 | 30 | public function getIcon(){ |
| 31 | 31 | if(\is_array($this->content)){ |
| 32 | 32 | foreach ($this->content as $item){ |
| 33 | - if($item instanceof HtmlIcon) |
|
| 34 | - return $item; |
|
| 33 | + if($item instanceof HtmlIcon) { |
|
| 34 | + return $item; |
|
| 35 | + } |
|
| 35 | 36 | } |
| 36 | 37 | } |
| 37 | 38 | } |
@@ -15,6 +15,9 @@ |
||
| 15 | 15 | protected $_equalWidth; |
| 16 | 16 | protected $_name; |
| 17 | 17 | |
| 18 | + /** |
|
| 19 | + * @param string $identifier |
|
| 20 | + */ |
|
| 18 | 21 | public function __construct($identifier, $fields=array(), $equalWidth=true) { |
| 19 | 22 | parent::__construct($identifier, "div"); |
| 20 | 23 | $this->_equalWidth=$equalWidth; |
@@ -5,7 +5,6 @@ |
||
| 5 | 5 | use Ajax\semantic\html\base\HtmlSemCollection; |
| 6 | 6 | use Ajax\semantic\html\base\constants\Wide; |
| 7 | 7 | use Ajax\JsUtils; |
| 8 | - |
|
| 9 | 8 | use Ajax\semantic\html\base\HtmlSemDoubleElement; |
| 10 | 9 | use Ajax\semantic\html\collections\form\traits\FieldsTrait; |
| 11 | 10 | |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | } |
| 36 | 36 | if (isset($label)) |
| 37 | 37 | $this->setLabel($label); |
| 38 | - foreach ( $fields as $field ) { |
|
| 38 | + foreach ($fields as $field) { |
|
| 39 | 39 | $this->addItem($field); |
| 40 | 40 | } |
| 41 | 41 | return $this; |
@@ -96,9 +96,9 @@ discard block |
||
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | public static function radios($name, $items=array(), $label=NULL, $value=null, $type=NULL) { |
| 99 | - $fields=array (); |
|
| 99 | + $fields=array(); |
|
| 100 | 100 | $i=0; |
| 101 | - foreach ( $items as $val => $caption ) { |
|
| 101 | + foreach ($items as $val => $caption) { |
|
| 102 | 102 | $itemO=new HtmlFormRadio($name."-".$i++, $name, $caption, $val, $type); |
| 103 | 103 | if ($val===$value) { |
| 104 | 104 | $itemO->getField()->getField()->setProperty("checked", ""); |
@@ -112,9 +112,9 @@ discard block |
||
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | public static function checkeds($name, $items=array(), $label=NULL, $values=array(), $type=NULL) { |
| 115 | - $fields=array (); |
|
| 115 | + $fields=array(); |
|
| 116 | 116 | $i=0; |
| 117 | - foreach ( $items as $val => $caption ) { |
|
| 117 | + foreach ($items as $val => $caption) { |
|
| 118 | 118 | $itemO=new HtmlFormCheckbox($name."-".$i++, $name, $caption, $val, $type); |
| 119 | 119 | if (\array_search($val, $values)!==false) { |
| 120 | 120 | $itemO->getField()->getField()->setProperty("checked", ""); |
@@ -29,12 +29,14 @@ discard block |
||
| 29 | 29 | if (\is_string($end)) { |
| 30 | 30 | $label=$end; |
| 31 | 31 | \array_pop($fields); |
| 32 | - } else |
|
| 33 | - $label=NULL; |
|
| 32 | + } else { |
|
| 33 | + $label=NULL; |
|
| 34 | + } |
|
| 34 | 35 | } |
| 35 | 36 | } |
| 36 | - if (isset($label)) |
|
| 37 | - $this->setLabel($label); |
|
| 37 | + if (isset($label)) { |
|
| 38 | + $this->setLabel($label); |
|
| 39 | + } |
|
| 38 | 40 | foreach ( $fields as $field ) { |
| 39 | 41 | $this->addItem($field); |
| 40 | 42 | } |
@@ -65,8 +67,9 @@ discard block |
||
| 65 | 67 | if ($this->_equalWidth) { |
| 66 | 68 | $count=$this->count(); |
| 67 | 69 | $this->addToProperty("class", Wide::getConstants()["W".$count]." fields"); |
| 68 | - } else |
|
| 69 | - $this->addToProperty("class", "fields"); |
|
| 70 | + } else { |
|
| 71 | + $this->addToProperty("class", "fields"); |
|
| 72 | + } |
|
| 70 | 73 | return parent::compile($js, $view); |
| 71 | 74 | } |
| 72 | 75 | |
@@ -106,8 +109,9 @@ discard block |
||
| 106 | 109 | $fields[]=$itemO; |
| 107 | 110 | } |
| 108 | 111 | $radios=new HtmlFormFields("fields-".$name, $fields); |
| 109 | - if (isset($label)) |
|
| 110 | - $radios->setLabel($label)->setProperty("for", $name); |
|
| 112 | + if (isset($label)) { |
|
| 113 | + $radios->setLabel($label)->setProperty("for", $name); |
|
| 114 | + } |
|
| 111 | 115 | return $radios; |
| 112 | 116 | } |
| 113 | 117 | |
@@ -122,8 +126,9 @@ discard block |
||
| 122 | 126 | $fields[]=$itemO; |
| 123 | 127 | } |
| 124 | 128 | $radios=new HtmlFormFields("fields-".$name, $fields); |
| 125 | - if (isset($label)) |
|
| 126 | - $radios->setLabel($label)->setProperty("for", $name); |
|
| 129 | + if (isset($label)) { |
|
| 130 | + $radios->setLabel($label)->setProperty("for", $name); |
|
| 131 | + } |
|
| 127 | 132 | return $radios; |
| 128 | 133 | } |
| 129 | 134 | |
@@ -6,6 +6,9 @@ |
||
| 6 | 6 | |
| 7 | 7 | trait CheckboxTrait { |
| 8 | 8 | |
| 9 | + /** |
|
| 10 | + * @param string $name |
|
| 11 | + */ |
|
| 9 | 12 | public abstract function addToPropertyCtrl($name, $value, $typeCtrl); |
| 10 | 13 | |
| 11 | 14 | public function setType($checkboxType) { |
@@ -64,8 +64,7 @@ discard block |
||
| 64 | 64 | * Associate an ajax get to the breadcrumb elements, displayed in $targetSelector |
| 65 | 65 | * $attr member is used to build each element url |
| 66 | 66 | * @param string $targetSelector the target of the get |
| 67 | - * @param string $attr the html attribute used to build the elements url |
|
| 68 | - * @return HtmlBreadcrumbs |
|
| 67 | + * @return HtmlBreadcrumb |
|
| 69 | 68 | */ |
| 70 | 69 | public function autoGetOnClick($targetSelector) { |
| 71 | 70 | return $this->getOnClick($this->root, $targetSelector, array ("attr" => $this->attr )); |
@@ -91,7 +90,7 @@ discard block |
||
| 91 | 90 | * Add new elements in breadcrumbs corresponding to request dispatcher : controllerName, actionName, parameters |
| 92 | 91 | * @param JsUtils $js |
| 93 | 92 | * @param Dispatcher $dispatcher the request dispatcher |
| 94 | - * @return \Ajax\bootstrap\html\HtmlBreadcrumbs |
|
| 93 | + * @return HtmlBreadcrumb |
|
| 95 | 94 | */ |
| 96 | 95 | public function fromDispatcher(JsUtils $js,$dispatcher, $startIndex=0) { |
| 97 | 96 | return $this->addItems($js->fromDispatcher($dispatcher)); |
@@ -120,7 +119,7 @@ discard block |
||
| 120 | 119 | * sets the function who generates the href elements. |
| 121 | 120 | * default : function($element){return $element->getContent()} |
| 122 | 121 | * @param function $_hrefFunction |
| 123 | - * @return \Ajax\bootstrap\html\HtmlBreadcrumbs |
|
| 122 | + * @return HtmlBreadcrumb |
|
| 124 | 123 | */ |
| 125 | 124 | public function setHrefFunction($_hrefFunction) { |
| 126 | 125 | $this->_hrefFunction=$_hrefFunction; |
@@ -4,7 +4,6 @@ |
||
| 4 | 4 | |
| 5 | 5 | use Ajax\semantic\html\base\HtmlSemNavElement; |
| 6 | 6 | use Ajax\semantic\html\base\HtmlSemDoubleElement; |
| 7 | - |
|
| 8 | 7 | use Ajax\semantic\html\elements\HtmlIcon; |
| 9 | 8 | use Ajax\JsUtils; |
| 10 | 9 | |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | $this->startIndex=$startIndex; |
| 52 | 52 | $this->autoActive=$autoActive; |
| 53 | 53 | $this->_contentSeparator="<div class='divider'> / </div>"; |
| 54 | - $this->_hrefFunction=function ($e) { |
|
| 54 | + $this->_hrefFunction=function($e) { |
|
| 55 | 55 | return $e->getContent(); |
| 56 | 56 | }; |
| 57 | 57 | if (isset($hrefFunction)) { |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @return HtmlBreadcrumbs |
| 69 | 69 | */ |
| 70 | 70 | public function autoGetOnClick($targetSelector) { |
| 71 | - return $this->getOnClick($this->root, $targetSelector, array ("attr" => $this->attr )); |
|
| 71 | + return $this->getOnClick($this->root, $targetSelector, array("attr" => $this->attr)); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | public function contentAsString() { |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | public function setActive($index=null) { |
| 82 | 82 | if (!isset($index)) { |
| 83 | - $index=sizeof($this->content) - 1; |
|
| 83 | + $index=sizeof($this->content)-1; |
|
| 84 | 84 | } |
| 85 | 85 | $activeItem=$this->content[$index]; |
| 86 | 86 | $activeItem->addToProperty("class", "active"); |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | * @param Dispatcher $dispatcher the request dispatcher |
| 94 | 94 | * @return \Ajax\bootstrap\html\HtmlBreadcrumbs |
| 95 | 95 | */ |
| 96 | - public function fromDispatcher(JsUtils $js,$dispatcher, $startIndex=0) { |
|
| 96 | + public function fromDispatcher(JsUtils $js, $dispatcher, $startIndex=0) { |
|
| 97 | 97 | return $this->addItems($js->fromDispatcher($dispatcher)); |
| 98 | 98 | } |
| 99 | 99 | |
@@ -107,12 +107,12 @@ discard block |
||
| 107 | 107 | if (!isset($index)) { |
| 108 | 108 | $index=sizeof($this->content); |
| 109 | 109 | } |
| 110 | - if ($this->absolutePaths === true) { |
|
| 110 | + if ($this->absolutePaths===true) { |
|
| 111 | 111 | return $this->_hrefFunction($this->content[$index]); |
| 112 | 112 | } else { |
| 113 | - return $this->root . implode($separator, array_slice(array_map(function ($e) { |
|
| 113 | + return $this->root.implode($separator, array_slice(array_map(function($e) { |
|
| 114 | 114 | return $this->_hrefFunction($e); |
| 115 | - }, $this->content), $this->startIndex, $index + 1)); |
|
| 115 | + }, $this->content), $this->startIndex, $index+1)); |
|
| 116 | 116 | } |
| 117 | 117 | } |
| 118 | 118 | |
@@ -146,8 +146,8 @@ discard block |
||
| 146 | 146 | $this->setActive(); |
| 147 | 147 | } |
| 148 | 148 | $count=$this->count(); |
| 149 | - for($i=1; $i < $count; $i++) { |
|
| 150 | - $this->content[$i]->wrap($this->getContentDivider($i - 1)); |
|
| 149 | + for ($i=1; $i<$count; $i++) { |
|
| 150 | + $this->content[$i]->wrap($this->getContentDivider($i-1)); |
|
| 151 | 151 | } |
| 152 | 152 | return parent::compile($js, $view); |
| 153 | 153 | } |
@@ -157,15 +157,15 @@ discard block |
||
| 157 | 157 | * @see \Ajax\bootstrap\html\base\BaseHtml::on() |
| 158 | 158 | */ |
| 159 | 159 | public function on($event, $jsCode, $stopPropagation=false, $preventDefault=false) { |
| 160 | - foreach ( $this->content as $element ) { |
|
| 160 | + foreach ($this->content as $element) { |
|
| 161 | 161 | $element->on($event, $jsCode, $stopPropagation, $preventDefault); |
| 162 | 162 | } |
| 163 | 163 | return $this; |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | public function _ajaxOn($operation, $event, $url, $responseElement="", $parameters=array()) { |
| 167 | - foreach ( $this->content as $element ) { |
|
| 168 | - if ($element->getProperty($this->attr) != NULL){ |
|
| 167 | + foreach ($this->content as $element) { |
|
| 168 | + if ($element->getProperty($this->attr)!=NULL) { |
|
| 169 | 169 | $element->_ajaxOn($operation, $event, $url, $responseElement, $parameters); |
| 170 | 170 | } |
| 171 | 171 | } |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | */ |
| 181 | 181 | protected function createItem($value) { |
| 182 | 182 | $count=$this->count(); |
| 183 | - $itemO=new HtmlSemDoubleElement("item-" . $this->identifier . "-" . $count, "a", "section"); |
|
| 183 | + $itemO=new HtmlSemDoubleElement("item-".$this->identifier."-".$count, "a", "section"); |
|
| 184 | 184 | if (\is_array($value)) |
| 185 | 185 | $itemO->fromArray($value); |
| 186 | 186 | else { |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | public function addIconAt($icon, $index) { |
| 193 | 193 | $item=$this->getItem($index); |
| 194 | 194 | if (isset($item)) { |
| 195 | - $icon=new HtmlIcon("icon-" . $this->identifier, $icon); |
|
| 195 | + $icon=new HtmlIcon("icon-".$this->identifier, $icon); |
|
| 196 | 196 | $item->wrapContent($icon); |
| 197 | 197 | } |
| 198 | 198 | } |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | public function addItem($item) { |
| 201 | 201 | $count=$this->count(); |
| 202 | 202 | $itemO=parent::addItem($item); |
| 203 | - $this->addToPropertyCtrl("class", "section", array ("section" )); |
|
| 203 | + $this->addToPropertyCtrl("class", "section", array("section")); |
|
| 204 | 204 | $itemO->setProperty($this->attr, $this->getHref($count)); |
| 205 | 205 | return $itemO; |
| 206 | 206 | } |
@@ -181,9 +181,9 @@ |
||
| 181 | 181 | protected function createItem($value) { |
| 182 | 182 | $count=$this->count(); |
| 183 | 183 | $itemO=new HtmlSemDoubleElement("item-" . $this->identifier . "-" . $count, "a", "section"); |
| 184 | - if (\is_array($value)) |
|
| 185 | - $itemO->fromArray($value); |
|
| 186 | - else { |
|
| 184 | + if (\is_array($value)) { |
|
| 185 | + $itemO->fromArray($value); |
|
| 186 | + } else { |
|
| 187 | 187 | $itemO->setContent($value); |
| 188 | 188 | } |
| 189 | 189 | return $itemO; |