function cs_post_list($type, $limit, $return = false) { $posts = qa_db_read_all_assoc(qa_db_query_sub('SELECT ^posts.* , ^users.* FROM ^posts, ^users WHERE ^posts.userid=^users.userid AND ^posts.type=$ ORDER BY ^posts.created DESC LIMIT #', $type, $limit)); $output = '<ul class="posts-list">'; foreach ($posts as $p) { if ($type == 'Q') { $what = qa_lang_html('cleanstrap/asked'); } elseif ($type == 'A') { $what = qa_lang_html('cleanstrap/answered'); } elseif ('C') { $what = qa_lang_html('cleanstrap/commented'); } $handle = $p['handle']; $timeCode = qa_when_to_html(strtotime($p['created']), 7); $when = @$timeCode['prefix'] . @$timeCode['data'] . @$timeCode['suffix']; $output .= '<li>'; $output .= cs_get_post_avatar($p, $p['userid'], 30, true); $output .= '<div class="post-content">'; if ($type == 'Q') { $output .= '<a class="title question" href="' . qa_q_path_html($p['postid'], $p['title']) . '" title="' . $p['title'] . '">' . qa_html($p['title']) . '</a>'; } elseif ($type == 'A') { $output .= '<a class="title" href="' . cs_post_link($p['parentid']) . '#a' . $p['postid'] . '">' . cs_truncate(strip_tags($p['content']), 100) . '</a>'; } else { $output .= '<a class="title" href="' . cs_post_link($p['parentid']) . '#c' . $p['postid'] . '">' . cs_truncate(strip_tags($p['content']), 100) . '</a>'; } $output .= '<div class="meta">'; //$output .= '<span><a href="' . qa_path_html('user/' . $handle) . '">' . cs_name($handle) . '</a> ' . $what . '</span>'; if ($type == 'Q') { $output .= '<span>' . qa_lang_sub('cleanstrap/x_answers', $p['acount']) . '</span>'; } $output .= '<span class="time icon-time">' . $when . '</span>'; $output .= '<span class="vote-count icon-thumbs-up2">' . qa_lang_sub('cleanstrap/x_votes', $p['netvotes']) . '</span>'; $output .= '</div>'; $output .= '</div>'; $output .= '</li>'; } $output .= '</ul>'; if ($return) { return $output; } echo $output; }
function output_widget($region, $place, $themeobject, $template, $request, $qa_content) { $widget_opt = @$themeobject->current_widget['param']['options']; require_once QA_INCLUDE_DIR . 'qa-db-selects.php'; if (@$qa_content['q_view']['raw']['type'] != 'Q') { // question might not be visible, etc... return; } $questionid = $qa_content['q_view']['raw']['postid']; $userid = qa_get_logged_in_userid(); $cookieid = qa_cookie_get(); $questions = qa_db_single_select(qa_db_related_qs_selectspec($userid, $questionid, (int) $widget_opt['count'])); $minscore = qa_match_to_min_score(qa_opt('match_related_qs')); foreach ($questions as $key => $question) { if ($question['score'] < $minscore) { unset($questions[$key]); } } $titlehtml = qa_lang_html(count($questions) ? 'main/related_qs_title' : 'main/no_related_qs_title'); if (@$themeobject->current_widget['param']['locations']['show_title']) { $themeobject->output('<h3 class="widget-title">' . qa_lang('cleanstrap/related_questions') . '</h3>'); } $themeobject->output('<div class="ra-rq-widget">'); $themeobject->output('<ul>'); foreach ($questions as $p) { $timeCode = qa_when_to_html($p['created'], 7); $when = @$timeCode['prefix'] . @$timeCode['data'] . @$timeCode['suffix']; $themeobject->output('<li>' . cs_get_post_avatar($p, $p['userid'], 30, true)); $themeobject->output('<div class="post-content">'); $themeobject->output('<a class="title" href="' . qa_q_path_html($p['postid'], $p['title']) . '">' . qa_html($p['title']) . '</a>'); $themeobject->output('<div class="meta">'); $themeobject->output('<span>' . qa_lang_sub('cleanstrap/x_answers', $p['acount']) . '</span>'); $themeobject->output('<span class="time icon-time">' . $when . '</span>'); $themeobject->output('<span class="vote-count icon-thumbs-up2">' . qa_lang_sub('cleanstrap/x_votes', $p['netvotes']) . '</span>'); $themeobject->output('</div>'); $themeobject->output('</div>'); $themeobject->output('</li>'); } $themeobject->output('</ul>'); $themeobject->output('</div>'); }
function cs_top_users($limit = 5, $size) { $users = qa_db_read_all_assoc(qa_db_query_sub('SELECT * FROM ^users JOIN ^userpoints ON ^users.userid=^userpoints.userid ORDER BY ^userpoints.points DESC LIMIT #', $limit)); $output = '<ul class="top-users-list clearfix">'; foreach ($users as $u) { if (defined('QA_WORDPRESS_INTEGRATE_PATH')) { require_once QA_INCLUDE_DIR . 'qa-app-posts.php'; $u['handle'] = qa_post_userid_to_handle($u['userid']); } $output .= '<li class="top-user clearfix">'; $output .= cs_get_post_avatar($u, $u['userid'], $size, true); $output .= '<div class="top-user-data">'; $output .= '<span class="points">' . $u['points'] . ' ' . qa_lang('cleanstrap/points') . '</span>'; $output .= '<a href="' . qa_path_html('user/' . $u['handle']) . '" class="name">' . $u['handle'] . '</a>'; $output .= '<p class="counts"><span>' . qa_lang_sub('cleanstrap/x_questions', $u['qposts']) . '</span> <span>' . qa_lang_sub('cleanstrap/x_answers', $u['aposts']) . '</span><span>' . qa_lang_sub('cleanstrap/x_comments', $u['cposts']) . '</span></p>'; $output .= '</div>'; $output .= '</li>'; } $output .= '</ul>'; return $output; }
function q_item_main($q_item) { $avatar_arg = array('flags' => $q_item['raw']['flags'], 'email' => $q_item['raw']['email'], 'handle' => $q_item['raw']['handle'], 'avatarblobid' => $q_item['raw']['avatarblobid'], 'avatarwidth' => $q_item['raw']['avatarwidth'], 'avatarheight' => $q_item['raw']['avatarheight']); $enable_avatar = (int) qa_opt('avatar_q_page_q_size') > 0; $avatar_size = (bool) qa_opt('cs_enable_clean_qlist') ? 20 : 30; $timeCode = $q_item['when']; $when = @$timeCode['prefix'] . @$timeCode['data'] . @$timeCode['suffix']; if ($enable_avatar && isset($q_item['avatar']) && !(bool) qa_opt('cs_enable_clean_qlist')) { $this->output('<div class="asker-avatar">'); $this->output(cs_get_post_avatar($avatar_arg, $q_item['raw']['userid'], $avatar_size, true)); $this->output('</div>'); } $this->output('<div class="qa-q-item-main">'); if (!(bool) qa_opt('cs_enable_clean_qlist')) { $this->output('<div class="ans-count total-' . $q_item['raw']['acount'] . '">' . $q_item['raw']['acount'] . '<span>' . qa_lang('cleanstrap/ans') . '</span></div>'); } $this->output('<div class="q-item-head">'); if ($enable_avatar && (bool) qa_opt('cs_enable_clean_qlist')) { $this->output('<div class="count-time"><span class="time">' . $when . '</span>'); $this->output('<span class="ans-count total-' . $q_item['raw']['acount'] . '">' . $q_item['raw']['acount'] . '</span></div>'); $this->output(cs_get_post_avatar($avatar_arg, $q_item['raw']['userid'], $avatar_size, true)); $this->output('<span class="status-c">' . cs_post_status($q_item) . '</span>'); } $this->q_item_title($q_item); if (!(bool) qa_opt('cs_enable_clean_qlist')) { $this->output('<div class="list-meta">'); $this->output(cs_post_status($q_item)); $this->post_meta($q_item, 'qa-q-item'); qa_html_theme_base::view_count($q_item); if (qa_opt('cs_show_tags_list')) { $this->output('<span>' . qa_lang('cleanstrap/tagged') . ': </span>'); $this->post_tag_list($q_item, 'list-tag'); } $this->output('</div>'); } $this->output('</div>'); $this->q_item_content($q_item); $this->q_item_buttons($q_item); $this->output('</div>'); }
function cs_relative_post_list($limit, $slug, $type, $return = false, $avatar_size) { require_once QA_INCLUDE_DIR . 'qa-app-posts.php'; if (!empty($slug)) { if ($type == 'Category') { $post_type = 'Q'; $categories = explode("/", $slug); if (count($categories)) { $category_bread_crup = implode(" > ", $categories); $category_link = implode("/", $categories); $categories = array_reverse($categories); $slug = implode("/", $categories); } $posts = qa_db_read_all_assoc(qa_db_query_sub('SELECT * FROM ^posts WHERE ^posts.type=$ AND categoryid=(SELECT categoryid FROM ^categories WHERE ^categories.backpath=$ LIMIT 1) ORDER BY ^posts.created DESC LIMIT #', 'Q', $slug, $limit)); //refresh every 15 minutes $title = 'Questions in <a href="' . qa_path_html('questions/' . qa_strtolower($category_link)) . '">' . $category_bread_crup . '</a>'; } elseif ($type == 'Tags') { $post_type = 'Q'; $title = 'Questions in <a href="' . qa_path_html('tag/' . qa_strtolower($slug)) . '">' . $slug . '</a>'; $posts = qa_db_read_all_assoc(qa_db_query_sub('SELECT * FROM ^posts WHERE ^posts.type=$ AND ^posts.postid IN (SELECT postid FROM ^posttags WHERE wordid=(SELECT wordid FROM ^words WHERE word=$ OR word=$ COLLATE utf8_bin LIMIT 1) ORDER BY postcreated DESC) ORDER BY ^posts.created DESC LIMIT #', 'Q', $slug, qa_strtolower($slug), $limit)); } else { // Relative to Keyword require_once QA_INCLUDE_DIR . 'qa-app-search.php'; $keyword = $slug; $userid = qa_get_logged_in_userid(); $title = 'Posts About <a href="' . qa_path_html('search/' . qa_strtolower($keyword)) . '">' . $keyword . '</a>'; //$post=qa_get_search_results($keyword, 0, $limit, $userid , false, false); $words = qa_string_to_words($keyword); $posts = qa_db_select_with_pending(qa_db_search_posts_selectspec($userid, $words, $words, $words, $words, trim($keyword), 0, false, $limit)); $output = '<h3 class="widget-title">' . $title . '</h3>'; $output .= '<ul class="question-list">'; foreach ($posts as $post) { $post_type = $post['type']; if ($post_type == 'Q') { $what = qa_lang('cleanstrap/asked'); } elseif ($post_type == 'A') { $what = qa_lang('cleanstrap/answered'); } elseif ('C') { $what = qa_lang('cleanstrap/commented'); } $handle = qa_post_userid_to_handle($post['userid']); $avatar = cs_get_post_avatar($post, $avatar_size); $output .= '<li id="q-list-' . $post['postid'] . '" class="question-item">'; $output .= '<div class="pull-left avatar" data-handle="' . $handle . '" data-id="' . $post['userid'] . '">' . $avatar . '</div>'; $output .= '<div class="list-right">'; if ($post_type == 'Q') { $output .= '<a class="title" href="' . qa_q_path_html($post['postid'], $post['title']) . '" title="' . $post['title'] . '">' . cs_truncate(strip_tags($post['title']), 70) . '</a>'; } elseif ($post_type == 'A') { $output .= '<p><a href="' . cs_post_link($post['parentid']) . '#a' . $post['postid'] . '">' . cs_truncate(strip_tags($post['content']), 70) . '</a></p>'; } else { $output .= '<p><a href="' . cs_post_link($post['parentid']) . '#c' . $post['postid'] . '">' . cs_truncate(strip_tags($post['content']), 70) . '</a></p>'; } $output .= '<div class="meta"><a href="' . qa_path_html('user/' . $handle) . '">' . cs_name($handle) . '</a> ' . $what; if ($post_type == 'Q') { $output .= ' <span class="vote-count">' . $post['netvotes'] . ' votes</span>'; $output .= ' <span class="ans-count">' . $post['acount'] . ' ans</span>'; } elseif ($post_type == 'A') { $output .= ' <span class="vote-count">' . $post['netvotes'] . ' votes</span>'; } $output .= '</div></div>'; $output .= '</li>'; } $output .= '</ul>'; if ($return) { return $output; } echo $output; return; } } else { return; } $output = '<h3 class="widget-title">' . $title . '</h3>'; $output .= '<ul class="question-list">'; foreach ($posts as $p) { if (empty($p['userid'])) { $p['userid'] = NULL; } // to prevent error for anonymous posts while calling qa_post_userid_to_handle() if ($post_type == 'Q') { $what = qa_lang_html('cleanstrap/asked'); } elseif ($post_type == 'A') { $what = qa_lang_html('cleanstrap/answered'); } elseif ('C') { $what = qa_lang_html('cleanstrap/commented'); } $handle = qa_post_userid_to_handle($p['userid']); $avatar = cs_get_avatar($handle, 35, false); $output .= '<li id="q-list-' . $p['postid'] . '" class="question-item">'; $output .= '<div class="pull-left avatar" data-handle="' . $handle . '" data-id="' . qa_handle_to_userid($handle) . '">' . (isset($avatar) ? '<img src="' . $avatar . '" />' : '') . '</div>'; $output .= '<div class="list-right">'; if ($post_type == 'Q') { $output .= '<a class="title" href="' . qa_q_path_html($p['postid'], $p['title']) . '" title="' . $p['title'] . '">' . cs_truncate(qa_html($p['title']), 70) . '</a>'; } elseif ($post_type == 'A') { $output .= '<p><a href="' . cs_post_link($p['parentid']) . '#a' . $p['postid'] . '">' . cs_truncate(strip_tags($p['content']), 70) . '</a></p>'; } else { $output .= '<p><a href="' . cs_post_link($p['parentid']) . '#c' . $p['postid'] . '">' . cs_truncate(strip_tags($p['content']), 70) . '</a></p>'; } $output .= '<div class="meta"><a href="' . qa_path_html('user/' . $handle) . '">' . cs_name($handle) . '</a> ' . $what; if ($post_type == 'Q') { $output .= ' <span class="vote-count">' . $p['netvotes'] . ' votes</span>'; $output .= ' <span class="ans-count">' . $p['acount'] . ' ans</span>'; } elseif ($post_type == 'A') { $output .= ' <span class="vote-count">' . $p['netvotes'] . ' votes</span>'; } $output .= '</div></div>'; $output .= '</li>'; } $output .= '</ul>'; if ($return) { return $output; } echo $output; }