minor fixes here and there

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2018-12-22 13:42:10 +01:00
parent 13aa19e5f4
commit 3794003e63
8 changed files with 55 additions and 19 deletions

View File

@@ -31,7 +31,10 @@ return array(
'type' => 'option',
'default' => 'English',
'option_mode' => 'one',
'option_options_method' => array('\\Froxlor\\User', 'getLanguages'),
'option_options_method' => array(
'\\Froxlor\\User',
'getLanguages'
),
'save_method' => 'storeSettingField'
),
'panel_default_theme' => array(
@@ -44,7 +47,10 @@ return array(
'type' => 'option',
'default' => 'Froxlor',
'option_mode' => 'one',
'option_options_method' => 'getThemes',
'option_options_method' => array(
'\\Froxlor\\UI\\Template',
'getThemes'
),
'save_method' => 'storeSettingDefaultTheme'
),
'panel_allow_theme_change_customer' => array(

View File

@@ -300,7 +300,7 @@ if ($page == 'overview') {
$default_theme = $userinfo['theme'];
}
$themes_avail = getThemes();
$themes_avail = \Froxlor\UI\Template::getThemes();
foreach ($themes_avail as $t => $d) {
$theme_options .= \Froxlor\UI\HTML::makeoption($d, $t, $default_theme, true);
}

View File

@@ -59,7 +59,7 @@ if ($page == 'overview' && $userinfo['change_serversettings'] == '1') {
\Froxlor\UI\Response::standard_error($lng['error']['session_timeout'], $lng['error']['session_timeout_desc']);
}
if (processFormEx($settings_data, $_POST, array(
if (\Froxlor\UI\Form::processFormEx($settings_data, $_POST, array(
'filename' => $filename,
'action' => $action,
'page' => $page

View File

@@ -271,7 +271,7 @@ if ($page == 'overview') {
}
$theme_options = '';
$themes_avail = getThemes();
$themes_avail = \Froxlor\UI\Template::getThemes();
foreach ($themes_avail as $t => $d) {
$theme_options .= \Froxlor\UI\HTML::makeoption($d, $t, $default_theme, true);
}

View File

@@ -382,7 +382,7 @@ function parseAndOutputPreconfig(&$has_preconfig, &$return, $current_version, $c
$description = 'As you can (obviously) see, Froxlor now comes with a new theme. You also have the possibility to switch back to "Classic" if you want to.';
$question = '<strong>Select default panel theme:</strong>&nbsp;';
$question .= '<select name="update_default_theme">';
$themes = getThemes();
$themes = \Froxlor\UI\Template::getThemes();
foreach ($themes as $cur_theme) // $theme is already in use
{
$question .= makeoption($cur_theme, $cur_theme, 'Froxlor');
@@ -401,7 +401,7 @@ function parseAndOutputPreconfig(&$has_preconfig, &$return, $current_version, $c
$question = '<strong>Select your preferred Classic Theme replacement:</strong>&nbsp;';
$question .= '<select name="classic_theme_replacement">';
$themes = getThemes();
$themes = \Froxlor\UI\Template::getThemes();
foreach ($themes as $cur_theme) {
$question .= makeoption($cur_theme, $cur_theme, 'Froxlor');
}

View File

@@ -10,13 +10,13 @@ class Form
{
$fields = '';
if (validateFormDefinition($form)) {
if (\Froxlor\Validate\Form::validateFormDefinition($form)) {
foreach ($form['groups'] as $groupname => $groupdetails) {
if (isset($groupdetails['title']) && $groupdetails['title'] != '') {
$fields .= self::getFormGroupOutput($groupname, $groupdetails);
}
if (validateFieldDefinition($groupdetails)) {
if (\Froxlor\Validate\Form::validateFieldDefinition($groupdetails)) {
// Prefetch form fields
foreach ($groupdetails['fields'] as $fieldname => $fielddetails) {
$groupdetails['fields'][$fieldname] = self::array_merge_prefix($fielddetails, $fielddetails['type'], prefetchFormFieldData($fieldname, $fielddetails));
@@ -38,7 +38,7 @@ class Form
{
$fields = '';
if (validateFormDefinition($form)) {
if (\Froxlor\Validate\Form::validateFormDefinition($form)) {
foreach ($form['groups'] as $groupname => $groupdetails) {
// show overview
if ($part == '') {
@@ -73,10 +73,10 @@ class Form
$fields .= self::getFormGroupOutput($groupname, $groupdetails);
}
if (validateFieldDefinition($groupdetails)) {
if (\Froxlor\Validate\Form::validateFieldDefinition($groupdetails)) {
// Prefetch form fields
foreach ($groupdetails['fields'] as $fieldname => $fielddetails) {
$groupdetails['fields'][$fieldname] = self::array_merge_prefix($fielddetails, $fielddetails['type'], prefetchFormFieldData($fieldname, $fielddetails));
$groupdetails['fields'][$fieldname] = self::array_merge_prefix($fielddetails, $fielddetails['type'], self::prefetchFormFieldData($fieldname, $fielddetails));
$form['groups'][$groupname]['fields'][$fieldname] = $groupdetails['fields'][$fieldname];
}
@@ -93,7 +93,7 @@ class Form
return $fields;
}
function processForm(&$form, &$input, $url_params = array())
public static function processForm(&$form, &$input, $url_params = array())
{
if (\Froxlor\Validate\Form::validateFormDefinition($form)) {
$submitted_fields = array();
@@ -188,9 +188,9 @@ class Form
}
}
function processFormEx(&$form, &$input, $url_params = array(), $part, $settings_all, $settings_part, $only_enabledisable)
public static function processFormEx(&$form, &$input, $url_params = array(), $part, $settings_all, $settings_part, $only_enabledisable)
{
if (validateFormDefinition($form)) {
if (\Froxlor\Validate\Form::validateFormDefinition($form)) {
$submitted_fields = array();
$changed_fields = array();
$saved_fields = array();
@@ -201,7 +201,7 @@ class Form
// Prefetch form fields
foreach ($groupdetails['fields'] as $fieldname => $fielddetails) {
if (! $only_enabledisable || ($only_enabledisable && isset($fielddetails['overview_option']))) {
$groupdetails['fields'][$fieldname] = self::array_merge_prefix($fielddetails, $fielddetails['type'], prefetchFormFieldData($fieldname, $fielddetails));
$groupdetails['fields'][$fieldname] = self::array_merge_prefix($fielddetails, $fielddetails['type'], self::prefetchFormFieldData($fieldname, $fielddetails));
$form['groups'][$groupname]['fields'][$fieldname] = $groupdetails['fields'][$fieldname];
}
}
@@ -233,7 +233,7 @@ class Form
foreach ($form['groups'] as $groupname => $groupdetails) {
if (($settings_part && $part == $groupname) || $settings_all || $only_enabledisable) {
if (validateFieldDefinition($groupdetails)) {
if (\Froxlor\Validate\Form::validateFieldDefinition($groupdetails)) {
// Check fields for plausibility
foreach ($groupdetails['fields'] as $fieldname => $fielddetails) {
if (! $only_enabledisable || ($only_enabledisable && isset($fielddetails['overview_option']))) {
@@ -276,7 +276,7 @@ class Form
foreach ($form['groups'] as $groupname => $groupdetails) {
if (($settings_part && $part == $groupname) || $settings_all || $only_enabledisable) {
if (validateFieldDefinition($groupdetails)) {
if (\Froxlor\Validate\Form::validateFieldDefinition($groupdetails)) {
// Save fields
foreach ($groupdetails['fields'] as $fieldname => $fielddetails) {
if (! $only_enabledisable || ($only_enabledisable && isset($fielddetails['overview_option']))) {

View File

@@ -36,7 +36,8 @@ require dirname(__DIR__) . '/vendor/autoload.php';
require dirname(__DIR__) . '/lib/tables.inc.php';
// include consts
require dirname(__DIR__) . '/lib/functions/logger/constant.logger.php';
require dirname(__DIR__) . '/lib/functions/constant.formfields.php';
require dirname(__DIR__) . '/lib/functions/constant.logger.php';
use Froxlor\Database\Database;
use Froxlor\Settings;

29
tests/linting.php Normal file
View File

@@ -0,0 +1,29 @@
<?php
require dirname(__DIR__) . '/vendor/autoload.php';
// Includes the Functions
require \Froxlor\Froxlor::getInstallDir() . '/lib/functions/constant.formfields.php';
require \Froxlor\Froxlor::getInstallDir() . '/lib/functions/constant.logger.php';
// Includes the MySQL-Tabledefinitions etc.
require \Froxlor\Froxlor::getInstallDir() . '/lib/tables.inc.php';
$functions = get_defined_functions();
$calls = array();
foreach ($functions['user'] as $func) {
// grep for function
exec('grep -ir "'.$func.'" '.dirname(__DIR__).'/lib/', $output);
exec('grep -ir "'.$func.'" '.dirname(__DIR__).'/install/', $output);
exec('grep -ir "'.$func.'" '.dirname(__DIR__).'/actions/', $output);
exec('grep -ir "'.$func.'" '.dirname(__DIR__).'/*.php', $output);
echo "***********************************************".PHP_EOL;
echo "******* ". $func." ************************".PHP_EOL;
echo "***********************************************".PHP_EOL;
foreach ($output as $file) {
echo str_replace(dirname(__DIR__), "", $file) . PHP_EOL;
}
echo PHP_EOL;
$output = array();
}