From c5d8585824f5a8a5438c188d2ff0f43f1db0b408 Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 23 Feb 2020 18:12:14 +0000 Subject: [PATCH] info command --- core/extension.php | 5 +++-- core/imageboard/event.php | 2 +- core/polyfills.php | 3 ++- ext/et/main.php | 15 ++++++++++++++- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/core/extension.php b/core/extension.php index bfeaf900..bb2cc782 100644 --- a/core/extension.php +++ b/core/extension.php @@ -460,9 +460,10 @@ abstract class DataHandlerExtension extends Extension abstract protected function create_image_from_data(string $filename, array $metadata); abstract protected function create_thumb(string $hash, string $type): bool; - public static function get_all_supported_exts(): array { + public static function get_all_supported_exts(): array + { $arr = []; - foreach(getSubclassesOf("DataHandlerExtension") as $handler) { + foreach (getSubclassesOf("DataHandlerExtension") as $handler) { $arr = array_merge($arr, $handler->SUPPORTED_EXT); } return $arr; diff --git a/core/imageboard/event.php b/core/imageboard/event.php index ca163771..13883e67 100644 --- a/core/imageboard/event.php +++ b/core/imageboard/event.php @@ -137,7 +137,7 @@ class ParseLinkTemplateEvent extends Event public function replace(string $needle, ?string $replace): void { - if(!is_null($replace)) { + if (!is_null($replace)) { $this->link = str_replace($needle, $replace, $this->link); } } diff --git a/core/polyfills.php b/core/polyfills.php index 930f7b78..f78a4ced 100644 --- a/core/polyfills.php +++ b/core/polyfills.php @@ -341,7 +341,8 @@ function get_extension(?string $mime_type): ?string return ($ext ? $ext : null); } -function getSubclassesOf(string $parent) { +function getSubclassesOf(string $parent) +{ $result = []; foreach (get_declared_classes() as $class) { $rclass = new ReflectionClass($class); diff --git a/ext/et/main.php b/ext/et/main.php index 0bfb23f8..6f6fc9d8 100644 --- a/ext/et/main.php +++ b/ext/et/main.php @@ -33,10 +33,23 @@ class ET extends Extension } } + public function onCommand(CommandEvent $event) + { + if ($event->cmd == "help") { + print "\tget-info\n"; + print "\t\tList a bunch of info\n\n"; + } + if ($event->cmd == "info") { + foreach ($this->get_info() as $k => $v) { + print("$k = $v\n"); + } + } + } + /** * Collect the information and return it in a keyed array. */ - private function get_info() + private function get_info(): array { global $config, $database;