openrat-cms

# OpenRat Content Management System
git clone http://git.code.weiherhei.de/openrat-cms.git
Log | Files | Refs

commit dd683cbdb20705051fc549193c26549890515400
parent 5f0505b8253afdab0855c6417d052216f612dcdb
Author: Jan Dankert <develop@jandankert.de>
Date:   Tue, 12 Nov 2019 22:49:28 +0100

New: Nicer output of the whole configuration.

Diffstat:
.editorconfig | 3++-
modules/cms-core/action/ConfigurationAction.class.php | 20+++++++++++++-------
modules/util/ArrayUtils.class.php | 45+++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 60 insertions(+), 8 deletions(-)

diff --git a/.editorconfig b/.editorconfig @@ -11,12 +11,13 @@ tab_width = 4 [*.php] indent_style = tab -indent_size = 1 +indent_size = tab [*.xml] indent_style = tab indent_size = 1 + [*.js] indent_style = tab indent_size = 1 diff --git a/modules/cms-core/action/ConfigurationAction.class.php b/modules/cms-core/action/ConfigurationAction.class.php @@ -59,14 +59,20 @@ class ConfigurationAction extends BaseAction // Language are to much entries unset($conf_cms['language']); - $split = "\xC2\xA0"."\xC2\xA0"."\xC2\xBB"."\xC2\xA0"."\xC2\xA0"; - $conf_cms['system'] = $this->getSystemConfiguration(); - - $flatDefaultConfig = \ArrayUtils::flattenArray('', $conf_default , $split ); - $flatCMSConfig = \ArrayUtils::flattenArray('', Session::getConfig(), $split ); - $flatConfig = \ArrayUtils::flattenArray('', $conf_cms , $split ); - + $conf_cms['system'] = $this->getSystemConfiguration(); + + //$split = "\xC2\xA0"."\xC2\xA0"."\xC2\xBB"."\xC2\xA0"."\xC2\xA0"; + //$flatDefaultConfig = \ArrayUtils::flattenArray('', $conf_default , $split ); + //$flatCMSConfig = \ArrayUtils::flattenArray('', Session::getConfig(), $split ); + //$flatConfig = \ArrayUtils::flattenArray('', $conf_cms , $split ); + + $pad = str_repeat("\xC2\xA0",10); // Hard spaces + + $flatDefaultConfig = \ArrayUtils::dryFlattenArray( $conf_default , $pad ); + $flatCMSConfig = \ArrayUtils::dryFlattenArray( Session::getConfig(), $pad ); + $flatConfig = \ArrayUtils::dryFlattenArray( $conf_cms , $pad ); + $config = array(); foreach( $flatConfig as $key=>$val ) $config[] = array( 'key'=>$key,'value'=>substr($key,-8)=='password'?'*******************':$val,'class'=>(empty($flatCMSConfig[$key])?'readonly':(isset($flatDefaultConfig[$key]) && $flatDefaultConfig[$key]==$flatConfig[$key]?'default':'changed'))); diff --git a/modules/util/ArrayUtils.class.php b/modules/util/ArrayUtils.class.php @@ -61,4 +61,49 @@ class ArrayUtils } return $new; } + + + /** + * Make a dry flat array. + * + * @param $arr + * @param int $depth + * @return array + */ + public static function indentedFlattenArray($arr, $padChar = '', $depth = 0) + { + $new = array(); + foreach ($arr as $key => $val) { + if (is_array($val)) { + + $new[] = array('depth'=>$depth, 'key'=>$key,'val'=>''); + $new += self::indentedFlattenArray($val, $padChar, $depth + 1); + } else + $new[] = array('depth'=>$depth, 'key'=>$key,'val'=>$val); + } + return $new; + } + + + + /** + * Make a dry flat array. + * + * @param $arr + * @param $padChar + * @param int $depth + * @return array + */ + public static function dryFlattenArray($arr, $padChar = '', $depth = 0) + { + $new = array(); + foreach ($arr as $key => $val) { + if (is_array($val)) { + $new[str_repeat($padChar,$depth).$key] = ''; + $new += self::dryFlattenArray($val, $padChar, $depth + 1); + } else + $new[str_repeat($padChar,$depth).$key] = $val; + } + return $new; + } } \ No newline at end of file