refactoring
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
function compose_view($article_id = null)
|
||||
{
|
||||
if (!empty($article_id)) {
|
||||
$conn = get_connection();
|
||||
$stmt = $conn->prepare('SELECT * FROM article WHERE article_id = ?');
|
||||
$stmt->bind_param('i', $article_id);
|
||||
$stmt->execute();
|
||||
$article = $stmt->get_result()->fetch_assoc();
|
||||
|
||||
$stmt = $conn->prepare('SELECT tag_id FROM article_tags WHERE article_id = ?');
|
||||
$stmt->bind_param('i', $article_id);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$tags = [];
|
||||
while ($row = $result->fetch_assoc())
|
||||
$tags[] = $row['tag_id'];
|
||||
|
||||
$title = $article['title'];
|
||||
$excerpt = $article['excerpt'];
|
||||
$existing_markdown = read_file_one_string($_ENV['ARTICLES_FQ_PATH'] . $article_id . '/article.md');
|
||||
}
|
||||
|
||||
$view = '
|
||||
<div class="grid-2x1">
|
||||
' . (!empty($existing_markdown) ? form($article_id, $title, $excerpt, $existing_markdown, $tags) : form()) . '
|
||||
' . preview() . '
|
||||
';
|
||||
|
||||
$view .= preview() . '
|
||||
</div>
|
||||
';
|
||||
|
||||
return $view;
|
||||
}
|
||||
Reference in New Issue
Block a user