41 $this->mOriginalPageOutCallback =
42 $importer->setPageOutCallback( [ $this,
'reportPage' ] );
43 $this->mOriginalLogCallback =
44 $importer->setLogItemCallback( [ $this,
'reportLogItem' ] );
45 $importer->setNoticeCallback( [ $this,
'reportNotice' ] );
46 $this->mPageCount = 0;
47 $this->mIsUpload = $upload;
48 $this->mInterwiki = $interwiki;
59 $this->logTags = $tags;
73 $this->mLogItemCount++;
74 if ( is_callable( $this->mOriginalLogCallback ) ) {
75 call_user_func_array( $this->mOriginalLogCallback, func_get_args() );
87 public function reportPage( $title, $foreignTitle, $revisionCount,
88 $successCount, $pageInfo ) {
89 $args = func_get_args();
90 call_user_func_array( $this->mOriginalPageOutCallback,
$args );
93 # Invalid or non-importable title; a notice is already displayed
98 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
99 if ( $successCount > 0 ) {
105 $this->msg(
'import-revision-count' )->numParams( $successCount )->escaped() .
110 $logParams = [
'4:number:count' => $successCount ];
111 if ( $this->mIsUpload ) {
112 $detail = $this->
msg(
'import-logentry-upload-detail' )->numParams(
113 $successCount )->inContentLanguage()->text();
116 $pageTitle = $foreignTitle->getFullText();
117 $fullInterwikiPrefix = $this->mInterwiki;
118 Hooks::run(
'ImportLogInterwikiLink', [ &$fullInterwikiPrefix, &$pageTitle ] );
120 $interwikiTitleStr = $fullInterwikiPrefix .
':' . $pageTitle;
121 $interwiki =
'[[:' . $interwikiTitleStr .
']]';
122 $detail = $this->
msg(
'import-logentry-interwiki-detail' )->numParams(
123 $successCount )->params( $interwiki )->inContentLanguage()->text();
124 $action =
'interwiki';
125 $logParams[
'5:title-link:interwiki'] = $interwikiTitleStr;
127 if ( $this->reason ) {
128 $detail .= $this->
msg(
'colon-separator' )->inContentLanguage()->text()
134 $latest =
$title->getLatestRevID();
144 if ( !is_null( $nullRevision ) ) {
145 $nullRevId = $nullRevision->insertOn( $dbw );
148 $page->updateRevisionOn( $dbw, $nullRevision );
150 'NewRevisionFromEditComplete',
151 [ $page, $nullRevision, $latest, $this->
getUser() ]
157 $logEntry->setTarget(
$title );
158 $logEntry->setComment( $this->reason );
159 $logEntry->setPerformer( $this->
getUser() );
160 $logEntry->setParameters( $logParams );
161 $logid = $logEntry->insert();
162 if ( count( $this->logTags ) ) {
163 $logEntry->setTags( $this->logTags );
166 $logEntry->setAssociatedRevId( $nullRevId );
168 $logEntry->publish( $logid );
172 $this->msg(
'import-nonewrevisions' )->escaped() .
"</li>\n" );
178 if ( $this->mLogItemCount > 0 ) {
179 $msg = $this->
msg(
'imported-log-entries' )->numParams( $this->mLogItemCount )->parse();
180 $out->addHTML( Xml::tags(
'li',
null, $msg ) );
181 } elseif ( $this->mPageCount == 0 && $this->mLogItemCount == 0 ) {
182 $out->addHTML(
"</ul>\n" );
184 return Status::newFatal(
'importnopages' );
186 $out->addHTML(
"</ul>\n" );
188 return Status::newGood( $this->mPageCount );
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
msg( $key)
Get a Message object with context set Parameters are the same as wfMessage()
getUser()
Get the User object.
getOutput()
Get the OutputPage object.
reportNotice( $msg, array $params)
$mOriginalPageOutCallback
reportPage( $title, $foreignTitle, $revisionCount, $successCount, $pageInfo)
__construct( $importer, $upload, $interwiki, $reason=false)
setChangeTags(array $tags)
Sets change tags to apply to the import log entry and null revision.
Class for creating log entries manually, to inject them into the database.
static newNullRevision( $dbw, $pageId, $summary, $minor, $user=null)
Create a new null-revision for insertion into a page's history.
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
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
the array() calling protocol came about after MediaWiki 1.4rc1.
namespace and then decline to actually register it file or subcat img or subcat $title
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
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 an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing after in associative array form before processing starts Return false to skip default processing and return $ret $linkRenderer
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php