function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
 {
     require_once QA_INCLUDE_DIR . 'qa-db-selects.php';
     global $qa_login_userid, $questionid, $relatedcount, $question, $relatedquestions, $qa_cookieid, $usershtml;
     list($question, $relatedquestions) = qa_db_select_with_pending(qa_db_full_post_selectspec($qa_login_userid, $questionid), qa_db_related_qs_selectspec($qa_login_userid, $questionid));
     if ($relatedcount > 1 && !$question['hidden']) {
         $minscore = qa_match_to_min_score(qa_opt('match_related_qs'));
         foreach ($relatedquestions as $key => $related) {
             if ($related['postid'] == $questionid || $related['score'] < $minscore) {
                 unset($relatedquestions[$key]);
             }
         }
         if (count($relatedquestions)) {
             $themeobject->output('<h2>' . qa_lang('main/related_qs_title') . '</h2>');
         } else {
             $themeobject->output('<h2>' . qa_lang('main/no_related_qs_title') . '</h2>');
         }
         $upper = qa_opt('related_qs_num') < count($relatedquestions) ? qa_opt('related_qs_num') : count($relatedquestions);
         foreach ($relatedquestions as $related) {
             if ($upper <= 0) {
                 break;
             }
             $themeobject->output('<p style="margin:0 0 10px 0; font-weight:bold;"><a href="' . qa_path_html(qa_q_request($related['postid'], $related['title'])) . '">' . $related['title'] . '</a></p>');
             $upper--;
         }
     }
 }
 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>');
 }
Ejemplo n.º 3
0
 public function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
 {
     require_once QA_INCLUDE_DIR . 'db/selects.php';
     if (!isset($qa_content['q_view']['raw']['type']) || $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, qa_opt('page_size_related_qs')));
     $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 ($region == 'side') {
         $themeobject->output('<div class="qa-related-qs">', '<h2 style="margin-top:0; padding-top:0;">', $titlehtml, '</h2>');
         $themeobject->output('<ul class="qa-related-q-list">');
         foreach ($questions as $question) {
             $themeobject->output('<li class="qa-related-q-item">' . '<a href="' . qa_q_path_html($question['postid'], $question['title']) . '">' . qa_html($question['title']) . '</a>' . '</li>');
         }
         $themeobject->output('</ul>', '</div>');
     } else {
         $themeobject->output('<h2>', $titlehtml, '</h2>');
         $q_list = array('form' => array('tags' => 'method="post" action="' . qa_self_html() . '"', 'hidden' => array('code' => qa_get_form_security_code('vote'))), 'qs' => array());
         $defaults = qa_post_html_defaults('Q');
         $usershtml = qa_userids_handles_html($questions);
         foreach ($questions as $question) {
             $q_list['qs'][] = qa_post_html_fields($question, $userid, $cookieid, $usershtml, null, qa_post_html_options($question, $defaults));
         }
         $themeobject->q_list_and_form($q_list);
     }
 }
Ejemplo n.º 4
0
 function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
 {
     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, qa_opt('page_size_related_qs')));
     $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 ($region == 'side') {
         $themeobject->output('<DIV CLASS="qa-related-qs">', '<H2 STYLE="margin-top:0; padding-top:0;">', $titlehtml, '</H2>');
         $themeobject->output('<UL CLASS="qa-related-q-list">');
         foreach ($questions as $question) {
             $themeobject->output('<LI CLASS="qa-related-q-item"><A HREF="' . qa_q_path_html($question['postid'], $question['title']) . '">' . qa_html($question['title']) . '</A></LI>');
         }
         $themeobject->output('</UL>', '</DIV>');
     } else {
         $themeobject->output('<H2>', $titlehtml, '</H2>');
         $q_list = array('form' => array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"'), 'qs' => array());
         $options = qa_post_html_defaults('Q');
         $usershtml = qa_userids_handles_html($questions);
         foreach ($questions as $question) {
             $q_list['qs'][] = qa_post_html_fields($question, $userid, $cookieid, $usershtml, null, $options);
         }
         $themeobject->q_list_and_form($q_list);
     }
 }
Ejemplo n.º 5
0
function qa_page_q_load_q()
{
    global $qa_login_userid, $questionid, $question, $parentquestion, $answers, $commentsfollows, $relatedcount, $relatedquestions, $question, $categories;
    list($question, $childposts, $achildposts, $parentquestion, $relatedquestions, $categories) = qa_db_select_with_pending(qa_db_full_post_selectspec($qa_login_userid, $questionid), qa_db_full_child_posts_selectspec($qa_login_userid, $questionid), qa_db_full_a_child_posts_selectspec($qa_login_userid, $questionid), qa_db_post_parent_q_selectspec($questionid), qa_db_related_qs_selectspec($qa_login_userid, $questionid), qa_db_category_nav_selectspec($questionid, true, true));
    if ($question['basetype'] != 'Q') {
        // don't allow direct viewing of other types of post
        $question = null;
    }
    $answers = array();
    $commentsfollows = array();
    foreach ($childposts as $postid => $post) {
        switch ($post['type']) {
            case 'Q':
                // never show follow-on Qs which have been hidden, even to admins
            // never show follow-on Qs which have been hidden, even to admins
            case 'C':
            case 'C_HIDDEN':
                $commentsfollows[$postid] = $post;
                break;
            case 'A':
            case 'A_HIDDEN':
                $answers[$postid] = $post;
                break;
        }
    }
    foreach ($achildposts as $postid => $post) {
        switch ($post['type']) {
            case 'Q':
            case 'Q_HIDDEN':
            case 'C':
            case 'C_HIDDEN':
                $commentsfollows[$postid] = $post;
                break;
        }
    }
    if (isset($question)) {
        $relatedcount = qa_opt('do_related_qs') ? 1 + qa_opt('page_size_related_qs') : 0;
        $relatedquestions = array_slice($relatedquestions, 0, $relatedcount);
        // includes question itself at this point
        qa_page_q_post_rules($question);
        if ($question['selchildid'] && @$answers[$question['selchildid']]['type'] != 'A') {
            $question['selchildid'] = null;
        }
        // if selected answer is hidden or somehow not there, consider it not selected
        foreach ($answers as $key => $answer) {
            $question['deleteable'] = false;
            qa_page_q_post_rules($answers[$key]);
            if ($answers[$key]['isbyuser'] && !qa_opt('allow_multi_answers')) {
                $question['answerbutton'] = false;
            }
            $answers[$key]['isselected'] = $answer['postid'] == $question['selchildid'];
        }
        foreach ($commentsfollows as $key => $commentfollow) {
            if ($commentfollow['parentid'] == $questionid) {
                $question['deleteable'] = false;
            }
            if (isset($answers[$commentfollow['parentid']])) {
                $answers[$commentfollow['parentid']]['deleteable'] = false;
            }
            qa_page_q_post_rules($commentsfollows[$key]);
        }
    }
}