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;
// Reaching this point means that the operating system is configured badly.
return "";
}
+
+ /**
+ * Fetch the system rules
+ * @todo We should have got a better way to store and fetch the rules
+ *
+ * @return array
+ */
+ public static function getRules(): array
+ {
+ $rules = [];
+ $id = 0;
+
+ if (DI::config()->get('system', 'tosdisplay')) {
+ $html = BBCode::convert(DI::config()->get('system', 'tostext'), 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;
+ }
}
*/
protected function rawContent(array $request = [])
{
- System::jsonExit(new InstanceEntity($this->config, $this->baseUrl, $this->database));
+ System::jsonExit(new InstanceEntity($this->config, $this->baseUrl, $this->database, System::getRules()));
}
}
*/
protected function rawContent(array $request = [])
{
- $rules = [];
- $id = 0;
-
- if (DI::config()->get('system', 'tosdisplay')) {
- $html = BBCode::convert(DI::config()->get('system', 'tostext'), 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];
- }
- }
- }
-
- System::jsonExit($rules);
+ System::jsonExit(System::getRules());
}
}
* @param IManageConfigValues $config
* @param BaseURL $baseUrl
* @param Database $database
+ * @param array $rules
* @throws HTTPException\InternalServerErrorException
* @throws HTTPException\NotFoundException
* @throws \ImagickException
*/
- public function __construct(IManageConfigValues $config, BaseURL $baseUrl, Database $database)
+ public function __construct(IManageConfigValues $config, BaseURL $baseUrl, Database $database, array $rules = [])
{
$register_policy = intval($config->get('config', 'register_policy'));
$this->approval_required = ($register_policy == Register::APPROVE);
$this->invites_enabled = false;
$this->contact_account = [];
+ $this->rules = $rules;
$administrator = User::getFirstAdmin(['nickname']);
if ($administrator) {