Changing comments layout preparing for generated documentation with Phpdocumentor
[lhc/web/wiklou.git] / includes / EditPage.php
1 <?php
2 # $Id$
3 /**
4 * Contain the EditPage class
5 */
6
7 /**
8 * Splitting edit page/HTML interface from Article...
9 * The actual database and text munging is still in Article,
10 * but it should get easier to call those from alternate
11 * interfaces.
12 */
13 class EditPage {
14 var $mArticle;
15 var $mTitle;
16
17 # Form values
18 var $save = false, $preview = false;
19 var $minoredit = false, $watchthis = false;
20 var $textbox1 = '', $textbox2 = '', $summary = '';
21 var $edittime = '', $section = '';
22 var $oldid = 0;
23
24 function EditPage( $article ) {
25 $this->mArticle =& $article;
26 global $wgTitle;
27 $this->mTitle =& $wgTitle;
28 }
29
30 # This is the function that gets called for "action=edit".
31
32 function edit()
33 {
34 global $wgOut, $wgUser, $wgWhitelistEdit, $wgRequest;
35 // this is not an article
36 $wgOut->setArticleFlag(false);
37
38 $this->importFormData( $wgRequest );
39
40 if ( ! $this->mTitle->userCanEdit() ) {
41 $wgOut->readOnlyPage( $this->mArticle->getContent( true ), true );
42 return;
43 }
44 if ( $wgUser->isBlocked() ) {
45 $this->blockedIPpage();
46 return;
47 }
48 if ( !$wgUser->getID() && $wgWhitelistEdit ) {
49 $this->userNotLoggedInPage();
50 return;
51 }
52 if ( wfReadOnly() ) {
53 if( $this->save || $this->preview ) {
54 $this->editForm( 'preview' );
55 } else {
56 $wgOut->readOnlyPage( $this->mArticle->getContent( true ) );
57 }
58 return;
59 }
60 if ( $this->save ) {
61 $this->editForm( 'save' );
62 } else if ( $this->preview ) {
63 $this->editForm( 'preview' );
64 } else { # First time through
65 $this->editForm( 'initial' );
66 }
67 }
68
69 function importFormData( &$request ) {
70 # These fields need to be checked for encoding.
71 # Also remove trailing whitespace, but don't remove _initial_
72 # whitespace from the text boxes. This may be significant formatting.
73 $this->textbox1 = rtrim( $request->getText( 'wpTextbox1' ) );
74 $this->textbox2 = rtrim( $request->getText( 'wpTextbox2' ) );
75 $this->summary = trim( $request->getText( 'wpSummary' ) );
76
77 $this->edittime = $request->getVal( 'wpEdittime' );
78 if( !preg_match( '/^\d{14}$/', $this->edittime )) $this->edittime = '';
79
80 $this->preview = $request->getCheck( 'wpPreview' );
81 $this->save = $request->wasPosted() && !$this->preview;
82 $this->minoredit = $request->getCheck( 'wpMinoredit' );
83 $this->watchthis = $request->getCheck( 'wpWatchthis' );
84
85 $this->oldid = $request->getInt( 'oldid' );
86
87 # Section edit can come from either the form or a link
88 $this->section = $request->getVal( 'wpSection', $request->getVal( 'section' ) );
89 }
90
91 # Since there is only one text field on the edit form,
92 # pressing <enter> will cause the form to be submitted, but
93 # the submit button value won't appear in the query, so we
94 # Fake it here before going back to edit(). This is kind of
95 # ugly, but it helps some old URLs to still work.
96
97 function submit()
98 {
99 if( !$this->preview ) $this->save = true;
100
101 $this->edit();
102 }
103
104 # The edit form is self-submitting, so that when things like
105 # preview and edit conflicts occur, we get the same form back
106 # with the extra stuff added. Only when the final submission
107 # is made and all is well do we actually save and redirect to
108 # the newly-edited page.
109
110 function editForm( $formtype )
111 {
112 global $wgOut, $wgUser;
113 global $wgLang, $wgParser, $wgTitle;
114 global $wgAllowAnonymousMinor;
115 global $wgWhitelistEdit;
116 global $wgSpamRegex, $wgFilterCallback;
117
118 $sk = $wgUser->getSkin();
119 $isConflict = false;
120 // css / js subpages of user pages get a special treatment
121 $isCssJsSubpage = (Namespace::getUser() == $wgTitle->getNamespace() and preg_match("/\\.(css|js)$/", $wgTitle->getText() ));
122
123 if(!$this->mTitle->getArticleID()) { # new article
124 $wgOut->addWikiText(wfmsg('newarticletext'));
125 }
126
127 if( Namespace::isTalk( $this->mTitle->getNamespace() ) ) {
128 $wgOut->addWikiText(wfmsg('talkpagetext'));
129 }
130
131 # Attempt submission here. This will check for edit conflicts,
132 # and redundantly check for locked database, blocked IPs, etc.
133 # that edit() already checked just in case someone tries to sneak
134 # in the back door with a hand-edited submission URL.
135
136 if ( 'save' == $formtype ) {
137 # Check for spam
138 if ( $wgSpamRegex && preg_match( $wgSpamRegex, $this->textbox1, $matches ) ) {
139 $this->spamPage ( $matches );
140 return;
141 }
142 if ( $wgFilterCallback && $wgFilterCallback( $this->mTitle, $this->textbox1, $this->section ) ) {
143 # Error messages or other handling should be performed by the filter function
144 return;
145 }
146 if ( $wgUser->isBlocked() ) {
147 $this->blockedIPpage();
148 return;
149 }
150 if ( !$wgUser->getID() && $wgWhitelistEdit ) {
151 $this->userNotLoggedInPage();
152 return;
153 }
154 if ( wfReadOnly() ) {
155 $wgOut->readOnlyPage();
156 return;
157 }
158
159 # If article is new, insert it.
160 $aid = $this->mTitle->getArticleID( GAID_FOR_UPDATE );
161 if ( 0 == $aid ) {
162 # Don't save a new article if it's blank.
163 if ( ( '' == $this->textbox1 ) ||
164 ( wfMsg( 'newarticletext' ) == $this->textbox1 ) ) {
165 $wgOut->redirect( $this->mTitle->getFullURL() );
166 return;
167 }
168 $this->mArticle->insertNewArticle( $this->textbox1, $this->summary, $this->minoredit, $this->watchthis );
169 return;
170 }
171
172 # Article exists. Check for edit conflict.
173
174 $this->mArticle->clear(); # Force reload of dates, etc.
175 $this->mArticle->forUpdate( true ); # Lock the article
176
177 if( ( $this->section != 'new' ) &&
178 ($this->mArticle->getTimestamp() != $this->edittime ) ) {
179 $isConflict = true;
180 }
181 $userid = $wgUser->getID();
182
183 $text = $this->mArticle->getTextOfLastEditWithSectionReplacedOrAdded(
184 $this->section, $this->textbox1, $this->summary);
185 # Suppress edit conflict with self
186
187 if ( ( 0 != $userid ) && ( $this->mArticle->getUser() == $userid ) ) {
188 $isConflict = false;
189 } else {
190 # switch from section editing to normal editing in edit conflict
191 if($isConflict) {
192 # Attempt merge
193 if( $this->mergeChangesInto( $text ) ){
194 // Successful merge! Maybe we should tell the user the good news?
195 $isConflict = false;
196 } else {
197 $this->section = '';
198 $this->textbox1 = $text;
199 }
200 }
201 }
202 if ( ! $isConflict ) {
203 # All's well
204 $sectionanchor = '';
205 if( $this->section != '' ) {
206 # Try to get a section anchor from the section source, redirect to edited section if header found
207 # XXX: might be better to integrate this into Article::getTextOfLastEditWithSectionReplacedOrAdded
208 # for duplicate heading checking and maybe parsing
209 $hasmatch = preg_match( "/^ *([=]{1,6})(.*?)(\\1) *\\n/i", $this->textbox1, $matches );
210 # we can't deal with anchors, includes, html etc in the header for now,
211 # headline would need to be parsed to improve this
212 #if($hasmatch and strlen($matches[2]) > 0 and !preg_match( "/[\\['{<>]/", $matches[2])) {
213 if($hasmatch and strlen($matches[2]) > 0) {
214 global $wgInputEncoding;
215 $headline = do_html_entity_decode( $matches[2], ENT_COMPAT, $wgInputEncoding );
216 # strip out HTML
217 $headline = preg_replace( "/<.*?" . ">/","",$headline );
218 $headline = trim( $headline );
219 $sectionanchor = '#'.urlencode( str_replace(' ', '_', $headline ) );
220 $replacearray = array(
221 '%3A' => ':',
222 '%' => '.'
223 );
224 $sectionanchor = str_replace(array_keys($replacearray),array_values($replacearray),$sectionanchor);
225 }
226 }
227
228 # update the article here
229 if($this->mArticle->updateArticle( $text, $this->summary, $this->minoredit, $this->watchthis, '', $sectionanchor ))
230 return;
231 else
232 $isConflict = true;
233 }
234 }
235 # First time through: get contents, set time for conflict
236 # checking, etc.
237
238 if ( 'initial' == $formtype ) {
239 $this->edittime = $this->mArticle->getTimestamp();
240 $this->textbox1 = $this->mArticle->getContent( true );
241 $this->summary = '';
242 $this->proxyCheck();
243 }
244 $wgOut->setRobotpolicy( 'noindex,nofollow' );
245
246 # Enabled article-related sidebar, toplinks, etc.
247 $wgOut->setArticleRelated( true );
248
249 if ( $isConflict ) {
250 $s = wfMsg( 'editconflict', $this->mTitle->getPrefixedText() );
251 $wgOut->setPageTitle( $s );
252 $wgOut->addHTML( wfMsg( 'explainconflict' ) );
253
254 $this->textbox2 = $this->textbox1;
255 $this->textbox1 = $this->mArticle->getContent( true );
256 $this->edittime = $this->mArticle->getTimestamp();
257 } else {
258 $s = wfMsg( 'editing', $this->mTitle->getPrefixedText() );
259
260 if( $this->section != '' ) {
261 if( $this->section == 'new' ) {
262 $s.=wfMsg('commentedit');
263 } else {
264 $s.=wfMsg('sectionedit');
265 }
266 if(!$this->preview) {
267 $sectitle=preg_match("/^=+(.*?)=+/mi",
268 $this->textbox1,
269 $matches);
270 if( !empty( $matches[1] ) ) {
271 $this->summary = "/* ". trim($matches[1])." */ ";
272 }
273 }
274 }
275 $wgOut->setPageTitle( $s );
276 if ( $this->oldid ) {
277 $this->mArticle->setOldSubtitle();
278 $wgOut->addHTML( wfMsg( 'editingold' ) );
279 }
280 }
281
282 if( wfReadOnly() ) {
283 $wgOut->addHTML( '<strong>' .
284 wfMsg( 'readonlywarning' ) .
285 "</strong>" );
286 } else if ( $isCssJsSubpage and 'preview' != $formtype) {
287 $wgOut->addHTML( wfMsg( 'usercssjsyoucanpreview' ));
288 }
289 if( $this->mTitle->isProtected() ) {
290 $wgOut->addHTML( '<strong>' . wfMsg( 'protectedpagewarning' ) .
291 "</strong><br />\n" );
292 }
293
294 $kblength = (int)(strlen( $this->textbox1 ) / 1024);
295 if( $kblength > 29 ) {
296 $wgOut->addHTML( '<strong>' .
297 wfMsg( 'longpagewarning', $wgLang->formatNum( $kblength ) )
298 . '</strong>' );
299 }
300
301 $rows = $wgUser->getOption( 'rows' );
302 $cols = $wgUser->getOption( 'cols' );
303
304 $ew = $wgUser->getOption( 'editwidth' );
305 if ( $ew ) $ew = " style=\"width:100%\"";
306 else $ew = '';
307
308 $q = 'action=submit';
309 #if ( "no" == $redirect ) { $q .= "&redirect=no"; }
310 $action = $this->mTitle->escapeLocalURL( $q );
311
312 $summary = wfMsg('summary');
313 $subject = wfMsg('subject');
314 $minor = wfMsg('minoredit');
315 $watchthis = wfMsg ('watchthis');
316 $save = wfMsg('savearticle');
317 $prev = wfMsg('showpreview');
318
319 $cancel = $sk->makeKnownLink( $this->mTitle->getPrefixedText(),
320 wfMsg('cancel') );
321 $edithelpurl = $sk->makeUrl( wfMsg( 'edithelppage' ));
322 $edithelp = '<a target="helpwindow" href="'.$edithelpurl.'">'.
323 htmlspecialchars( wfMsg( 'edithelp' ) ).'</a> '.
324 htmlspecialchars( wfMsg( 'newwindow' ) );
325
326 global $wgRightsText;
327 $copywarn = "<div id=\"editpage-copywarn\">\n" .
328 wfMsg( $wgRightsText ? 'copyrightwarning' : 'copyrightwarning2',
329 '[[' . wfMsg( 'copyrightpage' ) . ']]',
330 $wgRightsText ) . "\n</div>";
331
332 if( $wgUser->getOption('showtoolbar') and !$isCssJsSubpage ) {
333 # prepare toolbar for edit buttons
334 $toolbar = $sk->getEditToolbar();
335 } else {
336 $toolbar = '';
337 }
338
339 // activate checkboxes if user wants them to be always active
340 if( !$this->preview ) {
341 if( $wgUser->getOption( 'watchdefault' ) ) $this->watchthis = true;
342 if( $wgUser->getOption( 'minordefault' ) ) $this->minoredit = true;
343
344 // activate checkbox also if user is already watching the page,
345 // require wpWatchthis to be unset so that second condition is not
346 // checked unnecessarily
347 if( !$this->watchthis && $this->mTitle->userIsWatching() ) $this->watchthis = true;
348 }
349
350 $minoredithtml = '';
351
352 if ( 0 != $wgUser->getID() || $wgAllowAnonymousMinor ) {
353 $minoredithtml =
354 "<input tabindex='3' type='checkbox' value='1' name='wpMinoredit'".($this->minoredit?" checked='checked'":"").
355 " accesskey='".wfMsg('accesskey-minoredit')."' id='wpMinoredit' />".
356 "<label for='wpMinoredit' title='".wfMsg('tooltip-minoredit')."'>{$minor}</label>";
357 }
358
359 $watchhtml = '';
360
361 if ( 0 != $wgUser->getID() ) {
362 $watchhtml = "<input tabindex='4' type='checkbox' name='wpWatchthis'".($this->watchthis?" checked='checked'":"").
363 " accesskey='".wfMsg('accesskey-watch')."' id='wpWatchthis' />".
364 "<label for='wpWatchthis' title='".wfMsg('tooltip-watch')."'>{$watchthis}</label>";
365 }
366
367 $checkboxhtml = $minoredithtml . $watchhtml . '<br />';
368
369 if ( 'preview' == $formtype) {
370 $previewhead='<h2>' . wfMsg( 'preview' ) . "</h2>\n<p><center><font color=\"#cc0000\">" .
371 wfMsg( 'note' ) . wfMsg( 'previewnote' ) . "</font></center></p>\n";
372 if ( $isConflict ) {
373 $previewhead.='<h2>' . wfMsg( 'previewconflict' ) .
374 "</h2>\n";
375 }
376
377 $parserOptions = ParserOptions::newFromUser( $wgUser );
378 $parserOptions->setEditSection( false );
379 $parserOptions->setEditSectionOnRightClick( false );
380
381 # don't parse user css/js, show message about preview
382 # XXX: stupid php bug won't let us use $wgTitle->isCssJsSubpage() here
383
384 if ( $isCssJsSubpage ) {
385 if(preg_match("/\\.css$/", $wgTitle->getText() ) ) {
386 $previewtext = wfMsg('usercsspreview');
387 } else if(preg_match("/\\.js$/", $wgTitle->getText() ) ) {
388 $previewtext = wfMsg('userjspreview');
389 }
390 $parserOutput = $wgParser->parse( $previewtext , $wgTitle, $parserOptions );
391 $wgOut->addHTML( $parserOutput->mText );
392 } else {
393 $parserOutput = $wgParser->parse( $this->mArticle->preSaveTransform( $this->textbox1 ) ."\n\n",
394 $wgTitle, $parserOptions );
395 $previewHTML = $parserOutput->mText;
396
397 if($wgUser->getOption('previewontop')) {
398 $wgOut->addHTML($previewhead);
399 $wgOut->addHTML($previewHTML);
400 }
401 $wgOut->addCategoryLinks($parserOutput->getCategoryLinks());
402 $wgOut->addLanguageLinks($parserOutput->getLanguageLinks());
403 $wgOut->addHTML( "<br style=\"clear:both;\" />\n" );
404 }
405 }
406
407 # if this is a comment, show a subject line at the top, which is also the edit summary.
408 # Otherwise, show a summary field at the bottom
409 $summarytext = htmlspecialchars( $wgLang->recodeForEdit( $this->summary ) ); # FIXME
410 if( $this->section == 'new' ) {
411 $commentsubject="{$subject}: <input tabindex='1' type='text' value=\"$summarytext\" name=\"wpSummary\" maxlength='200' size='60' /><br />";
412 $editsummary = '';
413 } else {
414 $commentsubject = '';
415 $editsummary="{$summary}: <input tabindex='3' type='text' value=\"$summarytext\" name=\"wpSummary\" maxlength='200' size='60' /><br />";
416 }
417
418 if( !$this->preview ) {
419 # Don't select the edit box on preview; this interferes with seeing what's going on.
420 $wgOut->setOnloadHandler( 'document.editform.wpTextbox1.focus()' );
421 }
422 # Prepare a list of templates used by this page
423 $db =& wfGetDB( DB_SLAVE );
424 $cur = $db->tableName( 'cur' );
425 $links = $db->tableName( 'links' );
426 $id = $this->mTitle->getArticleID();
427 $sql = "SELECT cur_namespace,cur_title,cur_id ".
428 "FROM $cur,$links WHERE l_to=cur_id AND l_from={$id} and cur_namespace=".NS_TEMPLATE;
429 $res = $db->query( $sql, "EditPage::editform" );
430
431 if ( $db->numRows( $res ) ) {
432 $templates = '<br />'. wfMsg( 'templatesused' ) . '<ul>';
433 while ( $row = $db->fetchObject( $res ) ) {
434 if ( $titleObj = Title::makeTitle( $row->cur_namespace, $row->cur_title ) ) {
435 $templates .= '<li>' . $sk->makeLinkObj( $titleObj ) . '</li>';
436 }
437 }
438 $templates .= '</ul>';
439 } else {
440 $templates = '';
441 }
442 $wgOut->addHTML( "
443 {$toolbar}
444 <form id=\"editform\" name=\"editform\" method=\"post\" action=\"$action\"
445 enctype=\"application/x-www-form-urlencoded\">
446 {$commentsubject}
447 <textarea tabindex='1' accesskey=\",\" name=\"wpTextbox1\" rows='{$rows}'
448 cols='{$cols}'{$ew}>" .
449 htmlspecialchars( $wgLang->recodeForEdit( $this->textbox1 ) ) .
450 "
451 </textarea>
452 <br />{$editsummary}
453 {$checkboxhtml}
454 <input tabindex='5' id='wpSave' type='submit' value=\"{$save}\" name=\"wpSave\" accesskey=\"".wfMsg('accesskey-save')."\"".
455 " title=\"".wfMsg('tooltip-save')."\"/>
456 <input tabindex='6' id='wpPreview' type='submit' value=\"{$prev}\" name=\"wpPreview\" accesskey=\"".wfMsg('accesskey-preview')."\"".
457 " title=\"".wfMsg('tooltip-preview')."\"/>
458 <em>{$cancel}</em> | <em>{$edithelp}</em>{$templates}" );
459 $wgOut->addWikiText( $copywarn );
460 $wgOut->addHTML( "
461 <input type='hidden' value=\"" . htmlspecialchars( $this->section ) . "\" name=\"wpSection\" />
462 <input type='hidden' value=\"{$this->edittime}\" name=\"wpEdittime\" />\n" );
463
464 if ( $isConflict ) {
465 require_once( "DifferenceEngine.php" );
466 $wgOut->addHTML( "<h2>" . wfMsg( "yourdiff" ) . "</h2>\n" );
467 DifferenceEngine::showDiff( $this->textbox2, $this->textbox1,
468 wfMsg( "yourtext" ), wfMsg( "storedversion" ) );
469
470 $wgOut->addHTML( "<h2>" . wfMsg( "yourtext" ) . "</h2>
471 <textarea tabindex=6 id='wpTextbox2' name=\"wpTextbox2\" rows='{$rows}' cols='{$cols}' wrap='virtual'>"
472 . htmlspecialchars( $wgLang->recodeForEdit( $this->textbox2 ) ) .
473 "
474 </textarea>" );
475 }
476 $wgOut->addHTML( "</form>\n" );
477 if($formtype =="preview" && !$wgUser->getOption("previewontop")) {
478 $wgOut->addHTML($previewhead);
479 $wgOut->addHTML($previewHTML);
480 }
481 }
482
483 function blockedIPpage()
484 {
485 global $wgOut, $wgUser, $wgLang, $wgIP;
486
487 $wgOut->setPageTitle( wfMsg( 'blockedtitle' ) );
488 $wgOut->setRobotpolicy( 'noindex,nofollow' );
489 $wgOut->setArticleRelated( false );
490
491 $id = $wgUser->blockedBy();
492 $reason = $wgUser->blockedFor();
493 $ip = $wgIP;
494
495 if ( is_numeric( $id ) ) {
496 $name = User::whoIs( $id );
497 } else {
498 $name = $id;
499 }
500 $link = '[[' . $wgLang->getNsText( Namespace::getUser() ) .
501 ":{$name}|{$name}]]";
502
503 $wgOut->addWikiText( wfMsg( 'blockedtext', $link, $reason, $ip, $name ) );
504 $wgOut->returnToMain( false );
505 }
506
507
508
509 function userNotLoggedInPage()
510 {
511 global $wgOut, $wgUser, $wgLang;
512
513 $wgOut->setPageTitle( wfMsg( 'whitelistedittitle' ) );
514 $wgOut->setRobotpolicy( 'noindex,nofollow' );
515 $wgOut->setArticleRelated( false );
516
517 $wgOut->addWikiText( wfMsg( 'whitelistedittext' ) );
518 $wgOut->returnToMain( false );
519 }
520
521 function spamPage ( $matches = array() )
522 {
523 global $wgOut;
524 $wgOut->setPageTitle( wfMsg( 'spamprotectiontitle' ) );
525 $wgOut->setRobotpolicy( 'noindex,nofollow' );
526 $wgOut->setArticleRelated( false );
527
528 $wgOut->addWikiText( wfMsg( 'spamprotectiontext' ) );
529 if ( isset ( $matches[0] ) ) {
530 $wgOut->addWikiText( wfMsg( 'spamprotectionmatch', "<nowiki>{$matches[0]}</nowiki>" ) );
531 }
532 $wgOut->returnToMain( false );
533 }
534
535 # Forks processes to scan the originating IP for an open proxy server
536 # MemCached can be used to skip IPs that have already been scanned
537 function proxyCheck()
538 {
539 global $wgBlockOpenProxies, $wgProxyPorts, $wgProxyScriptPath;
540 global $wgIP, $wgUseMemCached, $wgMemc, $wgDBname, $wgProxyMemcExpiry;
541
542 if ( !$wgBlockOpenProxies ) {
543 return;
544 }
545
546 # Get MemCached key
547 $skip = false;
548 if ( $wgUseMemCached ) {
549 $mcKey = $wgDBname.':proxy:ip:'.$wgIP;
550 $mcValue = $wgMemc->get( $mcKey );
551 if ( $mcValue ) {
552 $skip = true;
553 }
554 }
555
556 # Fork the processes
557 if ( !$skip ) {
558 $title = Title::makeTitle( NS_SPECIAL, 'Blockme' );
559 $iphash = md5( $wgIP . $wgProxyKey );
560 $url = $title->getFullURL( 'ip='.$iphash );
561
562 foreach ( $wgProxyPorts as $port ) {
563 $params = implode( ' ', array(
564 escapeshellarg( $wgProxyScriptPath ),
565 escapeshellarg( $wgIP ),
566 escapeshellarg( $port ),
567 escapeshellarg( $url )
568 ));
569 exec( "php $params &>/dev/null &" );
570 }
571 # Set MemCached key
572 if ( $wgUseMemCached ) {
573 $wgMemc->set( $mcKey, 1, $wgProxyMemcExpiry );
574 }
575 }
576 }
577
578 /* private */ function mergeChangesInto( &$text ){
579 $fname = 'EditPage::mergeChangesInto';
580 $oldDate = $this->edittime;
581 $dbw =& wfGetDB( DB_MASTER );
582 $obj = $dbw->getArray( 'cur', array( 'cur_text' ), array( 'cur_id' => $this->mTitle->getArticleID() ),
583 $fname, 'FOR UPDATE' );
584
585 $yourtext = $obj->cur_text;
586 $ns = $this->mTitle->getNamespace();
587 $title = $this->mTitle->getDBkey();
588 $obj = $dbw->getArray( 'old',
589 array( 'old_text','old_flags'),
590 array( 'old_namespace' => $ns, 'old_title' => $title,
591 'old_timestamp' => $dbw->timestamp($oldDate)),
592 $fname );
593 $oldText = Article::getRevisionText( $obj );
594
595 if(wfMerge($oldText, $text, $yourtext, $result)){
596 $text = $result;
597 return true;
598 } else {
599 return false;
600 }
601 }
602 }
603
604 ?>