47 lines
1.6 KiB
PHP
47 lines
1.6 KiB
PHP
<?php
|
|
function form($article_id = null, $title = null, $excerpt = null, $existing_markdown = null, $tags = null)
|
|
{
|
|
$raw_tags = article_tags();
|
|
$tags_boxes = '
|
|
<div class="checkboxes">
|
|
<label>Tags</label>
|
|
';
|
|
|
|
foreach ($raw_tags as $row) {
|
|
$tags_boxes .= '
|
|
<label class="form_checkbox_container">' . $row['tag'] . '
|
|
<input name="tags[]" value="' . $row['tag_id'] . '" type="checkbox"' . (isset($tags) && in_array($row['tag_id'], $tags) ? ' checked' : '') . '>
|
|
<span class="checkmark"></span>
|
|
</label>
|
|
';
|
|
}
|
|
|
|
$tags_boxes .= '
|
|
</div>
|
|
';
|
|
|
|
$form = '
|
|
<div class="full-height">
|
|
<div class="form_card" id="composer">
|
|
<form method="post">
|
|
<input type="hidden" name="form_id" value="compose">
|
|
' . (isset($article_id) ? '<input type="hidden" name="article_id" value="' . $article_id . '">' : '') . '
|
|
|
|
<label for="title">Title</label>
|
|
<input id="title" name="title" placeholder="Article Title" required' . (isset($title) ? ' value="' . $title . '"' : '') . '>
|
|
|
|
<label for="markdown">Markdown</label>
|
|
<textarea id="markdown" name="markdown" required>' . (isset($existing_markdown) ? $existing_markdown : '') . '</textarea>
|
|
|
|
<label for="excerpt">Excerpt</label>
|
|
<input id="excerpt" name="excerpt" placeholder="Article Excerpt"' . (isset($excerpt) ? 'value="' . $excerpt . '"' : '') . '>
|
|
' . $tags_boxes . '
|
|
<input class="button" type="submit" value="' . (isset($article_id) ? 'Update Article' : 'Create Article') . '">
|
|
</form>
|
|
</div>
|
|
</div>
|
|
';
|
|
|
|
return $form;
|
|
}
|