$wgScriptPath = "/wiki";
-# ATTN: Old installations used wiki.phtml and redirect.phtml -
# Whether to support URLs like index.php/Page_title
$wgUsePathInfo = ( strpos( php_sapi_name(), "cgi" ) === false );
+# ATTN: Old installations used wiki.phtml and redirect.phtml -
# make sure that LocalSettings.php is correctly set!
$wgScript = "{$wgScriptPath}/index.php";
$wgRedirectScript = "{$wgScriptPath}/redirect.php";
$wgUseImageMagick = false;
$wgImageMagickConvertCommand = "/usr/bin/convert";
-# Enable experimental smarty skins (put Smarty/libs in your include_path!)
-$wgUseSmarty = false;
-$wgUsePHPTal = false;
+# Make sure include_path is set correctly
+$wgUsePHPTal = true;
if( !isset( $wgCommandLineMode ) ) {
$wgCommandLineMode = false;
# RDF metadata toggles
-
$wgEnableDublinCoreRdf = false;
$wgEnableCreativeCommonsRdf = false;
# Override for copyright metadata.
-
$wgRightsPage = NULL;
$wgRightsUrl = NULL;
$wgRightsText = NULL;
+$wgRightsIcon = NULL;
# Set this to false to avoid forcing the first letter of links
# to capitals. WARNING: may break links! This makes links
# as links in the middle of a sentence using a lowercase initial.
$wgCapitalLinks = true;
+# List of interwiki prefixes for wikis we'll accept as sources
+# for Special:Import (for sysops). Since complete page history
+# can be imported, these should be 'trusted'.
+$wgImportSources = array();
+
?>
function wfSpecialImport( $page = "" ) {
global $wgOut, $wgLang, $wgRequest, $wgTitle;
+ global $wgImportSources;
if( $wgRequest->wasPosted() && $wgRequest->getVal( 'action' ) == 'submit') {
$importer = new WikiImporter();
- if( $importer->setupFromUpload( "xmlimport" ) ) {
+
+ switch( $wgRequest->getVal( "source" ) ) {
+ case "upload":
+ $ok = $importer->setupFromUpload( "xmlimport" );
+ break;
+ case "interwiki":
+ $ok = $importer->setupFromInterwiki(
+ $wgRequest->getVal( "interwiki" ),
+ $wgRequest->getText( "frompage" ) );
+ break;
+ default:
+ $ok = false;
+ }
+
+ if( $ok ) {
$importer->setRevisionHandler( "wfImportOldRevision" );
if( $importer->doImport() ) {
# Success!
$wgOut->addWikiText( "<p>" . wfMsg( "importtext" ) . "</p>" );
$action = $wgTitle->escapeLocalUrl();
$wgOut->addHTML( "
-<form enctype='multipart/form-data' method='post' action=\"$action\">
- <input type='hidden' name='action' value='submit' />
- <input type='hidden' name='MAX_FILE_SIZE' value='200000' />
- <input type='file' name='xmlimport' value='' size='40' /><br />
- <input type='submit' value='" . htmlspecialchars( wfMsg( "uploadbtn" ) ) . "'/>
-</form>
+<fieldset>
+ <legend>Upload XML</legend>
+ <form enctype='multipart/form-data' method='post' action=\"$action\">
+ <input type='hidden' name='action' value='submit' />
+ <input type='hidden' name='source' value='upload' />
+ <input type='hidden' name='MAX_FILE_SIZE' value='200000' />
+ <input type='file' name='xmlimport' value='' size='30' />
+ <input type='submit' value='" . htmlspecialchars( wfMsg( "uploadbtn" ) ) . "'/>
+ </form>
+</fieldset>
" );
+
+ if( !empty( $wgImportSources ) ) {
+ $wgOut->addHTML( "
+<fieldset>
+ <legend>Interwiki import</legend>
+ <form method='post' action=\"$action\">
+ <input type='hidden' name='action' value='submit' />
+ <input type='hidden' name='source' value='interwiki' />
+ <select name='interwiki'>
+" );
+ foreach( $wgImportSources as $interwiki ) {
+ $iw = htmlspecialchars( $interwiki );
+ $wgOut->addHTML( "<option value=\"$iw\">$iw</option>\n" );
+ }
+ $wgOut->addHTML( "
+ </select>
+ <input name='frompage' />
+ <input type='submit' />
+ </form>
+</fieldset>
+" );
+ }
}
-function wfImportOldRevision( $revision ) {
+function wfImportOldRevision( &$revision ) {
global $wgOut;
$fname = "wfImportOldRevision";
# Make sure it doesn't already exist
$sql = "SELECT 1 FROM old WHERE old_namespace=$ns AND old_title='$t' AND old_timestamp='$ts'";
- $wgOut->addHtml( htmlspecialchars( $sql ) . "<br />\n" );
-
$res = wfQuery( $sql, DB_WRITE, $fname );
$numrows = wfNumRows( $res );
wfFreeResult( $res );
if( $numrows > 0 ) {
- $wgOut->addHTML( "DIE<br />" );
- return false;
+ return wfMsg( "importhistoryconflict" );
}
$res = wfQuery( "INSERT INTO old " .
"old_timestamp,inverse_timestamp,old_minor_edit,old_flags) " .
"VALUES ($ns,'$t','$text','$comment',$user_id,'$user_text','$ts','$its',$minor,'$flags')",
DB_WRITE, $fname );
- $wgOut->addHTML( "OK<br />" );
- return true;
+ return wfMsg( "ok" );
}
class WikiRevision {
}
function setupFromURL( $url ) {
- # FIXME
- wfDebugDieBacktrace( "Not yet implemented." );
+ # fopen-wrappers are normally turned off for security.
+ ini_set( "allow_url_fopen", true );
+ $ret = $this->setupFromFile( $url );
+ ini_set( "allow_url_fopen", false );
+ return $ret;
}
+ function setupFromInterwiki( $interwiki, $page ) {
+ $base = Title::getInterwikiLink( $interwiki );
+ if( empty( $base ) ) {
+ return false;
+ } else {
+ $import = wfUrlencode( "Special:Export/$page" );
+ $url = str_replace( "$1", $import, $base );
+ $this->notice( "Importing from $url" );
+ return $this->setupFromURL( $url );
+ }
+ }
+
+ # --------------
+
function doImport() {
if( empty( $this->mSource ) ) {
return $this->setError( wfMsg( "importnotext" ) );
function debug( $data ) {
global $wgOut;
- # $wgOut->addHTML( htmlspecialchars( $data ) . "<br />\n" );
+ # $this->notice( "DEBUG: $data\n" );
+ }
+
+ function notice( $data ) {
+ global $wgCommandLineMode;
+ if( $wgCommandLineMode ) {
+ print "$data\n";
+ } else {
+ global $wgOut;
+ $wgOut->addHTML( "<li>$data</li>\n" );
+ }
}
function setRevisionHandler( $functionref ) {
$this->mRevisionHandler = $functionref;
}
- function defaultRevisionHandler( $revision ) {
+ function defaultRevisionHandler( &$revision ) {
$this->debug( "Got revision:" );
if( is_object( $revision->title ) ) {
$this->debug( "-- Title: " . $revision->title->getPrefixedText() );
return $this->throwXMLerror( "Element <$name> not allowed in a <revision>." );
}
}
+
function out_revision( $parser, $name ) {
$this->debug( "out_revision $name" );
if( $name != "revision" ) {
}
xml_set_element_handler( $parser, "in_page", "out_page" );
- call_user_func( $this->mRevisionHandler, $this->workRevision );
+ $out = call_user_func( $this->mRevisionHandler, &$this->workRevision, &$this );
+ if( !empty( $out ) ) {
+ global $wgOut;
+ $wgOut->addHTML( "<li>" . $out . "</li>\n" );
+ }
}
function in_contributor( $parser, $name, $attribs ) {