コード例 #1
0
ファイル: user.php プロジェクト: nathan-osman/Stack-Mobile
 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>';
     }
 }
コード例 #2
0
ファイル: post.php プロジェクト: nathan-osman/Stack-Mobile
 public static function GenerateCommentButton($site_prefix, $comments, $post_id)
 {
     // Generate the comment HTML
     $comments_html = "<ul id='comment_content_{$post_id}' data-role='listview' data-inset='true'>";
     foreach ($comments as $comment) {
         if ($comment['owner']['user_type'] == 'does_not_exist') {
             $comments_html .= '<li>' . strip_tags($comment['body']) . ' - <b>' . User::GenerateUsername($comment['owner']) . '</b></li>';
         } else {
             // Generate the URL for the comment
             $comment_url = "{$site_prefix}/users/{$comment['owner']['user_id']}";
             $comments_html .= "<li><a href='{$comment_url}'>" . strip_tags($comment['body']) . ' - <b>' . User::GenerateUsername($comment['owner']) . ' <span class="reputation">' . Number::FormatUnit($comment['owner']['reputation']) . '</span></b></a></li>';
         }
     }
     $comments_html .= '</ul>';
     $s = ($count = count($comments)) == 1 ? '' : 's';
     return "<div id='comment_{$post_id}' class='comment'><div data-role='button' id='comment_button_{$post_id}' onclick='ShowComments({$post_id});'>Show {$count} comment{$s}</div>{$comments_html}</div>";
 }