Example #1
0
 public static function GeneratePostList($site_prefix, $response, $paginate = FALSE)
 {
     $questions_html = array();
     // IF total > 30 then we display page numbers
     if ($paginate && $response->Total(TRUE) > 30) {
         $questions_html[] = Page::GeneratePageNumbers(ceil($response->Total() / 30));
     }
     while ($question = $response->Fetch(FALSE)) {
         // Generate the question title
         $title = self::GenerateQuestionTitle($question);
         // Generate the brief portion of the question shown
         $preview = strip_tags($question['body']);
         $preview = substr($preview, 0, 100) . (strlen($preview) > 100 ? '…' : '');
         // Generate the tags for the post if applicable
         if (isset($question['tags'])) {
             $tags_html = self::GenerateTagList($site_prefix, $question['tags']);
         } else {
             $tags_html = '';
         }
         // Generate the URL for the question
         $question_url = "{$site_prefix}/questions/{$question['question_id']}";
         // Generate the content of the count bubble
         if (isset($question['answer_count'])) {
             $answer_bubble = Number::FormatUnit($question['answer_count']);
         } else {
             $answer_bubble = $question['score'];
         }
         $questions_html[] = "<li><span class='ui-li-count'>{$answer_bubble}</span><a href='{$question_url}' class='question'><h3>{$title}</h3><p>{$preview}</p></a>{$tags_html}</li>";
     }
     if (count($questions_html)) {
         return implode('', $questions_html);
     } else {
         return '<li><span class="unknown">[empty]</span></li>';
     }
 }
Example #2
0
 public static function GenerateTagList($site_prefix, $response, $paginate = FALSE)
 {
     $tags_html = array();
     // IF total > 30 then we display page numbers
     if ($paginate && $response->Total(TRUE) > 30) {
         $tags_html[] = Page::GeneratePageNumbers(ceil($response->Total() / 30));
     }
     while ($tag = $response->Fetch(FALSE)) {
         // Generate the URL for the tag page
         $escaped_tag = urlencode($tag['name']);
         $tag_url = "/{$site_prefix}/tags/{$escaped_tag}";
         $tags_html[] = "<li><a href='/{$tag_url}'>{$tag['name']}</a></li>";
     }
     if (count($tags_html)) {
         return implode('', $tags_html);
     } else {
         return '<li><span class="unknown">[empty]</span></li>';
     }
 }
Example #3
0
 public static function GenerateUserList($site_prefix, $response, $paginate = FALSE)
 {
     $users_html = array();
     // IF total > 30 then we display page numbers
     if ($paginate && $response->Total(TRUE) > 30) {
         $users_html[] = Page::GeneratePageNumbers(ceil($response->Total() / 30));
     }
     while ($user = $response->Fetch(FALSE)) {
         // Get the user's location
         $user['location'] = ViewUtils::GetIndexValue($user, 'location');
         // Generate the URL of their profile
         $profile_url = "{$site_prefix}/users/{$user['user_id']}";
         $users_html[] = '<li><span class="ui-li-count">' . Number::FormatUnit($user['reputation']) . "</span><a href='{$profile_url}'><img src='{$user['profile_image']}&s=16' class='site-icon ui-li-icon' />" . self::GenerateUsername($user) . "<p>{$user['location']}</p></a></li>";
     }
     if (count($users_html)) {
         return implode('', $users_html);
     } else {
         return '<li><span class="unknown">[empty]</span></li>';
     }
 }