From ade9edeb849803082856f7633194913ad4df93a0 Mon Sep 17 00:00:00 2001 From: Laria Carolin Chabowski Date: Sun, 26 Apr 2020 21:03:08 +0200 Subject: Automatic code formatting --- ratatoeskr/sys/textprocessors.php | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'ratatoeskr/sys/textprocessors.php') diff --git a/ratatoeskr/sys/textprocessors.php b/ratatoeskr/sys/textprocessors.php index d5d959d..7ff3bbb 100644 --- a/ratatoeskr/sys/textprocessors.php +++ b/ratatoeskr/sys/textprocessors.php @@ -21,10 +21,10 @@ require_once(dirname(__FILE__) . "/utils.php"); * $fx - The textprocessor function (function($input), returns HTML) * $visible_in_backend - Should this textprocessor be visible in the backend? Defaults to True. */ -function textprocessor_register($name, $fx, $visible_in_backend=True) +function textprocessor_register($name, $fx, $visible_in_backend=true) { global $textprocessors; - $textprocessors[$name] = array($fx, $visible_in_backend); + $textprocessors[$name] = [$fx, $visible_in_backend]; } /* @@ -41,12 +41,14 @@ function textprocessor_register($name, $fx, $visible_in_backend=True) function textprocessor_apply($text, $textprocessor) { global $textprocessors; - if(!isset($textprocessors[$textprocessor])) + if (!isset($textprocessors[$textprocessor])) { throw new Exception("Unknown Textprocessor: $textprocessor"); + } $fx = @$textprocessors[$textprocessor][0]; - if(!is_callable($fx)) + if (!is_callable($fx)) { throw new Exception("Invalid Textprocessor: $textprocessor"); + } return call_user_func($fx, $text); } @@ -66,11 +68,14 @@ function textprocessor_apply_translation($translationobj) return textprocessor_apply($translationobj->text, $translationobj->texttype); } -if(!isset($textprocessors)) -{ - $textprocessors = array( - "Markdown" => array("Markdown", True), - "Plain Text" => array(function($text) { return str_replace(array("\r\n", "\n"), array("
", "
"), htmlesc($text)); }, True), - "HTML" => array(function($text) { return $text; }, True) - ); +if (!isset($textprocessors)) { + $textprocessors = [ + "Markdown" => ["Markdown", true], + "Plain Text" => [function ($text) { + return str_replace(["\r\n", "\n"], ["
", "
"], htmlesc($text)); + }, true], + "HTML" => [function ($text) { + return $text; + }, true] + ]; } -- cgit v1.2.3-70-g09d2