$query); $questions = array(); foreach ($results as $result) { $setarray = array( 'title' => $result['title'], 'url' => $result['url'], ); if (isset($result['question'])) $questions[] = array_merge($result['question'], $setarray); elseif (isset($result['url'])) $questions[] = $setarray; } break; } // Remove duplicate questions (perhaps referenced in an answer and a comment) and cut down to size require_once QA_INCLUDE_DIR . 'app/format.php'; require_once QA_INCLUDE_DIR . 'app/updates.php'; require_once QA_INCLUDE_DIR . 'app/posts.php'; require_once QA_INCLUDE_DIR . 'util/string.php'; if ($feedtype != 'search' && $feedtype != 'hot') // leave search results and hot questions sorted by relevance $questions = qa_any_sort_and_dedupe($questions); $questions = array_slice($questions, 0, $count); $blockwordspreg = qa_get_block_words_preg(); // Prepare the XML output $lines = array(); $lines[] = ''; $lines[] = ''; $lines[] = ''; $lines[] = '' . qa_xml($sitetitle . ' - ' . $title) . ''; $lines[] = '' . qa_xml(qa_path($linkrequest, $linkparams, $siteurl)) . ''; $lines[] = 'Powered by Question2Answer'; foreach ($questions as $question) { // Determine whether this is a question, answer or comment, and act accordingly $options = array('blockwordspreg' => @$blockwordspreg, 'showurllinks' => $showurllinks); $time = null; $htmlcontent = null; if (isset($question['opostid'])) { $time = $question['otime']; if ($full) $htmlcontent = qa_viewer_html($question['ocontent'], $question['oformat'], $options); } elseif (isset($question['postid'])) { $time = $question['created']; if ($full) $htmlcontent = qa_viewer_html($question['content'], $question['format'], $options); } if ($feedtype == 'search') { $titleprefix = ''; $urlxml = qa_xml($question['url']); } else { switch (@$question['obasetype'] . '-' . @$question['oupdatetype']) { case 'Q-': case '-': $langstring = null; break; case 'Q-' . QA_UPDATE_VISIBLE: $langstring = $question['hidden'] ? 'misc/feed_hidden_prefix' : 'misc/feed_reshown_prefix'; break; case 'Q-' . QA_UPDATE_CLOSED: $langstring = qa_post_is_closed($question) ? 'misc/feed_closed_prefix' : 'misc/feed_reopened_prefix'; break; case 'Q-' . QA_UPDATE_TAGS: $langstring = 'misc/feed_retagged_prefix'; break; case 'Q-' . QA_UPDATE_CATEGORY: $langstring = 'misc/feed_recategorized_prefix'; break; case 'A-': $langstring = 'misc/feed_a_prefix'; break; case 'A-' . QA_UPDATE_SELECTED: $langstring = 'misc/feed_a_selected_prefix'; break; case 'A-' . QA_UPDATE_VISIBLE: $langstring = $question['ohidden'] ? 'misc/feed_hidden_prefix' : 'misc/feed_a_reshown_prefix'; break; case 'A-' . QA_UPDATE_CONTENT: $langstring = 'misc/feed_a_edited_prefix'; break; case 'C-': $langstring = 'misc/feed_c_prefix'; break; case 'C-' . QA_UPDATE_TYPE: $langstring = 'misc/feed_c_moved_prefix'; break; case 'C-' . QA_UPDATE_VISIBLE: $langstring = $question['ohidden'] ? 'misc/feed_hidden_prefix' : 'misc/feed_c_reshown_prefix'; break; case 'C-' . QA_UPDATE_CONTENT: $langstring = 'misc/feed_c_edited_prefix'; break; case 'Q-' . QA_UPDATE_CONTENT: default: $langstring = 'misc/feed_edited_prefix'; break; } $titleprefix = isset($langstring) ? qa_lang($langstring) : ''; $urlxml = qa_xml(qa_q_path($question['postid'], $question['title'], true, @$question['obasetype'], @$question['opostid'])); } if (isset($blockwordspreg)) $question['title'] = qa_block_words_replace($question['title'], $blockwordspreg); // Build the inner XML structure for each item $lines[] = ''; $lines[] = '' . qa_xml($titleprefix . $question['title']) . ''; $lines[] = '' . $urlxml . ''; if (isset($htmlcontent)) $lines[] = '' . qa_xml($htmlcontent) . ''; if (isset($question['categoryname'])) $lines[] = '' . qa_xml($question['categoryname']) . ''; $lines[] = '' . $urlxml . ''; if (isset($time)) $lines[] = '' . qa_xml(gmdate('r', $time)) . ''; $lines[] = ''; } $lines[] = ''; $lines[] = ''; // Disconnect here, once all output is ready to go qa_db_disconnect(); // Output the XML - and we're done! header('Content-type: text/xml; charset=utf-8'); echo implode("\n", $lines);