Sometimes no title object....?
[lhc/web/wiklou.git] / includes / Article.php
1 <?
2 # Class representing a Wikipedia article and history.
3 # See design.doc for an overview.
4
5 # Note: edit user interface and cache support functions have been
6 # moved to separate EditPage and CacheManager classes.
7
8 /* CHECK MERGE @@@
9 TEST THIS @@@
10
11 * s/\$wgTitle/\$this->mTitle/ performed, many replacements
12 * mTitle variable added to class
13 */
14
15 include_once( "CacheManager.php" );
16
17 class Article {
18 /* private */ var $mContent, $mContentLoaded;
19 /* private */ var $mUser, $mTimestamp, $mUserText;
20 /* private */ var $mCounter, $mComment, $mCountAdjustment;
21 /* private */ var $mMinorEdit, $mRedirectedFrom;
22 /* private */ var $mTouched, $mFileCache, $mTitle;
23
24 function Article( &$title ) {
25 $this->mTitle =& $title;
26 $this->clear();
27 }
28
29 /* private */ function clear()
30 {
31 $this->mContentLoaded = false;
32 $this->mUser = $this->mCounter = -1; # Not loaded
33 $this->mRedirectedFrom = $this->mUserText =
34 $this->mTimestamp = $this->mComment = $this->mFileCache = "";
35 $this->mCountAdjustment = 0;
36 $this->mTouched = "19700101000000";
37 }
38
39 # Note that getContent/loadContent may follow redirects if
40 # not told otherwise, and so may cause a change to mTitle.
41
42 function getContent( $noredir = false )
43 {
44 global $action,$section,$count; # From query string
45 $fname = "Article::getContent";
46 wfProfileIn( $fname );
47
48 if ( 0 == $this->getID() ) {
49 if ( "edit" == $action ) {
50 wfProfileOut( $fname );
51 return ""; # was "newarticletext", now moved above the box)
52 }
53 wfProfileOut( $fname );
54 return wfMsg( "noarticletext" );
55 } else {
56 $this->loadContent( $noredir );
57
58 if(
59 # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page
60 ( $this->mTitle->getNamespace() == Namespace::getTalk( Namespace::getUser()) ) &&
61 preg_match("/^\d{1,3}\.\d{1,3}.\d{1,3}\.\d{1,3}$/",$this->mTitle->getText()) &&
62 $action=="view"
63 )
64 {
65 wfProfileOut( $fname );
66 return $this->mContent . "\n" .wfMsg("anontalkpagetext"); }
67 else {
68 if($action=="edit") {
69 if($section!="") {
70 if($section=="new") {
71 wfProfileOut( $fname );
72 return "";
73 }
74
75 $secs=preg_split("/(^=+.*?=+|^<h[1-6].*?>.*?<\/h[1-6].*?>)/mi",
76 $this->mContent, -1,
77 PREG_SPLIT_DELIM_CAPTURE);
78 if($section==0) {
79 wfProfileOut( $fname );
80 return trim($secs[0]);
81 } else {
82 wfProfileOut( $fname );
83 return trim($secs[$section*2-1] . $secs[$section*2]);
84 }
85 }
86 }
87 wfProfileOut( $fname );
88 return $this->mContent;
89 }
90 }
91 }
92
93 function loadContent( $noredir = false )
94 {
95 global $wgOut, $wgMwRedir;
96 global $oldid, $redirect; # From query
97
98 if ( $this->mContentLoaded ) return;
99 $fname = "Article::loadContent";
100
101 # Pre-fill content with error message so that if something
102 # fails we'll have something telling us what we intended.
103
104 $t = $this->mTitle->getPrefixedText();
105 if ( isset( $oldid ) ) {
106 $oldid = IntVal( $oldid );
107 $t .= ",oldid={$oldid}";
108 }
109 if ( isset( $redirect ) ) {
110 $redirect = ($redirect == "no") ? "no" : "yes";
111 $t .= ",redirect={$redirect}";
112 }
113 $this->mContent = wfMsg( "missingarticle", $t );
114
115 if ( ! $oldid ) { # Retrieve current version
116 $id = $this->getID();
117 if ( 0 == $id ) return;
118
119 $sql = "SELECT " .
120 "cur_text,cur_timestamp,cur_user,cur_counter,cur_restrictions,cur_touched " .
121 "FROM cur WHERE cur_id={$id}";
122 wfDebug( "$sql\n" );
123 $res = wfQuery( $sql, DB_READ, $fname );
124 if ( 0 == wfNumRows( $res ) ) {
125 return;
126 }
127
128 $s = wfFetchObject( $res );
129 # If we got a redirect, follow it (unless we've been told
130 # not to by either the function parameter or the query
131 if ( ( "no" != $redirect ) && ( false == $noredir ) &&
132 ( $wgMwRedir->matchStart( $s->cur_text ) ) ) {
133 if ( preg_match( "/\\[\\[([^\\]\\|]+)[\\]\\|]/",
134 $s->cur_text, $m ) ) {
135 $rt = Title::newFromText( $m[1] );
136
137 # Gotta hand redirects to special pages differently:
138 # Fill the HTTP response "Location" header and ignore
139 # the rest of the page we're on.
140
141 if ( $rt->getInterwiki() != "" ) {
142 $wgOut->redirect( $rt->getFullURL() ) ;
143 return;
144 }
145 if ( $rt->getNamespace() == Namespace::getSpecial() ) {
146 $wgOut->redirect( wfLocalUrl(
147 $rt->getPrefixedURL() ) );
148 return;
149 }
150 $rid = $rt->getArticleID();
151 if ( 0 != $rid ) {
152 $sql = "SELECT cur_text,cur_timestamp,cur_user," .
153 "cur_counter,cur_restrictions,cur_touched FROM cur WHERE cur_id={$rid}";
154 $res = wfQuery( $sql, DB_READ, $fname );
155
156 if ( 0 != wfNumRows( $res ) ) {
157 $this->mRedirectedFrom = $this->mTitle->getPrefixedText();
158 $this->mTitle = $rt;
159 $s = wfFetchObject( $res );
160 }
161 }
162 }
163 }
164
165 $this->mContent = $s->cur_text;
166 $this->mUser = $s->cur_user;
167 $this->mCounter = $s->cur_counter;
168 $this->mTimestamp = $s->cur_timestamp;
169 $this->mTouched = $s->cur_touched;
170 $this->mTitle->mRestrictions = explode( ",", trim( $s->cur_restrictions ) );
171 $this->mTitle->mRestrictionsLoaded = true;
172 wfFreeResult( $res );
173 } else { # oldid set, retrieve historical version
174 $sql = "SELECT old_text,old_timestamp,old_user FROM old " .
175 "WHERE old_id={$oldid}";
176 $res = wfQuery( $sql, DB_READ, $fname );
177 if ( 0 == wfNumRows( $res ) ) { return; }
178
179 $s = wfFetchObject( $res );
180 $this->mContent = $s->old_text;
181 $this->mUser = $s->old_user;
182 $this->mCounter = 0;
183 $this->mTimestamp = $s->old_timestamp;
184 wfFreeResult( $res );
185 }
186 $this->mContentLoaded = true;
187 }
188
189 function getID() {
190 if( $this->mTitle ) {
191 return $this->mTitle->getArticleID();
192 } else {
193 return 0;
194 }
195 }
196
197 function getCount()
198 {
199 if ( -1 == $this->mCounter ) {
200 $id = $this->getID();
201 $this->mCounter = wfGetSQL( "cur", "cur_counter", "cur_id={$id}" );
202 }
203 return $this->mCounter;
204 }
205
206 # Would the given text make this article a "good" article (i.e.,
207 # suitable for including in the article count)?
208
209 function isCountable( $text )
210 {
211 global $wgUseCommaCount, $wgMwRedir;
212
213 if ( 0 != $this->mTitle->getNamespace() ) { return 0; }
214 if ( $wgMwRedir->matchStart( $text ) ) { return 0; }
215 $token = ($wgUseCommaCount ? "," : "[[" );
216 if ( false === strstr( $text, $token ) ) { return 0; }
217 return 1;
218 }
219
220 # Load the field related to the last edit time of the article.
221 # This isn't necessary for all uses, so it's only done if needed.
222
223 /* private */ function loadLastEdit()
224 {
225 global $wgOut;
226 if ( -1 != $this->mUser ) return;
227
228 $sql = "SELECT cur_user,cur_user_text,cur_timestamp," .
229 "cur_comment,cur_minor_edit FROM cur WHERE " .
230 "cur_id=" . $this->getID();
231 $res = wfQuery( $sql, DB_READ, "Article::loadLastEdit" );
232
233 if ( wfNumRows( $res ) > 0 ) {
234 $s = wfFetchObject( $res );
235 $this->mUser = $s->cur_user;
236 $this->mUserText = $s->cur_user_text;
237 $this->mTimestamp = $s->cur_timestamp;
238 $this->mComment = $s->cur_comment;
239 $this->mMinorEdit = $s->cur_minor_edit;
240 }
241 }
242
243 function getTimestamp()
244 {
245 $this->loadLastEdit();
246 return $this->mTimestamp;
247 }
248
249 function getUser()
250 {
251 $this->loadLastEdit();
252 return $this->mUser;
253 }
254
255 function getUserText()
256 {
257 $this->loadLastEdit();
258 return $this->mUserText;
259 }
260
261 function getComment()
262 {
263 $this->loadLastEdit();
264 return $this->mComment;
265 }
266
267 function getMinorEdit()
268 {
269 $this->loadLastEdit();
270 return $this->mMinorEdit;
271 }
272
273 # This is the default action of the script: just view the page of
274 # the given title.
275
276 function view()
277 {
278 global $wgUser, $wgOut, $wgLang;
279 global $oldid, $diff; # From query
280 global $wgLinkCache, $IP;
281 $fname = "Article::view";
282 wfProfileIn( $fname );
283
284 $wgOut->setArticleFlag( true );
285 $wgOut->setRobotpolicy( "index,follow" );
286
287 # If we got diff and oldid in the query, we want to see a
288 # diff page instead of the article.
289
290 if ( isset( $diff ) ) {
291 $wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
292 $de = new DifferenceEngine( $oldid, $diff );
293 $de->showDiffPage();
294 wfProfileOut( $fname );
295 return;
296 }
297
298 if ( !isset( $oldid ) ) {
299 if( $this->checkTouched() ) {
300 $wgOut->checkLastModified( $this->mTouched );
301 $this->tryFileCache();
302 }
303 }
304
305 $text = $this->getContent(); # May change mTitle
306 $wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
307 $wgOut->setHTMLTitle( $this->mTitle->getPrefixedText() .
308 " - " . wfMsg( "wikititlesuffix" ) );
309
310 # We're looking at an old revision
311
312 if ( $oldid ) {
313 $this->setOldSubtitle();
314 $wgOut->setRobotpolicy( "noindex,follow" );
315 }
316 if ( "" != $this->mRedirectedFrom ) {
317 $sk = $wgUser->getSkin();
318 $redir = $sk->makeKnownLink( $this->mRedirectedFrom, "",
319 "redirect=no" );
320 $s = wfMsg( "redirectedfrom", $redir );
321 $wgOut->setSubtitle( $s );
322 }
323 $wgLinkCache->preFill( $this->mTitle );
324 $wgOut->addWikiText( $text );
325
326 $this->viewUpdates();
327 wfProfileOut( $fname );
328 }
329
330 # Theoretically we could defer these whole insert and update
331 # functions for after display, but that's taking a big leap
332 # of faith, and we want to be able to report database
333 # errors at some point.
334
335 /* private */ function insertNewArticle( $text, $summary, $isminor, $watchthis )
336 {
337 global $wgOut, $wgUser, $wgLinkCache, $wgMwRedir;
338 global $wgEnablePersistentLC;
339
340 $fname = "Article::insertNewArticle";
341
342 $ns = $this->mTitle->getNamespace();
343 $ttl = $this->mTitle->getDBkey();
344 $text = $this->preSaveTransform( $text );
345 if ( $wgMwRedir->matchStart( $text ) ) { $redir = 1; }
346 else { $redir = 0; }
347
348 $now = wfTimestampNow();
349 $won = wfInvertTimestamp( $now );
350 wfSeedRandom();
351 $rand = number_format( mt_rand() / mt_getrandmax(), 12, ".", "" );
352 $sql = "INSERT INTO cur (cur_namespace,cur_title,cur_text," .
353 "cur_comment,cur_user,cur_timestamp,cur_minor_edit,cur_counter," .
354 "cur_restrictions,cur_user_text,cur_is_redirect," .
355 "cur_is_new,cur_random,cur_touched,inverse_timestamp) VALUES ({$ns},'" . wfStrencode( $ttl ) . "', '" .
356 wfStrencode( $text ) . "', '" .
357 wfStrencode( $summary ) . "', '" .
358 $wgUser->getID() . "', '{$now}', " .
359 ( $isminor ? 1 : 0 ) . ", 0, '', '" .
360 wfStrencode( $wgUser->getName() ) . "', $redir, 1, $rand, '{$now}', '{$won}')";
361 $res = wfQuery( $sql, DB_WRITE, $fname );
362
363 $newid = wfInsertId();
364 $this->mTitle->resetArticleID( $newid );
365
366 if ( $wgEnablePersistentLC ) {
367 // Purge related entries in links cache on new page, to heal broken links
368 $ptitle = wfStrencode( $ttl );
369 wfQuery("DELETE linkscc FROM linkscc,brokenlinks ".
370 "WHERE lcc_pageid=bl_from AND bl_to='{$ptitle}'", DB_WRITE);
371 }
372
373 $sql = "INSERT INTO recentchanges (rc_timestamp,rc_cur_time," .
374 "rc_namespace,rc_title,rc_new,rc_minor,rc_cur_id,rc_user," .
375 "rc_user_text,rc_comment,rc_this_oldid,rc_last_oldid,rc_bot) VALUES (" .
376 "'{$now}','{$now}',{$ns},'" . wfStrencode( $ttl ) . "',1," .
377 ( $isminor ? 1 : 0 ) . ",{$newid}," . $wgUser->getID() . ",'" .
378 wfStrencode( $wgUser->getName() ) . "','" .
379 wfStrencode( $summary ) . "',0,0," .
380 ( $wgUser->isBot() ? 1 : 0 ) . ")";
381 wfQuery( $sql, DB_WRITE, $fname );
382 if ($watchthis) {
383 if(!$this->mTitle->userIsWatching()) $this->watch();
384 } else {
385 if ( $this->mTitle->userIsWatching() ) {
386 $this->unwatch();
387 }
388 }
389
390 # The talk page isn't in the regular link tables, so we need to update manually:
391 $talkns = $ns ^ 1; # talk -> normal; normal -> talk
392 $sql = "UPDATE cur set cur_touched='$now' WHERE cur_namespace=$talkns AND cur_title='" . wfStrencode( $ttl ) . "'";
393 wfQuery( $sql, DB_WRITE );
394
395 $this->showArticle( $text, wfMsg( "newarticle" ) );
396 }
397
398 function updateArticle( $text, $summary, $minor, $watchthis, $section = "")
399 {
400 global $wgOut, $wgUser, $wgLinkCache;
401 global $wgDBtransactions, $wgMwRedir;
402 $fname = "Article::updateArticle";
403
404 $this->loadLastEdit();
405
406 // insert updated section into old text if we have only edited part
407 // of the article
408 if ($section != "") {
409 $oldtext=$this->getContent();
410 if($section=="new") {
411 if($summary) $subject="== {$summary} ==\n\n";
412 $text=$oldtext."\n\n".$subject.$text;
413 } else {
414 $secs=preg_split("/(^=+.*?=+|^<h[1-6].*?>.*?<\/h[1-6].*?>)/mi",
415 $oldtext,-1,PREG_SPLIT_DELIM_CAPTURE);
416 $secs[$section*2]=$text."\n\n"; // replace with edited
417 if($section) { $secs[$section*2-1]=""; } // erase old headline
418 $text=join("",$secs);
419 }
420 }
421 if ( $this->mMinorEdit ) { $me1 = 1; } else { $me1 = 0; }
422 if ( $minor ) { $me2 = 1; } else { $me2 = 0; }
423 if ( preg_match( "/^((" . $wgMwRedir->getBaseRegex() . ")[^\\n]+)/i", $text, $m ) ) {
424 $redir = 1;
425 $text = $m[1] . "\n"; # Remove all content but redirect
426 }
427 else { $redir = 0; }
428
429 $text = $this->preSaveTransform( $text );
430
431 # Update article, but only if changed.
432
433 if( $wgDBtransactions ) {
434 $sql = "BEGIN";
435 wfQuery( $sql, DB_WRITE );
436 }
437 $oldtext = $this->getContent( true );
438
439 if ( 0 != strcmp( $text, $oldtext ) ) {
440 $this->mCountAdjustment = $this->isCountable( $text )
441 - $this->isCountable( $oldtext );
442
443 $now = wfTimestampNow();
444 $won = wfInvertTimestamp( $now );
445 $sql = "UPDATE cur SET cur_text='" . wfStrencode( $text ) .
446 "',cur_comment='" . wfStrencode( $summary ) .
447 "',cur_minor_edit={$me2}, cur_user=" . $wgUser->getID() .
448 ",cur_timestamp='{$now}',cur_user_text='" .
449 wfStrencode( $wgUser->getName() ) .
450 "',cur_is_redirect={$redir}, cur_is_new=0, cur_touched='{$now}', inverse_timestamp='{$won}' " .
451 "WHERE cur_id=" . $this->getID() .
452 " AND cur_timestamp='" . $this->getTimestamp() . "'";
453 $res = wfQuery( $sql, DB_WRITE, $fname );
454
455 if( wfAffectedRows() == 0 ) {
456 /* Belated edit conflict! Run away!! */
457 return false;
458 }
459
460 $sql = "INSERT INTO old (old_namespace,old_title,old_text," .
461 "old_comment,old_user,old_user_text,old_timestamp," .
462 "old_minor_edit,inverse_timestamp) VALUES (" .
463 $this->mTitle->getNamespace() . ", '" .
464 wfStrencode( $this->mTitle->getDBkey() ) . "', '" .
465 wfStrencode( $oldtext ) . "', '" .
466 wfStrencode( $this->getComment() ) . "', " .
467 $this->getUser() . ", '" .
468 wfStrencode( $this->getUserText() ) . "', '" .
469 $this->getTimestamp() . "', " . $me1 . ", '" .
470 wfInvertTimestamp( $this->getTimestamp() ) . "')";
471 $res = wfQuery( $sql, DB_WRITE, $fname );
472 $oldid = wfInsertID( $res );
473
474 $sql = "INSERT INTO recentchanges (rc_timestamp,rc_cur_time," .
475 "rc_namespace,rc_title,rc_new,rc_minor,rc_bot,rc_cur_id,rc_user," .
476 "rc_user_text,rc_comment,rc_this_oldid,rc_last_oldid) VALUES (" .
477 "'{$now}','{$now}'," . $this->mTitle->getNamespace() . ",'" .
478 wfStrencode( $this->mTitle->getDBkey() ) . "',0,{$me2}," .
479 ( $wgUser->isBot() ? 1 : 0 ) . "," .
480 $this->getID() . "," . $wgUser->getID() . ",'" .
481 wfStrencode( $wgUser->getName() ) . "','" .
482 wfStrencode( $summary ) . "',0,{$oldid})";
483 wfQuery( $sql, DB_WRITE, $fname );
484
485 $sql = "UPDATE recentchanges SET rc_this_oldid={$oldid} " .
486 "WHERE rc_namespace=" . $this->mTitle->getNamespace() . " AND " .
487 "rc_title='" . wfStrencode( $this->mTitle->getDBkey() ) . "' AND " .
488 "rc_timestamp='" . $this->getTimestamp() . "'";
489 wfQuery( $sql, DB_WRITE, $fname );
490
491 $sql = "UPDATE recentchanges SET rc_cur_time='{$now}' " .
492 "WHERE rc_cur_id=" . $this->getID();
493 wfQuery( $sql, DB_WRITE, $fname );
494
495 if ( $wgEnablePersistentLC ) {
496
497 // Purge link cache for this page
498 $pageid=$this->getID();
499 wfQuery("DELETE FROM linkscc WHERE lcc_pageid='{$pageid}'", DB_WRITE);
500
501 // This next query just makes sure stub colored links to this page
502 // are updated correctly (I think). If performance is more important
503 // than real-time updating of stub links, we really should skip
504 // this query.
505 wfQuery("DELETE linkscc FROM linkscc,links ".
506 "WHERE lcc_title=links.l_from AND l_to={$pageid}", DB_WRITE);
507 }
508
509 }
510 if( $wgDBtransactions ) {
511 $sql = "COMMIT";
512 wfQuery( $sql, DB_WRITE );
513 }
514
515 if ($watchthis) {
516 if (!$this->mTitle->userIsWatching()) $this->watch();
517 } else {
518 if ( $this->mTitle->userIsWatching() ) {
519 $this->unwatch();
520 }
521 }
522
523 $this->showArticle( $text, wfMsg( "updated" ) );
524 return true;
525 }
526
527 # After we've either updated or inserted the article, update
528 # the link tables and redirect to the new page.
529
530 function showArticle( $text, $subtitle )
531 {
532 global $wgOut, $wgUser, $wgLinkCache, $wgUseBetterLinksUpdate;
533 global $wgMwRedir;
534
535 $wgLinkCache = new LinkCache();
536
537 # Get old version of link table to allow incremental link updates
538 if ( $wgUseBetterLinksUpdate ) {
539 $wgLinkCache->preFill( $this->mTitle );
540 $wgLinkCache->clear();
541 }
542
543 # Now update the link cache by parsing the text
544 $wgOut = new OutputPage();
545 $wgOut->addWikiText( $text );
546
547 $this->editUpdates( $text );
548 if( $wgMwRedir->matchStart( $text ) )
549 $r = "redirect=no";
550 else
551 $r = "";
552 $wgOut->redirect( wfLocalUrl( $this->mTitle->getPrefixedURL(), $r ) );
553 }
554
555 # Add this page to my watchlist
556
557 function watch( $add = true )
558 {
559 global $wgUser, $wgOut, $wgLang;
560 global $wgDeferredUpdateList;
561
562 if ( 0 == $wgUser->getID() ) {
563 $wgOut->errorpage( "watchnologin", "watchnologintext" );
564 return;
565 }
566 if ( wfReadOnly() ) {
567 $wgOut->readOnlyPage();
568 return;
569 }
570 if( $add )
571 $wgUser->addWatch( $this->mTitle );
572 else
573 $wgUser->removeWatch( $this->mTitle );
574
575 $wgOut->setPagetitle( wfMsg( $add ? "addedwatch" : "removedwatch" ) );
576 $wgOut->setRobotpolicy( "noindex,follow" );
577
578 $sk = $wgUser->getSkin() ;
579 $link = $sk->makeKnownLink ( $this->mTitle->getPrefixedText() ) ;
580
581 if($add)
582 $text = wfMsg( "addedwatchtext", $link );
583 else
584 $text = wfMsg( "removedwatchtext", $link );
585 $wgOut->addHTML( $text );
586
587 $up = new UserUpdate();
588 array_push( $wgDeferredUpdateList, $up );
589
590 $wgOut->returnToMain( false );
591 }
592
593 function unwatch()
594 {
595 $this->watch( false );
596 }
597
598 # This shares a lot of issues (and code) with Recent Changes
599
600 function history()
601 {
602 global $wgUser, $wgOut, $wgLang, $offset, $limit;
603
604 # If page hasn't changed, client can cache this
605
606 $wgOut->checkLastModified( $this->getTimestamp() );
607 $fname = "Article::history";
608 wfProfileIn( $fname );
609
610 $wgOut->setPageTitle( $this->mTitle->getPRefixedText() );
611 $wgOut->setSubtitle( wfMsg( "revhistory" ) );
612 $wgOut->setArticleFlag( false );
613 $wgOut->setRobotpolicy( "noindex,nofollow" );
614
615 if( $this->mTitle->getArticleID() == 0 ) {
616 $wgOut->addHTML( wfMsg( "nohistory" ) );
617 wfProfileOut( $fname );
618 return;
619 }
620
621 $offset = (int)$offset;
622 $limit = (int)$limit;
623 if( $limit == 0 ) $limit = 50;
624 $namespace = $this->mTitle->getNamespace();
625 $title = $this->mTitle->getText();
626 $sql = "SELECT old_id,old_user," .
627 "old_comment,old_user_text,old_timestamp,old_minor_edit ".
628 "FROM old USE INDEX (name_title_timestamp) " .
629 "WHERE old_namespace={$namespace} AND " .
630 "old_title='" . wfStrencode( $this->mTitle->getDBkey() ) . "' " .
631 "ORDER BY inverse_timestamp LIMIT $offset, $limit";
632 $res = wfQuery( $sql, DB_READ, "Article::history" );
633
634 $revs = wfNumRows( $res );
635 if( $this->mTitle->getArticleID() == 0 ) {
636 $wgOut->addHTML( wfMsg( "nohistory" ) );
637 wfProfileOut( $fname );
638 return;
639 }
640
641 $sk = $wgUser->getSkin();
642 $numbar = wfViewPrevNext(
643 $offset, $limit,
644 $this->mTitle->getPrefixedText(),
645 "action=history" );
646 $s = $numbar;
647 $s .= $sk->beginHistoryList();
648
649 if($offset == 0 )
650 $s .= $sk->historyLine( $this->getTimestamp(), $this->getUser(),
651 $this->getUserText(), $namespace,
652 $title, 0, $this->getComment(),
653 ( $this->getMinorEdit() > 0 ) );
654
655 $revs = wfNumRows( $res );
656 while ( $line = wfFetchObject( $res ) ) {
657 $s .= $sk->historyLine( $line->old_timestamp, $line->old_user,
658 $line->old_user_text, $namespace,
659 $title, $line->old_id,
660 $line->old_comment, ( $line->old_minor_edit > 0 ) );
661 }
662 $s .= $sk->endHistoryList();
663 $s .= $numbar;
664 $wgOut->addHTML( $s );
665 wfProfileOut( $fname );
666 }
667
668 function protect( $limit = "sysop" )
669 {
670 global $wgUser, $wgOut;
671
672 if ( ! $wgUser->isSysop() ) {
673 $wgOut->sysopRequired();
674 return;
675 }
676 if ( wfReadOnly() ) {
677 $wgOut->readOnlyPage();
678 return;
679 }
680 $id = $this->mTitle->getArticleID();
681 if ( 0 == $id ) {
682 $wgOut->fatalEror( wfMsg( "badarticleerror" ) );
683 return;
684 }
685 $sql = "UPDATE cur SET cur_touched='" . wfTimestampNow() . "'," .
686 "cur_restrictions='{$limit}' WHERE cur_id={$id}";
687 wfQuery( $sql, DB_WRITE, "Article::protect" );
688
689 $log = new LogPage( wfMsg( "protectlogpage" ), wfMsg( "protectlogtext" ) );
690 if ( $limit === "" ) {
691 $log->addEntry( wfMsg( "unprotectedarticle", $this->mTitle->getPrefixedText() ), "" );
692 } else {
693 $log->addEntry( wfMsg( "protectedarticle", $this->mTitle->getPrefixedText() ), "" );
694 }
695 $wgOut->redirect( wfLocalUrl( $this->mTitle->getPrefixedURL() ) );
696 }
697
698 function unprotect()
699 {
700 return $this->protect( "" );
701 }
702
703 function delete()
704 {
705 global $wgUser, $wgOut;
706 global $wpConfirm, $wpReason, $image, $oldimage;
707
708 # This code desperately needs to be totally rewritten
709
710 if ( ( ! $wgUser->isSysop() ) ) {
711 $wgOut->sysopRequired();
712 return;
713 }
714 if ( wfReadOnly() ) {
715 $wgOut->readOnlyPage();
716 return;
717 }
718
719 # Better double-check that it hasn't been deleted yet!
720 $wgOut->setPagetitle( wfMsg( "confirmdelete" ) );
721 if ( ( "" == trim( $this->mTitle->getText() ) )
722 or ( $this->mTitle->getArticleId() == 0 ) ) {
723 $wgOut->fatalError( wfMsg( "cannotdelete" ) );
724 return;
725 }
726
727 if ( $_POST["wpConfirm"] ) {
728 $this->doDelete();
729 return;
730 }
731
732 # determine whether this page has earlier revisions
733 # and insert a warning if it does
734 # we select the text because it might be useful below
735 $ns = $this->mTitle->getNamespace();
736 $title = $this->mTitle->getDBkey();
737 $etitle = wfStrencode( $title );
738 $sql = "SELECT old_text FROM old WHERE old_namespace=$ns and old_title='$etitle' ORDER BY inverse_timestamp LIMIT 1";
739 $res = wfQuery( $sql, DB_READ, $fname );
740 if( ($old=wfFetchObject($res)) && !$wpConfirm ) {
741 $skin=$wgUser->getSkin();
742 $wgOut->addHTML("<B>".wfMsg("historywarning"));
743 $wgOut->addHTML( $skin->historyLink() ."</B><P>");
744 }
745
746 $sql="SELECT cur_text FROM cur WHERE cur_namespace=$ns and cur_title='$etitle'";
747 $res=wfQuery($sql, DB_READ, $fname);
748 if( ($s=wfFetchObject($res))) {
749
750 # if this is a mini-text, we can paste part of it into the deletion reason
751
752 #if this is empty, an earlier revision may contain "useful" text
753 if($s->cur_text!="") {
754 $text=$s->cur_text;
755 } else {
756 if($old) {
757 $text=$old->old_text;
758 $blanked=1;
759 }
760
761 }
762
763 $length=strlen($text);
764
765 # this should not happen, since it is not possible to store an empty, new
766 # page. Let's insert a standard text in case it does, though
767 if($length==0 && !$wpReason) { $wpReason=wfmsg("exblank");}
768
769
770 if($length < 500 && !$wpReason) {
771
772 # comment field=255, let's grep the first 150 to have some user
773 # space left
774 $text=substr($text,0,150);
775 # let's strip out newlines and HTML tags
776 $text=preg_replace("/\"/","'",$text);
777 $text=preg_replace("/\</","&lt;",$text);
778 $text=preg_replace("/\>/","&gt;",$text);
779 $text=preg_replace("/[\n\r]/","",$text);
780 if(!$blanked) {
781 $wpReason=wfMsg("excontent"). " '".$text;
782 } else {
783 $wpReason=wfMsg("exbeforeblank") . " '".$text;
784 }
785 if($length>150) { $wpReason .= "..."; } # we've only pasted part of the text
786 $wpReason.="'";
787 }
788 }
789
790 return $this->confirmDelete();
791 }
792
793 function confirmDelete( $par = "" )
794 {
795 global $wgOut;
796 global $wpReason;
797
798 wfDebug( "Article::confirmDelete\n" );
799
800 $sub = htmlspecialchars( $this->mTitle->getPrefixedText() );
801 $wgOut->setSubtitle( wfMsg( "deletesub", $sub ) );
802 $wgOut->setRobotpolicy( "noindex,nofollow" );
803 $wgOut->addWikiText( wfMsg( "confirmdeletetext" ) );
804
805 $t = $this->mTitle->getPrefixedURL();
806
807 $formaction = wfEscapeHTML( wfLocalUrl( $t, "action=delete" . $par ) );
808 $confirm = wfMsg( "confirm" );
809 $check = wfMsg( "confirmcheck" );
810 $delcom = wfMsg( "deletecomment" );
811
812 $wgOut->addHTML( "
813 <form id=\"deleteconfirm\" method=\"post\" action=\"{$formaction}\">
814 <table border=0><tr><td align=right>
815 {$delcom}:</td><td align=left>
816 <input type=text size=60 name=\"wpReason\" value=\"" . htmlspecialchars( $wpReason ) . "\">
817 </td></tr><tr><td>&nbsp;</td></tr>
818 <tr><td align=right>
819 <input type=checkbox name=\"wpConfirm\" value='1' id=\"wpConfirm\">
820 </td><td><label for=\"wpConfirm\">{$check}</label></td>
821 </tr><tr><td>&nbsp;</td><td>
822 <input type=submit name=\"wpConfirmB\" value=\"{$confirm}\">
823 </td></tr></table></form>\n" );
824
825 $wgOut->returnToMain( false );
826 }
827
828 function doDelete()
829 {
830 global $wgOut, $wgUser, $wgLang;
831 global $wpReason;
832 $fname = "Article::doDelete";
833 wfDebug( "$fname\n" );
834
835 $this->doDeleteArticle( $this->mTitle );
836 $deleted = $this->mTitle->getPrefixedText();
837
838 $wgOut->setPagetitle( wfMsg( "actioncomplete" ) );
839 $wgOut->setRobotpolicy( "noindex,nofollow" );
840
841 $sk = $wgUser->getSkin();
842 $loglink = $sk->makeKnownLink( $wgLang->getNsText(
843 Namespace::getWikipedia() ) .
844 ":" . wfMsg( "dellogpage" ), wfMsg( "deletionlog" ) );
845
846 $text = wfMsg( "deletedtext", $deleted, $loglink );
847
848 $wgOut->addHTML( "<p>" . $text );
849 $wgOut->returnToMain( false );
850 }
851
852 function doDeleteArticle( $title )
853 {
854 global $wgUser, $wgOut, $wgLang, $wpReason, $wgDeferredUpdateList;
855
856 $fname = "Article::doDeleteArticle";
857 wfDebug( "$fname\n" );
858
859 $ns = $title->getNamespace();
860 $t = wfStrencode( $title->getDBkey() );
861 $id = $title->getArticleID();
862
863 if ( "" == $t ) {
864 $wgOut->fatalError( wfMsg( "cannotdelete" ) );
865 return;
866 }
867
868 $u = new SiteStatsUpdate( 0, 1, -$this->isCountable( $this->getContent( true ) ) );
869 array_push( $wgDeferredUpdateList, $u );
870
871 # Move article and history to the "archive" table
872 $sql = "INSERT INTO archive (ar_namespace,ar_title,ar_text," .
873 "ar_comment,ar_user,ar_user_text,ar_timestamp,ar_minor_edit," .
874 "ar_flags) SELECT cur_namespace,cur_title,cur_text,cur_comment," .
875 "cur_user,cur_user_text,cur_timestamp,cur_minor_edit,0 FROM cur " .
876 "WHERE cur_namespace={$ns} AND cur_title='{$t}'";
877 wfQuery( $sql, DB_WRITE, $fname );
878
879 $sql = "INSERT INTO archive (ar_namespace,ar_title,ar_text," .
880 "ar_comment,ar_user,ar_user_text,ar_timestamp,ar_minor_edit," .
881 "ar_flags) SELECT old_namespace,old_title,old_text,old_comment," .
882 "old_user,old_user_text,old_timestamp,old_minor_edit,old_flags " .
883 "FROM old WHERE old_namespace={$ns} AND old_title='{$t}'";
884 wfQuery( $sql, DB_WRITE, $fname );
885
886 # Now that it's safely backed up, delete it
887
888 $sql = "DELETE FROM cur WHERE cur_namespace={$ns} AND " .
889 "cur_title='{$t}'";
890 wfQuery( $sql, DB_WRITE, $fname );
891
892 $sql = "DELETE FROM old WHERE old_namespace={$ns} AND " .
893 "old_title='{$t}'";
894 wfQuery( $sql, DB_WRITE, $fname );
895
896 $sql = "DELETE FROM recentchanges WHERE rc_namespace={$ns} AND " .
897 "rc_title='{$t}'";
898 wfQuery( $sql, DB_WRITE, $fname );
899
900 # Finally, clean up the link tables
901
902 if ( 0 != $id ) {
903
904 $t = wfStrencode( $title->getPrefixedDBkey() );
905
906 if ( $wgEnablePersistentLC ) {
907 // Purge related entries in links cache on delete,
908 wfQuery("DELETE linkscc FROM linkscc,links ".
909 "WHERE lcc_title=links.l_from AND l_to={$id}", DB_WRITE);
910 wfQuery("DELETE FROM linkscc WHERE lcc_title='{$t}'", DB_WRITE);
911 }
912
913 $sql = "SELECT l_from FROM links WHERE l_to={$id}";
914 $res = wfQuery( $sql, DB_READ, $fname );
915
916 $sql = "INSERT INTO brokenlinks (bl_from,bl_to) VALUES ";
917 $now = wfTimestampNow();
918 $sql2 = "UPDATE cur SET cur_touched='{$now}' WHERE cur_id IN (";
919 $first = true;
920
921 while ( $s = wfFetchObject( $res ) ) {
922 $nt = Title::newFromDBkey( $s->l_from );
923 $lid = $nt->getArticleID();
924
925 if ( ! $first ) { $sql .= ","; $sql2 .= ","; }
926 $first = false;
927 $sql .= "({$lid},'{$t}')";
928 $sql2 .= "{$lid}";
929 }
930 $sql2 .= ")";
931 if ( ! $first ) {
932 wfQuery( $sql, DB_WRITE, $fname );
933 wfQuery( $sql2, DB_WRITE, $fname );
934 }
935 wfFreeResult( $res );
936
937 $sql = "DELETE FROM links WHERE l_to={$id}";
938 wfQuery( $sql, DB_WRITE, $fname );
939
940 $sql = "DELETE FROM links WHERE l_from='{$t}'";
941 wfQuery( $sql, DB_WRITE, $fname );
942
943 $sql = "DELETE FROM imagelinks WHERE il_from='{$t}'";
944 wfQuery( $sql, DB_WRITE, $fname );
945
946 $sql = "DELETE FROM brokenlinks WHERE bl_from={$id}";
947 wfQuery( $sql, DB_WRITE, $fname );
948 }
949
950 $log = new LogPage( wfMsg( "dellogpage" ), wfMsg( "dellogpagetext" ) );
951 $art = $title->getPrefixedText();
952 $wpReason = wfCleanQueryVar( $wpReason );
953 $log->addEntry( wfMsg( "deletedarticle", $art ), $wpReason );
954
955 # Clear the cached article id so the interface doesn't act like we exist
956 $this->mTitle->resetArticleID( 0 );
957 $this->mTitle->mArticleID = 0;
958 }
959
960 function rollback()
961 {
962 global $wgUser, $wgLang, $wgOut, $from;
963
964 if ( ! $wgUser->isSysop() ) {
965 $wgOut->sysopRequired();
966 return;
967 }
968
969 # Replace all this user's current edits with the next one down
970 $tt = wfStrencode( $this->mTitle->getDBKey() );
971 $n = $this->mTitle->getNamespace();
972
973 # Get the last editor
974 $sql = "SELECT cur_id,cur_user,cur_user_text,cur_comment FROM cur WHERE cur_title='{$tt}' AND cur_namespace={$n}";
975 $res = wfQuery( $sql, DB_READ );
976 if( ($x = wfNumRows( $res )) != 1 ) {
977 # Something wrong
978 $wgOut->addHTML( wfMsg( "notanarticle" ) );
979 return;
980 }
981 $s = wfFetchObject( $res );
982 $ut = wfStrencode( $s->cur_user_text );
983 $uid = $s->cur_user;
984 $pid = $s->cur_id;
985
986 $from = str_replace( '_', ' ', wfCleanQueryVar( $from ) );
987 if( $from != $s->cur_user_text ) {
988 $wgOut->setPageTitle(wfmsg("rollbackfailed"));
989 $wgOut->addWikiText( wfMsg( "alreadyrolled",
990 htmlspecialchars( $this->mTitle->getPrefixedText()),
991 htmlspecialchars( $from ),
992 htmlspecialchars( $s->cur_user_text ) ) );
993 if($s->cur_comment != "") {
994 $wgOut->addHTML(
995 wfMsg("editcomment",
996 htmlspecialchars( $s->cur_comment ) ) );
997 }
998 return;
999 }
1000
1001 # Get the last edit not by this guy
1002 $sql = "SELECT old_text,old_user,old_user_text
1003 FROM old USE INDEX (name_title_timestamp)
1004 WHERE old_namespace={$n} AND old_title='{$tt}'
1005 AND (old_user <> {$uid} OR old_user_text <> '{$ut}')
1006 ORDER BY inverse_timestamp LIMIT 1";
1007 $res = wfQuery( $sql, DB_READ );
1008 if( wfNumRows( $res ) != 1 ) {
1009 # Something wrong
1010 $wgOut->setPageTitle(wfMsg("rollbackfailed"));
1011 $wgOut->addHTML( wfMsg( "cantrollback" ) );
1012 return;
1013 }
1014 $s = wfFetchObject( $res );
1015
1016 # Save it!
1017 $newcomment = wfMsg( "revertpage", $s->old_user_text );
1018 $wgOut->setPagetitle( wfMsg( "actioncomplete" ) );
1019 $wgOut->setRobotpolicy( "noindex,nofollow" );
1020 $wgOut->addHTML( "<h2>" . $newcomment . "</h2>\n<hr>\n" );
1021 $this->updateArticle( $s->old_text, $newcomment, 1, $this->mTitle->userIsWatching() );
1022
1023 $wgOut->returnToMain( false );
1024 }
1025
1026
1027 # Do standard deferred updates after page view
1028
1029 /* private */ function viewUpdates()
1030 {
1031 global $wgDeferredUpdateList;
1032
1033 if ( 0 != $this->getID() ) {
1034 global $wgDisableCounters;
1035 if( !$wgDisableCounters ) {
1036 $u = new ViewCountUpdate( $this->getID() );
1037 array_push( $wgDeferredUpdateList, $u );
1038 $u = new SiteStatsUpdate( 1, 0, 0 );
1039 array_push( $wgDeferredUpdateList, $u );
1040 }
1041 $u = new UserTalkUpdate( 0, $this->mTitle->getNamespace(),
1042 $this->mTitle->getDBkey() );
1043 array_push( $wgDeferredUpdateList, $u );
1044 }
1045 }
1046
1047 # Do standard deferred updates after page edit.
1048 # Every 1000th edit, prune the recent changes table.
1049
1050 /* private */ function editUpdates( $text )
1051 {
1052 global $wgDeferredUpdateList, $wgDBname, $wgMemc;
1053
1054 wfSeedRandom();
1055 if ( 0 == mt_rand( 0, 999 ) ) {
1056 $cutoff = wfUnix2Timestamp( time() - ( 7 * 86400 ) );
1057 $sql = "DELETE FROM recentchanges WHERE rc_timestamp < '{$cutoff}'";
1058 wfQuery( $sql, DB_WRITE );
1059 }
1060 $id = $this->getID();
1061 $title = $this->mTitle->getPrefixedDBkey();
1062 $adj = $this->mCountAdjustment;
1063
1064 if ( 0 != $id ) {
1065 $u = new LinksUpdate( $id, $title );
1066 array_push( $wgDeferredUpdateList, $u );
1067 $u = new SiteStatsUpdate( 0, 1, $adj );
1068 array_push( $wgDeferredUpdateList, $u );
1069 $u = new SearchUpdate( $id, $title, $text );
1070 array_push( $wgDeferredUpdateList, $u );
1071
1072 $u = new UserTalkUpdate( 1, $this->mTitle->getNamespace(),
1073 $this->mTitle->getDBkey() );
1074 array_push( $wgDeferredUpdateList, $u );
1075
1076 if ( $this->getNamespace == NS_MEDIAWIKI ) {
1077 $messageCache = $wgMemc->get( "$wgDBname:messages" );
1078 if (!$messageCache) {
1079 $messageCache = wfLoadAllMessages();
1080 }
1081 $messageCache[$title] = $text;
1082 $wgMemc->set( "$wgDBname:messages" );
1083 }
1084 }
1085 }
1086
1087 /* private */ function setOldSubtitle()
1088 {
1089 global $wgLang, $wgOut;
1090
1091 $td = $wgLang->timeanddate( $this->mTimestamp, true );
1092 $r = wfMsg( "revisionasof", $td );
1093 $wgOut->setSubtitle( "({$r})" );
1094 }
1095
1096 # This function is called right before saving the wikitext,
1097 # so we can do things like signatures and links-in-context.
1098
1099 function preSaveTransform( $text )
1100 {
1101 $s = "";
1102 while ( "" != $text ) {
1103 $p = preg_split( "/<\\s*nowiki\\s*>/i", $text, 2 );
1104 $s .= $this->pstPass2( $p[0] );
1105
1106 if ( ( count( $p ) < 2 ) || ( "" == $p[1] ) ) { $text = ""; }
1107 else {
1108 $q = preg_split( "/<\\/\\s*nowiki\\s*>/i", $p[1], 2 );
1109 $s .= "<nowiki>{$q[0]}</nowiki>";
1110 $text = $q[1];
1111 }
1112 }
1113 return rtrim( $s );
1114 }
1115
1116 /* private */ function pstPass2( $text )
1117 {
1118 global $wgUser, $wgLang, $wgLocaltimezone;
1119
1120 # Signatures
1121 #
1122 $n = $wgUser->getName();
1123 $k = $wgUser->getOption( "nickname" );
1124 if ( "" == $k ) { $k = $n; }
1125 if(isset($wgLocaltimezone)) {
1126 $oldtz = getenv("TZ"); putenv("TZ=$wgLocaltimezone");
1127 }
1128 /* Note: this is an ugly timezone hack for the European wikis */
1129 $d = $wgLang->timeanddate( date( "YmdHis" ), false ) .
1130 " (" . date( "T" ) . ")";
1131 if(isset($wgLocaltimezone)) putenv("TZ=$oldtz");
1132
1133 $text = preg_replace( "/~~~~/", "[[" . $wgLang->getNsText(
1134 Namespace::getUser() ) . ":$n|$k]] $d", $text );
1135 $text = preg_replace( "/~~~/", "[[" . $wgLang->getNsText(
1136 Namespace::getUser() ) . ":$n|$k]]", $text );
1137
1138 # Context links: [[|name]] and [[name (context)|]]
1139 #
1140 $tc = "[&;%\\-,.\\(\\)' _0-9A-Za-z\\/:\\x80-\\xff]";
1141 $np = "[&;%\\-,.' _0-9A-Za-z\\/:\\x80-\\xff]"; # No parens
1142 $namespacechar = '[ _0-9A-Za-z\x80-\xff]'; # Namespaces can use non-ascii!
1143 $conpat = "/^({$np}+) \\(({$tc}+)\\)$/";
1144
1145 $p1 = "/\[\[({$np}+) \\(({$np}+)\\)\\|]]/"; # [[page (context)|]]
1146 $p2 = "/\[\[\\|({$tc}+)]]/"; # [[|page]]
1147 $p3 = "/\[\[($namespacechar+):({$np}+)\\|]]/"; # [[namespace:page|]]
1148 $p4 = "/\[\[($namespacechar+):({$np}+) \\(({$np}+)\\)\\|]]/";
1149 # [[ns:page (cont)|]]
1150 $context = "";
1151 $t = $this->mTitle->getText();
1152 if ( preg_match( $conpat, $t, $m ) ) {
1153 $context = $m[2];
1154 }
1155 $text = preg_replace( $p4, "[[\\1:\\2 (\\3)|\\2]]", $text );
1156 $text = preg_replace( $p1, "[[\\1 (\\2)|\\1]]", $text );
1157 $text = preg_replace( $p3, "[[\\1:\\2|\\2]]", $text );
1158
1159 if ( "" == $context ) {
1160 $text = preg_replace( $p2, "[[\\1]]", $text );
1161 } else {
1162 $text = preg_replace( $p2, "[[\\1 ({$context})|\\1]]", $text );
1163 }
1164
1165 # {{SUBST:xxx}} variables
1166 #
1167 $mw =& MagicWord::get( MAG_SUBST );
1168 $text = $mw->substituteCallback( $text, "wfReplaceSubstVar" );
1169
1170 return $text;
1171 }
1172
1173 /* Caching functions */
1174
1175 function tryFileCache() {
1176 static $called = false;
1177 if( $called ) {
1178 wfDebug( " tryFileCache() -- called twice!?\n" );
1179 return;
1180 }
1181 $called = true;
1182 if($this->isFileCacheable()) {
1183 $touched = $this->mTouched;
1184 if( strpos( $this->mContent, "{{" ) !== false ) {
1185 # Expire pages with variable replacements in an hour
1186 $expire = wfUnix2Timestamp( time() - 3600 );
1187 $touched = max( $expire, $touched );
1188 }
1189 $cache = new CacheManager( $this->mTitle );
1190 if($cache->isFileCacheGood( $touched )) {
1191 global $wgOut;
1192 wfDebug( " tryFileCache() - about to load\n" );
1193 $cache->loadFromFileCache();
1194 $wgOut->reportTime(); # For profiling
1195 exit;
1196 } else {
1197 wfDebug( " tryFileCache() - starting buffer\n" );
1198 if($cache->useGzip() && wfClientAcceptsGzip()) {
1199 /* For some reason, adding this header line over in
1200 CacheManager::saveToFileCache() fails on my test
1201 setup at home, though it works on the live install.
1202 Make double-sure... --brion */
1203 header( "Content-Encoding: gzip" );
1204 }
1205 ob_start( array(&$cache, 'saveToFileCache' ) );
1206 }
1207 } else {
1208 wfDebug( " tryFileCache() - not cacheable\n" );
1209 }
1210 }
1211
1212 function isFileCacheable() {
1213 global $wgUser, $wgUseFileCache, $wgShowIPinHeader;
1214 global $action, $oldid, $diff, $redirect, $printable;
1215 return $wgUseFileCache
1216 and (!$wgShowIPinHeader)
1217 and ($this->getID() != 0)
1218 and ($wgUser->getId() == 0)
1219 and (!$wgUser->getNewtalk())
1220 and ($this->mTitle->getNamespace != Namespace::getSpecial())
1221 and ($action == "view")
1222 and (!isset($oldid))
1223 and (!isset($diff))
1224 and (!isset($redirect))
1225 and (!isset($printable))
1226 and (!$this->mRedirectedFrom);
1227 }
1228
1229 function checkTouched() {
1230 $id = $this->getID();
1231 $sql = "SELECT cur_touched,cur_is_redirect FROM cur WHERE cur_id=$id";
1232 $res = wfQuery( $sql, DB_READ, "Article::checkTouched" );
1233 if( $s = wfFetchObject( $res ) ) {
1234 $this->mTouched = $s->cur_touched;
1235 return !$s->cur_is_redirect;
1236 } else {
1237 return false;
1238 }
1239 }
1240 }
1241
1242 function wfReplaceSubstVar( $matches ) {
1243 return wfMsg( $matches[1] );
1244 }
1245
1246 ?>