forked from projects/fipamo
Updated PHP lint to @PSR12 b/c @PSR2 is deprecated
So, @PSR12 is the recommended coding standard, so I updated the config and reformatted the appropriate files. Again. Whew.
This commit is contained in:
parent
63eaba08e2
commit
a31dff94cb
23 changed files with 106 additions and 27 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
return (new PhpCsFixer\Config())
|
||||
->setRules([
|
||||
'@PSR2' => true,
|
||||
'@PSR12' => true,
|
||||
'array_indentation' => true,
|
||||
'array_syntax' => [
|
||||
'syntax' => 'short',
|
||||
|
@ -11,8 +11,10 @@ return (new PhpCsFixer\Config())
|
|||
'method_chaining_indentation' => true,
|
||||
'class_attributes_separation' => [
|
||||
'elements' => [
|
||||
'method' => 'none',
|
||||
'trait_import' => 'none'
|
||||
'const' => 'none',
|
||||
'method' => 'one',
|
||||
'property' => 'none',
|
||||
'trait_import' => 'none',
|
||||
],
|
||||
],
|
||||
'multiline_whitespace_before_semicolons' => [
|
||||
|
@ -44,7 +46,6 @@ return (new PhpCsFixer\Config())
|
|||
'lowercase_cast' => true,
|
||||
'no_extra_blank_lines' => [
|
||||
'tokens' => [
|
||||
'use',
|
||||
'curly_brace_block',
|
||||
'extra',
|
||||
'parenthesis_brace_block',
|
||||
|
|
|
@ -10,6 +10,7 @@ class AuthAPI
|
|||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function status()
|
||||
{
|
||||
$result = [];
|
||||
|
@ -28,6 +29,7 @@ class AuthAPI
|
|||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function login($body)
|
||||
{
|
||||
$result = [];
|
||||
|
@ -54,6 +56,7 @@ class AuthAPI
|
|||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function logout($body)
|
||||
{
|
||||
Auth::logout($body);
|
||||
|
@ -63,11 +66,13 @@ class AuthAPI
|
|||
];
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function requestSecret($body)
|
||||
{
|
||||
$result = Auth::findSecret($body);
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function resetPassword($body)
|
||||
{
|
||||
$result = Auth::makeNewPassword($body);
|
||||
|
|
|
@ -11,6 +11,7 @@ class ImagesAPI
|
|||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function uploadImage($request, $type = null)
|
||||
{
|
||||
$file = $request->getUploadedFiles();
|
||||
|
|
|
@ -9,6 +9,7 @@ class InitAPI
|
|||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function handleInitTasks($task, $request)
|
||||
{
|
||||
//check if a site config already exists. if it does, deny set up request
|
||||
|
|
|
@ -10,6 +10,7 @@ class MailerAPI
|
|||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function handleMail($request, $body, $response)
|
||||
{
|
||||
// if testing, verify session is active
|
||||
|
|
|
@ -6,6 +6,7 @@ use brain\data\Book;
|
|||
use brain\data\Settings;
|
||||
use brain\data\Session;
|
||||
use brain\utility\StringTools;
|
||||
|
||||
use function _\filter;
|
||||
|
||||
class PagesAPI
|
||||
|
@ -13,6 +14,7 @@ class PagesAPI
|
|||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function getPageContent($request, $args)
|
||||
{
|
||||
$task = $args['fourth'];
|
||||
|
@ -101,6 +103,7 @@ class PagesAPI
|
|||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function handlePageTask($request, $args)
|
||||
{
|
||||
$task = $args['fourth'];
|
||||
|
|
|
@ -12,6 +12,7 @@ class SettingsAPI
|
|||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function handleSettingsTask($request, $args, $body = null)
|
||||
{
|
||||
$task = $args['fourth'];
|
||||
|
@ -26,7 +27,8 @@ class SettingsAPI
|
|||
true
|
||||
);
|
||||
//check to see if dynamic rendering is active
|
||||
if (isset($settings['global']['dynamicRender']) &&
|
||||
if (
|
||||
isset($settings['global']['dynamicRender']) &&
|
||||
$settings['global']['dynamicRender'] === 'true'
|
||||
) {
|
||||
$result = [
|
||||
|
@ -97,6 +99,7 @@ class SettingsAPI
|
|||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function getInfo($request, $args)
|
||||
{
|
||||
$task = $args['fourth'];
|
||||
|
@ -140,6 +143,7 @@ class SettingsAPI
|
|||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function createBackup()
|
||||
{
|
||||
$result = Maintenance::makeBackup();
|
||||
|
|
|
@ -103,6 +103,7 @@ class APIControl
|
|||
return $response->withHeader('Content-Type', 'application/json');
|
||||
}
|
||||
}
|
||||
|
||||
public static function post(
|
||||
ServerRequestInterface $request,
|
||||
ResponseInterface $response,
|
||||
|
|
|
@ -7,6 +7,7 @@ use Psr\Http\Message\ServerRequestInterface;
|
|||
use Slim\Views\Twig;
|
||||
use brain\data\Settings;
|
||||
use brain\utility\Sorting;
|
||||
|
||||
use function _\find;
|
||||
|
||||
class IndexControl
|
||||
|
|
|
@ -24,6 +24,7 @@ class RouteControl
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function post(
|
||||
ServerRequestInterface $request,
|
||||
ResponseInterface $response,
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace brain\data;
|
||||
|
||||
use ReallySimpleJWT\Token;
|
||||
|
||||
use function _\find;
|
||||
|
||||
class Auth
|
||||
|
@ -10,6 +11,7 @@ class Auth
|
|||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function sessionStatus()
|
||||
{
|
||||
if (isset($_SESSION['member'])) {
|
||||
|
@ -19,6 +21,7 @@ class Auth
|
|||
}
|
||||
//return $this->secret;
|
||||
}
|
||||
|
||||
public static function status()
|
||||
{
|
||||
$result = '';
|
||||
|
@ -29,6 +32,7 @@ class Auth
|
|||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function login($who)
|
||||
{
|
||||
//grab member list
|
||||
|
@ -69,14 +73,13 @@ class Auth
|
|||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function findSecret($data)
|
||||
{
|
||||
$result = [];
|
||||
$folks = (new Settings())->getFolks();
|
||||
|
||||
if (!empty($data['email']) &&
|
||||
filter_var($data['email'], FILTER_VALIDATE_EMAIL)
|
||||
) {
|
||||
if (!empty($data['email']) && filter_var($data['email'], FILTER_VALIDATE_EMAIL)) {
|
||||
$found = find($folks, ['email' => $data['email']]);
|
||||
if ($found) {
|
||||
//if email is cool, check mail relay status
|
||||
|
@ -110,6 +113,7 @@ class Auth
|
|||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function makeNewPassword($data)
|
||||
{
|
||||
//check if passwordsmatch
|
||||
|
@ -142,6 +146,7 @@ class Auth
|
|||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function logout()
|
||||
{
|
||||
Session::kill();
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace brain\data;
|
|||
use brain\utility\DocTools;
|
||||
use brain\utility\StringTools;
|
||||
use brain\utility\FileUploader;
|
||||
|
||||
use function _\find;
|
||||
use function _\filter;
|
||||
|
||||
|
@ -13,6 +14,7 @@ class Book
|
|||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function findPageById(string $uuid)
|
||||
{
|
||||
$content = $this->getContents();
|
||||
|
@ -20,6 +22,7 @@ class Book
|
|||
|
||||
return $page;
|
||||
}
|
||||
|
||||
public function findPageBySlug(string $slug = null)
|
||||
{
|
||||
$content = $this->getContents();
|
||||
|
@ -31,6 +34,7 @@ class Book
|
|||
|
||||
return $page;
|
||||
}
|
||||
|
||||
public function editPage($task, $request)
|
||||
{
|
||||
$content = $this->getContents();
|
||||
|
@ -204,6 +208,7 @@ class Book
|
|||
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function getPages(int $page, int $limit, string $sort = null)
|
||||
{
|
||||
$content = $this->getContents();
|
||||
|
@ -278,6 +283,7 @@ class Book
|
|||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function getContents()
|
||||
{
|
||||
// test new contents data class
|
||||
|
|
|
@ -2,28 +2,31 @@
|
|||
|
||||
namespace brain\data;
|
||||
|
||||
use HtmlSanitizer\Extension\Basic\BasicExtension;
|
||||
use HtmlSanitizer\Extension\Iframe\IframeExtension;
|
||||
use HtmlSanitizer\Extension\Listing\ListExtension;
|
||||
use HtmlSanitizer\SanitizerBuilder;
|
||||
use League\CommonMark\Environment\Environment;
|
||||
use League\CommonMark\Extension\Attributes\AttributesExtension;
|
||||
use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension;
|
||||
use League\CommonMark\Extension\FrontMatter\FrontMatterExtension;
|
||||
use League\CommonMark\Extension\FrontMatter\Output\RenderedContentWithFrontMatter;
|
||||
use League\CommonMark\Extension\Strikethrough\StrikethroughExtension;
|
||||
use League\CommonMark\MarkdownConverter;
|
||||
use League\CommonMark\Environment\Environment;
|
||||
use HtmlSanitizer\Extension\Basic\BasicExtension;
|
||||
use HtmlSanitizer\Extension\Listing\ListExtension;
|
||||
use HtmlSanitizer\Extension\Iframe\IframeExtension;
|
||||
use League\CommonMark\Extension\Attributes\AttributesExtension;
|
||||
use League\CommonMark\Extension\FrontMatter\FrontMatterExtension;
|
||||
use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension;
|
||||
use League\CommonMark\Extension\Strikethrough\StrikethroughExtension;
|
||||
use League\CommonMark\Extension\FrontMatter\Output\RenderedContentWithFrontMatter;
|
||||
|
||||
use function _\orderBy;
|
||||
|
||||
class Contents
|
||||
{
|
||||
public $files = [];
|
||||
public $files = [];
|
||||
|
||||
public $config = [];
|
||||
|
||||
public function __construct($folder)
|
||||
{
|
||||
$this->read($folder);
|
||||
}
|
||||
|
||||
public function read($folder)
|
||||
{
|
||||
$folders = glob("$folder/*", GLOB_ONLYDIR);
|
||||
|
@ -36,6 +39,7 @@ class Contents
|
|||
$this->files[] = $file;
|
||||
}
|
||||
}
|
||||
|
||||
public function getAll()
|
||||
{
|
||||
$environment = new Environment($this->config);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace brain\data;
|
||||
|
||||
use brain\utility\DocTools;
|
||||
|
||||
use function _\find;
|
||||
|
||||
class Member
|
||||
|
@ -10,6 +11,7 @@ class Member
|
|||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function verifyKey(string $key)
|
||||
{
|
||||
if (isset($key)) {
|
||||
|
@ -24,6 +26,7 @@ class Member
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function updateData(string $key, string $data, $secret = null)
|
||||
{
|
||||
$folks = (new Settings())->getFolks();
|
||||
|
|
|
@ -4,14 +4,19 @@ namespace brain\data;
|
|||
|
||||
use brain\utility\Sorting;
|
||||
use brain\utility\DocTools;
|
||||
|
||||
use function _\find;
|
||||
|
||||
class Render
|
||||
{
|
||||
public $loader;
|
||||
|
||||
public $twig;
|
||||
|
||||
public $pageInfo;
|
||||
|
||||
public $menu;
|
||||
|
||||
public $background;
|
||||
|
||||
public function __construct()
|
||||
|
@ -88,6 +93,7 @@ class Render
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function renderPages()
|
||||
{
|
||||
$pages = (new Book())->getContents();
|
||||
|
@ -122,6 +128,7 @@ class Render
|
|||
DocTools::writeHTML($location, $html, $dir);
|
||||
}
|
||||
}
|
||||
|
||||
public function renderArchive()
|
||||
{
|
||||
$archive = Sorting::archive();
|
||||
|
@ -138,6 +145,7 @@ class Render
|
|||
$location = '../public/archives.html';
|
||||
DocTools::writeHTML($location, $html);
|
||||
}
|
||||
|
||||
public function renderTags()
|
||||
{
|
||||
$list = Sorting::tags();
|
||||
|
@ -170,6 +178,7 @@ class Render
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function renderIndex()
|
||||
{
|
||||
//TODO: Need to fix this to account for new index templating system
|
||||
|
|
|
@ -23,6 +23,7 @@ class Session
|
|||
fclose($new);
|
||||
}
|
||||
}
|
||||
|
||||
public static function active()
|
||||
{
|
||||
if (!is_file(self::$file)) {
|
||||
|
@ -34,7 +35,8 @@ class Session
|
|||
if ($secret == null) {
|
||||
return false;
|
||||
} else {
|
||||
if (Token::validate($data['token'], $secret) &&
|
||||
if (
|
||||
Token::validate($data['token'], $secret) &&
|
||||
Token::validateExpiration($data['token'], $secret)
|
||||
) {
|
||||
return true;
|
||||
|
@ -47,12 +49,14 @@ class Session
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function verifyToken($token)
|
||||
{
|
||||
$data = json_decode(file_get_contents(self::$file), true);
|
||||
if ($data['member'] != null) {
|
||||
$secret = (new Settings())->getFolks('secret');
|
||||
if (Token::validate($token, $secret) &&
|
||||
if (
|
||||
Token::validate($token, $secret) &&
|
||||
Token::validateExpiration($token, $secret)
|
||||
) {
|
||||
return true;
|
||||
|
@ -63,6 +67,7 @@ class Session
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function set($key, $value)
|
||||
{
|
||||
$data = json_decode(file_get_contents(self::$file), true);
|
||||
|
@ -71,12 +76,14 @@ class Session
|
|||
fwrite($fresh, json_encode($data));
|
||||
fclose($fresh);
|
||||
}
|
||||
|
||||
public static function get($key)
|
||||
{
|
||||
$data = json_decode(file_get_contents(self::$file), true);
|
||||
|
||||
return $data[$key];
|
||||
}
|
||||
|
||||
public static function kill()
|
||||
{
|
||||
($fresh = fopen(self::$file, 'w')) or die('Unable to open file!');
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace brain\data;
|
|||
|
||||
use brain\utility\DocTools;
|
||||
use brain\utility\Sorting;
|
||||
|
||||
use function _\find;
|
||||
use function _\pull;
|
||||
use function _\remove;
|
||||
|
@ -24,6 +25,7 @@ class Settings
|
|||
true
|
||||
);
|
||||
}
|
||||
|
||||
public static function sync($data)
|
||||
{
|
||||
$settings = self::$settings;
|
||||
|
@ -46,6 +48,7 @@ class Settings
|
|||
|
||||
DocTools::writeSettings('../config/settings.json', $settings);
|
||||
}
|
||||
|
||||
public static function navSync($data)
|
||||
{
|
||||
$settings = self::$settings;
|
||||
|
@ -94,6 +97,7 @@ class Settings
|
|||
|
||||
DocTools::writeSettings('../config/settings.json', $settings);
|
||||
}
|
||||
|
||||
public function getFolks($key = null)
|
||||
{
|
||||
if (isset($key)) {
|
||||
|
@ -106,25 +110,30 @@ class Settings
|
|||
return $this->folks;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSettings($key = null)
|
||||
{
|
||||
return self::$settings;
|
||||
}
|
||||
|
||||
public static function getTags()
|
||||
{
|
||||
return self::$tags;
|
||||
}
|
||||
|
||||
public static function updateGlobalData($key, $data)
|
||||
{
|
||||
$settings = self::$settings;
|
||||
$settings['global'][$key] = $data;
|
||||
DocTools::writeSettings('../config/settings.json', $settings);
|
||||
}
|
||||
|
||||
public static function getCurrentIndex()
|
||||
{
|
||||
$settings = self::$settings;
|
||||
return $settings['library_stats']['current_index'];
|
||||
}
|
||||
|
||||
public static function updateIndex()
|
||||
{
|
||||
$settings = self::$settings;
|
||||
|
@ -133,6 +142,7 @@ class Settings
|
|||
|
||||
DocTools::writeSettings('../config/settings.json', $settings);
|
||||
}
|
||||
|
||||
public static function updateMenu($body)
|
||||
{
|
||||
$settings = self::$settings;
|
||||
|
@ -155,6 +165,7 @@ class Settings
|
|||
}
|
||||
DocTools::writeSettings('../config/settings.json', $settings);
|
||||
}
|
||||
|
||||
public static function updateTags()
|
||||
{
|
||||
$tags = Sorting::tags();
|
||||
|
|
|
@ -16,10 +16,12 @@ class Themes
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function getThemes()
|
||||
{
|
||||
return $this->themes;
|
||||
}
|
||||
|
||||
public function getCustomIndex()
|
||||
{
|
||||
$settings = (new Settings())->getSettings();
|
||||
|
@ -38,6 +40,7 @@ class Themes
|
|||
}
|
||||
return $views;
|
||||
}
|
||||
|
||||
public function getCustomViews()
|
||||
{
|
||||
$settings = (new Settings())->getSettings();
|
||||
|
|
|
@ -7,6 +7,7 @@ class DocTools
|
|||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function writePages($task, $path, $fileLocation, $fileContents)
|
||||
{
|
||||
try {
|
||||
|
@ -27,6 +28,7 @@ class DocTools
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function writeSettings($fileLocation, $fileContents)
|
||||
{
|
||||
if (!is_file($fileLocation)) {
|
||||
|
@ -37,6 +39,7 @@ class DocTools
|
|||
fclose($new);
|
||||
}
|
||||
}
|
||||
|
||||
public static function writeHTML($location, $html, $path = null)
|
||||
{
|
||||
if ($path != null) {
|
||||
|
@ -53,6 +56,7 @@ class DocTools
|
|||
fclose($new);
|
||||
}
|
||||
}
|
||||
|
||||
public static function deleteFolder($path)
|
||||
{
|
||||
if (!empty($path) && is_dir($path)) {
|
||||
|
@ -79,6 +83,7 @@ class DocTools
|
|||
rmdir($path);
|
||||
}
|
||||
}
|
||||
|
||||
public static function objectToMD($object)
|
||||
{
|
||||
$markdown = "---\n" .
|
||||
|
|
|
@ -9,6 +9,7 @@ class Maintenance
|
|||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function makeBackup()
|
||||
{
|
||||
//make sure back directory is there
|
||||
|
|
|
@ -14,6 +14,7 @@ class SetUp
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function init($body)
|
||||
{
|
||||
//grab template files
|
||||
|
@ -93,6 +94,7 @@ class SetUp
|
|||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function restore($request)
|
||||
{
|
||||
$result = [
|
||||
|
|
|
@ -10,8 +10,8 @@ use Mni\FrontYAML\Parser;
|
|||
|
||||
class Sorting
|
||||
{
|
||||
private static $_tags = [];
|
||||
private static $_archive = [];
|
||||
private static $p_tags = [];
|
||||
private static $p_archive = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
@ -24,8 +24,8 @@ class Sorting
|
|||
$temp = explode(',', $page['tags']);
|
||||
foreach ($temp as $tag) {
|
||||
$label = trim($tag);
|
||||
if (!find(self::$_tags, ['tag_name' => $label])) {
|
||||
array_push(self::$_tags, [
|
||||
if (!find(self::$p_tags, ['tag_name' => $label])) {
|
||||
array_push(self::$p_tags, [
|
||||
'tag_name' => $label,
|
||||
'slug' => StringTools::safeString($label),
|
||||
'pages' => self::tagPages($label, $pages),
|
||||
|
@ -34,7 +34,7 @@ class Sorting
|
|||
}
|
||||
}
|
||||
|
||||
return self::$_tags;
|
||||
return self::$p_tags;
|
||||
}
|
||||
private static function tagPages($tag, $pages)
|
||||
{
|
||||
|
@ -91,13 +91,13 @@ class Sorting
|
|||
]);
|
||||
}
|
||||
}
|
||||
array_push(self::$_archive, [
|
||||
array_push(self::$p_archive, [
|
||||
'year' => $year['year'],
|
||||
'year_data' => $sorted,
|
||||
]);
|
||||
}
|
||||
|
||||
return self::$_archive;
|
||||
return self::$p_archive;
|
||||
}
|
||||
public static function page($page)
|
||||
{
|
||||
|
|
|
@ -26,6 +26,7 @@ class StringTools
|
|||
mt_rand(0, 65535)
|
||||
);
|
||||
}
|
||||
|
||||
public static function sanitizeContent($entry)
|
||||
{
|
||||
$parser = new Parser();
|
||||
|
@ -62,6 +63,7 @@ class StringTools
|
|||
|
||||
return $cleaned;
|
||||
}
|
||||
|
||||
public static function safeString($string)
|
||||
{
|
||||
return strtolower(
|
||||
|
@ -83,6 +85,7 @@ class StringTools
|
|||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static function randomString(int $length)
|
||||
{
|
||||
$alphanum = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
|
@ -113,6 +116,7 @@ class StringTools
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function checkSpecial($string)
|
||||
{
|
||||
$specials = ['*', '&', '!', '@', '%', '^', '#', '$'];
|
||||
|
|
Loading…
Reference in a new issue