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