From 50a7a69bfefcdca59e1df0a852790316f32a1be5 Mon Sep 17 00:00:00 2001 From: Magnus Manske Date: Sat, 25 Jun 2005 09:16:16 +0000 Subject: [PATCH] Special::Export extension "list all articles since XXX" --- includes/DefaultSettings.php | 4 +++ includes/SpecialExport.php | 55 ++++++++++++++++++++++++++++++++++-- 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 402b7d0e12..0581906bac 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -1540,5 +1540,9 @@ $wgTrustedMediaFormats= array( */ $wgAllowSpecialInclusion = true; +/** + * Allow Special:Export to search/return a list of articles changed since XXX + */ +$wgAllowArticleList = false ; ?> diff --git a/includes/SpecialExport.php b/includes/SpecialExport.php index 1d517ca762..77a0a3ee2d 100644 --- a/includes/SpecialExport.php +++ b/includes/SpecialExport.php @@ -29,9 +29,13 @@ require_once( 'Revision.php' ); * */ function wfSpecialExport( $page = '' ) { - global $wgOut, $wgLang, $wgRequest; + global $wgOut, $wgLang, $wgRequest, $wgAllowArticleList; - if( $wgRequest->getVal( 'action' ) == 'submit') { + if( $wgAllowArticleList AND $wgRequest->getVal( 'action' ) == 'list') { # Return list of articles changed since XXX + $since = $wgRequest->getText( 'since' ) ; + print getListOfChangedArticlesSince ( $since ) ; + exit ( 0 ) ; + } else if( $wgRequest->getVal( 'action' ) == 'submit') { $page = $wgRequest->getText( 'pages' ); $curonly = $wgRequest->getCheck( 'curonly' ); } else { @@ -67,6 +71,53 @@ function wfSpecialExport( $page = '' ) { " ); } +/** + * This function returns a XML list with all article titles and namespaces changed since {$since} + * Using WikiExporter for this seems overkill, as the SQL query is pretty simple +*/ +function getListOfChangedArticlesSince ( $since ) { + if ( TRUE != preg_match ( "/^[0-9]{14,14}$/" , $since ) ) return "INVALID DATE!" ; + + global $wgLang ; + $fname = "getListOfChangedArticlesSince" ; + wfProfileIn( $fname ); + + $ret = "" ; + $dbr =& wfGetDB( DB_SLAVE ); + $sql = "SELECT page_namespace,page_title FROM page WHERE page_touched >= \"{$since}\"" ; + $res = $dbr->query ( $sql , $fname ) ; + + header( "Content-type: application/xml; charset=utf-8" ); + $ret .= "" ; + $ret .= "" ; + + while( $obj = $dbr->fetchObject( $res ) ) { + $t = Title::newFromText ( $obj->page_title , $obj->page_namespace ) ; + $ret .= "
getPrefixedDBkey() ) ; + $ret .= "\" title=\"" ; + $ret .= fixTitle4XML ( $t->getDBkey() ) ; + $ret .= "\" namespace_id=\"" ; + $ret .= $obj->page_namespace ; + $ret .= "\" namespace_name=\"" ; + $ret .= fixTitle4XML ( $wgLang->getNsText ( $obj->page_namespace ) ) ; + $ret .= "\"/>" ; + } + + $ret .= "" ; + $ret .= "" ; + + wfProfileOut( $fname ); + return $ret ; +} + +function fixTitle4XML ( $t ) { + $t = str_replace ( "&" , "&" , $t ) ; + $t = str_replace ( ">" , ">" , $t ) ; + $t = str_replace ( "<" , "<" , $t ) ; + return $t ; +} + define( 'MW_EXPORT_FULL', 0 ); define( 'MW_EXPORT_CURRENT', 1 ); -- 2.20.1