@@ -36,7 +36,7 @@ |
||
| 36 | 36 | |
| 37 | 37 | function load_partial(string $partial, array $parameters = null) |
| 38 | 38 | { |
| 39 | - load_file($partial, ".phtml", PIN_PATH . 'partials'. DS , "Parcial", $parameters); |
|
| 39 | + load_file($partial, ".phtml", PIN_PATH . 'partials' . DS, "Parcial", $parameters); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | function redirect_to(string $url) |
@@ -1,131 +1,131 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -function javascript_include_tag($src){ |
|
| 4 | - return "<script type='text/javascript' src='".PUBLIC_PATH."js/$src.js'></script>\r\n"; |
|
| 3 | +function javascript_include_tag($src) { |
|
| 4 | + return "<script type='text/javascript' src='" . PUBLIC_PATH . "js/$src.js'></script>\r\n"; |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | -function stylesheet_link($src=''){ |
|
| 8 | - return "<link rel='stylesheet' type='text/css' href='".PUBLIC_PATH."css/$src.css'/>\r\n"; |
|
| 7 | +function stylesheet_link($src = '') { |
|
| 8 | + return "<link rel='stylesheet' type='text/css' href='" . PUBLIC_PATH . "css/$src.css'/>\r\n"; |
|
| 9 | 9 | } |
| 10 | 10 | |
| 11 | -function link_to($action, $text, $attributes=''){ |
|
| 12 | - return "<a href='".PUBLIC_PATH."$action' $attributes>$text</a>"; |
|
| 11 | +function link_to($action, $text, $attributes = '') { |
|
| 12 | + return "<a href='" . PUBLIC_PATH . "$action' $attributes>$text</a>"; |
|
| 13 | 13 | } |
| 14 | 14 | |
| 15 | -function img_tag($img, $attributes=''){ |
|
| 16 | - return "<img src='".PUBLIC_PATH."img/$img' $attributes />\r\n"; |
|
| 15 | +function img_tag($img, $attributes = '') { |
|
| 16 | + return "<img src='" . PUBLIC_PATH . "img/$img' $attributes />\r\n"; |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | -function form_tag($action, $attributes=''){ |
|
| 20 | - return "<form action='".PUBLIC_PATH."$action' $attributes>\r\n"; |
|
| 19 | +function form_tag($action, $attributes = '') { |
|
| 20 | + return "<form action='" . PUBLIC_PATH . "$action' $attributes>\r\n"; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | -function end_form_tag(){ |
|
| 23 | +function end_form_tag() { |
|
| 24 | 24 | return "</form>\r\n"; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | -function submit_tag($caption, $attributes=''){ |
|
| 27 | +function submit_tag($caption, $attributes = '') { |
|
| 28 | 28 | return "<input type='submit' value='$caption' $attributes />\r\n"; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | -function button_tag($caption, $type='button', $attributes=''){ |
|
| 31 | +function button_tag($caption, $type = 'button', $attributes = '') { |
|
| 32 | 32 | return "<button type='$type' $attributes>$caption</button>\r\n"; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | function get_field_name_and_id($name) |
| 36 | 36 | { |
| 37 | - $id=""; |
|
| 37 | + $id = ""; |
|
| 38 | 38 | if (strpos($name, ".") != false) { |
| 39 | 39 | $items = explode(".", $name); |
| 40 | - $id=" id='{$items[0]}_{$items[1]}' "; |
|
| 41 | - $name = $items[0]."[".$items[1]."]"; |
|
| 40 | + $id = " id='{$items[0]}_{$items[1]}' "; |
|
| 41 | + $name = $items[0] . "[" . $items[1] . "]"; |
|
| 42 | 42 | } |
| 43 | 43 | return [$id, $name]; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | -function text_field_tag($name, $value='', $attributes=''){ |
|
| 46 | +function text_field_tag($name, $value = '', $attributes = '') { |
|
| 47 | 47 | list($id, $name) = get_field_name_and_id($name); |
| 48 | 48 | |
| 49 | 49 | return "<input type='text' name='$name' $id value='$value' $attributes />\r\n"; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | -function password_field_tag($name, $value='', $attributes=''){ |
|
| 52 | +function password_field_tag($name, $value = '', $attributes = '') { |
|
| 53 | 53 | list($id, $name) = get_field_name_and_id($name); |
| 54 | 54 | |
| 55 | 55 | return "<input type='password' name='$name' $id value='$value' $attributes />\r\n"; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | -function text_area_tag($name, $value='', $attributes=''){ |
|
| 58 | +function text_area_tag($name, $value = '', $attributes = '') { |
|
| 59 | 59 | list($id, $name) = get_field_name_and_id($name); |
| 60 | 60 | |
| 61 | 61 | return "<textarea name='$name' $id $attributes>$value</textarea>\r\n"; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | -function hidden_field_tag($name, $value='', $attributes=''){ |
|
| 64 | +function hidden_field_tag($name, $value = '', $attributes = '') { |
|
| 65 | 65 | list($id, $name) = get_field_name_and_id($name); |
| 66 | 66 | |
| 67 | 67 | return "<input type='hidden' name='$name' $id value='$value' $attributes />\r\n"; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | -function check_box_tag($name, $value, $text, $checked=false, $attributes=''){ |
|
| 70 | +function check_box_tag($name, $value, $text, $checked = false, $attributes = '') { |
|
| 71 | 71 | list($id, $name) = get_field_name_and_id($name); |
| 72 | 72 | $checked = $checked == true ? ' checked ' : ''; |
| 73 | 73 | return "<input type='checkbox' $id name='$name' $checked $attributes value='$value'/>\r\n"; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | -function radio_button_tag($name, $value, $checked=false, $attributes=''){ |
|
| 76 | +function radio_button_tag($name, $value, $checked = false, $attributes = '') { |
|
| 77 | 77 | list($id, $name) = get_field_name_and_id($name); |
| 78 | 78 | $checked = $checked == true ? ' checked ' : ''; |
| 79 | 79 | return "<input type='radio' $id name='$name' $checked $attributes value='$value'/>\r\n"; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | -function label_tag($field, $caption, $attributes='') { |
|
| 82 | +function label_tag($field, $caption, $attributes = '') { |
|
| 83 | 83 | return "<label for='$field' $attributes>$caption</label>\r\n"; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | -function select_tag($name='', $options, $include_blank=false, $attributes=''){ |
|
| 86 | +function select_tag($name = '', $options, $include_blank = false, $attributes = '') { |
|
| 87 | 87 | list($id, $name) = get_field_name_and_id($name); |
| 88 | 88 | |
| 89 | 89 | $code = ""; |
| 90 | 90 | if ($include_blank != false) { |
| 91 | - $code="<option value=''>$include_blank</option>\r\n"; |
|
| 91 | + $code = "<option value=''>$include_blank</option>\r\n"; |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | return "<select $id name='$name' $attributes>\r\n$code$options</select>\r\n"; |
| 95 | 95 | |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | -function options_for_dbselect($data, $show, $value, $selected='') |
|
| 98 | +function options_for_dbselect($data, $show, $value, $selected = '') |
|
| 99 | 99 | { |
| 100 | - $code=""; |
|
| 101 | - foreach($data as $item) { |
|
| 102 | - $selected_tag=""; |
|
| 103 | - if ($selected == $item[$value]){ |
|
| 100 | + $code = ""; |
|
| 101 | + foreach ($data as $item) { |
|
| 102 | + $selected_tag = ""; |
|
| 103 | + if ($selected == $item[$value]) { |
|
| 104 | 104 | $selected_tag = " selected='selected' "; |
| 105 | 105 | } |
| 106 | - $code.="<option value='{$item[$value]}' $selected_tag>{$item[$show]}</option>\r\n"; |
|
| 106 | + $code .= "<option value='{$item[$value]}' $selected_tag>{$item[$show]}</option>\r\n"; |
|
| 107 | 107 | } |
| 108 | 108 | return $code; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | -function options_for_select($data, $selected='') |
|
| 111 | +function options_for_select($data, $selected = '') |
|
| 112 | 112 | { |
| 113 | - $code=""; |
|
| 114 | - foreach($data as $key => $value) { |
|
| 115 | - $selected_tag=""; |
|
| 116 | - if ($selected == $value){ |
|
| 113 | + $code = ""; |
|
| 114 | + foreach ($data as $key => $value) { |
|
| 115 | + $selected_tag = ""; |
|
| 116 | + if ($selected == $value) { |
|
| 117 | 117 | $selected_tag = " selected='selected' "; |
| 118 | 118 | } |
| 119 | - $code.="<option value='$key' $selected_tag>$value</option>\r\n"; |
|
| 119 | + $code .= "<option value='$key' $selected_tag>$value</option>\r\n"; |
|
| 120 | 120 | } |
| 121 | 121 | return $code; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | -function js_redirect_to($action, $seconds = 0.01){ |
|
| 125 | - $seconds*=1000; |
|
| 124 | +function js_redirect_to($action, $seconds = 0.01) { |
|
| 125 | + $seconds *= 1000; |
|
| 126 | 126 | return "<script type=\"text/javascript\">setTimeout('window.location=\"?/$action\"', $seconds)</script>"; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | -function button_to_action($caption, $action, $attributes=''){ |
|
| 130 | - return "<button type='button' $attributes onclick='window.location=\"".PUBLIC_PATH."$action\"'>$caption</button>"; |
|
| 129 | +function button_to_action($caption, $action, $attributes = '') { |
|
| 130 | + return "<button type='button' $attributes onclick='window.location=\"" . PUBLIC_PATH . "$action\"'>$caption</button>"; |
|
| 131 | 131 | } |