From 0f649c975d91ff2fd792bd1b8adf93cf6138c9c5 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Tue, 15 Dec 2015 17:36:58 +0545 Subject: Code style pkg --- src/usr/local/www/pkg_edit.php | 95 +++++++++++++++++++++++------------------- 1 file changed, 52 insertions(+), 43 deletions(-) (limited to 'src/usr/local/www/pkg_edit.php') diff --git a/src/usr/local/www/pkg_edit.php b/src/usr/local/www/pkg_edit.php index 7a51378..823c575 100644 --- a/src/usr/local/www/pkg_edit.php +++ b/src/usr/local/www/pkg_edit.php @@ -129,8 +129,9 @@ if ($config['installedpackages'] && !is_array($config['installedpackages'][xml_s } // If the first entry in the array is an empty tag, kill it. -if ($config['installedpackages'] && (count($config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config']) > 0) - && ($config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'][0] == "")) { +if ($config['installedpackages'] && + (count($config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config']) > 0) && + ($config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'][0] == "")) { array_shift($config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config']); } @@ -293,7 +294,7 @@ function bootstrapTable($text) { $c = strpos($text, '>', $t); // And its closing bracket // Substitute everything inbetween with our new classes - if($t && $c && (($c - $t) < 200) ) { + if ($t && $c && (($c - $t) < 200)) { return(substr_replace($text, ' class="table table-striped table-hover table-condensed"', $t, ($c - $t))); } } @@ -381,7 +382,7 @@ function display_row($trc, $value, $fieldname, $type, $rowhelper, $description) foreach ($ifaces as $ifname => $iface) { $options[$ifname] = $iface; - if(in_array($ifname, $values)) { + if (in_array($ifname, $values)) { array_push($selected, $ifname); } } @@ -412,7 +413,7 @@ function display_row($trc, $value, $fieldname, $type, $rowhelper, $description) $source_value = ($rowhelper['source_value'] ? $opt[$rowhelper['source_value']] : $opt[$rowhelper['value']]); $options[$source_value] = $source_name; - if($source_value == $value) { + if ($source_value == $value) { array_push($selected, $value); } } @@ -517,7 +518,7 @@ function parse_package_templates() { //breadcrumb if ($pkg['title'] != "") { - if(!$only_edit) { + if (!$only_edit) { $pkg['title'] = $pkg['title'] . '/Edit'; } @@ -594,18 +595,20 @@ if ($pkg['custom_php_after_head_command']) { } else { include("head.inc"); } -if(isset($tab_array)) { +if (isset($tab_array)) { foreach ($tab_array as $tabid => $tab) { display_top_tabs($tab); //, $no_drop_down, $tabid); } } // Start of page display -if ($input_errors) +if ($input_errors) { print_input_errors($input_errors); +} -if ($savemsg) +if ($savemsg) { print_info_box($savemsg, 'success'); +} $cols = 0; $savevalue = gettext("Save"); @@ -658,8 +661,9 @@ foreach ($pkg['fields']['field'] as $pkga) { $advfield_count++; } else { - if(isset($section)) + if (isset($section)) { $form->add($section); + } $section = new Form_Section(strip_tags($pkga['name'])); } @@ -696,8 +700,9 @@ foreach ($pkg['fields']['field'] as $pkga) { // If we get here but have no $section, the package config file probably had no listtopic field // We can create a section with a generic name to fix that - if(!$section) + if (!$section) { $section = new Form_Section(gettext('General options')); + } switch ($pkga['type']) { // Create an input element. The format is slightly different depending on whether we are composing a group, @@ -770,10 +775,11 @@ foreach ($pkg['fields']['field'] as $pkga) { case "info": // If the info contains a table we should detect and Bootstrap it - if (strpos($pkga['description'], 'addInput(new Form_StaticText( @@ -815,12 +821,13 @@ foreach ($pkg['fields']['field'] as $pkga) { } } - if (isset($pkga['advancedfield']) && isset($advfield_count)) + if (isset($pkga['advancedfield']) && isset($advfield_count)) { $function = $grouping ? $advanced->add:$advanced->addInput; - else + } else { $function = ($grouping) ? $section->add:$section->addInput; + } - if($grouping) { + if ($grouping) { $group->add(new Form_Select( $pkga['fieldname'], strip_tags($pkga['fielddescr']), @@ -878,11 +885,12 @@ foreach ($pkg['fields']['field'] as $pkga) { $source_value =($pkga['source_value'] ? $opt[$pkga['source_value']] : $opt[$pkga['value']]); $srcoptions[$source_value] = $source_name; - if(in_array($source_value, $items)) + if (in_array($source_value, $items)) { array_push($srcselected, $source_value); + } } - if($grouping) { + if ($grouping) { $group->add(new Form_Select( $pkga['fieldname'], strip_tags($pkga['fielddescr']), @@ -920,7 +928,7 @@ foreach ($pkg['fields']['field'] as $pkga) { } - if($grouping) { + if ($grouping) { $group->add(new Form_Select( $pkga['fieldname'], null, @@ -950,12 +958,13 @@ foreach ($pkg['fields']['field'] as $pkga) { // Create a checkbox element case "checkbox": $onchange = (isset($pkga['onchange']) ? "{$pkga['onchange']}" : ''); - if (isset($pkga['enablefields']) || isset($pkga['checkenablefields'])) + if (isset($pkga['enablefields']) || isset($pkga['checkenablefields'])) { $onclick = 'javascript:enablechange();'; - else + } else { $onclick = ''; + } - if($grouping) { + if ($grouping) { $group->add(new Form_Checkbox( $pkga['fieldname'], $pkga['fielddescr'], @@ -1061,7 +1070,7 @@ foreach ($pkg['fields']['field'] as $pkga) { } } - if(grouping) { + if (grouping) { $group->add(new Form_Input( $pkga['fieldname'], $pkga['fielddescr'], @@ -1178,7 +1187,7 @@ foreach ($pkg['fields']['field'] as $pkga) { $optionlist[$iface['ip']] = $iface['description']; } - if($grouping) { + if ($grouping) { $group->add(new Form_Select( $pkga['fieldname'], $pkga['fielddescr'], @@ -1210,7 +1219,7 @@ foreach ($pkg['fields']['field'] as $pkga) { // Create radio button case "radio": - if($grouping) { + if ($grouping) { $group->add(new Form_Checkbox( $pkga['fieldname'], $pkga['fielddescr'], @@ -1247,22 +1256,22 @@ foreach ($pkg['fields']['field'] as $pkga) { $pkga['fieldname'] ); - if(grouping) { + if (grouping) { $group->add(new Form_StaticText( null, $newbtn . '
' . '
' . fixup_string($pkga['description']) . '
' )); } else { if (isset($pkga['advancedfield']) && isset($advfield_count)) { - $advanced->addInput(new Form_StaticText( - null, - $newbtn . '
' . '
' . fixup_string($pkga['description']) . '
' - )); + $advanced->addInput(new Form_StaticText( + null, + $newbtn . '
' . '
' . fixup_string($pkga['description']) . '
' + )); } else { - $section->addInput(new Form_StaticText( - null, - $newbtn . '
' . '
' . fixup_string($pkga['description']) . '
' - )); + $section->addInput(new Form_StaticText( + null, + $newbtn . '
' . '
' . fixup_string($pkga['description']) . '
' + )); } } @@ -1289,7 +1298,7 @@ foreach ($pkg['fields']['field'] as $pkga) { } } - if($grouping) { + if ($grouping) { $group->add(new Form_Select( $pkga['fieldname'], $pkga['fielddescr'], @@ -1350,7 +1359,7 @@ foreach ($pkg['fields']['field'] as $pkga) { } $type = $rowhelper['type']; - if ($type == "input" || $type == "password" || $type == "textarea" ) { + if ($type == "input" || $type == "password" || $type == "textarea") { if (($rowhelper['encoding'] == 'base64') && !$get_from_post && !empty($value)) { $value = base64_decode($value); } @@ -1397,10 +1406,11 @@ foreach ($pkg['fields']['field'] as $pkga) { null )); - if($advanced) + if ($advanced) { $advanced->add($group); - else + } else { $section->add($group); + } $grouping = false; } @@ -1419,7 +1429,7 @@ $form->addGlobal(new Form_Input( )); // If we created an advanced section, add it (and a button) to the form here -if(!empty($advanced)) { +if (!empty($advanced)) { $form->addGlobal(new Form_Button( 'showadv', 'Show advanced options' @@ -1440,7 +1450,7 @@ if ($pkg['custom_php_after_form_command']) if ($pkg['fields']['field'] != "") { ?>