68 parent::__construct(
'MergeHistory',
'mergehistory' );
80 $this->mAction =
$request->getVal(
'action' );
81 $this->mTarget =
$request->getVal(
'target' );
82 $this->mDest =
$request->getVal(
'dest' );
83 $this->mSubmitted =
$request->getBool(
'submitted' );
85 $this->mTargetID = intval(
$request->getVal(
'targetID' ) );
86 $this->mDestID = intval(
$request->getVal(
'destID' ) );
87 $this->mTimestamp =
$request->getVal(
'mergepoint' );
88 if ( !preg_match(
'/[0-9]{14}/', $this->mTimestamp ) ) {
89 $this->mTimestamp =
'';
91 $this->mComment =
$request->getText(
'wpComment' );
93 $this->mMerge =
$request->wasPosted()
94 && $this->
getUser()->matchEditToken(
$request->getVal(
'wpEditToken' ) );
97 if ( $this->mSubmitted ) {
101 $this->mTargetObj = null;
102 $this->mDestObj = null;
117 if ( $this->mTargetID && $this->mDestID && $this->mAction ==
'submit' && $this->mMerge ) {
123 if ( !$this->mSubmitted ) {
130 if ( !$this->mTargetObj instanceof
Title ) {
131 $errors[] = $this->
msg(
'mergehistory-invalid-source' )->parseAsBlock();
132 } elseif ( !$this->mTargetObj->exists() ) {
133 $errors[] = $this->
msg(
'mergehistory-no-source',
138 if ( !$this->mDestObj instanceof Title ) {
139 $errors[] = $this->
msg(
'mergehistory-invalid-destination' )->parseAsBlock();
140 } elseif ( !$this->mDestObj->exists() ) {
141 $errors[] = $this->
msg(
'mergehistory-no-destination',
146 if ( $this->mTargetObj && $this->mDestObj && $this->mTargetObj->equals( $this->mDestObj ) ) {
147 $errors[] = $this->
msg(
'mergehistory-same-destination' )->parseAsBlock();
150 if ( count( $errors ) ) {
152 $this->
getOutput()->addHTML( implode(
"\n", $errors ) );
160 $out->addWikiMsg(
'mergehistory-header' );
168 $this->
msg(
'mergehistory-box' )->
text() ) .
174 <td>' .
Xml::label( $this->
msg(
'mergehistory-from' )->
text(),
'target' ) .
'</td>
175 <td>' .
Xml::input(
'target', 30, $this->mTarget, [
'id' =>
'target' ] ) .
'</td>
178 <td>' .
Xml::input(
'dest', 30, $this->mDest, [
'id' =>
'dest' ] ) .
'</td>
193 # List all stored revisions
195 $this, [], $this->mTargetObj, $this->mDestObj
197 $haveRevisions = $revisions && $revisions->getNumRows() > 0;
201 $action = $titleObj->getLocalURL( [
'action' =>
'submit' ] );
202 # Start the form here
211 $out->addHTML( $top );
213 if ( $haveRevisions ) {
214 # Format the user-visible controls (comment field, submission button)
215 # in a nice little table
218 $this->
msg(
'mergehistory-merge', $this->mTargetObj->getPrefixedText(),
219 $this->mDestObj->getPrefixedText() )->parse() .
222 <td class="mw-label">' .
225 <td class="mw-input">' .
226 Xml::input(
'wpComment', 50, $this->mComment, [
'id' =>
'wpComment' ] ) .
231 <td class="mw-submit">' .
233 $this->
msg(
'mergehistory-submit' )->
text(),
234 [
'name' =>
'merge',
'id' =>
'mw-merge-submit' ]
241 $out->addHTML( $table );
245 '<h2 id="mw-mergehistory">' .
246 $this->
msg(
'mergehistory-list' )->escaped() .
"</h2>\n"
249 if ( $haveRevisions ) {
250 $out->addHTML( $revisions->getNavigationBar() );
251 $out->addHTML(
'<ul>' );
252 $out->addHTML( $revisions->getBody() );
253 $out->addHTML(
'</ul>' );
254 $out->addHTML( $revisions->getNavigationBar() );
256 $out->addWikiMsg(
'mergehistory-empty' );
259 # Show relevant lines from the merge log:
260 $mergeLogPage =
new LogPage(
'merge' );
261 $out->addHTML(
'<h2>' . $mergeLogPage->getName()->escaped() .
"</h2>\n" );
264 # When we submit, go by page ID to avoid some nasty but unlikely collisions.
265 # Such would happen if a page was renamed after the form loaded, but before submit
266 $misc =
Html::hidden(
'targetID', $this->mTargetObj->getArticleID() );
267 $misc .=
Html::hidden(
'destID', $this->mDestObj->getArticleID() );
272 $out->addHTML( $misc );
281 $last = $this->
msg(
'last' )->escaped();
284 $checkBox =
Xml::radio(
'mergepoint', $ts, ( $this->mTimestamp === $ts ) );
292 [
'oldid' =>
$rev->getId() ]
295 $pageLink =
'<span class="history-deleted">' . $pageLink .
'</span>';
300 $last = $this->
msg(
'last' )->escaped();
301 } elseif ( isset( $this->prevId[$row->rev_id] ) ) {
304 $this->
msg(
'last' )->escaped(),
307 'diff' => $row->rev_id,
308 'oldid' => $this->prevId[$row->rev_id]
315 $size = $row->rev_len;
316 if ( !is_null( $size ) ) {
322 $this->
msg(
'mergehistory-revisionrow' )
323 ->rawParams( $checkBox,
$last, $pageLink, $userLink, $stxt,
$comment )->escaped() );
339 # Get the titles directly from the IDs, in case the target page params
340 # were spoofed. The queries are done based on the IDs, so it's best to
341 # keep it consistent...
344 if ( is_null( $targetTitle ) || is_null( $destTitle ) ) {
347 if ( $targetTitle->getArticleID() == $destTitle->getArticleID() ) {
352 $mh =
new MergeHistory( $targetTitle, $destTitle, $this->mTimestamp );
355 $mergeStatus = $mh->merge( $this->
getUser(), $this->mComment );
356 if ( !$mergeStatus->isOK() ) {
358 $this->
getOutput()->addWikiMsg( $mergeStatus->getMessage() );
366 [
'redirect' =>
'no' ]
369 $this->
getOutput()->addWikiMsg( $this->
msg(
'mergehistory-done' )
370 ->rawParams( $targetLink )
371 ->params( $destTitle->getPrefixedText() )
372 ->numParams( $mh->getMergedRevisionCount() )
static newFromID($id, $flags=0)
Create a new Title from an article ID.
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...
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
wfScript($script= 'index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
static element($element, $attribs=null, $contents= '', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
static rawElement($element, $attribs=[], $contents= '')
Returns an HTML element in a string.
static formatRevisionSize($size)
static hidden($name, $value, array $attribs=[])
Convenience function to produce an input element with type=hidden.
static input($name, $size=false, $value=false, $attribs=[])
Convenience function to build an HTML text input field.
msg()
Wrapper around wfMessage that sets the current context.
getOutput()
Get the OutputPage being used for this instance.
static newFromText($text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
static submitButton($value, $attribs=[])
Convenience function to build an HTML submit button When $wgUseMediaWikiUIEverywhere is true it will ...
addHelpLink($to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
static label($label, $id, $attribs=[])
Convenience function to build an HTML form label.
static showLogExtract(&$out, $types=[], $page= '', $user= '', $param=[])
Show log extract.
outputHeader($summaryMessageKey= '')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
Class to simplify the use of log pages.
wfTimestamp($outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
static closeElement($element)
Shortcut to close an XML element.
Parent class for all special pages.
wfEscapeWikiText($text)
Escapes the given text so that it may be output using addWikiText() without any linking, formatting, etc.
static openElement($element, $attribs=null)
This opens an XML element.
Special page allowing users with the appropriate permissions to merge article histories, with some restrictions.
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes! ...
static linkKnown($target, $html=null, $customAttribs=[], $query=[], $options=[ 'known'])
Identical to link(), except $options defaults to 'known'.
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
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
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 local account $user
static link($target, $html=null, $customAttribs=[], $query=[], $options=[])
This function returns an HTML link to the given target.
static radio($name, $value, $checked=false, $attribs=[])
Convenience function to build an HTML radio button.
bool $mSubmitted
Was submitted?
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
error also a ContextSource you ll probably need to make sure the header is varied on $request
useTransactionalTimeLimit()
Call wfTransactionalTimeLimit() if this request was POSTed.
getUser()
Shortcut to get the User executing this instance.
getLanguage()
Shortcut to get user's language.
Handles the backend logic of merging the histories of two pages.
checkPermissions()
Checks if userCanExecute, and if not throws a PermissionsError.
merge()
Actually attempt the history move.
getRequest()
Get the WebRequest being used for this instance.
checkReadOnly()
If the wiki is currently in readonly mode, throws a ReadOnlyError.
static revUserTools($rev, $isPublic=false)
Generate a user tool link cluster if the current user is allowed to view it.
getPageTitle($subpage=false)
Get a self-referential title object.