From 89e756819d49d87f7ec55e5292475b3cc08d7d90 Mon Sep 17 00:00:00 2001 From: "Marcel Kapfer (mmk2410)" Date: Thu, 29 Dec 2016 21:54:37 +0100 Subject: [PATCH] Made BlogListGenerator PSR-2 conform --- index.php | 5 ++++- rcc/index.php | 4 +++- res/php/BlogListGenerator.php | 11 +++++------ res/php/Pagination.php | 1 + tests/BlogListGeneratorTest.php | 4 +++- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/index.php b/index.php index 9b90e2d..02e6d8a 100644 --- a/index.php +++ b/index.php @@ -25,7 +25,10 @@ date_default_timezone_set('UTC'); require __DIR__ . '/vendor/autoload.php'; // loading composer libs require './res/php/Config.php'; +require_once './res/php/BlogListGenerator.php'; + use mmk2410\rbe\config\Config as Config; +use mmk2410\rbe\BlogListGenerator\BlogListGenerator as BlogListGenerator; $configParser = new Config('config.yaml', 'vendor/autoload.php'); @@ -33,7 +36,7 @@ $config = $configParser->getConfig(); require './lang/' . $config["language"] . ".php"; // Language file require_once 'res/php/ArticleGenerator.php'; // The article generator -require_once './res/php/BlogListGenerator.php'; // and the blog list generator + // Getting some variables ($_GET and $_SERVER) $getblog = filter_input(INPUT_GET, "blog"); // get the blog variable diff --git a/rcc/index.php b/rcc/index.php index 3dd445d..74c6630 100644 --- a/rcc/index.php +++ b/rcc/index.php @@ -35,8 +35,10 @@ require '../vendor/autoload.php'; require '../res/php/Config.php'; +require "./../res/php/BlogListGenerator.php"; use \mmk2410\rbe\config\Config as Config; +use mmk2410\rbe\BlogListGenerator\BlogListGenerator as BlogListGenerator; $config = new Config("../config.yaml", '../vendor/autoload.php'); $settings = $config->getConfig(); @@ -108,7 +110,7 @@ if ($config["rcc"]["rcc"] == "on") { } else { if (password_verify($passwd, $password)) { $_SESSION['login'] = true; - include_once "./../res/php/BlogListGenerator.php"; + ?> diff --git a/res/php/BlogListGenerator.php b/res/php/BlogListGenerator.php index ab0159f..dc959dd 100644 --- a/res/php/BlogListGenerator.php +++ b/res/php/BlogListGenerator.php @@ -10,7 +10,7 @@ * @license MIT License * @link http://marcel-kapfer.de/rangitaki */ - +namespace mmk2410\rbe\BlogListGenerator; /** * The blog list generator class is a collection of functions for generating @@ -37,7 +37,7 @@ class BlogListGenerator * * @return None */ - function listBlog($directory, $blogname, $blogmaintitle) + public function listBlog($directory, $blogname, $blogmaintitle) { // get content of the blog file; $blog = file_get_contents($directory . $blogname); @@ -74,7 +74,7 @@ class BlogListGenerator * * @return string */ - function getName($file) + public function getName($file) { // get the content of the blog file $blog = file_get_contents($file); @@ -96,7 +96,7 @@ class BlogListGenerator * * @return int Amount of files */ - static function getArticleAmount($blog) + public static function getArticleAmount($blog) { $directory = "./articles/" . $blog . "/"; if (!file_exists($directory)) { @@ -104,7 +104,7 @@ class BlogListGenerator } else { $i = 0; $handle = opendir($directory); - while (($file = readdir($handle)) !== false ) { + while (($file = readdir($handle)) !== false) { if (!in_array($file, array('.','..'))) { $i++; } @@ -112,5 +112,4 @@ class BlogListGenerator return $i; } } - } diff --git a/res/php/Pagination.php b/res/php/Pagination.php index 1555fee..80ee618 100644 --- a/res/php/Pagination.php +++ b/res/php/Pagination.php @@ -11,6 +11,7 @@ * @link http://marcel-kapfer.de/rangitaki */ require_once "BlogListGenerator.php"; +use mmk2410\rbe\BlogListGenerator\BlogListGenerator as BlogListGenerator; require_once './res/php/Config.php'; diff --git a/tests/BlogListGeneratorTest.php b/tests/BlogListGeneratorTest.php index 6c883a2..28038cc 100644 --- a/tests/BlogListGeneratorTest.php +++ b/tests/BlogListGeneratorTest.php @@ -1,7 +1,9 @@