public getBlogPostVersionByUniqueId ( string $uniqueID ) : array | ||
$uniqueID | string | |
return | array |
public function getBlogPostVersionByUniqueId(string $uniqueID) : array
{
$post = $this->db->row(\Airship\queryString('blog.posts.get_version'), $uniqueID);
if (empty($post)) {
return [];
}
if (!empty($post['metadata'])) {
$post['metadata'] = \json_decode($post['metadata'], true);
}
return $post;
}
/** * View a version of a blog post. * * @param string $postID * @param string $uniqueID * * @route blog/post/history/{id}/view/{string} */ public function postHistoryView(string $postID = '', string $uniqueID = '') { $postID = (int) $postID; $blog = $this->blog->getBlogPostById($postID); if (!$blog || !$this->can('read')) { \Airship\redirect($this->airship_cabin_prefix . '/blog/post'); } $blog['tags'] = $this->blog->getTagsForPost($postID); $version = $this->blog->getBlogPostVersionByUniqueId($uniqueID); if ((int) $version['postid'] !== $postID || empty($version)) { \Airship\redirect($this->airship_cabin_prefix . '/blog/post/history/' . $postID); } if ($this->isSuperUser()) { $authors = $this->author->getAll(); } else { $authors = $this->author->getForUser($this->getActiveUserId()); } $categories = $this->blog->getCategoryTree(); $tags = $this->blog->getTags(); $this->lens('blog/post_history_view', ['active_link' => 'bridge-link-blog-posts', 'authors' => $authors, 'blogpost' => $blog, 'categories' => $categories, 'tags' => $tags, 'title' => \__('Revision for Blog Post "%s"', 'default', Util::noHTML($blog['title'])), 'prev_uniqueid' => $this->blog->getPrevVersionUniqueId($postID, (int) $version['versionid']), 'next_uniqueid' => $this->blog->getNextVersionUniqueId($postID, (int) $version['versionid']), 'version' => $version]); }