MediaWiki  1.23.8
WikiImporter Class Reference

XML file reader for the page data importer. More...

Public Member Functions

 __construct ( $source)
 Creates an ImportXMLReader drawing from the source provided. More...
 
 debugRevisionHandler (&$revision)
 Alternate per-revision callback, for debugging. More...
 
 doImport ()
 Primary entry point. More...
 
 finishImportPage ( $title, $origTitle, $revCount, $sRevCount, $pageInfo)
 Mostly for hook use. More...
 
 importLogItem ( $rev)
 Default per-revision callback, performs the import. More...
 
 importRevision ( $revision)
 Default per-revision callback, performs the import. More...
 
 importUpload ( $revision)
 Dummy for now... More...
 
 pageCallback ( $title)
 Notify the callback function when a new "<page>" is reached. More...
 
 setDebug ( $debug)
 Set debug mode... More...
 
 setImageBasePath ( $dir)
 
 setImportUploads ( $import)
 
 setLogItemCallback ( $callback)
 Sets the action to perform as each log item reached. More...
 
 setNoticeCallback ( $callback)
 Set a callback that displays notice messages. More...
 
 setNoUpdates ( $noupdates)
 Set 'no updates' mode. More...
 
 setPageCallback ( $callback)
 Sets the action to perform as each new page in the stream is reached. More...
 
 setPageOutCallback ( $callback)
 Sets the action to perform as each page in the stream is completed. More...
 
 setRevisionCallback ( $callback)
 Sets the action to perform as each page revision is reached. More...
 
 setSiteInfoCallback ( $callback)
 Sets the action to perform when site info is encountered. More...
 
 setTargetNamespace ( $namespace)
 Set a target namespace to override the defaults. More...
 
 setTargetRootPage ( $rootpage)
 Set a target root page under which all pages are imported. More...
 
 setUploadCallback ( $callback)
 Sets the action to perform as each file upload version is reached. More...
 

Public Attributes

 $mDebug
 
 $mImageBasePath
 
 $mPageCallback
 
 $mPageOutCallback
 
 $mRevisionCallback
 
 $mTargetNamespace
 
 $mTargetRootPage
 
 $mUploadCallback
 

Private Member Functions

 debug ( $data)
 
 dumpElement ()
 Left in for debugging. More...
 
 dumpTemp ( $contents)
 
 handleContributor ()
 
 handleLogItem ()
 
 handlePage ()
 
 handleRevision (&$pageInfo)
 
 handleSiteInfo ()
 
 handleUpload (&$pageInfo)
 
 logItemCallback ( $revision)
 Notify the callback function of a new log item. More...
 
 nodeContents ()
 Shouldn't something like this be built-in to XMLReader? Fetches text contents of the current element, assuming no sub-elements or such scary things. More...
 
 notice ( $msg)
 
 pageOutCallback ( $title, $origTitle, $revCount, $sucCount, $pageInfo)
 Notify the callback function when a "</page>" is closed. More...
 
 processLogItem ( $logInfo)
 
 processRevision ( $pageInfo, $revisionInfo)
 
 processTitle ( $text)
 
 processUpload ( $pageInfo, $uploadInfo)
 
 revisionCallback ( $revision)
 Notify the callback function of a revision. More...
 
 throwXmlError ( $err)
 
 warn ( $data)
 

Private Attributes

 $mImportUploads
 
 $mLogItemCallback
 
 $mNoticeCallback
 
 $mNoUpdates = false
 
 $mSiteInfoCallback
 
 $reader = null
 

Detailed Description

XML file reader for the page data importer.

implements Special:Import

Definition at line 33 of file Import.php.

Constructor & Destructor Documentation

◆ __construct()

WikiImporter::__construct (   $source)

Creates an ImportXMLReader drawing from the source provided.

Parameters
$source

Definition at line 45 of file Import.php.

References $source, array(), UploadSourceAdapter\registerSource(), setLogItemCallback(), setPageOutCallback(), setRevisionCallback(), and setUploadCallback().

Member Function Documentation

◆ debug()

WikiImporter::debug (   $data)
private

◆ debugRevisionHandler()

WikiImporter::debugRevisionHandler ( $revision)

Alternate per-revision callback, for debugging.

Parameters
$revisionWikiRevision

Definition at line 317 of file Import.php.

References debug().

◆ doImport()

WikiImporter::doImport ( )

Primary entry point.

Exceptions
MWException
Returns
bool

Definition at line 455 of file Import.php.

References $type, array(), debug(), handleLogItem(), handlePage(), handleSiteInfo(), warn(), and wfRunHooks().

◆ dumpElement()

WikiImporter::dumpElement ( )
private

Left in for debugging.

Definition at line 413 of file Import.php.

References $name, array(), and as.

◆ dumpTemp()

WikiImporter::dumpTemp (   $contents)
private
Parameters
$contents
Returns
string

Definition at line 780 of file Import.php.

References wfTempDir().

Referenced by handleUpload().

◆ finishImportPage()

WikiImporter::finishImportPage (   $title,
  $origTitle,
  $revCount,
  $sRevCount,
  $pageInfo 
)

Mostly for hook use.

Parameters
$title
$origTitle
$revCount
$sRevCount
$pageInfo
Returns

Definition at line 308 of file Import.php.

References $args, and wfRunHooks().

◆ handleContributor()

WikiImporter::handleContributor ( )
private
Returns
array

Definition at line 828 of file Import.php.

References array(), and nodeContents().

Referenced by handleLogItem(), handleRevision(), and handleUpload().

◆ handleLogItem()

WikiImporter::handleLogItem ( )
private

Definition at line 521 of file Import.php.

References array(), debug(), handleContributor(), nodeContents(), processLogItem(), warn(), and wfRunHooks().

Referenced by doImport().

◆ handlePage()

WikiImporter::handlePage ( )
private

◆ handleRevision()

WikiImporter::handleRevision ( $pageInfo)
private
Parameters
$pageInfoarray

Definition at line 639 of file Import.php.

References array(), debug(), handleContributor(), nodeContents(), processRevision(), warn(), and wfRunHooks().

Referenced by handlePage().

◆ handleSiteInfo()

WikiImporter::handleSiteInfo ( )
private
Returns
bool
Exceptions
MWException

Definition at line 511 of file Import.php.

Referenced by doImport().

◆ handleUpload()

WikiImporter::handleUpload ( $pageInfo)
private
Parameters
$pageInfo
Returns
mixed

Definition at line 725 of file Import.php.

References $path, array(), debug(), dumpTemp(), handleContributor(), nodeContents(), processUpload(), warn(), and wfRunHooks().

Referenced by handlePage().

◆ importLogItem()

WikiImporter::importLogItem (   $rev)

Default per-revision callback, performs the import.

Parameters
$revWikiRevision
Returns
bool

Definition at line 284 of file Import.php.

References $rev, array(), DB_MASTER, and wfGetDB().

◆ importRevision()

WikiImporter::importRevision (   $revision)

Default per-revision callback, performs the import.

Parameters
$revisionWikiRevision
Returns
bool

Definition at line 254 of file Import.php.

References array(), DB_MASTER, notice(), and wfGetDB().

◆ importUpload()

WikiImporter::importUpload (   $revision)

Dummy for now...

Parameters
$revision
Returns
bool

Definition at line 294 of file Import.php.

References array(), DB_MASTER, and wfGetDB().

◆ logItemCallback()

WikiImporter::logItemCallback (   $revision)
private

Notify the callback function of a new log item.

Parameters
$revisionWikiRevision object
Returns
bool|mixed

Definition at line 374 of file Import.php.

References array().

Referenced by processLogItem().

◆ nodeContents()

WikiImporter::nodeContents ( )
private

Shouldn't something like this be built-in to XMLReader? Fetches text contents of the current element, assuming no sub-elements or such scary things.

Returns
string
Access:\n private

Definition at line 390 of file Import.php.

Referenced by handleContributor(), handleLogItem(), handlePage(), handleRevision(), and handleUpload().

◆ notice()

WikiImporter::notice (   $msg)
private

Definition at line 78 of file Import.php.

References $params, and wfMessage().

Referenced by importRevision(), and processTitle().

◆ pageCallback()

WikiImporter::pageCallback (   $title)

Notify the callback function when a new "<page>" is reached.

Parameters
$titleTitle

Definition at line 334 of file Import.php.

References $title.

Referenced by handlePage().

◆ pageOutCallback()

WikiImporter::pageOutCallback (   $title,
  $origTitle,
  $revCount,
  $sucCount,
  $pageInfo 
)
private

Notify the callback function when a "</page>" is closed.

Parameters
$titleTitle
$origTitleTitle
$revCountInteger
int$sucCountnumber of revisions for which callback returned true
array$pageInfoassociative array of page information

Definition at line 348 of file Import.php.

References $args.

Referenced by handlePage().

◆ processLogItem()

WikiImporter::processLogItem (   $logInfo)
private
Parameters
$logInfo
Returns
bool|mixed

Definition at line 557 of file Import.php.

References logItemCallback(), Title\newFromText(), and WikiRevision\setID().

Referenced by handleLogItem().

◆ processRevision()

WikiImporter::processRevision (   $pageInfo,
  $revisionInfo 
)
private
Parameters
$pageInfo
$revisionInfo
Returns
bool|mixed

Definition at line 680 of file Import.php.

References revisionCallback(), WikiRevision\setID(), and wfTimestampNow().

Referenced by handleRevision().

◆ processTitle()

WikiImporter::processTitle (   $text)
private
Parameters
$textstring
Returns
Array or false

Definition at line 852 of file Import.php.

References $title, $wgCommandLineMode, array(), global, Title\makeTitleSafe(), Title\newFromText(), and notice().

Referenced by handlePage().

◆ processUpload()

WikiImporter::processUpload (   $pageInfo,
  $uploadInfo 
)
private
Parameters
$pageInfo
$uploadInfo
Returns
mixed

Definition at line 791 of file Import.php.

References WikiRevision\setTitle().

Referenced by handleUpload().

◆ revisionCallback()

WikiImporter::revisionCallback (   $revision)
private

Notify the callback function of a revision.

Parameters
$revisionWikiRevision object
Returns
bool|mixed

Definition at line 360 of file Import.php.

References array().

Referenced by processRevision().

◆ setDebug()

WikiImporter::setDebug (   $debug)

Set debug mode...

Parameters
$debugbool

Definition at line 93 of file Import.php.

References $debug.

◆ setImageBasePath()

WikiImporter::setImageBasePath (   $dir)
Parameters
$dir

Definition at line 238 of file Import.php.

References $dir.

◆ setImportUploads()

WikiImporter::setImportUploads (   $import)
Parameters
$import

Definition at line 245 of file Import.php.

◆ setLogItemCallback()

WikiImporter::setLogItemCallback (   $callback)

Sets the action to perform as each log item reached.

Parameters
$callbackcallback
Returns
callback

Definition at line 168 of file Import.php.

References $mLogItemCallback.

Referenced by __construct().

◆ setNoticeCallback()

WikiImporter::setNoticeCallback (   $callback)

Set a callback that displays notice messages.

Parameters
$callbackcallback
Returns
callback

Definition at line 111 of file Import.php.

References wfSetVar().

◆ setNoUpdates()

WikiImporter::setNoUpdates (   $noupdates)

Set 'no updates' mode.

In this mode, the link tables will not be updated by the importer

Parameters
$noupdatesbool

Definition at line 101 of file Import.php.

◆ setPageCallback()

WikiImporter::setPageCallback (   $callback)

Sets the action to perform as each new page in the stream is reached.

Parameters
$callbackcallback
Returns
callback

Definition at line 120 of file Import.php.

References $mPageCallback.

◆ setPageOutCallback()

WikiImporter::setPageOutCallback (   $callback)

Sets the action to perform as each page in the stream is completed.

Callback accepts the page title (as a Title object), a second object with the original title form (in case it's been overridden into a local namespace), and a count of revisions.

Parameters
$callbackcallback
Returns
callback

Definition at line 135 of file Import.php.

References $mPageOutCallback.

Referenced by __construct().

◆ setRevisionCallback()

WikiImporter::setRevisionCallback (   $callback)

Sets the action to perform as each page revision is reached.

Parameters
$callbackcallback
Returns
callback

Definition at line 146 of file Import.php.

References $mRevisionCallback.

Referenced by __construct().

◆ setSiteInfoCallback()

WikiImporter::setSiteInfoCallback (   $callback)

Sets the action to perform when site info is encountered.

Parameters
$callbackcallback
Returns
callback

Definition at line 179 of file Import.php.

References $mSiteInfoCallback.

◆ setTargetNamespace()

WikiImporter::setTargetNamespace (   $namespace)

Set a target namespace to override the defaults.

Parameters
$namespace
Returns
bool

Definition at line 190 of file Import.php.

Referenced by setTargetRootPage().

◆ setTargetRootPage()

WikiImporter::setTargetRootPage (   $rootpage)

Set a target root page under which all pages are imported.

Parameters
$rootpage
Returns
status object

Definition at line 207 of file Import.php.

References $title, $wgContLang, global, MWNamespace\hasSubpages(), Title\newFromText(), Status\newGood(), NS_MAIN, setTargetNamespace(), and wfMessage().

◆ setUploadCallback()

WikiImporter::setUploadCallback (   $callback)

Sets the action to perform as each file upload version is reached.

Parameters
$callbackcallback
Returns
callback

Definition at line 157 of file Import.php.

References $mUploadCallback.

Referenced by __construct().

◆ throwXmlError()

WikiImporter::throwXmlError (   $err)
private

Definition at line 63 of file Import.php.

References debug(), and wfDebug().

◆ warn()

WikiImporter::warn (   $data)
private

Definition at line 74 of file Import.php.

References wfDebug().

Referenced by doImport(), handleLogItem(), handlePage(), handleRevision(), and handleUpload().

Member Data Documentation

◆ $mDebug

WikiImporter::$mDebug

Definition at line 37 of file Import.php.

◆ $mImageBasePath

WikiImporter::$mImageBasePath

Definition at line 38 of file Import.php.

◆ $mImportUploads

WikiImporter::$mImportUploads
private

Definition at line 38 of file Import.php.

◆ $mLogItemCallback

WikiImporter::$mLogItemCallback
private

Definition at line 35 of file Import.php.

Referenced by setLogItemCallback().

◆ $mNoticeCallback

WikiImporter::$mNoticeCallback
private

Definition at line 37 of file Import.php.

◆ $mNoUpdates

WikiImporter::$mNoUpdates = false
private

Definition at line 39 of file Import.php.

◆ $mPageCallback

WikiImporter::$mPageCallback

Definition at line 35 of file Import.php.

Referenced by setPageCallback().

◆ $mPageOutCallback

WikiImporter::$mPageOutCallback

Definition at line 36 of file Import.php.

Referenced by setPageOutCallback().

◆ $mRevisionCallback

WikiImporter::$mRevisionCallback

Definition at line 35 of file Import.php.

Referenced by setRevisionCallback().

◆ $mSiteInfoCallback

WikiImporter::$mSiteInfoCallback
private

Definition at line 36 of file Import.php.

Referenced by setSiteInfoCallback().

◆ $mTargetNamespace

WikiImporter::$mTargetNamespace

Definition at line 36 of file Import.php.

◆ $mTargetRootPage

WikiImporter::$mTargetRootPage

Definition at line 36 of file Import.php.

◆ $mUploadCallback

WikiImporter::$mUploadCallback

Definition at line 35 of file Import.php.

Referenced by setUploadCallback().

◆ $reader

WikiImporter::$reader = null
private

Definition at line 34 of file Import.php.


The documentation for this class was generated from the following file: