From f026b959a2b14d75a4e6d51dfb09ce585b27a65a Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 3 Mar 2020 09:28:00 +0000 Subject: [PATCH] Fixing style errors. --- .../core/class/HtmlToOdtConverter.class.php | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/htdocs/core/class/HtmlToOdtConverter.class.php b/htdocs/core/class/HtmlToOdtConverter.class.php index ff8e90ccfb0..e9f210eb889 100644 --- a/htdocs/core/class/HtmlToOdtConverter.class.php +++ b/htdocs/core/class/HtmlToOdtConverter.class.php @@ -3,14 +3,16 @@ // Learn more about this regex pattern: https://regexr.com/4vi60 define('HTML_REGEX_PATTERN', '/<([A-Za-z]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>(.*)<\/\1>))/'); -class HtmlToOdtConverter { +class HtmlToOdtConverter +{ /** * Converts a string with html inside into an odt compatible string * @param string The text to convert * @return array */ - public static function htmlToOdt($htmlText) { + public static function htmlToOdt($htmlText) + { /* Default styles: @@ -40,7 +42,7 @@ class HtmlToOdtConverter { '', '' ); - + $odtText = self::replaceHtmlWithOdtTag(self::getDataFromHtml($htmlText), $customStyles, $fontDeclarations); foreach ($customStyles as $key => $value) { @@ -59,7 +61,8 @@ class HtmlToOdtConverter { * @param array $tags An array with html tags generated by the getDataFromHtml() function * @param array $customStyles An array of style defenitions that should be included inside the odt file */ - private static function replaceHtmlWithOdtTag($tags, &$customStyles, &$fontDeclarations) { + private static function replaceHtmlWithOdtTag($tags, &$customStyles, &$fontDeclarations) + { if ($customStyles == null) $customStyles = array(); if ($fontDeclarations == null) $fontDeclarations = array(); @@ -69,7 +72,7 @@ class HtmlToOdtConverter { // Check if the current item is a tag or just plain text if (isset($tag['text'])) { $odtResult .= $tag['text']; - } else if (isset($tag['name'])) { + } elseif (isset($tag['name'])) { switch ($tag['name']) { case 'br': $odtResult .= ''; @@ -145,7 +148,8 @@ class HtmlToOdtConverter { * Checks if the given text is a html string * @param string $text The text to check */ - public static function isHtmlTag($text) { + public static function isHtmlTag($text) + { return preg_match(HTML_REGEX_PATTERN, $text); } @@ -153,7 +157,8 @@ class HtmlToOdtConverter { * Checks if the given text includes a html string * @param string $text The text to check */ - public static function hasHtmlTag($text) { + public static function hasHtmlTag($text) + { $result = preg_match_all(HTML_REGEX_PATTERN, $text); return is_numeric($result) && $result > 0; } @@ -162,7 +167,8 @@ class HtmlToOdtConverter { * Returns an array of html elements * @param string $html A string with html tags */ - private static function getDataFromHtml($html) { + private static function getDataFromHtml($html) + { $tags = array(); $tempHtml = $html; @@ -231,4 +237,4 @@ class HtmlToOdtConverter { } return $tags; } -} \ No newline at end of file +}