/
CustomMoveForm.php
202 lines (183 loc) · 5.64 KB
/
CustomMoveForm.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<?php
/**
* HTML form for Special:Movepage
* @ingroup SpecialPage
*/
class CustomMovePageForm extends MovePageForm {
/**
* Show the form
* @param mixed $err Error message. May either be a string message name or
* array message name and parameters, like the second argument to
* OutputPage::wrapWikiMsg().
*/
function showForm( $err ) {
global $wgOut, $wgUser, $wgFixDoubleRedirects;
$oldTitleLink = Linker::link( $this->oldTitle );
$wgOut->setPagetitle( wfMsg( 'move-page', $this->oldTitle->getPrefixedText() ) );
//$wgOut->setSubtitle( wfMsg( 'move-page-backlink', $oldTitleLink ) );
$newTitle = $this->newTitle;
if ( !$newTitle ) {
# Show the current title as a default
# when the form is first opened.
$newTitle = $this->oldTitle;
} else {
if ( empty( $err ) ) {
# If a title was supplied, probably from the move log revert
# link, check for validity. We can then show some diagnostic
# information and save a click.
$newerr = $this->oldTitle->isValidMoveOperation( $newTitle );
if ( $newerr ) {
$err = $newerr[0];
}
}
}
if ( !empty( $err ) && $err[0] == 'articleexists' && $wgUser->isAllowed( 'delete' ) ) {
$wgOut->addWikiMsg( 'delete_and_move_text', $newTitle->getPrefixedText() );
$movepagebtn = wfMsg( 'delete_and_move' );
$submitVar = 'wpDeleteAndMove';
$confirm = '
<tr>
<td></td>
<td class="mw-input">' .
Xml::checkLabel( wfMsg( 'delete_and_move_confirm' ), 'wpConfirm', 'wpConfirm' ) .
'</td>
</tr>';
$err = '';
} else {
$wgOut->addWikiMsg( 'movepagetext' );
$movepagebtn = wfMsg( 'movepagebtn' );
$submitVar = 'wpMove';
$confirm = false;
}
$oldTalk = $this->oldTitle->getTalkPage();
$considerTalk = ( !$this->oldTitle->isTalkPage() && $oldTalk->exists() );
$dbr = wfGetDB( DB_SLAVE );
if ( $wgFixDoubleRedirects ) {
$hasRedirects = $dbr->selectField(
'redirect',
'1',
array(
'rd_namespace' => $this->oldTitle->getNamespace(),
'rd_title' => $this->oldTitle->getDBkey(),
),
__METHOD__
);
} else {
$hasRedirects = false;
}
if ( $considerTalk ) {
$wgOut->addWikiMsg( 'movepagetalktext' );
}
$titleObj = SpecialPage::getTitleFor( 'Movepage' );
$token = htmlspecialchars( $wgUser->getEditToken() );
if ( !empty( $err ) ) {
$wgOut->setSubtitle( wfMsg( 'formerror' ) );
if ( $err[0] == 'hookaborted' ) {
$hookErr = $err[1];
$errMsg = "<p><strong class=\"error\">$hookErr</strong></p>\n";
$wgOut->addHTML( $errMsg );
} else {
$wgOut->wrapWikiMsg( '<p><strong class="error">$1</strong></p>', $err );
}
}
$wgOut->addHTML(
Xml::openElement(
'form',
array(
'onsubmit' => 'this.wpNewTitle.value=this.wpNewTitle.value.replace(/\?/g,\'\')',
'method' => 'post',
'action' => $titleObj->getLocalURL( 'action=submit' ),
'id' => 'movepage'
)
)
);
wfRunHooks( 'ArticleMoveForm', array( &$wgOut ) );
$wgOut->addHTML(
//Xml::openElement( 'fieldset' ) .
//Xml::element( 'legend', null, wfMsg( 'move-page-legend' ) ) .
Xml::openElement( 'table', array( 'border' => '0', 'id' => 'mw-movepage-table' ) ) .
'<tr>
<td class="mw-label">' .
Xml::label( wfMsg( 'newtitle' ), 'wpNewTitle' ) .
'</td>
<td class="mw-input">' .
Xml::input( 'wpNewTitle', 75, $newTitle->getPrefixedText(), array( 'type' => 'text', 'id' => 'wpNewTitle' ) ) . ' <b>?</b>' .
Html::hidden( 'wpOldTitle', $this->oldTitle->getPrefixedText() ) .
'</td>
</tr>'
);
if ( $considerTalk ) {
$wgOut->addHTML( '
<tr>
<td></td>
<td class="mw-input">' .
Xml::checkLabel( wfMsg( 'movetalk' ), 'wpMovetalk', 'wpMovetalk', $this->moveTalk ) .
'</td>
</tr>'
);
}
if ( $wgUser->isAllowed( 'suppressredirect' ) ) {
$wgOut->addHTML( '
<tr>
<td></td>
<td class="mw-input">' .
Xml::checkLabel( wfMsg( 'move-leave-redirect' ), 'wpLeaveRedirect',
'wpLeaveRedirect', $this->leaveRedirect ) .
'</td>
</tr>'
);
}
if ( $hasRedirects ) {
$wgOut->addHTML( '
<tr>
<td></td>
<td class="mw-input">' .
Xml::checkLabel( wfMsg( 'fix-double-redirects' ), 'wpFixRedirects',
'wpFixRedirects', $this->fixRedirects ) .
'</td>
</tr>'
);
}
if (
( $this->oldTitle->hasSubpages() || $this->oldTitle->getTalkPage()->hasSubpages() ) &&
$this->oldTitle->userCan( 'move-subpages' )
)
{
$wgOut->addHTML( '
<tr>
<td></td>
<td class="mw-input">' .
Xml::checkLabel( wfMsg(
$this->oldTitle->hasSubpages()
? 'move-subpages'
: 'move-talk-subpages'
),
'wpMovesubpages', 'wpMovesubpages',
# Don't check the box if we only have talk subpages to
# move and we aren't moving the talk page.
$this->moveSubpages && ( $this->oldTitle->hasSubpages() || $this->moveTalk )
) .
'</td>
</tr>'
);
}
// FIXME: $this->watch shows up as undefined since it's a private variable in MovePageForm.
$watchChecked = $this->watch || $wgUser->getBoolOption( 'watchmoves' )
|| $this->oldTitle->userIsWatching();
$wgOut->addHTML( "
{$confirm}
<tr>
<td> </td>
<td class='mw-submit'>" .
Xml::submitButton( $movepagebtn, array( 'name' => $submitVar ) ) .
"</td>
</tr>" .
Xml::closeElement( 'table' ) .
Html::hidden( 'wpEditToken', $token ) .
//Xml::closeElement( 'fieldset' ) .
Xml::closeElement( 'form' ) .
"\n"
);
//$this->showLogFragment( $this->oldTitle, $wgOut );
}
}