+
+ /**
+ * Fetch the system rules
+ * @param bool $numeric_id If set to "true", the rules are returned with a numeric id as key.
+ *
+ * @return array
+ */
+ public static function getRules(bool $numeric_id = false): 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", trim($msg)) as $line) {
+ $line = trim($line);
+ if ($line) {
+ if ($numeric_id) {
+ $rules[++$id] = $line;
+ } else {
+ $rules[] = ['id' => (string)++$id, 'text' => $line];
+ }
+ }
+ }
+ }
+
+ return $rules;
+ }