예제 #1
0
function it_q_list_page_content($questions, $pagesize, $start, $count, $sometitle, $nonetitle, $navcategories, $categoryid, $categoryqcount, $categorypathprefix, $feedpathprefix, $suggest, $pagelinkparams = null, $categoryparams = null, $dummy = null)
{
    require_once QA_INCLUDE_DIR . 'qa-app-format.php';
    require_once QA_INCLUDE_DIR . 'qa-app-updates.php';
    $userid = qa_get_logged_in_userid();
    //	Chop down to size, get user information for display
    if (isset($pagesize)) {
        $questions = array_slice($questions, 0, $pagesize);
    }
    $usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions));
    $qa_content['q_list']['form'] = array('tags' => 'method="post" action="' . qa_self_html() . '"', 'hidden' => array('code' => qa_get_form_security_code('vote')));
    $qa_content['q_list']['qs'] = array();
    if (count($questions)) {
        $qa_content['title'] = $sometitle;
        $defaults = qa_post_html_defaults('Q');
        foreach ($questions as $question) {
            $qa_content['q_list']['qs'][] = qa_any_to_q_html_fields($question, $userid, it_cookie_get(), $usershtml, null, qa_post_html_options($question, $defaults));
        }
    } else {
        $qa_content['title'] = $nonetitle;
    }
    if (isset($count) && isset($pagesize)) {
        $qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $count, qa_opt('pages_prev_next'), $pagelinkparams);
    }
    return $qa_content;
}
예제 #2
0
function qa_q_list_page_content($questions, $pagesize, $start, $count, $sometitle, $nonetitle, $navcategories, $categoryid, $categoryqcount, $categorypathprefix, $feedpathprefix, $suggest, $pagelinkparams = null, $categoryparams = null, $dummy = null)
{
    if (qa_to_override(__FUNCTION__)) {
        $args = func_get_args();
        return qa_call_override(__FUNCTION__, $args);
    }
    require_once QA_INCLUDE_DIR . 'app/format.php';
    require_once QA_INCLUDE_DIR . 'app/updates.php';
    $userid = qa_get_logged_in_userid();
    //	Chop down to size, get user information for display
    if (isset($pagesize)) {
        $questions = array_slice($questions, 0, $pagesize);
    }
    $usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions));
    //	Prepare content for theme
    $qa_content = qa_content_prepare(true, array_keys(qa_category_path($navcategories, $categoryid)));
    $qa_content['q_list']['form'] = array('tags' => 'method="post" action="' . qa_self_html() . '"', 'hidden' => array('code' => qa_get_form_security_code('vote')));
    $qa_content['q_list']['qs'] = array();
    if (count($questions)) {
        $qa_content['title'] = $sometitle;
        $defaults = qa_post_html_defaults('Q');
        if (isset($categorypathprefix)) {
            $defaults['categorypathprefix'] = $categorypathprefix;
        }
        foreach ($questions as $question) {
            $fields = qa_any_to_q_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, qa_post_html_options($question, $defaults));
            if (!empty($fields['raw']['closedbyid'])) {
                $fields['closed'] = array('state' => qa_lang_html('main/closed'));
            }
            $qa_content['q_list']['qs'][] = $fields;
        }
    } else {
        $qa_content['title'] = $nonetitle;
    }
    if (isset($userid) && isset($categoryid)) {
        $favoritemap = qa_get_favorite_non_qs_map();
        $categoryisfavorite = @$favoritemap['category'][$navcategories[$categoryid]['backpath']];
        $qa_content['favorite'] = qa_favorite_form(QA_ENTITY_CATEGORY, $categoryid, $categoryisfavorite, qa_lang_sub($categoryisfavorite ? 'main/remove_x_favorites' : 'main/add_category_x_favorites', $navcategories[$categoryid]['title']));
    }
    if (isset($count) && isset($pagesize)) {
        $qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $count, qa_opt('pages_prev_next'), $pagelinkparams);
    }
    if (empty($qa_content['page_links'])) {
        $qa_content['suggest_next'] = $suggest;
    }
    if (qa_using_categories() && count($navcategories) && isset($categorypathprefix)) {
        $qa_content['navigation']['cat'] = qa_category_navigation($navcategories, $categoryid, $categorypathprefix, $categoryqcount, $categoryparams);
    }
    if (isset($feedpathprefix) && (qa_opt('feed_per_category') || !isset($categoryid))) {
        $qa_content['feed'] = array('url' => qa_path_html(qa_feed_request($feedpathprefix . (isset($categoryid) ? '/' . qa_category_path_request($navcategories, $categoryid) : ''))), 'label' => strip_tags($sometitle));
    }
    return $qa_content;
}
예제 #3
0
function qa_favorite_q_list_view($questions, $usershtml)
{
    $q_list = array('qs' => array());
    if (count($questions) === 0) {
        return $q_list;
    }
    $q_list['form'] = array('tags' => 'method="post" action="' . qa_self_html() . '"', 'hidden' => array('code' => qa_get_form_security_code('vote')));
    $defaults = qa_post_html_defaults('Q');
    foreach ($questions as $question) {
        $q_list['qs'][] = qa_post_html_fields($question, qa_get_logged_in_userid(), qa_cookie_get(), $usershtml, null, qa_post_html_options($question, $defaults));
    }
    return $q_list;
}
예제 #4
0
 function get_user_activity($handle, $limit = 10)
 {
     $userid = qa_handle_to_userid($handle);
     require_once QA_INCLUDE_DIR . 'qa-db-selects.php';
     require_once QA_INCLUDE_DIR . 'qa-app-format.php';
     $identifier = QA_FINAL_EXTERNAL_USERS ? $userid : $handle;
     list($useraccount, $questions, $answerqs, $commentqs, $editqs) = qa_db_select_with_pending(QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_account_selectspec($handle, false), qa_db_user_recent_qs_selectspec($userid, $identifier, $limit), qa_db_user_recent_a_qs_selectspec($userid, $identifier), qa_db_user_recent_c_qs_selectspec($userid, $identifier), qa_db_user_recent_edit_qs_selectspec($userid, $identifier));
     if (!QA_FINAL_EXTERNAL_USERS && !is_array($useraccount)) {
         // check the user exists
         return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
     }
     //	Get information on user references
     $questions = qa_any_sort_and_dedupe(array_merge($questions, $answerqs, $commentqs, $editqs));
     $questions = array_slice($questions, 0, $limit);
     $usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions), false);
     $htmldefaults = qa_post_html_defaults('Q');
     $htmldefaults['whoview'] = false;
     $htmldefaults['voteview'] = false;
     $htmldefaults['avatarsize'] = 0;
     foreach ($questions as $question) {
         $qa_content[] = qa_any_to_q_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, array('voteview' => false) + qa_post_html_options($question, $htmldefaults));
     }
     $output = '<div class="user-activities">';
     $output .= '<ul>';
     if (isset($qa_content)) {
         foreach ($qa_content as $qs) {
             $icon = 'icon-time undefined';
             $output .= '<li class="activity-item">';
             $output .= '<div class="list-right">';
             $output .= '<div class="type pull-left ' . $icon . '"></div>';
             $output .= '<div class="what"><a class="what-task" href="' . @$qs['url'] . '">' . $qs['what'] . '</a>';
             $output .= '<a href="' . $qs['url'] . '">' . $qs['title'] . '</a> </div>';
             $output .= '<strong class="when">' . implode(' ', $qs['when']) . '</strong>';
             $output .= '</div>';
             $output .= '</li>';
         }
     } else {
         $output .= '<li>' . qa_lang('cleanstrap/no_activity_yet') . '</li>';
     }
     $output .= '</ul>';
     $output .= '</div>';
     return $output;
 }
예제 #5
0
function qa_q_list_page_content($questions, $pagesize, $start, $count, $sometitle, $nonetitle, $navcategories, $categoryid, $categoryqcount, $categorypathprefix, $feedpathprefix, $suggest, $pagelinkparams = array())
{
    require_once QA_INCLUDE_DIR . 'qa-app-format.php';
    global $qa_login_userid, $qa_cookieid, $qa_request;
    // get globals from qa-page.php
    //	Chop down to size, get user information for display
    if (isset($pagesize)) {
        $questions = array_slice($questions, 0, $pagesize);
    }
    $usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions));
    //	Prepare content for theme
    $qa_content = qa_content_prepare(true, array_keys(qa_category_path($navcategories, $categoryid)));
    $qa_content['q_list']['form'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"');
    $qa_content['q_list']['qs'] = array();
    if (count($questions)) {
        $qa_content['title'] = $sometitle;
        $options = qa_post_html_defaults('Q');
        if (isset($categorypathprefix)) {
            $options['categorypathprefix'] = $categorypathprefix;
        }
        foreach ($questions as $question) {
            $qa_content['q_list']['qs'][] = qa_any_to_q_html_fields($question, $qa_login_userid, $qa_cookieid, $usershtml, null, $options);
        }
    } else {
        $qa_content['title'] = $nonetitle;
    }
    if (isset($count) && isset($pagesize)) {
        $qa_content['page_links'] = qa_html_page_links($qa_request, $start, $pagesize, $count, qa_opt('pages_prev_next'), $pagelinkparams);
    }
    if (empty($qa_content['page_links'])) {
        $qa_content['suggest_next'] = $suggest;
    }
    if (qa_using_categories() && count($navcategories) && isset($categorypathprefix)) {
        $qa_content['navigation']['cat'] = qa_category_navigation($navcategories, $categoryid, $categorypathprefix, $categoryqcount);
    }
    if (isset($feedpathprefix) && (qa_opt('feed_per_category') || !isset($categoryid))) {
        $qa_content['feed'] = array('url' => qa_path_html(qa_feed_request($feedpathprefix . (isset($categoryid) ? '/' . qa_category_path_request($navcategories, $categoryid) : ''))), 'label' => strip_tags($sometitle));
    }
    return $qa_content;
}
예제 #6
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);
     }
 }
예제 #7
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);
     }
 }
예제 #8
0
파일: options.php 프로젝트: swuit/swuit-q2a
function qa_post_html_options($post, $defaults = null, $full = false)
{
    if (qa_to_override(__FUNCTION__)) {
        $args = func_get_args();
        return qa_call_override(__FUNCTION__, $args);
    }
    if (!isset($defaults)) {
        $defaults = qa_post_html_defaults($post['basetype'], $full);
    }
    $defaults['voteview'] = qa_get_vote_view($post, $full);
    $defaults['ipview'] = !qa_user_post_permit_error('permit_anon_view_ips', $post);
    return $defaults;
}
예제 #9
0
    qa_redirect('tags');
}
@(list($questions, $tagword, $favorite) = qa_db_select_with_pending(qa_db_tag_recent_qs_selectspec($userid, $tag, $start, false, qa_opt_if_loaded('page_size_tag_qs')), qa_db_tag_word_selectspec($tag), isset($userid) ? qa_db_is_favorite_selectspec($userid, QA_ENTITY_TAG, $tag) : null));
$pagesize = qa_opt('page_size_tag_qs');
$questions = array_slice($questions, 0, $pagesize);
$usershtml = qa_userids_handles_html($questions);
//	Prepare content for theme
$qa_content = qa_content_prepare(true);
$qa_content['title'] = qa_lang_html_sub('main/questions_tagged_x', qa_html($tag));
if (isset($userid) && isset($tagword)) {
    $qa_content['favorite'] = qa_favorite_form(QA_ENTITY_TAG, $tagword['wordid'], $favorite, qa_lang_sub($favorite ? 'main/remove_x_favorites' : 'main/add_tag_x_favorites', $tagword['word']));
}
if (!count($questions)) {
    $qa_content['q_list']['title'] = qa_lang_html('main/no_questions_found');
}
$qa_content['q_list']['form'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"');
$qa_content['q_list']['qs'] = array();
foreach ($questions as $postid => $question) {
    $qa_content['q_list']['qs'][] = qa_post_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, qa_post_html_defaults('Q'));
}
$qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $tagword['tagcount'], qa_opt('pages_prev_next'));
if (empty($qa_content['page_links'])) {
    $qa_content['suggest_next'] = qa_html_suggest_qs_tags(true);
}
if (qa_opt('feed_for_tag_qs')) {
    $qa_content['feed'] = array('url' => qa_path_html(qa_feed_request('tag/' . $tag)), 'label' => qa_lang_html_sub('main/questions_tagged_x', qa_html($tag)));
}
return $qa_content;
/*
	Omit PHP closing tag to help avoid accidental output
*/
예제 #10
0
function get_user_activity($handle)
{
    $userid = qa_handle_to_userid($handle);
    require_once QA_INCLUDE_DIR . 'qa-db-selects.php';
    require_once QA_INCLUDE_DIR . 'qa-app-format.php';
    $loginuserid = qa_get_logged_in_userid();
    $identifier = QA_FINAL_EXTERNAL_USERS ? $userid : $handle;
    list($useraccount, $questions, $answerqs, $commentqs, $editqs) = qa_db_select_with_pending(QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_account_selectspec($handle, false), qa_db_user_recent_qs_selectspec($loginuserid, $identifier, qa_opt_if_loaded('page_size_activity')), qa_db_user_recent_a_qs_selectspec($loginuserid, $identifier), qa_db_user_recent_c_qs_selectspec($loginuserid, $identifier), qa_db_user_recent_edit_qs_selectspec($loginuserid, $identifier));
    if (!QA_FINAL_EXTERNAL_USERS && !is_array($useraccount)) {
        // check the user exists
        return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
    }
    //	Get information on user references
    $questions = qa_any_sort_and_dedupe(array_merge($questions, $answerqs, $commentqs, $editqs));
    $questions = array_slice($questions, 0, qa_opt('page_size_activity'));
    $usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions), false);
    $htmldefaults = qa_post_html_defaults('Q');
    $htmldefaults['whoview'] = false;
    $htmldefaults['voteview'] = false;
    $htmldefaults['avatarsize'] = 0;
    foreach ($questions as $question) {
        $qa_content[] = qa_any_to_q_html_fields($question, $loginuserid, qa_cookie_get(), $usershtml, null, array('voteview' => false) + qa_post_html_options($question, $htmldefaults));
    }
    $output = '<div class="widget user-activities">';
    $output .= '<h3 class="widget-title">' . ra_name($handle) . '\'s ' . _ra_lang('activities') . '</h3>';
    $output .= '<ul class="question-list">';
    if (isset($qa_content)) {
        foreach ($qa_content as $qs) {
            if ($qs['what'] == 'answered') {
                $icon = 'icon-chat-3 answered';
            } elseif ($qs['what'] == 'asked') {
                $icon = 'icon-question asked';
            } elseif ($qs['what'] == 'commented') {
                $icon = 'icon-chat-2 commented';
            } elseif ($qs['what'] == 'edited' || $qs['what'] == 'answer edited') {
                $icon = 'icon-edit edited';
            } elseif ($qs['what'] == 'closed') {
                $icon = 'icon-error closed';
            } elseif ($qs['what'] == 'answer selected') {
                $icon = 'icon-checked selected';
            } elseif ($qs['what'] == 'recategorized') {
                $icon = 'icon-folder-close recategorized';
            } else {
                $icon = 'icon-pin undefined';
            }
            $output .= '<li class="activity-item">';
            $output .= '<div class="type pull-left ' . $icon . '"></div>';
            $output .= '<div class="list-right">';
            $output .= '<h5 class="when"><a href="' . @$qs['what_url'] . '">' . $qs['what'] . '</a> ' . implode(' ', $qs['when']) . '</h5>';
            $output .= '<h5 class="what"><a href="' . $qs['url'] . '">' . $qs['title'] . '</a></h5>';
            $output .= '</div>';
            $output .= '</li>';
        }
    } else {
        $output .= '<li>' . _ra_lang('No activity yet.') . '</li>';
    }
    $output .= '</ul>';
    $output .= '</div>';
    return $output;
}
    $usershtml = qa_userids_handles_html($fullquestions);
    //	Report the search event
    qa_report_event('search', $userid, qa_get_logged_in_handle(), qa_cookie_get(), array('query' => $inquery, 'start' => $start));
}
//	Prepare content for theme
$qa_content = qa_content_prepare(true);
if (strlen(qa_get('q'))) {
    $qa_content['search']['value'] = qa_html($inquery);
    if (count($results)) {
        $qa_content['title'] = qa_lang_html_sub('main/results_for_x', qa_html($inquery));
    } else {
        $qa_content['title'] = qa_lang_html_sub('main/no_results_for_x', qa_html($inquery));
    }
    $qa_content['q_list']['form'] = array('tags' => 'method="post" action="' . qa_self_html() . '"', 'hidden' => array('code' => qa_get_form_security_code('vote')));
    $qa_content['q_list']['qs'] = array();
    $qdefaults = qa_post_html_defaults('Q');
    foreach ($results as $result) {
        if (!isset($result['question'])) {
            // if we have any non-question results, display with less statistics
            $qdefaults['voteview'] = false;
            $qdefaults['answersview'] = false;
            $qdefaults['viewsview'] = false;
            break;
        }
    }
    foreach ($results as $result) {
        if (isset($result['question'])) {
            $fields = qa_post_html_fields($result['question'], $userid, qa_cookie_get(), $usershtml, null, qa_post_html_options($result['question'], $qdefaults));
        } elseif (isset($result['url'])) {
            $fields = array('what' => qa_html($result['url']), 'meta_order' => qa_lang_html('main/meta_order'));
        } else {
예제 #12
0
if (@$userpoints['aselects']) {
    $qa_content['form_activity']['fields']['questions']['value'] .= $userpoints['aselects'] == 1 ? qa_lang_html_sub('profile/1_with_best_chosen', '<SPAN CLASS="qa-uf-user-q-selects">1</SPAN>', '1') : qa_lang_html_sub('profile/x_with_best_chosen', '<SPAN CLASS="qa-uf-user-q-selects">' . number_format($userpoints['aselects']) . '</SPAN>');
}
if (@$userpoints['aselecteds']) {
    $qa_content['form_activity']['fields']['answers']['value'] .= $userpoints['aselecteds'] == 1 ? qa_lang_html_sub('profile/1_chosen_as_best', '<SPAN CLASS="qa-uf-user-a-selecteds">1</SPAN>', '1') : qa_lang_html_sub('profile/x_chosen_as_best', '<SPAN CLASS="qa-uf-user-a-selecteds">' . number_format($userpoints['aselecteds']) . '</SPAN>');
}
//	For plugin layers to access
$qa_content['raw']['userid'] = $userid;
$qa_content['raw']['points'] = $userpoints;
$qa_content['raw']['rank'] = $userrank;
//	Recent posts by this user
if ($pagesize > 0) {
    if (count($questions)) {
        $qa_content['q_list']['title'] = qa_lang_html_sub('profile/recent_activity_by_x', $userhtml);
    } else {
        $qa_content['q_list']['title'] = qa_lang_html_sub('profile/no_posts_by_x', $userhtml);
    }
    $qa_content['q_list']['form_profile'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"');
    $qa_content['q_list']['qs'] = array();
    $htmloptions = qa_post_html_defaults('Q');
    $htmloptions['whoview'] = true;
    //false;
    $htmloptions['avatarsize'] = 0;
    foreach ($questions as $question) {
        $qa_content['q_list']['qs'][] = qa_any_to_q_html_fields($question, $loginuserid, qa_cookie_get(), $usershtml, null, $htmloptions);
    }
}
return $qa_content;
/*
	Omit PHP closing tag to help avoid accidental output
*/
 function process_request($request)
 {
     // get all variables
     preg_match($this->reqmatch, $request, $matches);
     $post_type = $matches[1];
     $handle = $matches[2];
     $start = (int) qa_get('start');
     $pagesize = qa_opt('page_size_qs');
     $hidecss = qa_opt($this->cssopt) === '1';
     // regular page request
     $qa_content = qa_content_prepare();
     require_once QA_INCLUDE_DIR . 'qa-util-string.php';
     // display CSS for stat summary
     if (!$hidecss) {
         $qa_content['custom'] = "<style>\n" . ".qa-useract-page-links { margin: 16px 0; color: #555753; font-size: 16px; text-align: center; }\n" . ".qa-useract-page-links > a { font-weight: bold; }\n" . ".qa-useract-stats { margin: 8px 0; text-align: center; }\n" . ".qa-useract-stat { display: inline-block; margin: 0 16px 8px; }\n" . ".qa-useract-count { font-size: 18px; font-weight: bold; }\n" . ".qa-useract-wrapper .qa-q-item-main { width: 658px; }\n" . ".qa-useract-wrapper .qa-a-count { height: auto; border: 1px solid #ebeaca; border-radius: 8px; -moz-border-radius: 8px; -webkit-border-radius:8px; }\n" . ".qa-useract-wrapper .qa-a-snippet { margin-top: 2px; color: #555753; }\n" . ".qa-useract-wrapper .qa-q-item-meta { float: none; }\n" . "</style>\n\n";
     }
     // list of questions by this user
     if ($post_type === 'questions') {
         $qa_content['title'] = qa_lang_html_sub('useractivity/questions_by', $handle);
         list($userid, $count, $sel_count) = $this->_questions_stats($handle);
         // get questions
         $columns = 'postid, categoryid, type, LEFT(type,1) AS basetype, INSTR(type,"_HIDDEN")>0 AS hidden, acount, selchildid, closedbyid, upvotes, downvotes, netvotes, hotness, flagcount, BINARY title AS title, BINARY tags AS tags, UNIX_TIMESTAMP(created) AS created';
         $sql_questions = 'SELECT ' . $columns . ' FROM ^posts WHERE type="Q" AND userid=# ORDER BY created DESC LIMIT #,#';
         $result = qa_db_query_sub($sql_questions, $userid, $start, $pagesize);
         $questions = qa_db_read_all_assoc($result);
         $htmloptions = qa_post_html_defaults('Q');
         $htmloptions['whoview'] = false;
         $htmloptions['avatarsize'] = 0;
         // html for stats
         $qa_content['custom'] .= '<div class="qa-useract-stats">' . '	<div class="qa-useract-stat"><span class="qa-useract-count">' . $count . '</span><br>' . ($count == 1 ? qa_lang_html('useractivity/question') : qa_lang_html('useractivity/questions')) . '</div>' . '	<div class="qa-useract-stat"><span class="qa-useract-count">' . $sel_count . '</span><br>' . ($sel_count == 1 ? qa_lang_html('useractivity/best_answer_given') : qa_lang_html('useractivity/best_answers_given')) . '</div>' . '</div>';
         // create html for question list
         $qa_content['q_list']['qs'] = array();
         foreach ($questions as $question) {
             $qa_content['q_list']['qs'][] = qa_any_to_q_html_fields($question, qa_get_logged_in_userid(), qa_cookie_get(), null, null, $htmloptions);
         }
         // pagination
         $qa_content['page_links'] = qa_html_page_links($request, $start, $pagesize, $count, qa_opt('pages_prev_next'), null);
         return $qa_content;
     } else {
         if ($post_type === 'answers') {
             $qa_content['title'] = qa_lang_html_sub('useractivity/answers_by', $handle);
             // userid and answer count
             $sql_count = 'SELECT u.userid, count(a.postid) AS qs, sum(q.selchildid=a.postid) AS selected ' . 'FROM ^posts a, ^posts q, ^users u ' . 'WHERE a.parentid=q.postid AND u.userid=a.userid AND a.type="A" AND q.type="Q" AND u.handle=$';
             $result = qa_db_query_sub($sql_count, $handle);
             $row = qa_db_read_one_assoc($result);
             $userid = $row['userid'];
             $count = $row['qs'];
             $sel_count = $row['selected'];
             // get answers
             $columns = 'q.postid AS qpostid, BINARY q.title AS qtitle, q.selchildid AS qselid, q.netvotes AS qvotes, a.postid AS apostid, BINARY a.content AS acontent, a.netvotes AS avotes, UNIX_TIMESTAMP(a.created) AS acreated, a.format';
             $sql_answers = 'SELECT ' . $columns . ' FROM ^posts a, ^posts q WHERE a.parentid=q.postid AND a.type="A" AND q.type="Q" AND a.userid=# ORDER BY a.created DESC LIMIT #,#';
             $result = qa_db_query_sub($sql_answers, $userid, $start, $pagesize);
             $answers = qa_db_read_all_assoc($result);
             $qa_content['custom'] .= '<div class="qa-useract-stats">' . '	<div class="qa-useract-stat"><span class="qa-useract-count">' . $count . '</span><br>' . ($count == 1 ? qa_lang_html('useractivity/answer') : qa_lang_html('useractivity/answers')) . '</div>' . '	<div class="qa-useract-stat"><span class="qa-useract-count">' . $sel_count . '</span><br>' . ($sel_count == 1 ? qa_lang_html('useractivity/best_answer_received') : qa_lang_html('useractivity/best_answers_received')) . '</div>' . '</div>';
             $qa_content['custom_2'] = '<div class="qa-useract-wrapper">';
             foreach ($answers as $ans) {
                 // to avoid ugly content, convert answer to HTML then strip the tags and remove any URLs
                 $ans['acontent'] = qa_viewer_html($ans['acontent'], $ans['format']);
                 $ans['acontent'] = strip_tags($ans['acontent']);
                 $ans['acontent'] = preg_replace('#\\shttp://[^\\s]+#', '', $ans['acontent']);
                 $ans['acontent'] = qa_substr($ans['acontent'], 0, 100);
                 if (strlen($ans['acontent']) == 100) {
                     $ans['acontent'] .= '...';
                 }
                 // question url
                 $ans['qurl'] = qa_path_html(qa_q_request($ans['qpostid'], $ans['qtitle']));
                 // answer date
                 $ans['acreated'] = qa_when_to_html($ans['acreated'], qa_opt('show_full_date_days'));
                 // html content
                 $qa_content['custom_2'] .= $this->_answer_tmpl($ans);
             }
             $qa_content['custom_2'] .= '</div>';
             // pagination
             $qa_content['page_links'] = qa_html_page_links($request, $start, $pagesize, $count, qa_opt('pages_prev_next'), null);
             return $qa_content;
         }
     }
 }
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) {
            // related questions will include itself so remove that
            unset($relatedquestions[$key]);
        }
    }
    if (count($relatedquestions)) {
        $qa_content['q_list']['title'] = qa_lang('main/related_qs_title');
    } else {
        $qa_content['q_list']['title'] = qa_lang('main/no_related_qs_title');
    }
    $qa_content['q_list']['qs'] = array();
    foreach ($relatedquestions as $related) {
        $qa_content['q_list']['qs'][] = qa_post_html_fields($related, $qa_login_userid, $qa_cookieid, $usershtml, null, qa_post_html_defaults('Q'));
    }
}
//	Some generally useful stuff
if (qa_using_categories() && count($categories)) {
    $qa_content['navigation']['cat'] = qa_category_navigation($categories, $question['categoryid']);
}
if (isset($jumptoanchor)) {
    $qa_content['script_onloads'][] = array("window.location.hash=" . qa_js($jumptoanchor) . ";");
}
if (isset($focusonid)) {
    $qa_content['script_onloads'][] = array("document.getElementById(" . qa_js($focusonid) . ").focus();");
}
//	Determine whether the page view should be counted
if (qa_opt('do_count_q_views') && !$formrequested && !qa_is_http_post() && qa_is_human_probably() && (!$question['views'] || ($question['lastviewip'] != qa_remote_ip_address() || !isset($question['lastviewip'])) && ($question['createip'] != qa_remote_ip_address() || !isset($question['createip'])) && ($question['userid'] != $qa_login_userid || !isset($question['userid'])) && ($question['cookieid'] != $qa_cookieid || !isset($question['cookieid'])))) {
    $qa_content['inc_views_postid'] = $questionid;
예제 #15
0
function qa_page_q_comment_follow_list($parent, $commentsfollows, $alwaysfull, $usershtml, $formrequested, $formpostid)
{
    $parentid = $parent['postid'];
    $userid = qa_get_logged_in_userid();
    $cookieid = qa_cookie_get();
    $commentlist = array('tags' => 'ID="c' . qa_html($parentid) . '_list"', 'cs' => array());
    $showcomments = array();
    foreach ($commentsfollows as $commentfollowid => $commentfollow) {
        if ($commentfollow['parentid'] == $parentid && $commentfollow['viewable'] && $commentfollowid != $formpostid) {
            $showcomments[$commentfollowid] = $commentfollow;
        }
    }
    $countshowcomments = count($showcomments);
    if (!$alwaysfull && $countshowcomments > qa_opt('show_fewer_cs_from')) {
        $skipfirst = $countshowcomments - qa_opt('show_fewer_cs_count');
    } else {
        $skipfirst = 0;
    }
    if ($skipfirst == $countshowcomments) {
        // showing none
        if ($skipfirst == 1) {
            $expandtitle = qa_lang_html('question/show_1_comment');
        } else {
            $expandtitle = qa_lang_html_sub('question/show_x_comments', $skipfirst);
        }
    } else {
        if ($skipfirst == 1) {
            $expandtitle = qa_lang_html('question/show_1_previous_comment');
        } else {
            $expandtitle = qa_lang_html_sub('question/show_x_previous_comments', $skipfirst);
        }
    }
    if ($skipfirst > 0) {
        $commentlist['cs'][$parentid] = array('url' => qa_html('?state=showcomments-' . $parentid . '&show=' . $parentid . '#' . urlencode(qa_anchor($parent['basetype'], $parentid))), 'expand_tags' => 'onClick="return qa_show_comments(' . qa_js($parentid) . ', this);"', 'title' => $expandtitle);
    }
    foreach ($showcomments as $commentfollowid => $commentfollow) {
        if ($skipfirst > 0) {
            $skipfirst--;
        } elseif ($commentfollow['basetype'] == 'C') {
            $commentlist['cs'][$commentfollowid] = qa_page_q_comment_view($parent, $commentfollow, $usershtml, $formrequested);
        } elseif ($commentfollow['basetype'] == 'Q') {
            $htmloptions = qa_post_html_defaults('Q');
            $htmloptions['avatarsize'] = qa_opt('avatar_q_page_c_size');
            $commentlist['cs'][$commentfollowid] = qa_post_html_fields($commentfollow, $userid, $cookieid, $usershtml, null, $htmloptions);
        }
    }
    if (!count($commentlist['cs'])) {
        $commentlist['hidden'] = true;
    }
    return $commentlist;
}
예제 #16
0
 function get_single_question($data, $questionin)
 {
     $userid = qa_get_logged_in_userid();
     $questionid = $questionin['postid'];
     $options = qa_post_html_defaults('Q', @$data['full']);
     if (@$data['full']) {
         require_once QA_INCLUDE_DIR . 'qa-page-question-view.php';
         $cookieid = isset($userid) ? qa_cookie_get() : qa_cookie_get_create();
         // create a new cookie if necessary
         $coptions = qa_post_html_defaults('C', true);
         @(list($childposts, $achildposts, $parentquestion, $closepost, $extravalue, $categories, $favorite) = qa_db_select_with_pending(qa_db_full_child_posts_selectspec($userid, $questionid), qa_db_full_a_child_posts_selectspec($userid, $questionid), qa_db_post_parent_q_selectspec($questionid), qa_db_post_close_post_selectspec($questionid), qa_db_post_meta_selectspec($questionid, 'qa_q_extra'), qa_db_category_nav_selectspec($questionid, true, true, true), isset($userid) ? qa_db_is_favorite_selectspec($userid, QA_ENTITY_QUESTION, $questionid) : null));
         if ($questionin['basetype'] != 'Q') {
             // don't allow direct viewing of other types of post
             return null;
         }
         $questionin['extra'] = $extravalue;
         $answers = qa_page_q_load_as($questionin, $childposts);
         $allcomments = qa_page_q_load_c_follows($questionin, $childposts, $achildposts);
         $questionin = $questionin + qa_page_q_post_rules($questionin, null, null, $childposts);
         // array union
         if ($questionin['selchildid'] && @$answers[$questionin['selchildid']]['type'] != 'A') {
             $questionin['selchildid'] = null;
         }
         // if selected answer is hidden or somehow not there, consider it not selected
         foreach ($answers as $key => $answer) {
             $answers[$key] = $answer + qa_page_q_post_rules($answer, $questionin, $answers, $achildposts);
             $answers[$key]['isselected'] = $answer['postid'] == $questionin['selchildid'];
         }
         foreach ($allcomments as $key => $commentfollow) {
             $parent = $commentfollow['parentid'] == $questionid ? $questionin : @$answers[$commentfollow['parentid']];
             $allcomments[$key] = $commentfollow + qa_page_q_post_rules($commentfollow, $parent, $allcomments, null);
         }
         $usershtml = qa_userids_handles_html(array_merge(array($questionin), $answers, $allcomments), true);
         $question = $this->get_full_post($questionin, $options, $usershtml);
         $qcomments = array();
         foreach ($allcomments as $idx => $comment) {
             if ($comment['basetype'] == 'C') {
                 $comment = $this->get_full_post($comment, $coptions, $usershtml);
             } else {
                 $comment = $this->get_full_post($comment, $options, $usershtml);
             }
             $comment['username'] = $this->get_username($comment['raw']['userid']);
             if ($comment['raw']['parentid'] == $questionid) {
                 $qcomments[] = $comment;
             }
             $allcomments[$idx] = $comment;
         }
         $aoptions = qa_post_html_defaults('A', true);
         $outanswers = array();
         foreach ($answers as $answer) {
             $aoptions['isselected'] = @$answer['isselected'];
             $answer = $this->get_full_post($answer, $aoptions, $usershtml);
             if (!$answer) {
                 continue;
             }
             $answer['username'] = $this->get_username($answer['raw']['userid']);
             $acomments = array();
             foreach ($allcomments as $comment) {
                 if ($comment['raw']['parentid'] == $answer['raw']['postid']) {
                     $acomments[] = $comment;
                 }
             }
             $answer['comments'] = $acomments;
             $outanswers[] = $answer;
         }
         $question['answers'] = $outanswers;
         $question['comments'] = $qcomments;
         $question['parentquestion'] = $parentquestion;
         $question['closepost'] = $closepost;
         $question['extravalue'] = $extravalue;
         $question['categories'] = $categories;
         $question['favorite'] = $favorite;
     } else {
         $questionin = qa_db_select_with_pending(qa_db_full_post_selectspec($userid, $questionid));
         $usershtml = qa_userids_handles_html(array($questionin), true);
         $question = qa_any_to_q_html_fields($questionin, $userid, qa_cookie_get(), $usershtml, null, $options);
     }
     $question['username'] = $this->get_username($userid);
     return $question;
 }
예제 #17
0
}
//	Prepare content for theme
$qa_content = qa_content_prepare(true);
if (strlen(qa_get('q'))) {
    $qa_content['search']['value'] = qa_html($inquery);
}
if (isset($questions)) {
    if (count($questions)) {
        $qa_content['title'] = qa_lang_html_sub('main/results_for_x', qa_html($inquery));
    } else {
        $qa_content['title'] = qa_lang_html_sub('main/no_results_for_x', qa_html($inquery));
    }
    $qa_content['q_list']['form'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"');
    $qa_content['q_list']['qs'] = array();
    foreach ($questions as $question) {
        $fields = qa_post_html_fields($question, $qa_login_userid, $qa_cookieid, $usershtml, null, qa_post_html_defaults('Q'));
        $fields['url'] = qa_path_html(qa_q_request($question['postid'], $question['title']), null, null, null, qa_search_max_match_anchor($question));
        $qa_content['q_list']['qs'][] = $fields;
    }
    $qa_content['page_links'] = qa_html_page_links($qa_request, $qa_start, $pagesize, $qa_start + $gotcount, qa_opt('pages_prev_next'), array('q' => $inquery), $gotcount >= $retrieve);
    if (qa_opt('feed_for_search')) {
        $qa_content['feed'] = array('url' => qa_path_html(qa_feed_request('search/' . $inquery)), 'label' => qa_lang_html_sub('main/results_for_x', qa_html($inquery)));
    }
} else {
    $qa_content['title'] = qa_lang_html('main/search_title');
}
if (empty($qa_content['page_links'])) {
    $qa_content['suggest_next'] = qa_html_suggest_qs_tags(qa_using_tags());
}
return $qa_content;
/*
예제 #18
0
function qa_page_q_comment_follow_list($parent)
{
    global $commentsfollows, $qa_login_userid, $qa_cookieid, $usershtml, $formtype, $formpostid, $formrequested;
    foreach ($commentsfollows as $commentfollowid => $commentfollow) {
        if ($commentfollow['parentid'] == $parent['postid'] && $commentfollow['viewable'] && $commentfollowid != $formpostid) {
            if ($commentfollow['basetype'] == 'C') {
                $htmloptions = qa_post_html_defaults('C', true);
                $htmloptions['avatarsize'] = qa_opt('avatar_q_page_c_size');
                $c_view = qa_post_html_fields($commentfollow, $qa_login_userid, $qa_cookieid, $usershtml, null, $htmloptions);
                //	Buttons for operating on this comment
                if (!$formrequested) {
                    // don't show if another form is currently being shown on page
                    $c_view['form'] = array('style' => 'light', 'buttons' => array());
                    if ($commentfollow['editbutton']) {
                        $c_view['form']['buttons']['edit'] = array('tags' => 'NAME="doeditc_' . qa_html($commentfollowid) . '"', 'label' => qa_lang_html('question/edit_button'), 'popup' => qa_lang_html('question/edit_c_popup'));
                    }
                    if ($commentfollow['flagbutton']) {
                        $c_view['form']['buttons']['flag'] = array('tags' => 'NAME="doflagc_' . qa_html($commentfollowid) . '"', 'label' => qa_lang_html($commentfollow['flagtohide'] ? 'question/flag_hide_button' : 'question/flag_button'), 'popup' => qa_lang_html('question/flag_c_popup'));
                    }
                    if ($commentfollow['unflaggable']) {
                        $c_view['form']['buttons']['unflag'] = array('tags' => 'NAME="dounflagc_' . qa_html($commentfollowid) . '"', 'label' => qa_lang_html('question/unflag_button'), 'popup' => qa_lang_html('question/unflag_popup'));
                    }
                    if ($commentfollow['clearflaggable']) {
                        $c_view['form']['buttons']['clearflags'] = array('tags' => 'NAME="doclearflagsc_' . qa_html($commentfollowid) . '"', 'label' => qa_lang_html('question/clear_flags_button'), 'popup' => qa_lang_html('question/clear_flags_popup'));
                    }
                    if ($commentfollow['hideable']) {
                        $c_view['form']['buttons']['hide'] = array('tags' => 'NAME="dohidec_' . qa_html($commentfollowid) . '"', 'label' => qa_lang_html('question/hide_button'), 'popup' => qa_lang_html('question/hide_c_popup'));
                    }
                    if ($commentfollow['reshowable']) {
                        $c_view['form']['buttons']['reshow'] = array('tags' => 'NAME="doshowc_' . qa_html($commentfollowid) . '"', 'label' => qa_lang_html('question/reshow_button'));
                    }
                    if ($commentfollow['deleteable']) {
                        $c_view['form']['buttons']['delete'] = array('tags' => 'NAME="dodeletec_' . qa_html($commentfollowid) . '"', 'label' => qa_lang_html('question/delete_button'), 'popup' => qa_lang_html('question/delete_c_popup'));
                    }
                    if ($commentfollow['claimable']) {
                        $c_view['form']['buttons']['claim'] = array('tags' => 'NAME="doclaimc_' . qa_html($commentfollowid) . '"', 'label' => qa_lang_html('question/claim_button'));
                    }
                    if ($parent['commentbutton'] && qa_opt('show_c_reply_buttons') && !$commentfollow['hidden']) {
                        $c_view['form']['buttons']['comment'] = array('tags' => 'NAME="' . ($parent['basetype'] == 'Q' ? 'docommentq' : 'docommenta_' . qa_html($parent['postid'])) . '"', 'label' => qa_lang_html('question/reply_button'), 'popup' => qa_lang_html('question/reply_c_popup'));
                    }
                }
            } elseif ($commentfollow['basetype'] == 'Q') {
                $htmloptions = qa_post_html_defaults('Q');
                $htmloptions['avatarsize'] = qa_opt('avatar_q_page_c_size');
                $c_view = qa_post_html_fields($commentfollow, $qa_login_userid, $qa_cookieid, $usershtml, null, $htmloptions);
            }
            $commentlist[] = $c_view;
        }
    }
    return @$commentlist;
}
예제 #19
0
    $usershtml = qa_userids_handles_html($fullquestions);
    //	Report the search event
    qa_report_event('search', $userid, qa_get_logged_in_handle(), qa_cookie_get(), array('query' => $inquery, 'start' => $start));
}
//	Prepare content for theme
$qa_content = qa_content_prepare(true);
if (strlen(qa_get('q'))) {
    $qa_content['search']['value'] = qa_html($inquery);
    if (count($results)) {
        $qa_content['title'] = qa_lang_html_sub('main/results_for_x', qa_html($inquery));
    } else {
        $qa_content['title'] = qa_lang_html_sub('main/no_results_for_x', qa_html($inquery));
    }
    $qa_content['q_list']['form'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"');
    $qa_content['q_list']['qs'] = array();
    $questionoptions = qa_post_html_defaults('Q');
    foreach ($results as $result) {
        if (!isset($result['question'])) {
            // if we have any non-question results, display with less statistics
            $questionoptions['voteview'] = false;
            $questionoptions['answersview'] = false;
            $questionoptions['viewsview'] = false;
            $fakeoptions = $questionoptions;
            $fakeoptions['whoview'] = false;
            $fakeoptions['whenview'] = false;
            $fakeoptions['whatview'] = false;
            break;
        }
    }
    foreach ($results as $result) {
        if (isset($result['question'])) {
예제 #20
0
 function ajaxCommentCreate($parent, $cid)
 {
     global $qa_login_userid, $qa_cookieid, $usershtml, $formtype, $formpostid, $formrequested;
     $comment = qa_db_single_select(qa_db_full_post_selectspec(null, $cid));
     $htmloptions = qa_post_html_defaults('C', true);
     $htmloptions['avatarsize'] = qa_opt('avatar_q_page_c_size');
     $c_view = qa_post_html_fields($comment, $qa_login_userid, $qa_cookieid, $usershtml, null, $htmloptions);
     //	Buttons for operating on this comment
     $c_view['form'] = array('style' => 'light', 'buttons' => array());
     $c_view['form']['buttons']['edit'] = array('tags' => 'NAME="doeditc_' . qa_html($cid) . '"', 'label' => qa_lang_html('question/edit_button'), 'popup' => qa_lang_html('question/edit_c_popup'));
     $c_view['form']['buttons']['hide'] = array('tags' => 'NAME="dohidec_' . qa_html($cid) . '"', 'label' => qa_lang_html('question/hide_button'), 'popup' => qa_lang_html('question/hide_c_popup'));
     $comment['claimable'] = !isset($comment['userid']) && isset($qa_login_userid) && strcmp(@$comment['cookieid'], $qa_cookieid) == 0 && !$permiterror_post_c;
     if ($comment['claimable']) {
         $c_view['form']['buttons']['claim'] = array('tags' => 'NAME="doclaimc_' . qa_html($cid) . '"', 'label' => qa_lang_html('question/claim_button'));
     }
     $parent['commentbutton'] = qa_user_permit_error('permit_post_c') != 'level' && qa_opt($comment['type'] == 'Q' ? 'comment_on_qs' : 'comment_on_as');
     if ($parent['commentbutton'] && qa_opt('show_c_reply_buttons') && !$comment['hidden']) {
         $c_view['form']['buttons']['comment'] = array('tags' => 'NAME="' . ($parent['basetype'] == 'Q' ? 'docommentq' : 'docommenta_' . qa_html($parent['postid'])) . '"', 'label' => qa_lang_html('question/reply_button'), 'popup' => qa_lang_html('question/reply_c_popup'));
     }
     return @$c_view;
 }