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