@@ -5,8 +5,8 @@ discard block |
||
5 | 5 | * @param string $src |
6 | 6 | * @return string |
7 | 7 | */ |
8 | -function javascript_include_tag($src){ |
|
9 | - return "<script type='text/javascript' src='".PUBLIC_PATH."js/$src.js'></script>\r\n"; |
|
8 | +function javascript_include_tag($src) { |
|
9 | + return "<script type='text/javascript' src='" . PUBLIC_PATH . "js/$src.js'></script>\r\n"; |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | /** |
@@ -14,8 +14,8 @@ discard block |
||
14 | 14 | * @param string $src |
15 | 15 | * @return string |
16 | 16 | */ |
17 | -function stylesheet_link($src=''){ |
|
18 | - return "<link rel='stylesheet' type='text/css' href='".PUBLIC_PATH."css/$src.css'/>\r\n"; |
|
17 | +function stylesheet_link($src = '') { |
|
18 | + return "<link rel='stylesheet' type='text/css' href='" . PUBLIC_PATH . "css/$src.css'/>\r\n"; |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -25,8 +25,8 @@ discard block |
||
25 | 25 | * @param string $attributes |
26 | 26 | * @return string |
27 | 27 | */ |
28 | -function link_to($action, $text, $attributes=''){ |
|
29 | - return "<a href='".PUBLIC_PATH."$action' $attributes>$text</a>"; |
|
28 | +function link_to($action, $text, $attributes = '') { |
|
29 | + return "<a href='" . PUBLIC_PATH . "$action' $attributes>$text</a>"; |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | * @param string $attributes |
36 | 36 | * @return string |
37 | 37 | */ |
38 | -function img_tag($img, $attributes=''){ |
|
39 | - return "<img src='".PUBLIC_PATH."img/$img' $attributes />\r\n"; |
|
38 | +function img_tag($img, $attributes = '') { |
|
39 | + return "<img src='" . PUBLIC_PATH . "img/$img' $attributes />\r\n"; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -45,15 +45,15 @@ discard block |
||
45 | 45 | * @param string $attributes |
46 | 46 | * @return string |
47 | 47 | */ |
48 | -function form_tag($action, $attributes=''){ |
|
49 | - return "<form action='".PUBLIC_PATH."$action' $attributes>\r\n"; |
|
48 | +function form_tag($action, $attributes = '') { |
|
49 | + return "<form action='" . PUBLIC_PATH . "$action' $attributes>\r\n"; |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
53 | 53 | * end_form_tag |
54 | 54 | * @return string |
55 | 55 | */ |
56 | -function end_form_tag(){ |
|
56 | +function end_form_tag() { |
|
57 | 57 | return "</form>\r\n"; |
58 | 58 | } |
59 | 59 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @param string $attributes |
64 | 64 | * @return string |
65 | 65 | */ |
66 | -function submit_tag($caption, $attributes=''){ |
|
66 | +function submit_tag($caption, $attributes = '') { |
|
67 | 67 | return "<input type='submit' value='$caption' $attributes />\r\n"; |
68 | 68 | } |
69 | 69 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @param string $attributes |
75 | 75 | * @return string |
76 | 76 | */ |
77 | -function button_tag($caption, $type='button', $attributes=''){ |
|
77 | +function button_tag($caption, $type = 'button', $attributes = '') { |
|
78 | 78 | return "<button type='$type' $attributes>$caption</button>\r\n"; |
79 | 79 | } |
80 | 80 | |
@@ -85,11 +85,11 @@ discard block |
||
85 | 85 | */ |
86 | 86 | function get_field_name_and_id($name) |
87 | 87 | { |
88 | - $id=""; |
|
88 | + $id = ""; |
|
89 | 89 | if (strpos($name, ".") != false) { |
90 | 90 | $items = explode(".", $name); |
91 | - $id=" id='{$items[0]}_{$items[1]}' "; |
|
92 | - $name = $items[0]."[".$items[1]."]"; |
|
91 | + $id = " id='{$items[0]}_{$items[1]}' "; |
|
92 | + $name = $items[0] . "[" . $items[1] . "]"; |
|
93 | 93 | } |
94 | 94 | return [$id, $name]; |
95 | 95 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * @param string $attributes |
102 | 102 | * @return string |
103 | 103 | */ |
104 | -function text_field_tag($name, $value='', $attributes=''){ |
|
104 | +function text_field_tag($name, $value = '', $attributes = '') { |
|
105 | 105 | list($id, $name) = get_field_name_and_id($name); |
106 | 106 | |
107 | 107 | return "<input type='text' name='$name' $id value='$value' $attributes />\r\n"; |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * @param string $attributes |
115 | 115 | * @return string |
116 | 116 | */ |
117 | -function password_field_tag($name, $value='', $attributes=''){ |
|
117 | +function password_field_tag($name, $value = '', $attributes = '') { |
|
118 | 118 | list($id, $name) = get_field_name_and_id($name); |
119 | 119 | |
120 | 120 | return "<input type='password' name='$name' $id value='$value' $attributes />\r\n"; |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * @param string $attributes |
128 | 128 | * @return string |
129 | 129 | */ |
130 | -function text_area_tag($name, $value='', $attributes=''){ |
|
130 | +function text_area_tag($name, $value = '', $attributes = '') { |
|
131 | 131 | list($id, $name) = get_field_name_and_id($name); |
132 | 132 | |
133 | 133 | return "<textarea name='$name' $id $attributes>$value</textarea>\r\n"; |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @param string $attributes |
141 | 141 | * @return string |
142 | 142 | */ |
143 | -function hidden_field_tag($name, $value='', $attributes=''){ |
|
143 | +function hidden_field_tag($name, $value = '', $attributes = '') { |
|
144 | 144 | list($id, $name) = get_field_name_and_id($name); |
145 | 145 | |
146 | 146 | return "<input type='hidden' name='$name' $id value='$value' $attributes />\r\n"; |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * @param string $attributes |
156 | 156 | * @return string |
157 | 157 | */ |
158 | -function check_box_tag($name, $value, $text, $checked=false, $attributes=''){ |
|
158 | +function check_box_tag($name, $value, $text, $checked = false, $attributes = '') { |
|
159 | 159 | list($id, $name) = get_field_name_and_id($name); |
160 | 160 | $checked = $checked == true ? ' checked ' : ''; |
161 | 161 | return "<input type='checkbox' $id name='$name' $checked $attributes value='$value'/>\r\n"; |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * @param string $attributes |
170 | 170 | * @return string |
171 | 171 | */ |
172 | -function radio_button_tag($name, $value, $checked=false, $attributes=''){ |
|
172 | +function radio_button_tag($name, $value, $checked = false, $attributes = '') { |
|
173 | 173 | list($id, $name) = get_field_name_and_id($name); |
174 | 174 | $checked = $checked == true ? ' checked ' : ''; |
175 | 175 | return "<input type='radio' $id name='$name' $checked $attributes value='$value'/>\r\n"; |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * @param string $attributes |
183 | 183 | * @return string |
184 | 184 | */ |
185 | -function label_tag($field, $caption, $attributes='') { |
|
185 | +function label_tag($field, $caption, $attributes = '') { |
|
186 | 186 | return "<label for='$field' $attributes>$caption</label>\r\n"; |
187 | 187 | } |
188 | 188 | |
@@ -194,12 +194,12 @@ discard block |
||
194 | 194 | * @param string $attributes |
195 | 195 | * @return string |
196 | 196 | */ |
197 | -function select_tag($name, $options='', $include_blank=false, $attributes=''){ |
|
197 | +function select_tag($name, $options = '', $include_blank = false, $attributes = '') { |
|
198 | 198 | list($id, $name) = get_field_name_and_id($name); |
199 | 199 | |
200 | 200 | $code = ""; |
201 | 201 | if ($include_blank != false) { |
202 | - $code="<option value=''>$include_blank</option>\r\n"; |
|
202 | + $code = "<option value=''>$include_blank</option>\r\n"; |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | return "<select $id name='$name' $attributes>\r\n$code$options</select>\r\n"; |
@@ -214,15 +214,15 @@ discard block |
||
214 | 214 | * @param string $selected |
215 | 215 | * @return string |
216 | 216 | */ |
217 | -function options_for_dbselect($data, $show, $value, $selected='') |
|
217 | +function options_for_dbselect($data, $show, $value, $selected = '') |
|
218 | 218 | { |
219 | - $code=""; |
|
220 | - foreach($data as $item) { |
|
221 | - $selected_tag=""; |
|
222 | - if ($selected == $item[$value]){ |
|
219 | + $code = ""; |
|
220 | + foreach ($data as $item) { |
|
221 | + $selected_tag = ""; |
|
222 | + if ($selected == $item[$value]) { |
|
223 | 223 | $selected_tag = " selected='selected' "; |
224 | 224 | } |
225 | - $code.="<option value='{$item[$value]}' $selected_tag>{$item[$show]}</option>\r\n"; |
|
225 | + $code .= "<option value='{$item[$value]}' $selected_tag>{$item[$show]}</option>\r\n"; |
|
226 | 226 | } |
227 | 227 | return $code; |
228 | 228 | } |
@@ -233,15 +233,15 @@ discard block |
||
233 | 233 | * @param string $selected |
234 | 234 | * @return string |
235 | 235 | */ |
236 | -function options_for_select($data, $selected='') |
|
236 | +function options_for_select($data, $selected = '') |
|
237 | 237 | { |
238 | - $code=""; |
|
239 | - foreach($data as $key => $value) { |
|
240 | - $selected_tag=""; |
|
241 | - if ($selected == $value){ |
|
238 | + $code = ""; |
|
239 | + foreach ($data as $key => $value) { |
|
240 | + $selected_tag = ""; |
|
241 | + if ($selected == $value) { |
|
242 | 242 | $selected_tag = " selected='selected' "; |
243 | 243 | } |
244 | - $code.="<option value='$key' $selected_tag>$value</option>\r\n"; |
|
244 | + $code .= "<option value='$key' $selected_tag>$value</option>\r\n"; |
|
245 | 245 | } |
246 | 246 | return $code; |
247 | 247 | } |
@@ -252,8 +252,8 @@ discard block |
||
252 | 252 | * @param float $seconds |
253 | 253 | * @return string |
254 | 254 | */ |
255 | -function js_redirect_to($action, $seconds = 0.01){ |
|
256 | - $seconds*=1000; |
|
255 | +function js_redirect_to($action, $seconds = 0.01) { |
|
256 | + $seconds *= 1000; |
|
257 | 257 | return "<script type=\"text/javascript\">setTimeout('window.location=\"?/$action\"', $seconds)</script>"; |
258 | 258 | } |
259 | 259 | |
@@ -264,6 +264,6 @@ discard block |
||
264 | 264 | * @param string $attributes |
265 | 265 | * @return string |
266 | 266 | */ |
267 | -function button_to_action($caption, $action, $attributes=''){ |
|
268 | - return "<button type='button' $attributes onclick='window.location=\"".PUBLIC_PATH."$action\"'>$caption</button>"; |
|
267 | +function button_to_action($caption, $action, $attributes = '') { |
|
268 | + return "<button type='button' $attributes onclick='window.location=\"" . PUBLIC_PATH . "$action\"'>$caption</button>"; |
|
269 | 269 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | |
36 | 36 | function load_partial($partial, array $parameters = null) |
37 | 37 | { |
38 | - load_file($partial, ".phtml", PIN_PATH . 'partials'. DS , "Parcial", $parameters); |
|
38 | + load_file($partial, ".phtml", PIN_PATH . 'partials' . DS, "Parcial", $parameters); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | function redirect_to($url) |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | //implementar autoloader para clases |
48 | 48 | //espera que las clases se definan en PascalCase y los archivos |
49 | 49 | //usen snake_case. Ejemplo class QueryBuilder, archivo query_builder.php |
50 | -spl_autoload_register(function($className){ |
|
50 | +spl_autoload_register(function($className) { |
|
51 | 51 | $file_name = strtolower(preg_replace('/(?<!^)[A-Z]/', '_$0', $className)); |
52 | 52 | $file = PIN_PATH . 'libs' . DS . $file_name . '.php'; |
53 | 53 | if (file_exists($file)) { |