Merge "Remove hitcounters and associated code"
[lhc/web/wiklou.git] / includes / specialpage / SpecialPageFactory.php
1 <?php
2 /**
3 * Factory for handling the special page list and generating SpecialPage objects.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @ingroup SpecialPage
22 * @defgroup SpecialPage SpecialPage
23 */
24
25 /**
26 * Factory for handling the special page list and generating SpecialPage objects.
27 *
28 * To add a special page in an extension, add to $wgSpecialPages either
29 * an object instance or an array containing the name and constructor
30 * parameters. The latter is preferred for performance reasons.
31 *
32 * The object instantiated must be either an instance of SpecialPage or a
33 * sub-class thereof. It must have an execute() method, which sends the HTML
34 * for the special page to $wgOut. The parent class has an execute() method
35 * which distributes the call to the historical global functions. Additionally,
36 * execute() also checks if the user has the necessary access privileges
37 * and bails out if not.
38 *
39 * To add a core special page, use the similar static list in
40 * SpecialPageFactory::$list. To remove a core static special page at runtime, use
41 * a SpecialPage_initList hook.
42 *
43 * @ingroup SpecialPage
44 * @since 1.17
45 */
46 class SpecialPageFactory {
47 /**
48 * List of special page names to the subclass of SpecialPage which handles them.
49 */
50 private static $coreList = array(
51 // Maintenance Reports
52 'BrokenRedirects' => 'BrokenRedirectsPage',
53 'Deadendpages' => 'DeadendPagesPage',
54 'DoubleRedirects' => 'DoubleRedirectsPage',
55 'Longpages' => 'LongPagesPage',
56 'Ancientpages' => 'AncientPagesPage',
57 'Lonelypages' => 'LonelyPagesPage',
58 'Fewestrevisions' => 'FewestrevisionsPage',
59 'Withoutinterwiki' => 'WithoutInterwikiPage',
60 'Protectedpages' => 'SpecialProtectedpages',
61 'Protectedtitles' => 'SpecialProtectedtitles',
62 'Shortpages' => 'ShortPagesPage',
63 'Uncategorizedcategories' => 'UncategorizedCategoriesPage',
64 'Uncategorizedimages' => 'UncategorizedImagesPage',
65 'Uncategorizedpages' => 'UncategorizedPagesPage',
66 'Uncategorizedtemplates' => 'UncategorizedTemplatesPage',
67 'Unusedcategories' => 'UnusedCategoriesPage',
68 'Unusedimages' => 'UnusedimagesPage',
69 'Unusedtemplates' => 'UnusedtemplatesPage',
70 'Unwatchedpages' => 'UnwatchedpagesPage',
71 'Wantedcategories' => 'WantedCategoriesPage',
72 'Wantedfiles' => 'WantedFilesPage',
73 'Wantedpages' => 'WantedPagesPage',
74 'Wantedtemplates' => 'WantedTemplatesPage',
75
76 // List of pages
77 'Allpages' => 'SpecialAllPages',
78 'Prefixindex' => 'SpecialPrefixindex',
79 'Categories' => 'SpecialCategories',
80 'Listredirects' => 'ListredirectsPage',
81 'PagesWithProp' => 'SpecialPagesWithProp',
82 'TrackingCategories' => 'SpecialTrackingCategories',
83
84 // Login/create account
85 'Userlogin' => 'LoginForm',
86 'CreateAccount' => 'SpecialCreateAccount',
87
88 // Users and rights
89 'Block' => 'SpecialBlock',
90 'Unblock' => 'SpecialUnblock',
91 'BlockList' => 'SpecialBlockList',
92 'ChangePassword' => 'SpecialChangePassword',
93 'PasswordReset' => 'SpecialPasswordReset',
94 'DeletedContributions' => 'DeletedContributionsPage',
95 'Preferences' => 'SpecialPreferences',
96 'ResetTokens' => 'SpecialResetTokens',
97 'Contributions' => 'SpecialContributions',
98 'Listgrouprights' => 'SpecialListGroupRights',
99 'Listusers' => 'SpecialListUsers',
100 'Listadmins' => 'SpecialListAdmins',
101 'Listbots' => 'SpecialListBots',
102 'Userrights' => 'UserrightsPage',
103 'EditWatchlist' => 'SpecialEditWatchlist',
104
105 // Recent changes and logs
106 'Newimages' => 'SpecialNewFiles',
107 'Log' => 'SpecialLog',
108 'Watchlist' => 'SpecialWatchlist',
109 'Newpages' => 'SpecialNewpages',
110 'Recentchanges' => 'SpecialRecentChanges',
111 'Recentchangeslinked' => 'SpecialRecentChangesLinked',
112 'Tags' => 'SpecialTags',
113
114 // Media reports and uploads
115 'Listfiles' => 'SpecialListFiles',
116 'Filepath' => 'SpecialFilepath',
117 'MediaStatistics' => 'MediaStatisticsPage',
118 'MIMEsearch' => 'MIMEsearchPage',
119 'FileDuplicateSearch' => 'FileDuplicateSearchPage',
120 'Upload' => 'SpecialUpload',
121 'UploadStash' => 'SpecialUploadStash',
122 'ListDuplicatedFiles' => 'ListDuplicatedFilesPage',
123
124 // Data and tools
125 'Statistics' => 'SpecialStatistics',
126 'Allmessages' => 'SpecialAllMessages',
127 'Version' => 'SpecialVersion',
128 'Lockdb' => 'SpecialLockdb',
129 'Unlockdb' => 'SpecialUnlockdb',
130
131 // Redirecting special pages
132 'LinkSearch' => 'LinkSearchPage',
133 'Randompage' => 'RandomPage',
134 'RandomInCategory' => 'SpecialRandomInCategory',
135 'Randomredirect' => 'SpecialRandomredirect',
136
137 // High use pages
138 'Mostlinkedcategories' => 'MostlinkedCategoriesPage',
139 'Mostimages' => 'MostimagesPage',
140 'Mostinterwikis' => 'MostinterwikisPage',
141 'Mostlinked' => 'MostlinkedPage',
142 'Mostlinkedtemplates' => 'MostlinkedTemplatesPage',
143 'Mostcategories' => 'MostcategoriesPage',
144 'Mostrevisions' => 'MostrevisionsPage',
145
146 // Page tools
147 'ComparePages' => 'SpecialComparePages',
148 'Export' => 'SpecialExport',
149 'Import' => 'SpecialImport',
150 'Undelete' => 'SpecialUndelete',
151 'Whatlinkshere' => 'SpecialWhatLinksHere',
152 'MergeHistory' => 'SpecialMergeHistory',
153 'ExpandTemplates' => 'SpecialExpandTemplates',
154
155 // Other
156 'Booksources' => 'SpecialBookSources',
157
158 // Unlisted / redirects
159 'ApiHelp' => 'SpecialApiHelp',
160 'Blankpage' => 'SpecialBlankpage',
161 'Diff' => 'SpecialDiff',
162 'Emailuser' => 'SpecialEmailUser',
163 'Movepage' => 'MovePageForm',
164 'Mycontributions' => 'SpecialMycontributions',
165 'MyLanguage' => 'SpecialMyLanguage',
166 'Mypage' => 'SpecialMypage',
167 'Mytalk' => 'SpecialMytalk',
168 'Myuploads' => 'SpecialMyuploads',
169 'AllMyUploads' => 'SpecialAllMyUploads',
170 'PermanentLink' => 'SpecialPermanentLink',
171 'Redirect' => 'SpecialRedirect',
172 'Revisiondelete' => 'SpecialRevisionDelete',
173 'RunJobs' => 'SpecialRunJobs',
174 'Specialpages' => 'SpecialSpecialpages',
175 'Userlogout' => 'SpecialUserlogout',
176 );
177
178 private static $list;
179 private static $aliases;
180
181 /**
182 * Reset the internal list of special pages. Useful when changing $wgSpecialPages after
183 * the internal list has already been initialized, e.g. during testing.
184 */
185 public static function resetList() {
186 self::$list = null;
187 self::$aliases = null;
188 }
189
190 /**
191 * Returns a list of canonical special page names.
192 * May be used to iterate over all registered special pages.
193 *
194 * @return string[]
195 */
196 public static function getNames() {
197 return array_keys( self::getPageList() );
198 }
199
200 /**
201 * Get the special page list as an array
202 *
203 * @deprecated since 1.24, use getNames() instead.
204 * @return array
205 */
206 public static function getList() {
207 wfDeprecated( __FUNCTION__, '1.24' );
208 return self::getPageList();
209 }
210
211 /**
212 * Get the special page list as an array
213 *
214 * @return array
215 */
216 private static function getPageList() {
217 global $wgSpecialPages;
218 global $wgDisableInternalSearch, $wgEmailAuthentication;
219 global $wgEnableEmail, $wgEnableJavaScriptTest;
220 global $wgPageLanguageUseDB;
221
222 if ( !is_array( self::$list ) ) {
223 wfProfileIn( __METHOD__ );
224
225 self::$list = self::$coreList;
226
227 if ( !$wgDisableInternalSearch ) {
228 self::$list['Search'] = 'SpecialSearch';
229 }
230
231 if ( $wgEmailAuthentication ) {
232 self::$list['Confirmemail'] = 'EmailConfirmation';
233 self::$list['Invalidateemail'] = 'EmailInvalidation';
234 }
235
236 if ( $wgEnableEmail ) {
237 self::$list['ChangeEmail'] = 'SpecialChangeEmail';
238 }
239
240 if ( $wgEnableJavaScriptTest ) {
241 self::$list['JavaScriptTest'] = 'SpecialJavaScriptTest';
242 }
243
244 if ( $wgPageLanguageUseDB ) {
245 self::$list['PageLanguage'] = 'SpecialPageLanguage';
246 }
247
248 self::$list['Activeusers'] = 'SpecialActiveUsers';
249
250 // Add extension special pages
251 self::$list = array_merge( self::$list, $wgSpecialPages );
252
253 // Run hooks
254 // This hook can be used to remove undesired built-in special pages
255 wfRunHooks( 'SpecialPage_initList', array( &self::$list ) );
256
257 wfProfileOut( __METHOD__ );
258 }
259
260 return self::$list;
261 }
262
263 /**
264 * Initialise and return the list of special page aliases. Returns an object with
265 * properties which can be accessed $obj->pagename - each property name is an
266 * alias, with the value being the canonical name of the special page. All
267 * registered special pages are guaranteed to map to themselves.
268 * @return object
269 */
270 private static function getAliasListObject() {
271 if ( !is_object( self::$aliases ) ) {
272 global $wgContLang;
273 $aliases = $wgContLang->getSpecialPageAliases();
274 $pageList = self::getPageList();
275
276 self::$aliases = array();
277 $keepAlias = array();
278
279 // Force every canonical name to be an alias for itself.
280 foreach ( $pageList as $name => $stuff ) {
281 $caseFoldedAlias = $wgContLang->caseFold( $name );
282 self::$aliases[$caseFoldedAlias] = $name;
283 $keepAlias[$caseFoldedAlias] = 'canonical';
284 }
285
286 // Check for $aliases being an array since Language::getSpecialPageAliases can return null
287 if ( is_array( $aliases ) ) {
288 foreach ( $aliases as $realName => $aliasList ) {
289 $aliasList = array_values( $aliasList );
290 foreach ( $aliasList as $i => $alias ) {
291 $caseFoldedAlias = $wgContLang->caseFold( $alias );
292
293 if ( isset( self::$aliases[$caseFoldedAlias] ) &&
294 $realName === self::$aliases[$caseFoldedAlias]
295 ) {
296 // Ignore same-realName conflicts
297 continue;
298 }
299
300 if ( !isset( $keepAlias[$caseFoldedAlias] ) ) {
301 self::$aliases[$caseFoldedAlias] = $realName;
302 if ( !$i ) {
303 $keepAlias[$caseFoldedAlias] = 'first';
304 }
305 } elseif ( !$i ) {
306 wfWarn( "First alias '$alias' for $realName conflicts with " .
307 "{$keepAlias[$caseFoldedAlias]} alias for " .
308 self::$aliases[$caseFoldedAlias]
309 );
310 }
311 }
312 }
313 }
314
315 // Cast to object: func()[$key] doesn't work, but func()->$key does
316 self::$aliases = (object)self::$aliases;
317 }
318
319 return self::$aliases;
320 }
321
322 /**
323 * Given a special page name with a possible subpage, return an array
324 * where the first element is the special page name and the second is the
325 * subpage.
326 *
327 * @param string $alias
328 * @return array Array( String, String|null ), or array( null, null ) if the page is invalid
329 */
330 public static function resolveAlias( $alias ) {
331 global $wgContLang;
332 $bits = explode( '/', $alias, 2 );
333
334 $caseFoldedAlias = $wgContLang->caseFold( $bits[0] );
335 $caseFoldedAlias = str_replace( ' ', '_', $caseFoldedAlias );
336 if ( isset( self::getAliasListObject()->$caseFoldedAlias ) ) {
337 $name = self::getAliasListObject()->$caseFoldedAlias;
338 } else {
339 return array( null, null );
340 }
341
342 if ( !isset( $bits[1] ) ) { // bug 2087
343 $par = null;
344 } else {
345 $par = $bits[1];
346 }
347
348 return array( $name, $par );
349 }
350
351 /**
352 * Add a page to a certain display group for Special:SpecialPages
353 *
354 * @param SpecialPage|string $page
355 * @param string $group
356 * @deprecated since 1.21 Override SpecialPage::getGroupName
357 */
358 public static function setGroup( $page, $group ) {
359 wfDeprecated( __METHOD__, '1.21' );
360
361 global $wgSpecialPageGroups;
362 $name = is_object( $page ) ? $page->getName() : $page;
363 $wgSpecialPageGroups[$name] = $group;
364 }
365
366 /**
367 * Get the group that the special page belongs in on Special:SpecialPage
368 *
369 * @param SpecialPage $page
370 * @return string
371 * @deprecated since 1.21 Use SpecialPage::getFinalGroupName
372 */
373 public static function getGroup( &$page ) {
374 wfDeprecated( __METHOD__, '1.21' );
375
376 return $page->getFinalGroupName();
377 }
378
379 /**
380 * Check if a given name exist as a special page or as a special page alias
381 *
382 * @param string $name Name of a special page
383 * @return bool True if a special page exists with this name
384 */
385 public static function exists( $name ) {
386 list( $title, /*...*/ ) = self::resolveAlias( $name );
387
388 $specialPageList = self::getPageList();
389 return isset( $specialPageList[$title] );
390 }
391
392 /**
393 * Find the object with a given name and return it (or NULL)
394 *
395 * @param string $name Special page name, may be localised and/or an alias
396 * @return SpecialPage|null SpecialPage object or null if the page doesn't exist
397 */
398 public static function getPage( $name ) {
399 list( $realName, /*...*/ ) = self::resolveAlias( $name );
400
401 $specialPageList = self::getPageList();
402
403 if ( isset( $specialPageList[$realName] ) ) {
404 $rec = $specialPageList[$realName];
405
406 if ( is_callable( $rec ) ) {
407 // Use callback to instantiate the special page
408 $page = call_user_func( $rec );
409 } elseif ( is_string( $rec ) ) {
410 $className = $rec;
411 $page = new $className;
412 } elseif ( is_array( $rec ) ) {
413 $className = array_shift( $rec );
414 // @deprecated, officially since 1.18, unofficially since forever
415 wfDeprecated( "Array syntax for \$wgSpecialPages is deprecated ($className), " .
416 "define a subclass of SpecialPage instead.", '1.18' );
417 $page = MWFunction::newObj( $className, $rec );
418 } elseif ( $rec instanceof SpecialPage ) {
419 $page = $rec; //XXX: we should deep clone here
420 } else {
421 $page = null;
422 }
423
424 if ( $page instanceof SpecialPage ) {
425 return $page;
426 } else {
427 // It's not a classname, nor a callback, nor a legacy constructor array,
428 // nor a special page object. Give up.
429 wfLogWarning( "Cannot instantiate special page $realName: bad spec!" );
430 return null;
431 }
432
433 } else {
434 return null;
435 }
436 }
437
438 /**
439 * Return categorised listable special pages which are available
440 * for the current user, and everyone.
441 *
442 * @param User $user User object to check permissions, $wgUser will be used
443 * if not provided
444 * @return array ( string => Specialpage )
445 */
446 public static function getUsablePages( User $user = null ) {
447 $pages = array();
448 if ( $user === null ) {
449 global $wgUser;
450 $user = $wgUser;
451 }
452 foreach ( self::getPageList() as $name => $rec ) {
453 $page = self::getPage( $name );
454 if ( $page ) { // not null
455 $page->setContext( RequestContext::getMain() );
456 if ( $page->isListed()
457 && ( !$page->isRestricted() || $page->userCanExecute( $user ) )
458 ) {
459 $pages[$name] = $page;
460 }
461 }
462 }
463
464 return $pages;
465 }
466
467 /**
468 * Return categorised listable special pages for all users
469 *
470 * @return array ( string => Specialpage )
471 */
472 public static function getRegularPages() {
473 $pages = array();
474 foreach ( self::getPageList() as $name => $rec ) {
475 $page = self::getPage( $name );
476 if ( $page->isListed() && !$page->isRestricted() ) {
477 $pages[$name] = $page;
478 }
479 }
480
481 return $pages;
482 }
483
484 /**
485 * Return categorised listable special pages which are available
486 * for the current user, but not for everyone
487 *
488 * @param User|null $user User object to use or null for $wgUser
489 * @return array ( string => Specialpage )
490 */
491 public static function getRestrictedPages( User $user = null ) {
492 $pages = array();
493 if ( $user === null ) {
494 global $wgUser;
495 $user = $wgUser;
496 }
497 foreach ( self::getPageList() as $name => $rec ) {
498 $page = self::getPage( $name );
499 if (
500 $page->isListed()
501 && $page->isRestricted()
502 && $page->userCanExecute( $user )
503 ) {
504 $pages[$name] = $page;
505 }
506 }
507
508 return $pages;
509 }
510
511 /**
512 * Execute a special page path.
513 * The path may contain parameters, e.g. Special:Name/Params
514 * Extracts the special page name and call the execute method, passing the parameters
515 *
516 * Returns a title object if the page is redirected, false if there was no such special
517 * page, and true if it was successful.
518 *
519 * @param Title $title
520 * @param IContextSource $context
521 * @param bool $including Bool output is being captured for use in {{special:whatever}}
522 *
523 * @return bool
524 */
525 public static function executePath( Title &$title, IContextSource &$context, $including = false ) {
526 wfProfileIn( __METHOD__ );
527
528 // @todo FIXME: Redirects broken due to this call
529 $bits = explode( '/', $title->getDBkey(), 2 );
530 $name = $bits[0];
531 if ( !isset( $bits[1] ) ) { // bug 2087
532 $par = null;
533 } else {
534 $par = $bits[1];
535 }
536 $page = self::getPage( $name );
537 // Nonexistent?
538 if ( !$page ) {
539 $context->getOutput()->setArticleRelated( false );
540 $context->getOutput()->setRobotPolicy( 'noindex,nofollow' );
541
542 global $wgSend404Code;
543 if ( $wgSend404Code ) {
544 $context->getOutput()->setStatusCode( 404 );
545 }
546
547 $context->getOutput()->showErrorPage( 'nosuchspecialpage', 'nospecialpagetext' );
548 wfProfileOut( __METHOD__ );
549
550 return false;
551 }
552
553 // Page exists, set the context
554 $page->setContext( $context );
555
556 if ( !$including ) {
557 // Redirect to canonical alias for GET commands
558 // Not for POST, we'd lose the post data, so it's best to just distribute
559 // the request. Such POST requests are possible for old extensions that
560 // generate self-links without being aware that their default name has
561 // changed.
562 if ( $name != $page->getLocalName() && !$context->getRequest()->wasPosted() ) {
563 $query = $context->getRequest()->getQueryValues();
564 unset( $query['title'] );
565 $title = $page->getPageTitle( $par );
566 $url = $title->getFullURL( $query );
567 $context->getOutput()->redirect( $url );
568 wfProfileOut( __METHOD__ );
569
570 return $title;
571 } else {
572 $context->setTitle( $page->getPageTitle( $par ) );
573 }
574 } elseif ( !$page->isIncludable() ) {
575 wfProfileOut( __METHOD__ );
576
577 return false;
578 }
579
580 $page->including( $including );
581
582 // Execute special page
583 $profName = 'Special:' . $page->getName();
584 wfProfileIn( $profName );
585 $page->run( $par );
586 wfProfileOut( $profName );
587 wfProfileOut( __METHOD__ );
588
589 return true;
590 }
591
592 /**
593 * Just like executePath() but will override global variables and execute
594 * the page in "inclusion" mode. Returns true if the execution was
595 * successful or false if there was no such special page, or a title object
596 * if it was a redirect.
597 *
598 * Also saves the current $wgTitle, $wgOut, $wgRequest, $wgUser and $wgLang
599 * variables so that the special page will get the context it'd expect on a
600 * normal request, and then restores them to their previous values after.
601 *
602 * @param Title $title
603 * @param IContextSource $context
604 * @return string HTML fragment
605 */
606 public static function capturePath( Title $title, IContextSource $context ) {
607 global $wgOut, $wgTitle, $wgRequest, $wgUser, $wgLang;
608
609 // Save current globals
610 $oldTitle = $wgTitle;
611 $oldOut = $wgOut;
612 $oldRequest = $wgRequest;
613 $oldUser = $wgUser;
614 $oldLang = $wgLang;
615
616 // Set the globals to the current context
617 $wgTitle = $title;
618 $wgOut = $context->getOutput();
619 $wgRequest = $context->getRequest();
620 $wgUser = $context->getUser();
621 $wgLang = $context->getLanguage();
622
623 // The useful part
624 $ret = self::executePath( $title, $context, true );
625
626 // And restore the old globals
627 $wgTitle = $oldTitle;
628 $wgOut = $oldOut;
629 $wgRequest = $oldRequest;
630 $wgUser = $oldUser;
631 $wgLang = $oldLang;
632
633 return $ret;
634 }
635
636 /**
637 * Get the local name for a specified canonical name
638 *
639 * @param string $name
640 * @param string|bool $subpage
641 * @return string
642 */
643 public static function getLocalNameFor( $name, $subpage = false ) {
644 global $wgContLang;
645 $aliases = $wgContLang->getSpecialPageAliases();
646 $aliasList = self::getAliasListObject();
647
648 // Find the first alias that maps back to $name
649 if ( isset( $aliases[$name] ) ) {
650 $found = false;
651 foreach ( $aliases[$name] as $alias ) {
652 $caseFoldedAlias = $wgContLang->caseFold( $alias );
653 $caseFoldedAlias = str_replace( ' ', '_', $caseFoldedAlias );
654 if ( isset( $aliasList->$caseFoldedAlias ) &&
655 $aliasList->$caseFoldedAlias === $name
656 ) {
657 $name = $alias;
658 $found = true;
659 break;
660 }
661 }
662 if ( !$found ) {
663 wfWarn( "Did not find a usable alias for special page '$name'. " .
664 "It seems all defined aliases conflict?" );
665 }
666 } else {
667 // Check if someone misspelled the correct casing
668 if ( is_array( $aliases ) ) {
669 foreach ( $aliases as $n => $values ) {
670 if ( strcasecmp( $name, $n ) === 0 ) {
671 wfWarn( "Found alias defined for $n when searching for " .
672 "special page aliases for $name. Case mismatch?" );
673 return self::getLocalNameFor( $n, $subpage );
674 }
675 }
676 }
677
678 wfWarn( "Did not find alias for special page '$name'. " .
679 "Perhaps no aliases are defined for it?" );
680 }
681
682 if ( $subpage !== false && !is_null( $subpage ) ) {
683 $name = "$name/$subpage";
684 }
685
686 return $wgContLang->ucfirst( $name );
687 }
688
689 /**
690 * Get a title for a given alias
691 *
692 * @param string $alias
693 * @return Title|null Title or null if there is no such alias
694 */
695 public static function getTitleForAlias( $alias ) {
696 list( $name, $subpage ) = self::resolveAlias( $alias );
697 if ( $name != null ) {
698 return SpecialPage::getTitleFor( $name, $subpage );
699 } else {
700 return null;
701 }
702 }
703 }