]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/System.php
Merge branch 'develop' into new_image_presentation
[friendica.git] / src / Core / System.php
index aa2d81d8959e03c32fd182947418522eef6de235..707649a49d3406cf2f64ee7f943925bd57992cff 100644 (file)
@@ -21,6 +21,8 @@
 
 namespace Friendica\Core;
 
+use Friendica\Content\Text\BBCode;
+use Friendica\Content\Text\HTML;
 use Friendica\Core\Config\Capability\IManageConfigValues;
 use Friendica\DI;
 use Friendica\Module\Response;
@@ -660,4 +662,30 @@ class System
                // Reaching this point means that the operating system is configured badly.
                return "";
        }
+
+       /**
+        * Fetch the system rules
+        *
+        * @return array
+        */
+       public static function getRules(): array
+       {
+               $rules = [];
+               $id    = 0;
+
+               if (DI::config()->get('system', 'tosdisplay')) {
+                       $rulelist = DI::config()->get('system', 'tosrules') ?: DI::config()->get('system', 'tostext');
+                       $html = BBCode::convert($rulelist, false, BBCode::EXTERNAL);
+
+                       $msg = HTML::toPlaintext($html, 0, true);
+                       foreach (explode("\n", $msg) as $line) {
+                               $line = trim($line);
+                               if ($line) {
+                                       $rules[] = ['id' => (string)++$id, 'text' => $line];
+                               }
+                       }
+               }
+
+               return $rules;
+       }
 }