get_text($content, $format, array()); } /** * Return tagstring to store in the database based on $tags as an array or a comma-separated string. * @param $tags * @return mixed|string */ function qa_post_tags_to_tagstring($tags) { if (is_array($tags)) $tags = implode(',', $tags); return qa_tags_to_tagstring(array_unique(preg_split('/\s*,\s*/', qa_strtolower(strtr($tags, '/', ' ')), -1, PREG_SPLIT_NO_EMPTY))); } /** * Return the full database records for all answers to question $questionid * @param $questionid * @return array */ function qa_post_get_question_answers($questionid) { $answers = array(); $childposts = qa_db_single_select(qa_db_full_child_posts_selectspec(null, $questionid)); foreach ($childposts as $postid => $post) { if ($post['basetype'] == 'A') $answers[$postid] = $post; } return $answers; } /** * Return the full database records for all comments or follow-on questions for question $questionid or its answers * @param $questionid * @return array */ function qa_post_get_question_commentsfollows($questionid) { $commentsfollows = array(); list($childposts, $achildposts) = qa_db_multi_select(array( qa_db_full_child_posts_selectspec(null, $questionid), qa_db_full_a_child_posts_selectspec(null, $questionid), )); foreach ($childposts as $postid => $post) { if ($post['basetype'] == 'C') $commentsfollows[$postid] = $post; } foreach ($achildposts as $postid => $post) { if ($post['basetype'] == 'Q' || $post['basetype'] == 'C') $commentsfollows[$postid] = $post; } return $commentsfollows; } /** * Return the full database record for the post which closed $questionid, if there is any * @param $questionid * @return array|mixed */ function qa_post_get_question_closepost($questionid) { return qa_db_single_select(qa_db_post_close_post_selectspec($questionid)); } /** * Return the full database records for all comments or follow-on questions for answer $answerid * @param $answerid * @return array */ function qa_post_get_answer_commentsfollows($answerid) { $commentsfollows = array(); $childposts = qa_db_single_select(qa_db_full_child_posts_selectspec(null, $answerid)); foreach ($childposts as $postid => $post) { if ($post['basetype'] == 'Q' || $post['basetype'] == 'C') $commentsfollows[$postid] = $post; } return $commentsfollows; } /** * Return $parent if it's the database record for a question, otherwise return the database record for its parent * @param $parent * @return array|mixed */ function qa_post_parent_to_question($parent) { if ($parent['basetype'] == 'Q') $question = $parent; else $question = qa_post_get_full($parent['parentid'], 'Q'); return $question; }