protected function content(array $request = []): string
{
- function visible_whitespace($s)
- {
- return '<pre>' . htmlspecialchars($s) . '</pre>';
- }
+
$results = [];
if (!empty($_REQUEST['source'])) {
$formatted = json_encode($source, JSON_PRETTY_PRINT);
$results[] = [
'title' => DI::l10n()->t('Formatted'),
- 'content' => visible_whitespace(trim(var_export($formatted, true), "'")),
+ 'content' => $this->visible_whitespace(trim(var_export($formatted, true), "'")),
];
$results[] = [
'title' => DI::l10n()->t('Source'),
- 'content' => visible_whitespace(var_export($source, true))
+ 'content' => $this->visible_whitespace(var_export($source, true))
];
$activity = JsonLD::compact($source);
if (!$activity) {
}
$results[] = [
'title' => DI::l10n()->t('Activity'),
- 'content' => visible_whitespace(var_export($activity, true))
+ 'content' => $this->visible_whitespace(var_export($activity, true))
];
$type = JsonLD::fetchElement($activity, '@type');
$results[] = [
'title' => DI::l10n()->t('Object data'),
- 'content' => visible_whitespace(var_export($object_data, true))
+ 'content' => $this->visible_whitespace(var_export($object_data, true))
];
$item = ActivityPub\Processor::createItem($object_data, true);
$results[] = [
'title' => DI::l10n()->t('Result Item'),
- 'content' => visible_whitespace(var_export($item, true))
+ 'content' => $this->visible_whitespace(var_export($item, true))
];
} catch (\Throwable $e) {
$results[] = [
return $o;
}
+
+ private function visible_whitespace(string $s): string
+ {
+ return '<pre>' . htmlspecialchars($s) . '</pre>';
+ }
}