public static function getRecentComments($limit = 5)
{
$limit = (int) $limit;
// init var
$return = array();
// get comments
$comments = (array) FrontendModel::getContainer()->get('database')->getRecords('SELECT c.id, c.author, c.website, c.email, UNIX_TIMESTAMP(c.created_on) AS created_on, c.text,
i.id AS post_id, i.title AS post_title,
m.url AS post_url
FROM blog_comments AS c
INNER JOIN blog_posts AS i ON c.post_id = i.id AND c.language = i.language
INNER JOIN meta AS m ON i.meta_id = m.id
WHERE c.status = ? AND i.status = ? AND i.language = ? AND i.hidden = ? AND i.publish_on <= ?
ORDER BY c.id DESC
LIMIT ?', array('published', 'active', LANGUAGE, 'N', FrontendModel::getUTCDate('Y-m-d H:i'), $limit));
// validate
if (empty($comments)) {
return $return;
}
// get link
$link = FrontendNavigation::getURLForBlock('Blog', 'Detail');
// loop comments
foreach ($comments as &$row) {
// add some URLs
$row['post_full_url'] = $link . '/' . $row['post_url'];
$row['full_url'] = $link . '/' . $row['post_url'] . '#comment-' . $row['id'];
$row['gravatar_id'] = md5($row['email']);
}
return $comments;
}