Go to the documentation of this file.
39 parent::__construct(
'MergeHistory',
'mergehistory' );
47 $this->mAction = $request->getVal(
'action' );
48 $this->mTarget = $request->getVal(
'target' );
49 $this->mDest = $request->getVal(
'dest' );
50 $this->mSubmitted = $request->getBool(
'submitted' );
52 $this->mTargetID = intval( $request->getVal(
'targetID' ) );
53 $this->mDestID = intval( $request->getVal(
'destID' ) );
54 $this->mTimestamp = $request->getVal(
'mergepoint' );
55 if ( !preg_match(
'/[0-9]{14}/', $this->mTimestamp ) ) {
56 $this->mTimestamp =
'';
58 $this->mComment = $request->getText(
'wpComment' );
60 $this->mMerge = $request->wasPosted() && $this->
getUser()->matchEditToken( $request->getVal(
'wpEditToken' ) );
62 if ( $this->mSubmitted ) {
66 $this->mTargetObj =
null;
67 $this->mDestObj =
null;
78 if ( !isset( $this->
message ) ) {
79 $this->
message[
'last'] = $this->
msg(
'last' )->escaped();
83 public function execute( $par ) {
92 if ( $this->mTargetID && $this->mDestID && $this->mAction ==
'submit' && $this->mMerge ) {
98 if ( !$this->mSubmitted ) {
105 if ( !$this->mTargetObj instanceof
Title ) {
106 $errors[] = $this->
msg(
'mergehistory-invalid-source' )->parseAsBlock();
107 } elseif ( !$this->mTargetObj->exists() ) {
108 $errors[] = $this->
msg(
'mergehistory-no-source',
array(
'parse' ),
113 if ( !$this->mDestObj instanceof
Title ) {
114 $errors[] = $this->
msg(
'mergehistory-invalid-destination' )->parseAsBlock();
115 } elseif ( !$this->mDestObj->exists() ) {
116 $errors[] = $this->
msg(
'mergehistory-no-destination',
array(
'parse' ),
121 if ( $this->mTargetObj && $this->mDestObj && $this->mTargetObj->equals( $this->mDestObj ) ) {
122 $errors[] = $this->
msg(
'mergehistory-same-destination' )->parseAsBlock();
125 if ( count( $errors ) ) {
127 $this->
getOutput()->addHTML( implode(
"\n", $errors ) );
136 $this->
getOutput()->addWikiMsg(
'mergehistory-header' );
141 'action' => $wgScript ) ) .
144 $this->
msg(
'mergehistory-box' )->
text() ) .
150 <td>' .
Xml::label( $this->
msg(
'mergehistory-from' )->
text(),
'target' ) .
'</td>
151 <td>' .
Xml::input(
'target', 30, $this->mTarget,
array(
'id' =>
'target' ) ) .
'</td>
154 <td>' .
Xml::input(
'dest', 30, $this->mDest,
array(
'id' =>
'dest' ) ) .
'</td>
167 # List all stored revisions
169 $this,
array(), $this->mTargetObj, $this->mDestObj
171 $haveRevisions = $revisions && $revisions->getNumRows() > 0;
175 $action = $titleObj->getLocalURL(
array(
'action' =>
'submit' ) );
176 # Start the form here
185 $out->addHTML( $top );
187 if ( $haveRevisions ) {
188 # Format the user-visible controls (comment field, submission button)
189 # in a nice little table
192 $this->
msg(
'mergehistory-merge', $this->mTargetObj->getPrefixedText(),
193 $this->mDestObj->getPrefixedText() )->parse() .
196 <td class="mw-label">' .
199 <td class="mw-input">' .
200 Xml::input(
'wpComment', 50, $this->mComment,
array(
'id' =>
'wpComment' ) ) .
205 <td class="mw-submit">' .
212 $out->addHTML( $table );
216 '<h2 id="mw-mergehistory">' .
217 $this->
msg(
'mergehistory-list' )->escaped() .
"</h2>\n"
220 if ( $haveRevisions ) {
221 $out->addHTML( $revisions->getNavigationBar() );
222 $out->addHTML(
'<ul>' );
223 $out->addHTML( $revisions->getBody() );
224 $out->addHTML(
'</ul>' );
225 $out->addHTML( $revisions->getNavigationBar() );
227 $out->addWikiMsg(
'mergehistory-empty' );
230 # Show relevant lines from the merge log:
231 $mergeLogPage =
new LogPage(
'merge' );
232 $out->addHTML(
'<h2>' . $mergeLogPage->getName()->escaped() .
"</h2>\n" );
235 # When we submit, go by page ID to avoid some nasty but unlikely collisions.
236 # Such would happen if a page was renamed after the form loaded, but before submit
237 $misc =
Html::hidden(
'targetID', $this->mTargetObj->getArticleID() );
238 $misc .=
Html::hidden(
'destID', $this->mDestObj->getArticleID() );
243 $out->addHTML( $misc );
255 $checkBox =
Xml::radio(
'mergepoint', $ts,
false );
266 $pageLink =
'<span class="history-deleted">' . $pageLink .
'</span>';
272 } elseif ( isset( $this->prevId[$row->rev_id] ) ) {
278 'diff' => $row->rev_id,
279 'oldid' => $this->prevId[$row->rev_id]
286 $size = $row->rev_len;
287 if ( !is_null(
$size ) ) {
293 $this->
msg(
'mergehistory-revisionrow' )->rawParams( $checkBox,
$last, $pageLink, $userLink, $stxt,
$comment )->escaped() );
297 # Get the titles directly from the IDs, in case the target page params
298 # were spoofed. The queries are done based on the IDs, so it's best to
299 # keep it consistent...
302 if ( is_null( $targetTitle ) || is_null( $destTitle ) ) {
305 if ( $targetTitle->getArticleID() == $destTitle->getArticleID() ) {
308 # Verify that this timestamp is valid
309 # Must be older than the destination page
311 # Get timestamp into DB format
312 $this->mTimestamp = $this->mTimestamp ? $dbw->timestamp( $this->mTimestamp ) :
'';
313 # Max timestamp should be min of destination page
314 $maxtimestamp = $dbw->selectField(
316 'MIN(rev_timestamp)',
317 array(
'rev_page' => $this->mDestID ),
320 # Destination page must exist with revisions
321 if ( !$maxtimestamp ) {
322 $this->
getOutput()->addWikiMsg(
'mergehistory-fail' );
326 # Get the latest timestamp of the source
327 $lasttimestamp = $dbw->selectField(
328 array(
'page',
'revision' ),
330 array(
'page_id' => $this->mTargetID,
'page_latest = rev_id' ),
333 # $this->mTimestamp must be older than $maxtimestamp
334 if ( $this->mTimestamp >= $maxtimestamp ) {
335 $this->
getOutput()->addWikiMsg(
'mergehistory-fail' );
339 # Update the revisions
340 if ( $this->mTimestamp ) {
341 $timewhere =
"rev_timestamp <= {$this->mTimestamp}";
344 $timewhere =
"rev_timestamp <= {$maxtimestamp}";
350 array(
'rev_page' => $this->mDestID ),
351 array(
'rev_page' => $this->mTargetID, $timewhere ),
355 $count = $dbw->affectedRows();
356 # Make the source page a redirect if no revisions are left
357 $haveRevisions = $dbw->selectField(
360 array(
'rev_page' => $this->mTargetID ),
362 array(
'FOR UPDATE' )
364 if ( !$haveRevisions ) {
365 if ( $this->mComment ) {
367 'mergehistory-comment',
368 $targetTitle->getPrefixedText(),
369 $destTitle->getPrefixedText(),
371 )->inContentLanguage()->text();
374 'mergehistory-autocomment',
375 $targetTitle->getPrefixedText(),
376 $destTitle->getPrefixedText()
377 )->inContentLanguage()->text();
381 $redirectContent = $contentHandler->makeRedirectContent( $destTitle );
383 if ( $redirectContent ) {
386 'title' => $targetTitle,
387 'page' => $this->mTargetID,
389 'content' => $redirectContent ) );
390 $redirectRevision->insertOn( $dbw );
391 $redirectPage->updateRevisionOn( $dbw, $redirectRevision );
393 # Now, we record the link from the redirect to the new title.
394 # It should have no other outgoing links...
395 $dbw->delete(
'pagelinks',
array(
'pl_from' => $this->mDestID ), __METHOD__ );
396 $dbw->insert(
'pagelinks',
398 'pl_from' => $this->mDestID,
399 'pl_namespace' => $destTitle->getNamespace(),
400 'pl_title' => $destTitle->getDBkey() ),
407 $targetTitle->invalidateCache();
409 $destTitle->invalidateCache();
410 # Check if this did anything
412 $this->
getOutput()->addWikiMsg(
'mergehistory-fail' );
419 'merge', $targetTitle, $this->mComment,
420 array( $destTitle->getPrefixedText(), $timestampLimit ), $this->
getUser()
423 $this->
getOutput()->addWikiMsg(
'mergehistory-success',
424 $targetTitle->getPrefixedText(), $destTitle->getPrefixedText(),
$count );
426 wfRunHooks(
'ArticleMergeComplete',
array( $targetTitle, $destTitle ) );
440 $this->mForm =
$form;
441 $this->mConds = $conds;
443 $this->articleID =
$source->getArticleID();
446 $maxtimestamp =
$dbr->selectField(
448 'MIN(rev_timestamp)',
449 array(
'rev_page' => $dest->getArticleID() ),
452 $this->maxTimestamp = $maxtimestamp;
454 parent::__construct(
$form->getContext() );
459 # Do a link batch query
460 $this->mResult->seek( 0 );
462 # Give some pointers to make (last) links
463 $this->mForm->prevId =
array();
464 foreach ( $this->mResult
as $row ) {
468 $rev_id = isset( $rev_id ) ? $rev_id : $row->rev_id;
469 if ( $rev_id > $row->rev_id ) {
470 $this->mForm->prevId[$rev_id] = $row->rev_id;
471 } elseif ( $rev_id < $row->rev_id ) {
472 $this->mForm->prevId[$row->rev_id] = $rev_id;
475 $rev_id = $row->rev_id;
479 $this->mResult->seek( 0 );
487 return $this->mForm->formatRevisionRow( $row );
492 $conds[
'rev_page'] = $this->articleID;
493 $conds[] =
"rev_timestamp < {$this->maxTimestamp}";
496 'tables' =>
array(
'revision',
'page',
'user' ),
499 'join_conds' =>
array(
506 return 'rev_timestamp';
getPageTitle( $subpage=false)
Get a self-referential title object.
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
static pageJoinCond()
Return the value of a select() page conds array for the page table.
Class representing a list of titles The execute() method checks them all for existence and adds them ...
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
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 $form
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
wfProfileIn( $functionname)
Begin profiling of a function.
checkPermissions()
Checks if userCanExecute, and if not throws a PermissionsError.
static getForTitle(Title $title)
Returns the appropriate ContentHandler singleton for the given title.
static hidden( $name, $value, $attribs=array())
Convenience function to produce an input element with type=hidden.
getLanguage()
Shortcut to get user's language.
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'.
to move a page</td >< td > &*You are moving the page across *A non empty talk page already exists under the new or *You uncheck the box below In those you will have to move or merge the page manually if desired</td >< td > be sure to &You are responsible for making sure that links continue to point where they are supposed to go Note that the page will &a page at the new title
preCacheMessages()
As we use the same small set of messages in various methods and that they are called often,...
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
static revUserTools( $rev, $isPublic=false)
Generate a user tool link cluster if the current user is allowed to view it.
wfProfileOut( $functionname='missing')
Stop profiling of a function.
Class to simplify the use of log pages.
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
wfRunHooks( $event, array $args=array(), $deprecatedVersion=null)
Call hook functions defined in $wgHooks.
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
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
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
static revComment(Revision $rev, $local=false, $isPublic=false)
Wrap and format the given revision's comment block, if the current user is allowed to view it.
msg()
Wrapper around wfMessage that sets the current context.
Parent class for all special pages.
getRequest()
Get the WebRequest being used for this instance.
static newFromURL( $url)
THIS IS NOT THE FUNCTION YOU WANT.
static formatRevisionSize( $size)
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
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
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
Represents a title within MediaWiki.
static closeElement( $element)
Shortcut to close an XML element.
static radio( $name, $value, $checked=false, $attribs=array())
Convenience function to build an HTML radio button.
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 userJoinCond()
Return the value of a select() JOIN conds array for the user table.
if(PHP_SAPI !='cli') $source
static submitButton( $value, $attribs=array())
Convenience function to build an HTML submit button.
static selectUserFields()
Return the list of user fields that should be selected from user table.
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 rawElement( $element, $attribs=array(), $contents='')
Returns an HTML element in a string.
static selectFields()
Return the list of revision fields that should be selected to create a new revision.
static label( $label, $id, $attribs=array())
Convenience function to build an HTML form label.
static newFromID( $id, $flags=0)
Create a new Title from an article ID.
Special page allowing users with the appropriate permissions to merge article histories,...
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 externallinks including delete and has completed for all link tables default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a message
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
static showLogExtract(&$out, $types=array(), $page='', $user='', $param=array())
Show log extract.
execute( $par)
Default execute method Checks user permissions, calls the function given in mFunction.