Authorized as {$admin_login} | Sign out
Uploads
HTML;
}
// uploads page
// ------------
function uploads($ctx, $uploads, $error) {
return <<if_true($error, $ctx->formError, $error)}
{$ctx->bc([
['text' => $ctx->lang('admin_title'), 'url' => '/admin/'],
['text' => $ctx->lang('blog_uploads')],
])}
{$ctx->for_each($uploads, fn($u) => $ctx->uploadsItem(
id: $u->id,
name: $u->name,
direct_url: $u->getDirectUrl(),
note: $u->note,
addslashes_note: $u->note,
markdown: $u->getMarkdown(),
size: $u->getSize(),
))}
HTML;
}
function uploadsItem($ctx, $id, $direct_url, $note, $addslashes_note, $markdown, $name, $size) {
return <<
{$ctx->if_true($note, ''.$note.'
')}
{$size}
HTML;
}
function postForm(\SkinContext $ctx,
string|Stringable $title,
string|Stringable $text,
string|Stringable $short_name,
array $langs,
array $js_texts,
string|Stringable|null $date = null,
bool $is_edit = false,
?bool $saved = null,
?bool $visible = null,
?bool $toc = null,
string|Stringable|null $post_url = null,
?int $post_id = null,
?string $lang = null): array {
$form_url = !$is_edit ? '/articles/write/' : $post_url.'edit/';
// breadcrumbs
$bc_tree = [
['url' => '/articles/?lang='.$lang, 'text' => $ctx->lang('articles')]
];
if ($is_edit) {
$bc_tree[] = ['url' => $post_url.'?lang='.$lang, 'text' => $ctx->lang('blog_view_post')];
} else {
$bc_tree[] = ['text' => $ctx->lang('blog_new_post')];
}
$html = <<
{$ctx->if_true($saved, fn() => ''.$ctx->lang('info_saved').'
')}
{$ctx->bc($bc_tree, 'padding-bottom: 20px')}
HTML;
$js_params = [
'langs' => array_map(fn($lang) => $lang->value, $langs),
'token' => $is_edit ? csrf_get('editpost'.$post_id) : csrf_get('post_add')
];
if ($is_edit)
$js_params += [
'edit' => true,
'id' => $post_id,
'texts' => $js_texts
];
$js_params = jsonEncode($js_params);
$js = <<bc([
['url' => '/'.$short_name.'/', 'text' => $ctx->lang('view_page')]
], 'padding-bottom: 20px');
} else {
$bc_html = '';
}
$html = <<
{$ctx->if_true($saved, fn() => ''.$ctx->lang('info_saved').'
')}
{$bc_html}
|
|
HTML;
$js_params = [
'pages' => true,
'edit' => $is_edit,
'token' => $is_edit ? $ctx->csrf('editpage'.$short_name) : $ctx->csrf('addpage'),
'langs' => array_map(fn($lang) => $lang->value, $langs), // still needed for draft erasing
];
if ($js_text !== null)
$js_params['text'] = $js_text;
$js_params = jsonEncode($js_params);
$js = <<
|
|
|
HTML;
}
function pageFormAddOptions($ctx, $short_name) {
return <<
HTML;
}
function pageNew($ctx, $short_name) {
return <<
HTML;
}
// misc
function formError($ctx, $error) {
return <<{$ctx->lang('error')}: {$error}
HTML;
}
function markdownPreview($ctx, $unsafe_html, $title) {
return <<
{$ctx->if_true($title, ''.$title.'
')}
{$unsafe_html}
HTML;
}