From 65daf6a04a776055ac01d751a50d483effaef089 Mon Sep 17 00:00:00 2001 From: Andy Grunwald Date: Thu, 20 Apr 2017 22:15:39 +0200 Subject: [PATCH] #6: Apply coding style guide PSR 1 and PSR 2 to ./modules/about (with php-cs-fixer) --- modules/about/credits.php | 1 - modules/about/design_info.php | 18 ++--- modules/about/generate_file_stats.php | 111 +++++++++++++------------- modules/about/license.php | 1 - modules/about/overview.php | 1 - 5 files changed, 63 insertions(+), 69 deletions(-) diff --git a/modules/about/credits.php b/modules/about/credits.php index 380b4d69f..31ed8c62c 100644 --- a/modules/about/credits.php +++ b/modules/about/credits.php @@ -68,4 +68,3 @@ $dsp->AddBackButton("index.php?mod=about", "about/credits"); $dsp->AddContent(); -?> diff --git a/modules/about/design_info.php b/modules/about/design_info.php index c1b1b30b9..817762aa2 100644 --- a/modules/about/design_info.php +++ b/modules/about/design_info.php @@ -2,20 +2,18 @@ include_once("inc/classes/class_xml.php"); $xml = new xml; -$xml_file = @fopen("design/" . $auth["design"] . "/design.xml","r"); -$xml_content = @fread($xml_file,filesize("design/".$auth["design"]."/design.xml")); +$xml_file = @fopen("design/" . $auth["design"] . "/design.xml", "r"); +$xml_content = @fread($xml_file, filesize("design/".$auth["design"]."/design.xml")); $design_name = $xml->get_tag_content("name", $xml_content); $dsp->NewContent("Designinfo zu '$design_name'", "Auf dieser Seite erhälst du Informationen über das derzeitige Lansuite-Erscheinungsbild"); $dsp->AddDoubleRow("Name", $design_name); -$dsp->AddDoubleRow("Version", $xml->get_tag_content("version",$xml_content)); -$dsp->AddDoubleRow("Beschreibung", $xml->get_tag_content("description",$xml_content)); -$dsp->AddDoubleRow("Autor", $xml->get_tag_content("author",$xml_content)); -$dsp->AddDoubleRow("Kontakt", $xml->get_tag_content("contact",$xml_content)); -$dsp->AddDoubleRow("Website", $xml->get_tag_content("website",$xml_content)); -$dsp->AddDoubleRow("Kommentar", $xml->get_tag_content("comments",$xml_content)); +$dsp->AddDoubleRow("Version", $xml->get_tag_content("version", $xml_content)); +$dsp->AddDoubleRow("Beschreibung", $xml->get_tag_content("description", $xml_content)); +$dsp->AddDoubleRow("Autor", $xml->get_tag_content("author", $xml_content)); +$dsp->AddDoubleRow("Kontakt", $xml->get_tag_content("contact", $xml_content)); +$dsp->AddDoubleRow("Website", $xml->get_tag_content("website", $xml_content)); +$dsp->AddDoubleRow("Kommentar", $xml->get_tag_content("comments", $xml_content)); $dsp->AddBackButton("index.php?mod=about", "about/design"); $dsp->AddContent(); - -?> \ No newline at end of file diff --git a/modules/about/generate_file_stats.php b/modules/about/generate_file_stats.php index 5612589fd..e74bcca06 100644 --- a/modules/about/generate_file_stats.php +++ b/modules/about/generate_file_stats.php @@ -1,59 +1,58 @@ (.*)", "$php_lines", $filecontent ); - $filecontent = eregi_replace( "(.*)", "$php_chars", $filecontent ); - $filecontent = eregi_replace( "(.*)", "$html_lines", $filecontent ); - $filecontent = eregi_replace( "(.*)", "$html_chars", $filecontent ); - fwrite( $fo, $filecontent ); - } - fclose( $fo ); - - -?> + function lets_open_the_dir($dir) + { + global $files; + + // Open the design-dir + $thedir = opendir($dir); + + // Reading all subdirs from design and fill them into an array + while (false !== ($content = readdir($thedir))) { + if ($content != "." and $content != "..") { + if (is_dir($dir."/".$content)) { + lets_open_the_dir($dir."/".$content); + } + if (file_exists($dir."/".$content)) { + $files[] = $dir."/".$content; + } + } + } + } + function get_the_lines_and_chars($file) + { + $file_content = file($file); + $data[0] = count($file_content); + for ($i=0; $i < count($file_content); $i++) { + $data[1] += strlen($file_content[$i]); + } + return $data; + } + + lets_open_the_dir($dir); + + foreach ($files as $file) { + if (eregi(".php", $file)) { + $data = get_the_lines_and_chars($file); + $php_lines += $data[0]; + $php_chars += $data[1]; + } + if (eregi(".htm", $file)) { + $data = get_the_lines_and_chars($file); + $html_lines += $data[0]; + $html_chars += $data[1]; + } + } + + $filecontents = file("modules/about/credits.php"); + $fo = fopen("modules/about/credits.php", "w"); + foreach ($filecontents as $filecontent) { + $filecontent = eregi_replace("(.*)", "$php_lines", $filecontent); + $filecontent = eregi_replace("(.*)", "$php_chars", $filecontent); + $filecontent = eregi_replace("(.*)", "$html_lines", $filecontent); + $filecontent = eregi_replace("(.*)", "$html_chars", $filecontent); + fwrite($fo, $filecontent); + } + fclose($fo); diff --git a/modules/about/license.php b/modules/about/license.php index 28a6f540e..cb8d4127e 100644 --- a/modules/about/license.php +++ b/modules/about/license.php @@ -3,4 +3,3 @@ $dsp->AddSmartyTpl('license', 'about'); $dsp->AddBackButton("index.php?mod=about", "about/license"); $dsp->AddContent(); -?> diff --git a/modules/about/overview.php b/modules/about/overview.php index 90d12128f..cb0f8cc34 100644 --- a/modules/about/overview.php +++ b/modules/about/overview.php @@ -6,4 +6,3 @@ $dsp->AddDoubleRow('', 'design'); $dsp->AddDoubleRow('', 'license'); $dsp->AddFieldsetEnd(); -?> \ No newline at end of file