BUG#76 For categories, don't use the Category:-prefix for the sortkey.
[lhc/web/wiklou.git] / includes / Title.php
1 <?php
2 /**
3 * $Id$
4 * See title.doc
5 *
6 * @package MediaWiki
7 */
8
9 /** */
10 require_once( 'normal/UtfNormal.php' );
11
12 /**
13 *
14 */
15 $wgTitleInterwikiCache = array();
16 define ( 'GAID_FOR_UPDATE', 1 );
17
18 /**
19 * Title class
20 * - Represents a title, which may contain an interwiki designation or namespace
21 * - Can fetch various kinds of data from the database, albeit inefficiently.
22 *
23 * @todo migrate comments to phpdoc format
24 * @package MediaWiki
25 */
26 class Title {
27 # All member variables should be considered private
28 # Please use the accessor functions
29
30 var $mTextform; # Text form (spaces not underscores) of the main part
31 var $mUrlform; # URL-encoded form of the main part
32 var $mDbkeyform; # Main part with underscores
33 var $mNamespace; # Namespace index, i.e. one of the NS_xxxx constants
34 var $mInterwiki; # Interwiki prefix (or null string)
35 var $mFragment; # Title fragment (i.e. the bit after the #)
36 var $mArticleID; # Article ID, fetched from the link cache on demand
37 var $mRestrictions; # Array of groups allowed to edit this article
38 # Only null or "sysop" are supported
39 var $mRestrictionsLoaded; # Boolean for initialisation on demand
40 var $mPrefixedText; # Text form including namespace/interwiki, initialised on demand
41 var $mDefaultNamespace; # Namespace index when there is no namespace
42 # Zero except in {{transclusion}} tags
43
44 #----------------------------------------------------------------------------
45 # Construction
46 #----------------------------------------------------------------------------
47
48 /* private */ function Title() {
49 $this->mInterwiki = $this->mUrlform =
50 $this->mTextform = $this->mDbkeyform = '';
51 $this->mArticleID = -1;
52 $this->mNamespace = 0;
53 $this->mRestrictionsLoaded = false;
54 $this->mRestrictions = array();
55 $this->mDefaultNamespace = 0;
56 }
57
58 # From a prefixed DB key
59 /* static */ function newFromDBkey( $key ) {
60 $t = new Title();
61 $t->mDbkeyform = $key;
62 if( $t->secureAndSplit() )
63 return $t;
64 else
65 return NULL;
66 }
67
68 # From text, such as what you would find in a link
69 /* static */ function newFromText( $text, $defaultNamespace = 0 ) {
70 $fname = 'Title::newFromText';
71 wfProfileIn( $fname );
72
73 if( is_object( $text ) ) {
74 wfDebugDieBacktrace( 'Called with object instead of string.' );
75 }
76 global $wgInputEncoding;
77 $text = do_html_entity_decode( $text, ENT_COMPAT, $wgInputEncoding );
78
79 $text = wfMungeToUtf8( $text );
80
81
82 # What was this for? TS 2004-03-03
83 # $text = urldecode( $text );
84
85 $t = new Title();
86 $t->mDbkeyform = str_replace( ' ', '_', $text );
87 $t->mDefaultNamespace = $defaultNamespace;
88
89 wfProfileOut( $fname );
90 if ( !is_object( $t ) ) {
91 var_dump( debug_backtrace() );
92 }
93 if( $t->secureAndSplit() ) {
94 return $t;
95 } else {
96 return NULL;
97 }
98 }
99
100 # From a URL-encoded title
101 /* static */ function newFromURL( $url ) {
102 global $wgLang, $wgServer;
103 $t = new Title();
104
105 # For compatibility with old buggy URLs. "+" is not valid in titles,
106 # but some URLs used it as a space replacement and they still come
107 # from some external search tools.
108 $s = str_replace( '+', ' ', $url );
109
110 $t->mDbkeyform = str_replace( ' ', '_', $s );
111 if( $t->secureAndSplit() ) {
112 # check that length of title is < cur_title size
113 $dbr =& wfGetDB( DB_SLAVE );
114 $maxSize = $dbr->textFieldSize( 'cur', 'cur_title' );
115 if ( $maxSize != -1 && strlen( $t->mDbkeyform ) > $maxSize ) {
116 return NULL;
117 }
118
119 return $t;
120 } else {
121 return NULL;
122 }
123 }
124
125 # From a cur_id
126 # This is inefficiently implemented, the cur row is requested but not
127 # used for anything else
128 /* static */ function newFromID( $id ) {
129 $fname = 'Title::newFromID';
130 $dbr =& wfGetDB( DB_SLAVE );
131 $row = $dbr->getArray( 'cur', array( 'cur_namespace', 'cur_title' ),
132 array( 'cur_id' => $id ), $fname );
133 if ( $row !== false ) {
134 $title = Title::makeTitle( $row->cur_namespace, $row->cur_title );
135 } else {
136 $title = NULL;
137 }
138 return $title;
139 }
140
141 # From a namespace index and a DB key.
142 # It's assumed that $ns and $title are *valid*, for instance when
143 # they came directly from the database or a special page name.
144 /* static */ function &makeTitle( $ns, $title ) {
145 $t =& new Title();
146 $t->mInterwiki = '';
147 $t->mFragment = '';
148 $t->mNamespace = $ns;
149 $t->mDbkeyform = $title;
150 $t->mArticleID = ( $ns >= 0 ) ? 0 : -1;
151 $t->mUrlform = wfUrlencode( $title );
152 $t->mTextform = str_replace( '_', ' ', $title );
153 return $t;
154 }
155
156 # From a namespace index and a DB key.
157 # These will be checked for validity, which is a bit slower
158 # than makeTitle() but safer for user-provided data.
159 /* static */ function makeTitleSafe( $ns, $title ) {
160 $t = new Title();
161 $t->mDbkeyform = Title::makeName( $ns, $title );
162 if( $t->secureAndSplit() ) {
163 return $t;
164 } else {
165 return NULL;
166 }
167 }
168
169 /* static */ function newMainPage() {
170 return Title::newFromText( wfMsg( 'mainpage' ) );
171 }
172
173 # Get the title object for a redirect
174 # Returns NULL if the text is not a valid redirect
175 /* static */ function newFromRedirect( $text ) {
176 global $wgMwRedir;
177 $rt = NULL;
178 if ( $wgMwRedir->matchStart( $text ) ) {
179 if ( preg_match( '/\\[\\[([^\\]\\|]+)[\\]\\|]/', $text, $m ) ) {
180 # categories are escaped using : for example one can enter:
181 # #REDIRECT [[:Category:Music]]. Need to remove it.
182 if ( substr($m[1],0,1) == ':') {
183 # We don't want to keep the ':'
184 $m[1] = substr( $m[1], 1 );
185 }
186
187 $rt = Title::newFromText( $m[1] );
188 }
189 }
190 return $rt;
191 }
192
193 #----------------------------------------------------------------------------
194 # Static functions
195 #----------------------------------------------------------------------------
196
197 # Get the prefixed DB key associated with an ID
198 /* static */ function nameOf( $id ) {
199 $fname = 'Title::nameOf';
200 $dbr =& wfGetDB( DB_SLAVE );
201
202 $s = $dbr->getArray( 'cur', array( 'cur_namespace','cur_title' ), array( 'cur_id' => $id ), $fname );
203 if ( $s === false ) { return NULL; }
204
205 $n = Title::makeName( $s->cur_namespace, $s->cur_title );
206 return $n;
207 }
208
209 # Get a regex character class describing the legal characters in a link
210 /* static */ function legalChars() {
211 # Missing characters:
212 # * []|# Needed for link syntax
213 # * % and + are corrupted by Apache when they appear in the path
214 #
215 # % seems to work though
216 #
217 # The problem with % is that URLs are double-unescaped: once by Apache's
218 # path conversion code, and again by PHP. So %253F, for example, becomes "?".
219 # Our code does not double-escape to compensate for this, indeed double escaping
220 # would break if the double-escaped title was passed in the query string
221 # rather than the path. This is a minor security issue because articles can be
222 # created such that they are hard to view or edit. -- TS
223 #
224 # Theoretically 0x80-0x9F of ISO 8859-1 should be disallowed, but
225 # this breaks interlanguage links
226
227 $set = " %!\"$&'()*,\\-.\\/0-9:;=?@A-Z\\\\^_`a-z{}~\\x80-\\xFF";
228 return $set;
229 }
230
231 # Returns a stripped-down a title string ready for the search index
232 # Takes a namespace index and a text-form main part
233 /* static */ function indexTitle( $ns, $title ) {
234 global $wgDBminWordLen, $wgLang;
235 require_once( 'SearchEngine.php' );
236
237 $lc = SearchEngine::legalSearchChars() . '&#;';
238 $t = $wgLang->stripForSearch( $title );
239 $t = preg_replace( "/[^{$lc}]+/", ' ', $t );
240 $t = strtolower( $t );
241
242 # Handle 's, s'
243 $t = preg_replace( "/([{$lc}]+)'s( |$)/", "\\1 \\1's ", $t );
244 $t = preg_replace( "/([{$lc}]+)s'( |$)/", "\\1s ", $t );
245
246 $t = preg_replace( "/\\s+/", ' ', $t );
247
248 if ( $ns == Namespace::getImage() ) {
249 $t = preg_replace( "/ (png|gif|jpg|jpeg|ogg)$/", "", $t );
250 }
251 return trim( $t );
252 }
253
254 # Make a prefixed DB key from a DB key and a namespace index
255 /* static */ function makeName( $ns, $title ) {
256 global $wgLang;
257
258 $n = $wgLang->getNsText( $ns );
259 if ( '' == $n ) { return $title; }
260 else { return $n.':'.$title; }
261 }
262
263 # Arguably static
264 # Returns the URL associated with an interwiki prefix
265 # The URL contains $1, which is replaced by the title
266 function getInterwikiLink( $key ) {
267 global $wgMemc, $wgDBname, $wgInterwikiExpiry, $wgTitleInterwikiCache;
268 $fname = 'Title::getInterwikiLink';
269 $k = $wgDBname.':interwiki:'.$key;
270
271 if( array_key_exists( $k, $wgTitleInterwikiCache ) )
272 return $wgTitleInterwikiCache[$k]->iw_url;
273
274 $s = $wgMemc->get( $k );
275 # Ignore old keys with no iw_local
276 if( $s && isset( $s->iw_local ) ) {
277 $wgTitleInterwikiCache[$k] = $s;
278 return $s->iw_url;
279 }
280 $dbr =& wfGetDB( DB_SLAVE );
281 $res = $dbr->select( 'interwiki', array( 'iw_url', 'iw_local' ), array( 'iw_prefix' => $key ), $fname );
282 if(!$res) return '';
283
284 $s = $dbr->fetchObject( $res );
285 if(!$s) {
286 # Cache non-existence: create a blank object and save it to memcached
287 $s = (object)false;
288 $s->iw_url = '';
289 $s->iw_local = 0;
290 }
291 $wgMemc->set( $k, $s, $wgInterwikiExpiry );
292 $wgTitleInterwikiCache[$k] = $s;
293 return $s->iw_url;
294 }
295
296 function isLocal() {
297 global $wgTitleInterwikiCache, $wgDBname;
298
299 if ( $this->mInterwiki != '' ) {
300 # Make sure key is loaded into cache
301 $this->getInterwikiLink( $this->mInterwiki );
302 $k = $wgDBname.':interwiki:' . $this->mInterwiki;
303 return (bool)($wgTitleInterwikiCache[$k]->iw_local);
304 } else {
305 return true;
306 }
307 }
308
309 # Update the cur_touched field for an array of title objects
310 # Inefficient unless the IDs are already loaded into the link cache
311 /* static */ function touchArray( $titles, $timestamp = '' ) {
312 if ( count( $titles ) == 0 ) {
313 return;
314 }
315 $dbw =& wfGetDB( DB_MASTER );
316 if ( $timestamp == '' ) {
317 $timestamp = $dbw->timestamp();
318 }
319 $cur = $dbw->tableName( 'cur' );
320 $sql = "UPDATE $cur SET cur_touched='{$timestamp}' WHERE cur_id IN (";
321 $first = true;
322
323 foreach ( $titles as $title ) {
324 if ( ! $first ) {
325 $sql .= ',';
326 }
327 $first = false;
328 $sql .= $title->getArticleID();
329 }
330 $sql .= ')';
331 if ( ! $first ) {
332 $dbw->query( $sql, 'Title::touchArray' );
333 }
334 }
335
336 #----------------------------------------------------------------------------
337 # Other stuff
338 #----------------------------------------------------------------------------
339
340 # Simple accessors
341 # See the definitions at the top of this file
342
343 function getText() { return $this->mTextform; }
344 function getPartialURL() { return $this->mUrlform; }
345 function getDBkey() { return $this->mDbkeyform; }
346 function getNamespace() { return $this->mNamespace; }
347 function setNamespace( $n ) { $this->mNamespace = $n; }
348 function getInterwiki() { return $this->mInterwiki; }
349 function getFragment() { return $this->mFragment; }
350 function getDefaultNamespace() { return $this->mDefaultNamespace; }
351
352 # Get title for search index
353 function getIndexTitle() {
354 return Title::indexTitle( $this->mNamespace, $this->mTextform );
355 }
356
357 # Get prefixed title with underscores
358 function getPrefixedDBkey() {
359 $s = $this->prefix( $this->mDbkeyform );
360 $s = str_replace( ' ', '_', $s );
361 return $s;
362 }
363
364 # Get prefixed title with spaces
365 # This is the form usually used for display
366 function getPrefixedText() {
367 if ( empty( $this->mPrefixedText ) ) {
368 $s = $this->prefix( $this->mTextform );
369 $s = str_replace( '_', ' ', $s );
370 $this->mPrefixedText = $s;
371 }
372 return $this->mPrefixedText;
373 }
374
375 # As getPrefixedText(), plus fragment.
376 function getFullText() {
377 $text = $this->getPrefixedText();
378 if( '' != $this->mFragment ) {
379 $text .= '#' . $this->mFragment;
380 }
381 return $text;
382 }
383
384 # Get a URL-encoded title (not an actual URL) including interwiki
385 function getPrefixedURL() {
386 $s = $this->prefix( $this->mDbkeyform );
387 $s = str_replace( ' ', '_', $s );
388
389 $s = wfUrlencode ( $s ) ;
390
391 # Cleaning up URL to make it look nice -- is this safe?
392 $s = preg_replace( '/%3[Aa]/', ':', $s );
393 $s = preg_replace( '/%2[Ff]/', '/', $s );
394 $s = str_replace( '%28', '(', $s );
395 $s = str_replace( '%29', ')', $s );
396
397 return $s;
398 }
399
400 # Get a real URL referring to this title, with interwiki link and fragment
401 function getFullURL( $query = '' ) {
402 global $wgLang, $wgArticlePath, $wgServer, $wgScript;
403
404 if ( '' == $this->mInterwiki ) {
405 $p = $wgArticlePath;
406 return $wgServer . $this->getLocalUrl( $query );
407 } else {
408 $baseUrl = $this->getInterwikiLink( $this->mInterwiki );
409 $namespace = $wgLang->getNsText( $this->mNamespace );
410 if ( '' != $namespace ) {
411 # Can this actually happen? Interwikis shouldn't be parsed.
412 $namepace .= ':';
413 }
414 $url = str_replace( '$1', $namespace . $this->mUrlform, $baseUrl );
415 if ( '' != $this->mFragment ) {
416 $url .= '#' . $this->mFragment;
417 }
418 return $url;
419 }
420 }
421
422 # Get a URL with an optional query string, no fragment
423 # * If $query=="", it will use $wgArticlePath
424 # * Returns a full for an interwiki link, loses any query string
425 # * Optionally adds the server and escapes for HTML
426 # * Setting $query to "-" makes an old-style URL with nothing in the
427 # query except a title
428
429 function getURL() {
430 die( 'Call to obsolete obsolete function Title::getURL()' );
431 }
432
433 function getLocalURL( $query = '' ) {
434 global $wgLang, $wgArticlePath, $wgScript;
435
436 if ( $this->isExternal() ) {
437 return $this->getFullURL();
438 }
439
440 $dbkey = wfUrlencode( $this->getPrefixedDBkey() );
441 if ( $query == '' ) {
442 $url = str_replace( '$1', $dbkey, $wgArticlePath );
443 } else {
444 if ( $query == '-' ) {
445 $query = '';
446 }
447 if ( $wgScript != '' ) {
448 $url = "{$wgScript}?title={$dbkey}&{$query}";
449 } else {
450 # Top level wiki
451 $url = "/{$dbkey}?{$query}";
452 }
453 }
454 return $url;
455 }
456
457 function escapeLocalURL( $query = '' ) {
458 return htmlspecialchars( $this->getLocalURL( $query ) );
459 }
460
461 function escapeFullURL( $query = '' ) {
462 return htmlspecialchars( $this->getFullURL( $query ) );
463 }
464
465 function getInternalURL( $query = '' ) {
466 # Used in various Squid-related code, in case we have a different
467 # internal hostname for the server than the exposed one.
468 global $wgInternalServer;
469 return $wgInternalServer . $this->getLocalURL( $query );
470 }
471
472 # Get the edit URL, or a null string if it is an interwiki link
473 function getEditURL() {
474 global $wgServer, $wgScript;
475
476 if ( '' != $this->mInterwiki ) { return ''; }
477 $s = $this->getLocalURL( 'action=edit' );
478
479 return $s;
480 }
481
482 # Get HTML-escaped displayable text
483 # For the title field in <a> tags
484 function getEscapedText() {
485 return htmlspecialchars( $this->getPrefixedText() );
486 }
487
488 # Is the title interwiki?
489 function isExternal() { return ( '' != $this->mInterwiki ); }
490
491 # Does the title correspond to a protected article?
492 function isProtected() {
493 if ( -1 == $this->mNamespace ) { return true; }
494 $a = $this->getRestrictions();
495 if ( in_array( 'sysop', $a ) ) { return true; }
496 return false;
497 }
498
499 # Is the page a log page, i.e. one where the history is messed up by
500 # LogPage.php? This used to be used for suppressing diff links in recent
501 # changes, but now that's done by setting a flag in the recentchanges
502 # table. Hence, this probably is no longer used.
503 function isLog() {
504 if ( $this->mNamespace != Namespace::getWikipedia() ) {
505 return false;
506 }
507 if ( ( 0 == strcmp( wfMsg( 'uploadlogpage' ), $this->mDbkeyform ) ) ||
508 ( 0 == strcmp( wfMsg( 'dellogpage' ), $this->mDbkeyform ) ) ) {
509 return true;
510 }
511 return false;
512 }
513
514 # Is $wgUser is watching this page?
515 function userIsWatching() {
516 global $wgUser;
517
518 if ( -1 == $this->mNamespace ) { return false; }
519 if ( 0 == $wgUser->getID() ) { return false; }
520
521 return $wgUser->isWatched( $this );
522 }
523
524 # Can $wgUser edit this page?
525 function userCanEdit() {
526 global $wgUser;
527 if ( -1 == $this->mNamespace ) { return false; }
528 if ( NS_MEDIAWIKI == $this->mNamespace && !$wgUser->isSysop() ) { return false; }
529 # if ( 0 == $this->getArticleID() ) { return false; }
530 if ( $this->mDbkeyform == '_' ) { return false; }
531 # protect global styles and js
532 if ( NS_MEDIAWIKI == $this->mNamespace
533 && preg_match("/\\.(css|js)$/", $this->mTextform )
534 && !$wgUser->isSysop() )
535 { return false; }
536 //if ( $this->isCssJsSubpage() and !$this->userCanEditCssJsSubpage() ) { return false; }
537 # protect css/js subpages of user pages
538 # XXX: this might be better using restrictions
539 # XXX: Find a way to work around the php bug that prevents using $this->userCanEditCssJsSubpage() from working
540 if( Namespace::getUser() == $this->mNamespace
541 and preg_match("/\\.(css|js)$/", $this->mTextform )
542 and !$wgUser->isSysop()
543 and !preg_match('/^'.preg_quote($wgUser->getName(), '/').'/', $this->mTextform) )
544 { return false; }
545 $ur = $wgUser->getRights();
546 foreach ( $this->getRestrictions() as $r ) {
547 if ( '' != $r && ( ! in_array( $r, $ur ) ) ) {
548 return false;
549 }
550 }
551 return true;
552 }
553
554 function userCanRead() {
555 global $wgUser;
556 global $wgWhitelistRead;
557
558 if( 0 != $wgUser->getID() ) return true;
559 if( !is_array( $wgWhitelistRead ) ) return true;
560
561 $name = $this->getPrefixedText();
562 if( in_array( $name, $wgWhitelistRead ) ) return true;
563
564 # Compatibility with old settings
565 if( $this->getNamespace() == NS_MAIN ) {
566 if( in_array( ':' . $name, $wgWhitelistRead ) ) return true;
567 }
568 return false;
569 }
570
571 function isCssJsSubpage() {
572 return ( Namespace::getUser() == $this->mNamespace and preg_match("/\\.(css|js)$/", $this->mTextform ) );
573 }
574 function isCssSubpage() {
575 return ( Namespace::getUser() == $this->mNamespace and preg_match("/\\.css$/", $this->mTextform ) );
576 }
577 function isJsSubpage() {
578 return ( Namespace::getUser() == $this->mNamespace and preg_match("/\\.js$/", $this->mTextform ) );
579 }
580 function userCanEditCssJsSubpage() {
581 # protect css/js subpages of user pages
582 # XXX: this might be better using restrictions
583 global $wgUser;
584 return ( $wgUser->isSysop() or preg_match('/^'.preg_quote($wgUser->getName()).'/', $this->mTextform) );
585 }
586
587 # Accessor/initialisation for mRestrictions
588 function getRestrictions() {
589 $id = $this->getArticleID();
590 if ( 0 == $id ) { return array(); }
591
592 if ( ! $this->mRestrictionsLoaded ) {
593 $dbr =& wfGetDB( DB_SLAVE );
594 $res = $dbr->getField( 'cur', 'cur_restrictions', 'cur_id='.$id );
595 $this->mRestrictions = explode( ',', trim( $res ) );
596 $this->mRestrictionsLoaded = true;
597 }
598 return $this->mRestrictions;
599 }
600
601 # Is there a version of this page in the deletion archive?
602 # Returns the number of archived revisions
603 function isDeleted() {
604 $fname = 'Title::isDeleted';
605 $dbr =& wfGetDB( DB_SLAVE );
606 $n = $dbr->getField( 'archive', 'COUNT(*)', array( 'ar_namespace' => $this->getNamespace(),
607 'ar_title' => $this->getDBkey() ), $fname );
608 return (int)$n;
609 }
610
611 # Get the article ID from the link cache
612 # $flags is a bit field, may be GAID_FOR_UPDATE to select for update
613 function getArticleID( $flags = 0 ) {
614 global $wgLinkCache;
615
616 if ( $flags & GAID_FOR_UPDATE ) {
617 $oldUpdate = $wgLinkCache->forUpdate( true );
618 $this->mArticleID = $wgLinkCache->addLinkObj( $this );
619 $wgLinkCache->forUpdate( $oldUpdate );
620 } else {
621 if ( -1 == $this->mArticleID ) {
622 $this->mArticleID = $wgLinkCache->addLinkObj( $this );
623 }
624 }
625 return $this->mArticleID;
626 }
627
628 # This clears some fields in this object, and clears any associated keys in the
629 # "bad links" section of $wgLinkCache. This is called from Article::insertNewArticle()
630 # to allow loading of the new cur_id. It's also called from Article::doDeleteArticle()
631 function resetArticleID( $newid ) {
632 global $wgLinkCache;
633 $wgLinkCache->clearBadLink( $this->getPrefixedDBkey() );
634
635 if ( 0 == $newid ) { $this->mArticleID = -1; }
636 else { $this->mArticleID = $newid; }
637 $this->mRestrictionsLoaded = false;
638 $this->mRestrictions = array();
639 }
640
641 # Updates cur_touched
642 # Called from LinksUpdate.php
643 function invalidateCache() {
644 $now = wfTimestampNow();
645 $dbw =& wfGetDB( DB_MASTER );
646 $success = $dbw->updateArray( 'cur',
647 array( /* SET */
648 'cur_touched' => $dbw->timestamp()
649 ), array( /* WHERE */
650 'cur_namespace' => $this->getNamespace() ,
651 'cur_title' => $this->getDBkey()
652 ), 'Title::invalidateCache'
653 );
654 return $success;
655 }
656
657 # Prefixes some arbitrary text with the namespace or interwiki prefix of this object
658 /* private */ function prefix( $name ) {
659 global $wgLang;
660
661 $p = '';
662 if ( '' != $this->mInterwiki ) {
663 $p = $this->mInterwiki . ':';
664 }
665 if ( 0 != $this->mNamespace ) {
666 $p .= $wgLang->getNsText( $this->mNamespace ) . ':';
667 }
668 return $p . $name;
669 }
670
671 # Secure and split - main initialisation function for this object
672 #
673 # Assumes that mDbkeyform has been set, and is urldecoded
674 # and uses underscores, but not otherwise munged. This function
675 # removes illegal characters, splits off the interwiki and
676 # namespace prefixes, sets the other forms, and canonicalizes
677 # everything.
678 #
679 /* private */ function secureAndSplit()
680 {
681 global $wgLang, $wgLocalInterwiki, $wgCapitalLinks;
682 $fname = 'Title::secureAndSplit';
683 wfProfileIn( $fname );
684
685 static $imgpre = false;
686 static $rxTc = false;
687
688 # Initialisation
689 if ( $imgpre === false ) {
690 $imgpre = ':' . $wgLang->getNsText( Namespace::getImage() ) . ':';
691 # % is needed as well
692 $rxTc = '/[^' . Title::legalChars() . ']/';
693 }
694
695 $this->mInterwiki = $this->mFragment = '';
696 $this->mNamespace = $this->mDefaultNamespace; # Usually NS_MAIN
697
698 # Clean up whitespace
699 #
700 $t = preg_replace( "/[\\s_]+/", '_', $this->mDbkeyform );
701 $t = preg_replace( '/^_*(.*?)_*$/', '$1', $t );
702
703 if ( '' == $t ) {
704 wfProfileOut( $fname );
705 return false;
706 }
707
708 global $wgUseLatin1;
709 if( !$wgUseLatin1 && false !== strpos( $t, UTF8_REPLACEMENT ) ) {
710 # Contained illegal UTF-8 sequences or forbidden Unicode chars.
711 wfProfileOut( $fname );
712 return false;
713 }
714
715 $this->mDbkeyform = $t;
716 $done = false;
717
718 # :Image: namespace
719 if ( 0 == strncasecmp( $imgpre, $t, strlen( $imgpre ) ) ) {
720 $t = substr( $t, 1 );
721 }
722
723 # Initial colon indicating main namespace
724 if ( ':' == $t{0} ) {
725 $r = substr( $t, 1 );
726 $this->mNamespace = NS_MAIN;
727 } else {
728 # Namespace or interwiki prefix
729 if ( preg_match( "/^(.+?)_*:_*(.*)$/", $t, $m ) ) {
730 #$p = strtolower( $m[1] );
731 $p = $m[1];
732 $lowerNs = strtolower( $p );
733 if ( $ns = Namespace::getCanonicalIndex( $lowerNs ) ) {
734 # Canonical namespace
735 $t = $m[2];
736 $this->mNamespace = $ns;
737 } elseif ( $ns = $wgLang->getNsIndex( $lowerNs )) {
738 # Ordinary namespace
739 $t = $m[2];
740 $this->mNamespace = $ns;
741 } elseif ( $this->getInterwikiLink( $p ) ) {
742 # Interwiki link
743 $t = $m[2];
744 $this->mInterwiki = $p;
745
746 if ( !preg_match( "/^([A-Za-z0-9_\\x80-\\xff]+):(.*)$/", $t, $m ) ) {
747 $done = true;
748 } elseif($this->mInterwiki != $wgLocalInterwiki) {
749 $done = true;
750 }
751 }
752 }
753 $r = $t;
754 }
755
756 # Redundant interwiki prefix to the local wiki
757 if ( 0 == strcmp( $this->mInterwiki, $wgLocalInterwiki ) ) {
758 $this->mInterwiki = '';
759 }
760 # We already know that some pages won't be in the database!
761 #
762 if ( '' != $this->mInterwiki || -1 == $this->mNamespace ) {
763 $this->mArticleID = 0;
764 }
765 $f = strstr( $r, '#' );
766 if ( false !== $f ) {
767 $this->mFragment = substr( $f, 1 );
768 $r = substr( $r, 0, strlen( $r ) - strlen( $f ) );
769 }
770
771 # Reject illegal characters.
772 #
773 if( preg_match( $rxTc, $r ) ) {
774 wfProfileOut( $fname );
775 return false;
776 }
777
778 # "." and ".." conflict with the directories of those namesa
779 if ( strpos( $r, '.' ) !== false &&
780 ( $r === '.' || $r === '..' ||
781 strpos( $r, './' ) === 0 ||
782 strpos( $r, '../' ) === 0 ||
783 strpos( $r, '/./' ) !== false ||
784 strpos( $r, '/../' ) !== false ) )
785 {
786 wfProfileOut( $fname );
787 return false;
788 }
789
790 # Initial capital letter
791 if( $wgCapitalLinks && $this->mInterwiki == '') {
792 $t = $wgLang->ucfirst( $r );
793 } else {
794 $t = $r;
795 }
796
797 # Fill fields
798 $this->mDbkeyform = $t;
799 $this->mUrlform = wfUrlencode( $t );
800
801 $this->mTextform = str_replace( '_', ' ', $t );
802
803 wfProfileOut( $fname );
804 return true;
805 }
806
807 # Get a title object associated with the talk page of this article
808 function getTalkPage() {
809 return Title::makeTitle( Namespace::getTalk( $this->getNamespace() ), $this->getDBkey() );
810 }
811
812 # Get a title object associated with the subject page of this talk page
813 function getSubjectPage() {
814 return Title::makeTitle( Namespace::getSubject( $this->getNamespace() ), $this->getDBkey() );
815 }
816
817 # Get an array of Title objects linking to this title
818 # Also stores the IDs in the link cache
819 # $options may be FOR UPDATE
820 function getLinksTo( $options = '' ) {
821 global $wgLinkCache;
822 $id = $this->getArticleID();
823
824 if ( $options ) {
825 $db =& wfGetDB( DB_MASTER );
826 } else {
827 $db =& wfGetDB( DB_SLAVE );
828 }
829 $cur = $db->tableName( 'cur' );
830 $links = $db->tableName( 'links' );
831
832 $sql = "SELECT cur_namespace,cur_title,cur_id FROM $cur,$links WHERE l_from=cur_id AND l_to={$id} $options";
833 $res = $db->query( $sql, 'Title::getLinksTo' );
834 $retVal = array();
835 if ( $db->numRows( $res ) ) {
836 while ( $row = $db->fetchObject( $res ) ) {
837 if ( $titleObj = Title::makeTitle( $row->cur_namespace, $row->cur_title ) ) {
838 $wgLinkCache->addGoodLink( $row->cur_id, $titleObj->getPrefixedDBkey() );
839 $retVal[] = $titleObj;
840 }
841 }
842 }
843 $db->freeResult( $res );
844 return $retVal;
845 }
846
847 # Get an array of Title objects linking to this non-existent title
848 # Also stores the IDs in the link cache
849 function getBrokenLinksTo( $options = '' ) {
850 global $wgLinkCache;
851
852 if ( $options ) {
853 $db =& wfGetDB( DB_MASTER );
854 } else {
855 $db =& wfGetDB( DB_SLAVE );
856 }
857 $cur = $db->tableName( 'cur' );
858 $brokenlinks = $db->tableName( 'brokenlinks' );
859 $encTitle = $db->strencode( $this->getPrefixedDBkey() );
860
861 $sql = "SELECT cur_namespace,cur_title,cur_id FROM $brokenlinks,$cur " .
862 "WHERE bl_from=cur_id AND bl_to='$encTitle' $options";
863 $res = $db->query( $sql, "Title::getBrokenLinksTo" );
864 $retVal = array();
865 if ( $db->numRows( $res ) ) {
866 while ( $row = $db->fetchObject( $res ) ) {
867 $titleObj = Title::makeTitle( $row->cur_namespace, $row->cur_title );
868 $wgLinkCache->addGoodLink( $row->cur_id, $titleObj->getPrefixedDBkey() );
869 $retVal[] = $titleObj;
870 }
871 }
872 $db->freeResult( $res );
873 return $retVal;
874 }
875
876 function getSquidURLs() {
877 return array(
878 $this->getInternalURL(),
879 $this->getInternalURL( 'action=history' )
880 );
881 }
882
883 function moveNoAuth( &$nt ) {
884 return $this->moveTo( $nt, false );
885 }
886
887 # Move a title to a new location
888 # Returns true on success, message name on failure
889 # auth indicates whether wgUser's permissions should be checked
890 function moveTo( &$nt, $auth = true ) {
891 if( !$this or !$nt ) {
892 return 'badtitletext';
893 }
894
895 $fname = 'Title::move';
896 $oldid = $this->getArticleID();
897 $newid = $nt->getArticleID();
898
899 if ( strlen( $nt->getDBkey() ) < 1 ) {
900 return 'articleexists';
901 }
902 if ( ( ! Namespace::isMovable( $this->getNamespace() ) ) ||
903 ( '' == $this->getDBkey() ) ||
904 ( '' != $this->getInterwiki() ) ||
905 ( !$oldid ) ||
906 ( ! Namespace::isMovable( $nt->getNamespace() ) ) ||
907 ( '' == $nt->getDBkey() ) ||
908 ( '' != $nt->getInterwiki() ) ) {
909 return 'badarticleerror';
910 }
911
912 if ( $auth && ( !$this->userCanEdit() || !$nt->userCanEdit() ) ) {
913 return 'protectedpage';
914 }
915
916 # The move is allowed only if (1) the target doesn't exist, or
917 # (2) the target is a redirect to the source, and has no history
918 # (so we can undo bad moves right after they're done).
919
920 if ( 0 != $newid ) { # Target exists; check for validity
921 if ( ! $this->isValidMoveTarget( $nt ) ) {
922 return 'articleexists';
923 }
924 $this->moveOverExistingRedirect( $nt );
925 } else { # Target didn't exist, do normal move.
926 $this->moveToNewTitle( $nt, $newid );
927 }
928
929 # Fixing category links (those without piped 'alternate' names) to be sorted under the new title
930
931 $dbw =& wfGetDB( DB_MASTER );
932 $sql = "UPDATE categorylinks SET cl_sortkey=" . $dbw->addQuotes( $nt->getPrefixedText() ) .
933 " WHERE cl_from=" . $dbw->addQuotes( $this->getArticleID() ) .
934 " AND cl_sortkey=" . $dbw->addQuotes( $this->getPrefixedText() );
935 $dbw->query( $sql, 'SpecialMovepage::doSubmit' );
936
937 # Update watchlists
938
939 $oldnamespace = $this->getNamespace() & ~1;
940 $newnamespace = $nt->getNamespace() & ~1;
941 $oldtitle = $this->getDBkey();
942 $newtitle = $nt->getDBkey();
943
944 if( $oldnamespace != $newnamespace || $oldtitle != $newtitle ) {
945 WatchedItem::duplicateEntries( $this, $nt );
946 }
947
948 # Update search engine
949 $u = new SearchUpdate( $oldid, $nt->getPrefixedDBkey() );
950 $u->doUpdate();
951 $u = new SearchUpdate( $newid, $this->getPrefixedDBkey(), '' );
952 $u->doUpdate();
953
954 return true;
955 }
956
957 # Move page to title which is presently a redirect to the source page
958
959 /* private */ function moveOverExistingRedirect( &$nt ) {
960 global $wgUser, $wgLinkCache, $wgUseSquid, $wgMwRedir;
961 $fname = 'Title::moveOverExistingRedirect';
962 $comment = wfMsg( '1movedto2', $this->getPrefixedText(), $nt->getPrefixedText() );
963
964 $now = wfTimestampNow();
965 $won = wfInvertTimestamp( $now );
966 $newid = $nt->getArticleID();
967 $oldid = $this->getArticleID();
968 $dbw =& wfGetDB( DB_MASTER );
969 $links = $dbw->tableName( 'links' );
970
971 # Change the name of the target page:
972 $dbw->updateArray( 'cur',
973 /* SET */ array(
974 'cur_touched' => $dbw->timestamp($now),
975 'cur_namespace' => $nt->getNamespace(),
976 'cur_title' => $nt->getDBkey()
977 ),
978 /* WHERE */ array( 'cur_id' => $oldid ),
979 $fname
980 );
981 $wgLinkCache->clearLink( $nt->getPrefixedDBkey() );
982
983 # Repurpose the old redirect. We don't save it to history since
984 # by definition if we've got here it's rather uninteresting.
985
986 $redirectText = $wgMwRedir->getSynonym( 0 ) . ' [[' . $nt->getPrefixedText() . "]]\n";
987 $dbw->updateArray( 'cur',
988 /* SET */ array(
989 'cur_touched' => $dbw->timestamp($now),
990 'cur_timestamp' => $dbw->timestamp($now),
991 'inverse_timestamp' => $won,
992 'cur_namespace' => $this->getNamespace(),
993 'cur_title' => $this->getDBkey(),
994 'cur_text' => $wgMwRedir->getSynonym( 0 ) . ' [[' . $nt->getPrefixedText() . "]]\n",
995 'cur_comment' => $comment,
996 'cur_user' => $wgUser->getID(),
997 'cur_minor_edit' => 0,
998 'cur_counter' => 0,
999 'cur_restrictions' => '',
1000 'cur_user_text' => $wgUser->getName(),
1001 'cur_is_redirect' => 1,
1002 'cur_is_new' => 1
1003 ),
1004 /* WHERE */ array( 'cur_id' => $newid ),
1005 $fname
1006 );
1007
1008 $wgLinkCache->clearLink( $this->getPrefixedDBkey() );
1009
1010 # Fix the redundant names for the past revisions of the target page.
1011 # The redirect should have no old revisions.
1012 $dbw->updateArray(
1013 /* table */ 'old',
1014 /* SET */ array(
1015 'old_namespace' => $nt->getNamespace(),
1016 'old_title' => $nt->getDBkey(),
1017 ),
1018 /* WHERE */ array(
1019 'old_namespace' => $this->getNamespace(),
1020 'old_title' => $this->getDBkey(),
1021 ),
1022 $fname
1023 );
1024
1025 RecentChange::notifyMoveOverRedirect( $now, $this, $nt, $wgUser, $comment );
1026
1027 # Swap links
1028
1029 # Load titles and IDs
1030 $linksToOld = $this->getLinksTo( 'FOR UPDATE' );
1031 $linksToNew = $nt->getLinksTo( 'FOR UPDATE' );
1032
1033 # Delete them all
1034 $sql = "DELETE FROM $links WHERE l_to=$oldid OR l_to=$newid";
1035 $dbw->query( $sql, $fname );
1036
1037 # Reinsert
1038 if ( count( $linksToOld ) || count( $linksToNew )) {
1039 $sql = "INSERT INTO $links (l_from,l_to) VALUES ";
1040 $first = true;
1041
1042 # Insert links to old title
1043 foreach ( $linksToOld as $linkTitle ) {
1044 if ( $first ) {
1045 $first = false;
1046 } else {
1047 $sql .= ',';
1048 }
1049 $id = $linkTitle->getArticleID();
1050 $sql .= "($id,$newid)";
1051 }
1052
1053 # Insert links to new title
1054 foreach ( $linksToNew as $linkTitle ) {
1055 if ( $first ) {
1056 $first = false;
1057 } else {
1058 $sql .= ',';
1059 }
1060 $id = $linkTitle->getArticleID();
1061 $sql .= "($id, $oldid)";
1062 }
1063
1064 $dbw->query( $sql, DB_MASTER, $fname );
1065 }
1066
1067 # Now, we record the link from the redirect to the new title.
1068 # It should have no other outgoing links...
1069 $dbw->delete( 'links', array( 'l_from' => $newid ) );
1070 $dbw->insertArray( 'links', array( 'l_from' => $newid, 'l_to' => $oldid ) );
1071
1072 # Clear linkscc
1073 LinkCache::linksccClearLinksTo( $oldid );
1074 LinkCache::linksccClearLinksTo( $newid );
1075
1076 # Purge squid
1077 if ( $wgUseSquid ) {
1078 $urls = array_merge( $nt->getSquidURLs(), $this->getSquidURLs() );
1079 $u = new SquidUpdate( $urls );
1080 $u->doUpdate();
1081 }
1082 }
1083
1084 # Move page to non-existing title.
1085 # Sets $newid to be the new article ID
1086
1087 /* private */ function moveToNewTitle( &$nt, &$newid ) {
1088 global $wgUser, $wgLinkCache, $wgUseSquid;
1089 $fname = 'MovePageForm::moveToNewTitle';
1090 $comment = wfMsg( '1movedto2', $this->getPrefixedText(), $nt->getPrefixedText() );
1091
1092 $newid = $nt->getArticleID();
1093 $oldid = $this->getArticleID();
1094 $dbw =& wfGetDB( DB_MASTER );
1095 $now = $dbw->timestamp();
1096 $won = wfInvertTimestamp( wfTimestamp(TS_MW,$now) );
1097
1098 # Rename cur entry
1099 $dbw->updateArray( 'cur',
1100 /* SET */ array(
1101 'cur_touched' => $now,
1102 'cur_namespace' => $nt->getNamespace(),
1103 'cur_title' => $nt->getDBkey()
1104 ),
1105 /* WHERE */ array( 'cur_id' => $oldid ),
1106 $fname
1107 );
1108
1109 $wgLinkCache->clearLink( $nt->getPrefixedDBkey() );
1110
1111 # Insert redirect
1112 $dbw->insertArray( 'cur', array(
1113 'cur_id' => $dbw->nextSequenceValue('cur_cur_id_seq'),
1114 'cur_namespace' => $this->getNamespace(),
1115 'cur_title' => $this->getDBkey(),
1116 'cur_comment' => $comment,
1117 'cur_user' => $wgUser->getID(),
1118 'cur_user_text' => $wgUser->getName(),
1119 'cur_timestamp' => $now,
1120 'inverse_timestamp' => $won,
1121 'cur_touched' => $now,
1122 'cur_is_redirect' => 1,
1123 'cur_is_new' => 1,
1124 'cur_text' => "#REDIRECT [[" . $nt->getPrefixedText() . "]]\n" ), $fname
1125 );
1126 $newid = $dbw->insertId();
1127 $wgLinkCache->clearLink( $this->getPrefixedDBkey() );
1128
1129 # Rename old entries
1130 $dbw->updateArray(
1131 /* table */ 'old',
1132 /* SET */ array(
1133 'old_namespace' => $nt->getNamespace(),
1134 'old_title' => $nt->getDBkey()
1135 ),
1136 /* WHERE */ array(
1137 'old_namespace' => $this->getNamespace(),
1138 'old_title' => $this->getDBkey()
1139 ), $fname
1140 );
1141
1142 # Record in RC
1143 RecentChange::notifyMoveToNew( $now, $this, $nt, $wgUser, $comment );
1144
1145 # Purge squid and linkscc as per article creation
1146 Article::onArticleCreate( $nt );
1147
1148 # Any text links to the old title must be reassigned to the redirect
1149 $dbw->updateArray( 'links', array( 'l_to' => $newid ), array( 'l_to' => $oldid ), $fname );
1150 LinkCache::linksccClearLinksTo( $oldid );
1151
1152 # Record the just-created redirect's linking to the page
1153 $dbw->insertArray( 'links', array( 'l_from' => $newid, 'l_to' => $oldid ), $fname );
1154
1155 # Non-existent target may have had broken links to it; these must
1156 # now be removed and made into good links.
1157 $update = new LinksUpdate( $oldid, $nt->getPrefixedDBkey() );
1158 $update->fixBrokenLinks();
1159
1160 # Purge old title from squid
1161 # The new title, and links to the new title, are purged in Article::onArticleCreate()
1162 $titles = $nt->getLinksTo();
1163 if ( $wgUseSquid ) {
1164 $urls = $this->getSquidURLs();
1165 foreach ( $titles as $linkTitle ) {
1166 $urls[] = $linkTitle->getInternalURL();
1167 }
1168 $u = new SquidUpdate( $urls );
1169 $u->doUpdate();
1170 }
1171 }
1172
1173 # Checks if $this can be moved to $nt
1174 # Selects for update, so don't call it unless you mean business
1175 function isValidMoveTarget( $nt ) {
1176 $fname = 'Title::isValidMoveTarget';
1177 $dbw =& wfGetDB( DB_MASTER );
1178
1179 # Is it a redirect?
1180 $id = $nt->getArticleID();
1181 $obj = $dbw->getArray( 'cur', array( 'cur_is_redirect','cur_text' ),
1182 array( 'cur_id' => $id ), $fname, 'FOR UPDATE' );
1183
1184 if ( !$obj || 0 == $obj->cur_is_redirect ) {
1185 # Not a redirect
1186 return false;
1187 }
1188
1189 # Does the redirect point to the source?
1190 if ( preg_match( "/\\[\\[\\s*([^\\]\\|]*)]]/", $obj->cur_text, $m ) ) {
1191 $redirTitle = Title::newFromText( $m[1] );
1192 if( !is_object( $redirTitle ) ||
1193 $redirTitle->getPrefixedDBkey() != $this->getPrefixedDBkey() ) {
1194 return false;
1195 }
1196 }
1197
1198 # Does the article have a history?
1199 $row = $dbw->getArray( 'old', array( 'old_id' ),
1200 array(
1201 'old_namespace' => $nt->getNamespace(),
1202 'old_title' => $nt->getDBkey()
1203 ), $fname, 'FOR UPDATE'
1204 );
1205
1206 # Return true if there was no history
1207 return $row === false;
1208 }
1209
1210 # Create a redirect, fails if the title already exists, does not notify RC
1211 # Returns success
1212 function createRedirect( $dest, $comment ) {
1213 global $wgUser;
1214 if ( $this->getArticleID() ) {
1215 return false;
1216 }
1217
1218 $fname = 'Title::createRedirect';
1219 $dbw =& wfGetDB( DB_MASTER );
1220 $now = wfTimestampNow();
1221 $won = wfInvertTimestamp( $now );
1222 $seqVal = $dbw->nextSequenceValue( 'cur_cur_id_seq' );
1223
1224 $dbw->insertArray( 'cur', array(
1225 'cur_id' => $seqVal,
1226 'cur_namespace' => $this->getNamespace(),
1227 'cur_title' => $this->getDBkey(),
1228 'cur_comment' => $comment,
1229 'cur_user' => $wgUser->getID(),
1230 'cur_user_text' => $wgUser->getName(),
1231 'cur_timestamp' => $now,
1232 'inverse_timestamp' => $won,
1233 'cur_touched' => $now,
1234 'cur_is_redirect' => 1,
1235 'cur_is_new' => 1,
1236 'cur_text' => "#REDIRECT [[" . $dest->getPrefixedText() . "]]\n"
1237 ), $fname );
1238 $newid = $dbw->insertId();
1239 $this->resetArticleID( $newid );
1240
1241 # Link table
1242 if ( $dest->getArticleID() ) {
1243 $dbw->insertArray( 'links',
1244 array(
1245 'l_to' => $dest->getArticleID(),
1246 'l_from' => $newid
1247 ), $fname
1248 );
1249 } else {
1250 $dbw->insertArray( 'brokenlinks',
1251 array(
1252 'bl_to' => $dest->getPrefixedDBkey(),
1253 'bl_from' => $newid
1254 ), $fname
1255 );
1256 }
1257
1258 Article::onArticleCreate( $this );
1259 return true;
1260 }
1261
1262 # Get categories to wich belong this title and return an array of
1263 # categories names.
1264 # Return an array of parents in the form:
1265 # $parent => $currentarticle
1266 function getParentCategories() {
1267 global $wgLang,$wgUser;
1268
1269 $titlekey = $this->getArticleId();
1270 $sk =& $wgUser->getSkin();
1271 $parents = array();
1272 $dbr =& wfGetDB( DB_SLAVE );
1273 $cur = $dbr->tableName( 'cur' );
1274 $categorylinks = $dbr->tableName( 'categorylinks' );
1275
1276 # NEW SQL
1277 $sql = "SELECT * FROM categorylinks"
1278 ." WHERE cl_from='$titlekey'"
1279 ." AND cl_from <> '0'"
1280 ." ORDER BY cl_sortkey";
1281
1282 $res = $dbr->query ( $sql ) ;
1283
1284 if($dbr->numRows($res) > 0) {
1285 while ( $x = $dbr->fetchObject ( $res ) )
1286 //$data[] = Title::newFromText($wgLang->getNSText ( NS_CATEGORY ).':'.$x->cl_to);
1287 $data[$wgLang->getNSText ( NS_CATEGORY ).':'.$x->cl_to] = $this->getFullText();
1288 $dbr->freeResult ( $res ) ;
1289 } else {
1290 $data = '';
1291 }
1292 return $data;
1293 }
1294
1295 # Go through all parents
1296 function getCategorieBrowser() {
1297 $parents = $this->getParentCategories();
1298
1299 if($parents != '') {
1300 foreach($parents as $parent => $current)
1301 {
1302 $nt = Title::newFromText($parent);
1303 $stack[$parent] = $nt->getCategorieBrowser();
1304 }
1305 return $stack;
1306 } else {
1307 return array();
1308 }
1309 }
1310
1311
1312 # Returns an associative array for selecting this title from cur
1313 function curCond() {
1314 return array( 'cur_namespace' => $this->mNamespace, 'cur_title' => $this->mDbkeyform );
1315 }
1316
1317 function oldCond() {
1318 return array( 'old_namespace' => $this->mNamespace, 'old_title' => $this->mDbkeyform );
1319 }
1320 }
1321 ?>