Index: branches/wikidata/includes/Article.php |
— | — | @@ -604,13 +604,28 @@ |
605 | 605 | function view() { |
606 | 606 | global $wgUser, $wgOut, $wgRequest, $wgContLang; |
607 | 607 | global $wgEnableParserCache, $wgStylePath, $wgUseRCPatrol, $wgParser; |
608 | | - global $wgUseTrackbacks, $wgNamespaceRobotPolicies; |
| 608 | + global $wgUseTrackbacks, $wgNamespaceRobotPolicies, $wgTitle; |
609 | 609 | $sk = $wgUser->getSkin(); |
610 | 610 | |
611 | 611 | wfProfileIn( __METHOD__ ); |
612 | 612 | |
| 613 | + # We may want to view this page using a handler class |
| 614 | + $ns=$this->mTitle->getNamespace(); |
| 615 | + $handlerClass=Namespace::getHandlerForNamespaceId($ns); |
| 616 | + if(!empty($handlerClass)) { |
| 617 | + $handlerPath=Namespace::getHandlerPathForNamespaceId($ns); |
| 618 | + $hfilename=$handlerPath.$handlerClass.".php"; |
| 619 | + if(file_exists($hfilename)) { |
| 620 | + require_once($hfilename); |
| 621 | + $handlerInstance=new $handlerClass(); |
| 622 | + $handlerInstance->view(); |
| 623 | + return; |
| 624 | + } else { |
| 625 | + $wgOut->showErrorPage('namespace_handler_not_found','namespace_handler_not_found_error',$hfilename,$wgContLang->getFormattedNsText($ns)); |
| 626 | + } |
| 627 | + } |
| 628 | + |
613 | 629 | $parserCache =& ParserCache::singleton(); |
614 | | - $ns = $this->mTitle->getNamespace(); # shortcut |
615 | 630 | |
616 | 631 | # Get variables from query string |
617 | 632 | $oldid = $this->getOldID(); |
Index: branches/wikidata/includes/NamespaceStore.php |
— | — | @@ -394,7 +394,7 @@ |
395 | 395 | |
396 | 396 | /** |
397 | 397 | * Maintain index used by getIndexByName |
398 | | - */ |
| 398 | + */ |
399 | 399 | function refreshReverseIndex() { |
400 | 400 | $this->reverseindex = array(); |
401 | 401 | foreach ($this->nsarray as $ns) { |
— | — | @@ -665,6 +665,15 @@ |
666 | 666 | function getAllNamespaceObjects( ) { |
667 | 667 | return $this->nsarray; |
668 | 668 | } |
| 669 | + |
| 670 | + function isContent($id) { |
| 671 | + return $this->nsarray[$id]->isCountable(); |
| 672 | + } |
| 673 | + function getHandlerForId($id) { |
| 674 | + return $this->nsarray[$id]->getHandlerClass(); |
| 675 | + |
| 676 | + } |
| 677 | + |
669 | 678 | } |
670 | 679 | |
671 | 680 | |
Index: branches/wikidata/includes/EditPage.php |
— | — | @@ -290,6 +290,23 @@ |
291 | 291 | wfProfileIn( $fname ); |
292 | 292 | wfDebug( "$fname: enter\n" ); |
293 | 293 | |
| 294 | + # We may want to edit this page using a handler class |
| 295 | + $ns=$wgTitle->getNamespace(); |
| 296 | + $handlerClass=Namespace::getHandlerForNamespaceId($ns); |
| 297 | + if(!empty($handlerClass)) { |
| 298 | + $handlerPath=Namespace::getHandlerPathForNamespaceId($ns); |
| 299 | + $hfilename=$handlerPath.$handlerClass.".php"; |
| 300 | + if(file_exists($hfilename)) { |
| 301 | + require_once($hfilename); |
| 302 | + $handlerInstance=new $handlerClass(); |
| 303 | + $handlerInstance->edit(); |
| 304 | + return; |
| 305 | + } else { |
| 306 | + $wgOut->showErrorPage('namespace_handler_not_found','namespace_handler_not_found_error',$hfilename,$wgContLang->getFormattedNsText($ns)); |
| 307 | + } |
| 308 | + } |
| 309 | + |
| 310 | + |
294 | 311 | // this is not an article |
295 | 312 | $wgOut->setArticleFlag(false); |
296 | 313 | |
Index: branches/wikidata/includes/OutputPage.php |
— | — | @@ -745,12 +745,16 @@ |
746 | 746 | * Outputs a pretty page to explain why the request exploded. |
747 | 747 | * |
748 | 748 | * @param string $title Message key for page title. |
749 | | - * @param string $msg Message key for page text. |
| 749 | + * @param string $msg Message key for page text. |
| 750 | + * @param string, string .. (optional) substitutions for $1, $2 .. in the error message. |
750 | 751 | * @return nothing |
751 | 752 | */ |
752 | 753 | public function showErrorPage( $title, $msg ) { |
753 | 754 | global $wgTitle; |
754 | | - |
| 755 | + |
| 756 | + # Optional error message substitutions $1, $2 ... |
| 757 | + $args = func_get_args(); |
| 758 | + array_shift( $args ); |
755 | 759 | $this->mDebugtext .= 'Original title: ' . |
756 | 760 | $wgTitle->getPrefixedText() . "\n"; |
757 | 761 | $this->setPageTitle( wfMsg( $title ) ); |
— | — | @@ -761,7 +765,7 @@ |
762 | 766 | $this->mRedirect = ''; |
763 | 767 | |
764 | 768 | $this->mBodytext = ''; |
765 | | - $this->addWikiText( wfMsg( $msg ) ); |
| 769 | + $this->addWikiText( wfMsg( $msg, $args ) ); |
766 | 770 | $this->returnToMain( false ); |
767 | 771 | } |
768 | 772 | |
Index: branches/wikidata/includes/Namespace.php |
— | — | @@ -640,6 +640,27 @@ |
641 | 641 | return $nsstore->deleteNamespace($this,$deleteSystem); |
642 | 642 | } |
643 | 643 | |
| 644 | + |
| 645 | + static function isContent($id) { |
| 646 | + $nsstore= wfGetNamespaceStore(); |
| 647 | + return $nsstore->isContent($id); |
| 648 | + } |
| 649 | + |
| 650 | + static function getHandlerForNamespaceId($id) { |
| 651 | + $nsstore=wfGetNamespaceStore(); |
| 652 | + return $nsstore->getHandlerForId($id); |
| 653 | + } |
| 654 | + |
| 655 | + static function getHandlerPathForNamespaceId($id) { |
| 656 | + global $wgCustomHandlerPath; |
| 657 | + $handler=Namespace::getHandlerForNamespaceId($id); |
| 658 | + if(array_key_exists($handler,$wgCustomHandlerPath)) { |
| 659 | + return $wgCustomHandlerPath[$handler]; |
| 660 | + } else { |
| 661 | + return $wgCustomHandlerPath['*']; |
| 662 | + } |
| 663 | + } |
| 664 | + |
644 | 665 | } |
645 | 666 | |
646 | 667 | ?> |
Index: branches/wikidata/includes/DefaultSettings.php |
— | — | @@ -1012,6 +1012,7 @@ |
1013 | 1013 | //$wgGroupPermissions['sysop']['deleterevision'] = true; |
1014 | 1014 | //$wgGroupPermissions['bureaucrat']['hiderevision'] = true; |
1015 | 1015 | |
| 1016 | + |
1016 | 1017 | /** |
1017 | 1018 | * The developer group is deprecated, but can be activated if need be |
1018 | 1019 | * to use the 'lockdb' and 'unlockdb' special pages. Those require |
— | — | @@ -1041,7 +1042,6 @@ |
1042 | 1043 | $wgNamespaceProtection = array(); |
1043 | 1044 | $wgNamespaceProtection[ NS_MEDIAWIKI ] = array( 'editinterface' ); |
1044 | 1045 | |
1045 | | - |
1046 | 1046 | /** |
1047 | 1047 | * Number of seconds an account is required to age before |
1048 | 1048 | * it's given the implicit 'autoconfirm' group membership. |
— | — | @@ -2460,4 +2460,21 @@ |
2461 | 2461 | */ |
2462 | 2462 | $wgEnableCascadingProtection = true; |
2463 | 2463 | |
| 2464 | + |
| 2465 | +/* This will be prepended to all search paths for namespace |
| 2466 | + * handler files, followed by the name of the handler as a filename. |
| 2467 | + * Something like: |
| 2468 | + * |
| 2469 | + * /var/www/mywiki/extensions/CustomEditor.php |
| 2470 | + * |
| 2471 | + * You can change this on a per-handler basis, relative to the |
| 2472 | + * path above (begin without slash, terminate with slash). |
| 2473 | + * Use '*' as a HandlerName to define he default path which |
| 2474 | + * will be used for all handlers which are not specifically set. |
| 2475 | + * |
| 2476 | + * Must be slash-terminated. |
| 2477 | + * |
| 2478 | + */ |
| 2479 | +$wgCustomHandlerPath = array('*'=>"{$IP}/extensions/"); |
| 2480 | + |
2464 | 2481 | ?> |
Index: branches/wikidata/includes/PageHistory.php |
— | — | @@ -59,6 +59,22 @@ |
60 | 60 | $fname = 'PageHistory::history'; |
61 | 61 | wfProfileIn( $fname ); |
62 | 62 | |
| 63 | + # We may want to view this page using a handler class |
| 64 | + $ns=$this->mTitle->getNamespace(); |
| 65 | + $handlerClass=Namespace::getHandlerForNamespaceId($ns); |
| 66 | + if(!empty($handlerClass)) { |
| 67 | + $handlerPath=Namespace::getHandlerPathForNamespaceId($ns); |
| 68 | + $hfilename=$handlerPath.$handlerClass.".php"; |
| 69 | + if(file_exists($hfilename)) { |
| 70 | + require_once($hfilename); |
| 71 | + $handlerInstance=new $handlerClass(); |
| 72 | + $handlerInstance->history(); |
| 73 | + return; |
| 74 | + } else { |
| 75 | + $wgOut->showErrorPage('namespace_handler_not_found','namespace_handler_not_found_error',$hfilename,$wgContLang->getFormattedNsText($ns)); |
| 76 | + } |
| 77 | + } |
| 78 | + |
63 | 79 | /* |
64 | 80 | * Setup page variables. |
65 | 81 | */ |
Index: branches/wikidata/includes/SpecialNamespaces.php |
— | — | @@ -784,7 +784,7 @@ |
785 | 785 | $nsobj = $nsstore->getNamespaceObjectByIndex($targetid); |
786 | 786 | |
787 | 787 | $talktargetid=$nsobj->getTalk(); |
788 | | - $talk4nsobj=$nsstore->getNamespaceObjectByIndex($targettalkid); |
| 788 | + $talk4nsobj=$nsstore->getNamespaceObjectByIndex($talktargetid); |
789 | 789 | |
790 | 790 | if($converttalk && is_null($talktargetid)) { |
791 | 791 | $this->showForm (wfMsg('pseudonamespace_target_talk_not_found')); |
— | — | @@ -823,8 +823,9 @@ |
824 | 824 | $this->showForm(); |
825 | 825 | } |
826 | 826 | function showPseudoError($rv,$targetid,$prefix) { |
827 | | - global $wgNamespaces; |
828 | | - $istalk=$wgNamespaces[$targetid]->isTalk(); |
| 827 | + $nsstore = wfGetNamespaceStore(); |
| 828 | + $targetobj=$nsstore->getNamespaceObjectByIndex($targetid); |
| 829 | + $istalk=$targetobj->isTalk(); |
829 | 830 | # For messages |
830 | 831 | $talk=$istalk ? 'talk_' : ''; |
831 | 832 | if($rv[NS_RESULT]==NS_PSEUDO_NOT_FOUND) { |
— | — | @@ -836,7 +837,7 @@ |
837 | 838 | } elseif($rv[NS_RESULT]==NS_DUPLICATE_TITLES) { |
838 | 839 | $this->showForm( |
839 | 840 | wfMsg("pseudonamespace_{$talk}conversion_error",$prefix), |
840 | | - $this->pseudoDupes($wgNamespaces[$targetid]->getDefaultName(),$rv[NS_DUPLICATE_TITLE_LIST])); |
| 841 | + $this->pseudoDupes($targetobj->getDefaultName(),$rv[NS_DUPLICATE_TITLE_LIST])); |
841 | 842 | } |
842 | 843 | } |
843 | 844 | |
Index: branches/wikidata/languages/messages/MessagesEn.php |
— | — | @@ -2865,6 +2865,8 @@ |
2866 | 2866 | 'namespace_not_deletable'=>'The namespace cannot be deleted.', |
2867 | 2867 | 'namespace_has_gone_missing'=>'A namespace with the number $1 was not found.', |
2868 | 2868 | 'namespace_not_deletable_system'=>'The namespace with the number $1 is a system namespace which is required for the operation of MediaWiki.', |
| 2869 | +'namespace_handler_not_found'=>'Namespace handler not found!', |
| 2870 | +'namespace_handler_not_found_error'=>'This page requires a special handler to view, expected in the directory \'$1\'! Please make sure that this file is present before viewing pages of the type \'$2\'.', |
2869 | 2871 | |
2870 | 2872 | ); |
2871 | 2873 | |