コード例 #1
0
ファイル: Comment.php プロジェクト: kaz6120/Loggix
     *
     * @return string
     */
    public function getRecentComments()
    {
        global $pathToIndex, $lang;
        $this->getModuleLanguage('comment');
        $commentList = '';
        $sql = 'SELECT ' . 'id, tid, title, comment, ' . 'user_name, user_pass, user_uri, date, refer_id, trash ' . 'FROM ' . COMMENT_TABLE . ' ' . 'WHERE ' . 'trash = :trash ' . 'ORDER BY ' . 'date DESC ' . 'LIMIT ' . self::$config['recent_comment_max'];
        $stmt = $this->db->prepare($sql);
        $res = $stmt->execute(array(':trash' => 0));
        if ($res) {
            while ($row = $stmt->fetch()) {
                if (!in_array($row['refer_id'], $this->getDraftLogIdArray())) {
                    $userClass = in_array($row['user_name'], $this->getAdminNicknameListArray()) ? 'admin' : 'guest';
                    $targetId = $pathToIndex . '/index.php?id=' . $row['refer_id'] . '#c' . $row['id'];
                    $commentTitle = htmlspecialchars($row['title']);
                    $commentList .= '<li>' . '<a href="' . $targetId . '" class="' . $userClass . '" title="&quot;' . $commentTitle . '&quot;">' . 'From ' . htmlspecialchars($row['user_name']) . '<br />' . date('y/m/d H:i', strtotime($row['date'])) . '</a>' . "</li>\n";
                }
            }
        }
        if ($commentList == '') {
            $commentList = '<li>' . $lang['comment']['default_message'] . '</li>';
        }
        return $commentList;
    }
}
// Create a recent comments list object
$aLoggixModuleComment = new Loggix_Module_Comment();
$module['LM']['comment']['recent'] = $aLoggixModuleComment->getRecentComments();