Go to the documentation of this file.
46 parent::__construct(
'Import',
'import' );
47 global $wgImportTargetNamespace;
48 $this->
namespace = $wgImportTargetNamespace;
59 if ( !
$user->isAllowedAny(
'import',
'importupload' ) ) {
63 # @todo Allow Title::getUserPermissionsErrors() to take an array
64 # @todo FIXME: Title::checkSpecialsAndNSPermissions() has a very wierd expectation of what
65 # getUserPermissionsErrors() might actually be used for, hence the 'ns-specialprotected'
68 'import',
$user,
true,
69 array(
'ns-specialprotected',
'badaccess-group0',
'badaccess-groups' )
72 'importupload',
$user,
true,
73 array(
'ns-specialprotected',
'badaccess-group0',
'badaccess-groups' )
94 global $wgImportSources, $wgExportMaxLinkDepth;
98 $this->
namespace =
$request->getIntOrNull( 'namespace' );
99 $sourceName =
$request->getVal(
"source" );
101 $this->logcomment =
$request->getText(
'log-comment' );
102 $this->pageLinkDepth = $wgExportMaxLinkDepth == 0 ? 0 :
$request->getIntOrNull(
'pagelink-depth' );
103 $this->rootpage =
$request->getText(
'rootpage' );
106 if ( !
$user->matchEditToken(
$request->getVal(
'editToken' ) ) ) {
108 } elseif ( $sourceName ==
'upload' ) {
110 if (
$user->isAllowed(
'importupload' ) ) {
115 } elseif ( $sourceName ==
"interwiki" ) {
116 if ( !
$user->isAllowed(
'import' ) ) {
119 $this->interwiki =
$request->getVal(
'interwiki' );
120 if ( !in_array( $this->interwiki, $wgImportSources ) ) {
123 $this->history =
$request->getCheck(
'interwikiHistory' );
124 $this->frompage =
$request->getText(
"frompage" );
125 $this->includeTemplates =
$request->getCheck(
'interwikiTemplates' );
130 $this->includeTemplates,
131 $this->pageLinkDepth );
140 "<p class=\"error\">\n$1\n</p>",
145 if ( !is_null( $this->
namespace ) ) {
146 $importer->setTargetNamespace( $this->
namespace );
148 if ( !is_null( $this->rootpage ) ) {
149 $statusRootPage = $importer->setTargetRootPage( $this->rootpage );
150 if ( !$statusRootPage->isGood() ) {
152 "<p class=\"error\">\n$1\n</p>",
154 'import-options-wrong',
155 $statusRootPage->getWikiText(),
156 count( $statusRootPage->getErrorsArray() )
164 $out->addWikiMsg(
"importstart" );
177 $importer->doImport();
184 # No source or XML parse error
186 "<p class=\"error\">\n$1\n</p>",
187 array(
'importfailed', $exception->getMessage() )
189 } elseif ( !
$result->isGood() ) {
192 "<p class=\"error\">\n$1\n</p>",
197 $out->addWikiMsg(
'importsuccess' );
199 $out->addHTML(
'<hr />' );
204 global $wgImportSources, $wgExportMaxLinkDepth;
210 if (
$user->isAllowed(
'importupload' ) ) {
216 'enctype' =>
'multipart/form-data',
219 'id' =>
'mw-import-upload-form'
222 $this->
msg(
'importtext' )->parseAsBlock() .
227 <td class='mw-label'>" .
230 <td class='mw-input'>" .
231 Html::input(
'xmlimport',
'',
'file',
array(
'id' =>
'xmlimport' ) ) .
' ' .
235 <td class='mw-label'>" .
238 <td class='mw-input'>" .
240 array(
'id' =>
'mw-import-comment',
'type' =>
'text' ) ) .
' ' .
244 <td class='mw-label'>" .
245 Xml::label( $this->
msg(
'import-interwiki-rootpage' )->
text(),
'mw-interwiki-rootpage-upload' ) .
247 <td class='mw-input'>" .
249 array(
'id' =>
'mw-interwiki-rootpage-upload',
'type' =>
'text' ) ) .
' ' .
254 <td class='mw-submit'>" .
264 if ( empty( $wgImportSources ) ) {
265 $out->addWikiMsg(
'importnosources' );
269 if (
$user->isAllowed(
'import' ) && !empty( $wgImportSources ) ) {
270 # Show input field for import depth only if $wgExportMaxLinkDepth > 0
272 if ( $wgExportMaxLinkDepth > 0 ) {
274 <td class='mw-label'>" .
275 $this->
msg(
'export-pagelinks' )->parse() .
277 <td class='mw-input'>" .
290 'id' =>
'mw-import-interwiki-form'
293 $this->
msg(
'import-interwiki-text' )->parseAsBlock() .
299 <td class='mw-label'>" .
300 Xml::label( $this->
msg(
'import-interwiki-source' )->text(),
'interwiki' ) .
302 <td class='mw-input'>" .
305 array(
'name' =>
'interwiki',
'id' =>
'interwiki' )
309 foreach ( $wgImportSources
as $prefix ) {
310 $selected = ( $this->interwiki === $prefix ) ?
' selected="selected"' :
'';
316 Xml::input(
'frompage', 50, $this->frompage,
array(
'id' =>
'frompage' ) ) .
322 <td class='mw-input'>" .
324 $this->
msg(
'import-interwiki-history' )->
text(),
334 <td class='mw-input'>" .
336 $this->
msg(
'import-interwiki-templates' )->
text(),
337 'interwikiTemplates',
338 'interwikiTemplates',
339 $this->includeTemplates
345 <td class='mw-label'>" .
348 <td class='mw-input'>" .
351 'selected' => $this->
namespace,
354 'name' =>
'namespace',
356 'class' =>
'namespaceselector',
362 <td class='mw-label'>" .
365 <td class='mw-input'>" .
367 array(
'id' =>
'mw-interwiki-comment',
'type' =>
'text' ) ) .
' ' .
371 <td class='mw-label'>" .
373 $this->
msg(
'import-interwiki-rootpage' )->
text(),
374 'mw-interwiki-rootpage-interwiki'
377 <td class='mw-input'>" .
379 array(
'id' =>
'mw-interwiki-rootpage-interwiki',
'type' =>
'text' ) ) .
' ' .
385 <td class='mw-submit'>" .
387 $this->
msg(
'import-interwiki-submit' )->
text(),
421 $this->mOriginalPageOutCallback =
422 $importer->setPageOutCallback(
array( $this,
'reportPage' ) );
423 $this->mOriginalLogCallback =
424 $importer->setLogItemCallback(
array( $this,
'reportLogItem' ) );
425 $importer->setNoticeCallback(
array( $this,
'reportNotice' ) );
426 $this->mPageCount = 0;
428 $this->mInterwiki = $interwiki;
441 $this->mLogItemCount++;
442 if ( is_callable( $this->mOriginalLogCallback ) ) {
443 call_user_func_array( $this->mOriginalLogCallback, func_get_args() );
456 $args = func_get_args();
457 call_user_func_array( $this->mOriginalPageOutCallback,
$args );
460 # Invalid or non-importable title; a notice is already displayed
466 if ( $successCount > 0 ) {
469 $this->
msg(
'import-revision-count' )->numParams( $successCount )->escaped() .
473 $log =
new LogPage(
'import' );
474 if ( $this->mIsUpload ) {
475 $detail = $this->
msg(
'import-logentry-upload-detail' )->numParams(
476 $successCount )->inContentLanguage()->text();
477 if ( $this->reason ) {
478 $detail .= $this->
msg(
'colon-separator' )->inContentLanguage()->text() .
$this->reason;
482 $interwiki =
'[[:' . $this->mInterwiki .
':' .
483 $origTitle->getPrefixedText() .
']]';
484 $detail = $this->
msg(
'import-logentry-interwiki-detail' )->numParams(
485 $successCount )->params( $interwiki )->inContentLanguage()->text();
486 if ( $this->reason ) {
487 $detail .= $this->
msg(
'colon-separator' )->inContentLanguage()->text() .
$this->reason;
494 $latest =
$title->getLatestRevID();
496 if ( !is_null( $nullRevision ) ) {
497 $nullRevision->insertOn( $dbw );
500 $page->updateRevisionOn( $dbw, $nullRevision );
505 $this->
msg(
'import-nonewrevisions' )->escaped() .
"</li>\n" );
511 if ( $this->mLogItemCount > 0 ) {
512 $msg = $this->
msg(
'imported-log-entries' )->numParams( $this->mLogItemCount )->parse();
514 } elseif ( $this->mPageCount == 0 && $this->mLogItemCount == 0 ) {
515 $out->addHTML(
"</ul>\n" );
519 $out->addHTML(
"</ul>\n" );
static checkLabel( $label, $name, $id, $checked=false, $attribs=array())
Convenience function to build an HTML checkbox with a label.
MediaWiki page data importer.
getPageTitle( $subpage=false)
Get a self-referential title object.
XML file reader for the page data importer.
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. $reader:XMLReader object $logInfo:Array of information Return false to stop further processing of the tag 'ImportHandlePageXMLTag':When parsing a XML tag in a page. $reader:XMLReader object $pageInfo:Array of information Return false to stop further processing of the tag 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information Return false to stop further processing of the tag 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. $reader:XMLReader object Return false to stop further processing of the tag 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. $reader:XMLReader object $revisionInfo:Array of information Return false to stop further processing of the tag 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. $title:Title object for the current page $request:WebRequest $ignoreRedirect:boolean to skip redirect check $target:Title/string of redirect target $article:Article object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) $article:article(object) being checked 'IsTrustedProxy':Override the result of wfIsTrustedProxy() $ip:IP being check $result:Change this value to override the result of wfIsTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of User::isValidEmailAddr(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetMagic':DEPRECATED, use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetSpecialPageAliases':DEPRECATED, use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Associative array mapping language codes to prefixed links of the form "language:title". & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LinkBegin':Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
reportPage( $title, $origTitle, $revisionCount, $successCount, $pageInfo)
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled also a ContextSource error or success you ll probably need to make sure the header is varied on WebRequest $request
wfMergeErrorArrays()
Merge arrays in the style of getUserPermissionsErrors, with duplicate removal e.g.
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
msg()
Get a Message object with context set Parameters are the same as wfMessage()
static newNullRevision( $dbw, $pageId, $summary, $minor)
Create a new null-revision for insertion into a page's history.
static tags( $element, $attribs=null, $contents)
Same as Xml::element(), but does not escape contents.
getOutput()
Get the OutputPage being used for this instance.
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
$mOriginalPageOutCallback
static option( $text, $value=null, $selected=false, $attribs=array())
Convenience function to build an HTML drop-down list item.
static newGood( $value=null)
Factory function for good results.
static hidden( $name, $value, $attribs=array())
Convenience function to produce an input element with type=hidden.
Show an error when a user tries to do something they do not have the necessary permissions for.
getUser()
Get the User object.
static openElement( $element, $attribs=null)
This opens an XML element.
static linkKnown( $target, $html=null, $customAttribs=array(), $query=array(), $options=array( 'known', 'noclasses'))
Identical to link(), except $options defaults to 'known'.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
static tooltipAndAccesskeyAttribs( $name)
Returns the attributes for the tooltip and access key.
doImport()
Do the actual import.
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
static element( $element, $attribs=array(), $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
getOutput()
Get the OutputPage object.
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
Class to simplify the use of log pages.
wfRunHooks( $event, array $args=array(), $deprecatedVersion=null)
Call hook functions defined in $wgHooks.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
__construct( $importer, $upload, $interwiki, $reason=false)
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getUser()
Shortcut to get the User executing this instance.
when a variable name is used in a it is silently declared as a new masking the global
static input( $name, $value='', $type='text', $attribs=array())
Convenience function to produce an "<input>" element.
getContext()
Gets the context this SpecialPage is executed in.
static newFromInterwiki( $interwiki, $page, $history=false, $templates=false, $pageLinkDepth=0)
presenting them properly to the user as errors is done by the caller $title
reportNotice( $msg, array $params)
msg()
Wrapper around wfMessage that sets the current context.
Parent class for all special pages.
getRequest()
Get the WebRequest being used for this instance.
usually copyright or history_copyright This message must be in HTML not wikitext $subpages will be ignored and the rest of subPageSubtitle() will run. 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink' whether MediaWiki currently thinks this is a CSS JS page Hooks may change this value to override the return value of Title::isCssOrJsPage(). 'TitleIsAlwaysKnown' whether MediaWiki currently thinks this page is known isMovable() always returns false. $title whether MediaWiki currently thinks this page is movable Hooks may change this value to override the return value of Title::isMovable(). 'TitleIsWikitextPage' whether MediaWiki currently thinks this is a wikitext page Hooks may change this value to override the return value of Title::isWikitextPage() 'TitleMove' use UploadVerification and UploadVerifyFile instead where the first element is the message key and the remaining elements are used as parameters to the message based on mime etc Preferred in most cases over UploadVerification object $upload
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
static closeElement( $element)
Shortcut to close an XML element.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
static namespaceSelector(array $params=array(), array $selectAttribs=array())
Build a drop-down box for selecting a namespace.
__construct()
Constructor.
if(PHP_SAPI !='cli') $source
static submitButton( $value, $attribs=array())
Convenience function to build an HTML submit button.
checkReadOnly()
If the wiki is currently in readonly mode, throws a ReadOnlyError.
static input( $name, $size=false, $value=false, $attribs=array())
Convenience function to build an HTML text input field.
static label( $label, $id, $attribs=array())
Convenience function to build an HTML form label.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
static fieldset( $legend=false, $content=false, $attribs=array())
Shortcut for creating fieldsets.
static newFromUpload( $fieldname="xmlimport")
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
static newFatal( $message)
Factory function for fatal errors.