Extension:AtomExporter/en

Details
The AtomExporter extension allows users to export the articles into Atom feeds.

Code
AtomExporter.i18n.php

AtomExporter_body.php ');				$wgOut->addHTML(' ');				$wgOut->addHTML(' ');			}			else									$this->writeXML($since, $until, $page_title);		       }		private function writeXML($since = null, $until = null, $page_title = null)		{					global $wgRequest, $wgOut, $wgParser;			global $wgServer, $wgScript, $wgTitle, $wgSitename, $wgUser;			global $wgLocalTZoffset;			if(!$wgLocalTZoffset)				date_default_timezone_set('UTC');			$wgOut->disable;			wfResetOutputBuffers;			$q_since = $wgRequest->getVal("since");			$q_until = $wgRequest->getVal("until");			$date_format = "YmdHis";			$since = ($q_since) ? date($date_format, strtotime($q_since)) : null;			$until = ($q_until) ? date($date_format, strtotime($q_until)) : date($date_format, time);			$wiki_link = $wgServer.$wgScript.'/'.$wgTitle.'/feed';						if($since)			{				$wiki_link .= "?since=".$q_since;				if($q_until)					$wiki_link .= "&amp;until=".$q_until;			} header( "Content-type: application/xml; charset=utf-8" ); print ''; print "\n"; print ''; print "\n"; print "\t"."".utf8_encode($wiki_link).""; print "\n"; print "\t".' '.utf8_encode($wgSitename).' '; print "\n"; print "\t".' '.$this->getWikiLastTouch.' '; print "\n"; if($page_title) {							print "\t".''; print "\n"; $wiki_link .= "/$page_title"; $dbr = wfGetDB(DB_SLAVE); list($page_tbl) = $dbr->tableNamesN('page'); $page_query = "SELECT * "; $page_query .= "FROM $dbr->addQuotes($page_tbl) "; $page_query .= "WHERE page_is_redirect = 0 AND page_namespace = 0 AND page_title = '$dbr->addQuotes($page_title)' "; $page_query .= "ORDER BY page_title;"; $page_res = $dbr->doQuery($page_query); if ($dbr->numRows($page_res)) {					$art_row = $dbr->fetchRow($page_res); $art_title = Title::newFromID($art_row['page_id']);

$article = new Article($art_title); $article->fetchContent($art_row['page_latest']);

$content = $article->getContent; $dt_upd = new DateTime($article->getTouched); $entry_updated = $dt_upd->format(DATE_RFC3339); $parserOptions = ParserOptions::newFromUser( $wgUser ); $parserOptions->setEditSection( false ); $parserOptions->setTidy(true); $wgParser->mShowToc = false; $parserOutput = $wgParser->parse($article->preSaveTransform($article->getContent)."\n\n", $art_title, $parserOptions ); $bhtml = $parserOutput->getText; $bhtml = $bhtml; $bhtml = str_replace ($wgScriptPath, $wgServer . $wgScriptPath, $bhtml); $bhtml = str_replace ('/w/',$wgServer . '/w/', $bhtml); $content = $bhtml; print "\t".' '; print "\n"; print "\t\t"."".utf8_encode($wiki_link).""; print "\n"; print "\t\t".' '.utf8_encode($page_title).' '; print "\n"; print "\t\t".''; print "\n"; print "\t\t".'getFullURL).'" />'; print "\n"; print "\t\t".' '.$entry_updated.' '; print "\n"; print "\t\t".' '; print "\n"; print "\t\t\t".' '.$article->getUserText.' '; print "\n"; print "\t\t".' '; print "\n"; print "\t\t".' '; print "\n"; print htmlspecialchars($content); print "\n"; print "\t\t".' '; print "\n"; print "\t".' '; print "\n"; print " "; }				else {									wfHttpError(500, "Internal Server Error", "Article not found."); $dbr->freeResult($page_res); }				$dbr->freeResult($page_res); }			else {					print "\t".''; print "\n"; $dbr =& wfGetDB(DB_SLAVE); list($page_tbl) = $dbr->tableNamesN('page'); $all_pages_query = "SELECT * "; $all_pages_query .= "FROM $dbr->addQuotes($page_tbl) "; $all_pages_query .= "WHERE `page_is_redirect` = 0 AND `page_namespace` = 0 "; if($since) $all_pages_query .= "AND `page_touched` between $dbr->addQuotes($since) and $dbr->addQuotes($until) "; $all_pages_query .= "ORDER BY `page_touched`;"; $all_pages_res = $dbr->doQuery($all_pages_query); if ($dbr->numRows($all_pages_res)) {					$last_updated = ""; while ($art_row = $dbr->fetchRow($all_pages_res)) { 						$article = array; $art_title = Title::newFromID($art_row['page_id']); $art_obj = new Article($art_title); $art_obj->fetchContent($art_row['page_latest']); $article["obj"] = $art_obj; $article["row"] = $art_row; $this->articles[] = $article; $entry_title = $art_title->getPrefixedURL; $entry_id   = $wgServer.$wgScript.'/'.$wgTitle.'/feed/'.$entry_title; $dt_upd = new DateTime($art_obj->getTouched); $entry_updated = $dt_upd->format(DATE_RFC3339); print "\t".' '; print "\n"; print "\t\t".''.utf8_encode($entry_id).''; print "\n"; print "\t\t".' '.utf8_encode($entry_title).' '; print "\n"; print "\t\t".''; print "\n"; print "\t\t".' '.$entry_updated.' '; print "\n"; print "\t\t".' '; print "\n"; print "\t\t\t".' '.$art_obj->getUserText.' '; print "\n"; print "\t\t".' '; print "\n"; print "\t".' '; print "\n"; }				}				print " "; $dbr->freeResult($all_pages_res); }           			}		private function getWikiLastTouch {			$dbr = wfGetDB(DB_SLAVE); list($page_tbl) = $dbr->tableNamesN('page'); $timespan_query = "SELECT MAX(page_touched) "; $timespan_query .= "FROM $dbr->addQuotes($page_tbl) "; $timespan_query .= "WHERE page_is_redirect = 0 AND page_namespace = 0;"; $timespan_res = $dbr->doQuery($timespan_query); $row = $dbr->fetchRow($timespan_res); $dt = new DateTime($row['MAX(page_touched)']); $last_updated = $dt->format(DATE_RFC3339); $dbr->freeResult($timespan_res); return $last_updated; } }

?>

AtomExporter.php