From 4c288e957ec4340af93f980c65eecea6d3a789f4 Mon Sep 17 00:00:00 2001 From: msquare Date: Thu, 29 Sep 2016 11:28:42 +0200 Subject: prohibit inline control structures on includes and index --- includes/sys_template.php | 66 +++++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 31 deletions(-) (limited to 'includes/sys_template.php') diff --git a/includes/sys_template.php b/includes/sys_template.php index 112bb483..23f4b77b 100644 --- a/includes/sys_template.php +++ b/includes/sys_template.php @@ -179,19 +179,10 @@ function form_date($name, $label, $value, $start_date = '') { */ function form_checkboxes($name, $label, $items, $selected) { $html = form_element($label, ''); - foreach ($items as $key => $item) - $html .= form_checkbox($name . '_' . $key, $item, array_search($key, $selected) !== false); - - return $html; - - $html = ""; - return form_element($label, $html); + return $html; } /** @@ -210,16 +201,18 @@ function form_checkboxes($name, $label, $items, $selected) { */ function form_multi_checkboxes($names, $label, $items, $selected, $disabled = array()) { $html = ""; - foreach ($names as $title) + foreach ($names as $title) { $html .= ""; + } $html .= ""; foreach ($items as $key => $item) { $html .= ""; foreach ($names as $name => $title) { $id = $name . '_' . $key; $sel = array_search($key, $selected[$name]) !== false ? ' checked="checked"' : ""; - if (! empty($disabled) && ! empty($disabled[$name]) && array_search($key, $disabled[$name]) !== false) + if (! empty($disabled) && ! empty($disabled[$name]) && array_search($key, $disabled[$name]) !== false) { $sel .= ' disabled="disabled"'; + } $html .= ''; } $html .= ''; @@ -246,10 +239,12 @@ function form_radio($name, $label, $selected, $value) { * Rendert einen Infotext in das Formular */ function form_info($label, $text = "") { - if ($label == "") + if ($label == "") { return '' . glyph('info-sign') . $text . ''; - if ($text == "") + } + if ($text == "") { return '

' . $label . '

'; + } return form_element($label, '

' . $text . '

', ''); } @@ -312,9 +307,9 @@ function form_select($name, $label, $values, $selected) { function form_element($label, $input, $for = "") { if ($label == '') { return '
' . $input . '
'; - } else { - return '
' . '' . $input . '
'; } + + return '
' . '' . $input . '
'; } /** @@ -346,34 +341,40 @@ function page_with_title($title, $elements) { function table($columns, $rows_raw, $data = true) { // If only one column is given if (! is_array($columns)) { - $columns = array( + $columns = [ 'col' => $columns - ); + ]; - $rows = array(); + $rows = []; foreach ($rows_raw as $row) - $rows[] = array( + $rows[] = [ 'col' => $row - ); - } else + ]; + } else { $rows = $rows_raw; + } - if (count($rows) == 0) + if (count($rows) == 0) { return info(_("No data found."), true); + } + $html = ""; $html .= '
$title
'; $html .= ''; - foreach ($columns as $key => $column) + foreach ($columns as $key => $column) { $html .= ''; + } $html .= ''; $html .= ''; foreach ($rows as $row) { $html .= ''; - foreach ($columns as $key => $column) - if (isset($row[$key])) + foreach ($columns as $key => $column) { + if (isset($row[$key])) { $html .= ''; - else + } else { $html .= ''; + } + } $html .= ''; } $html .= ''; @@ -410,10 +411,11 @@ function table_buttons($buttons = array()) { function template_render($file, $data) { if (file_exists($file)) { $template = file_get_contents($file); - if (is_array($data)) + if (is_array($data)) { foreach ($data as $name => $content) { $template = str_replace("%" . $name . "%", $content, $template); } + } return $template; } engelsystem_error("Cannot find template file «" . $file . "»."); @@ -430,8 +432,9 @@ function table_body($array) { foreach ($array as $line) { $html .= ""; if (is_array($line)) { - foreach ($line as $td) + foreach ($line as $td) { $html .= ""; + } } else { $html .= ""; } @@ -442,8 +445,9 @@ function table_body($array) { function html_options($name, $options, $selected = "") { $html = ""; - foreach ($options as $value => $label) + foreach ($options as $value => $label) { $html .= ' ' . $label; + } return $html; } -- cgit v1.2.3-54-g00ecf
' . $column . '
' . $row[$key] . ' 
" . $td . "" . $line . "