Ejemplo n.º 1
0
function news_fetch_a_news_summary_block($data, $group_id, $limit, $show_projectname, $hide_nb_comments)
{
    global $Language;
    $uh = new UserHelper();
    $html = '';
    $arr = explode("\n", $data['details']);
    if (strlen($arr[0]) < 200 && isset($arr[1]) && isset($arr[2]) && strlen($arr[1] . $arr[2]) < 300 && strlen($arr[2]) > 5) {
        $details = util_make_links($arr[0] . '<BR>' . $arr[1] . '<BR>' . $arr[2], $group_id);
    } else {
        $details = util_make_links($arr[0], $group_id);
    }
    $proj_name = '';
    if ($show_projectname && $limit) {
        //show the project name
        $proj_name = ' &middot; <a href="/projects/' . strtolower($data['unix_group_name']) . '/">' . $data['group_name'] . '</a>';
    }
    if (!$limit) {
        $html .= '<li><span class="news_summary"><a href="/forum/forum.php?forum_id=' . $data['forum_id'] . '">' . $data['summary'] . '</a></span> ';
        $html .= '<small><span class="news_date">' . html_time_ago($data['date']) . '</span></small></li>';
    } else {
        $comments_txt = '';
        if (!$hide_nb_comments) {
            $num_comments = (int) $data['num_comments'];
            $comments_txt .= ' <a href="/forum/forum.php?forum_id=' . $data['forum_id'] . '">(' . $num_comments . ' ';
            if ($num_comments == 1) {
                $comments_txt .= $Language->getText('news_utils', 'comment');
            } else {
                $comments_txt .= $Language->getText('news_utils', 'comments');
            }
            $comments_txt .= ')</a>';
        }
        $html .= '<div class="news">';
        $html .= '<span class="news_summary"><a href="/forum/forum.php?forum_id=' . $data['forum_id'] . '"><h4>' . $data['summary'] . '</h4></a></span>';
        $html .= '<blockquote>';
        $html .= '<div>' . $details . '</div>';
        $html .= '<small>
                    <span class="news_author">' . $uh->getLinkOnUserFromUserId($data['submitted_by']) . '</span>
                    <span class="news_date">' . html_time_ago($data['date']) . '</span>' . $comments_txt . $proj_name . '</small>';
        $html .= '</blockquote>';
        $html .= '<hr width="100%" size="1" noshade>';
        $html .= '</div>';
    }
    return $html;
}