if (is_numeric($position)) { $pagestart = floor($position / $pagesize) * $pagesize; } } // set the canonical url based on possible pagination $qa_content['canonical'] = qa_path_html(qa_q_request($question['postid'], $question['title']), $pagestart > 0 ? array('start' => $pagestart) : null, qa_opt('site_url')); // build the actual answer list $answerids = array_slice($answerids, $pagestart, $pagesize); foreach ($answerids as $answerid) { $answer = $answers[$answerid]; if (!($formtype == 'a_edit' && $formpostid == $answerid)) { $a_view = qa_page_q_answer_view($question, $answer, $answer['isselected'], $usershtml, $formrequested); // Prepare content for comments on this answer, plus add or edit comment forms if ($formtype == 'c_add' && $formpostid == $answerid || $answer['commentbutton'] && !$formrequested) { // ...to be added $a_view['c_form'] = qa_page_q_add_c_form($qa_content, $question, $answer, 'c' . $answerid, $captchareason, @$cnewin[$answerid], @$cnewerrors[$answerid], $formtype == 'c_add'); if ($formtype == 'c_add' && $formpostid == $answerid) { $jumptoanchor = 'c' . $answerid; $commentsall = $answerid; } } elseif ($formtype == 'c_edit' && @$commentsfollows[$formpostid]['parentid'] == $answerid) { // ...being edited $a_view['c_form'] = qa_page_q_edit_c_form($qa_content, 'c' . $formpostid, $commentsfollows[$formpostid], @$ceditin[$formpostid], @$cediterrors[$formpostid]); $jumptoanchor = 'c' . $formpostid; $commentsall = $answerid; } $a_view['c_list'] = qa_page_q_comment_follow_list($question, $answer, $commentsfollows, $commentsall == $answerid, $usershtml, $formrequested, $formpostid); // ...for viewing // Add the answer to the list $qa_content['a_list']['as'][] = $a_view; }
if ($answer['claimable']) { $a_view['form']['buttons']['claim'] = array('tags' => 'NAME="doclaima_' . qa_html($answerid) . '"', 'label' => qa_lang_html('question/claim_button')); } if ($answer['followable']) { $a_view['form']['buttons']['follow'] = array('tags' => 'NAME="dofollowa_' . qa_html($answerid) . '"', 'label' => qa_lang_html('question/follow_button'), 'popup' => qa_lang_html('question/follow_a_popup')); } if ($answer['commentbutton']) { $a_view['form']['buttons']['comment'] = array('tags' => 'NAME="docommenta_' . qa_html($answerid) . '"', 'label' => qa_lang_html('question/comment_button'), 'popup' => qa_lang_html('question/comment_a_popup')); } } // Prepare content for comments on this answer, plus add or edit comment forms $a_view['c_list'] = qa_page_q_comment_follow_list($answer); // ...for viewing if ($formtype == 'c_add' && $formpostid == $answerid) { // ...to be added $a_view['c_form'] = qa_page_q_add_c_form($answerid); } else { if ($formtype == 'c_edit' && @$commentsfollows[$formpostid]['parentid'] == $answerid) { // ...being edited $a_view['c_form'] = qa_page_q_edit_c_form($formpostid, $answerid); } } // Determine this answer's place in the order on the page if ($answer['hidden']) { $a_view['priority'] = 10000 + $priority++; } elseif ($answer['isselected'] && qa_opt('show_selected_first')) { $a_view['priority'] = 0; } else { $a_view['priority'] = 5000 + $priority++; } // Add the answer to the list