diff options
author | Laria Carolin Chabowski <laria@laria.me> | 2020-04-26 21:03:08 +0200 |
---|---|---|
committer | Laria Carolin Chabowski <laria@laria.me> | 2020-04-26 21:13:51 +0200 |
commit | ade9edeb849803082856f7633194913ad4df93a0 (patch) | |
tree | a864c593f92851678d7ab9fe4e7e9cfdefb539c8 /ratatoeskr/sys/textprocessors.php | |
parent | c3cc300a952a793b9655226db1aad050daaa3803 (diff) | |
download | ratatoeskr-cms-ade9edeb849803082856f7633194913ad4df93a0.tar.gz ratatoeskr-cms-ade9edeb849803082856f7633194913ad4df93a0.tar.bz2 ratatoeskr-cms-ade9edeb849803082856f7633194913ad4df93a0.zip |
Automatic code formatting
Diffstat (limited to 'ratatoeskr/sys/textprocessors.php')
-rw-r--r-- | ratatoeskr/sys/textprocessors.php | 27 |
1 files changed, 16 insertions, 11 deletions
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("<br />", "<br />"), 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"], ["<br />", "<br />"], htmlesc($text)); + }, true], + "HTML" => [function ($text) { + return $text; + }, true] + ]; } |