Index: trunk/phase3/docs/hooks.txt |
— | — | @@ -545,6 +545,11 @@ |
546 | 546 | follwed an redirect |
547 | 547 | $article: target article (object) |
548 | 548 | |
| 549 | +'ArticleViewCustom': allows to output the text of the article in a different format than wikitext |
| 550 | +$text: text of the page |
| 551 | +$title: title of the page |
| 552 | +$output: reference to $wgOut |
| 553 | + |
549 | 554 | 'AuthPluginAutoCreate': Called when creating a local account for an user logged |
550 | 555 | in from an external authentication method |
551 | 556 | $user: User object created locally |
— | — | @@ -1755,6 +1760,11 @@ |
1756 | 1761 | $title: Title object that is being checked |
1757 | 1762 | $result: Boolean; whether MediaWiki currently thinks this is a CSS/JS page. Hooks may change this value to override the return value of Title::isCssOrJsPage() |
1758 | 1763 | |
| 1764 | +'TitleIsWikitextPage': Called when determining if a page is a wikitext or should |
| 1765 | +be handled by seperate handler (via ArticleViewCustom) |
| 1766 | +$title: Title object that is being checked |
| 1767 | +$result: Boolean; whether MediaWiki currently thinks this is a wikitext page. Hooks may change this value to override the return value of Title::isWikitextPage() |
| 1768 | + |
1759 | 1769 | 'TitleMoveComplete': after moving an article (title) |
1760 | 1770 | $old: old title |
1761 | 1771 | $nt: new title |
Index: trunk/phase3/includes/Article.php |
— | — | @@ -510,6 +510,9 @@ |
511 | 511 | wfDebug( __METHOD__ . ": showing CSS/JS source\n" ); |
512 | 512 | $this->showCssOrJsPage(); |
513 | 513 | $outputDone = true; |
| 514 | + } elseif( !wfRunHooks( 'ArticleViewCustom', array( $this->mContent, $this->getTitle(), $wgOut ) ) ) { |
| 515 | + # Allow extensions do their own custom view for certain pages |
| 516 | + $outputDone = true; |
514 | 517 | } else { |
515 | 518 | $rt = Title::newFromRedirectArray( $text ); |
516 | 519 | if ( $rt ) { |
Index: trunk/phase3/includes/EditPage.php |
— | — | @@ -2019,25 +2019,30 @@ |
2020 | 2020 | return $parsedNote; |
2021 | 2021 | } |
2022 | 2022 | |
2023 | | - # don't parse user css/js, show message about preview |
| 2023 | + # don't parse non-wikitext pages, show message about preview |
2024 | 2024 | # XXX: stupid php bug won't let us use $this->getContextTitle()->isCssJsSubpage() here -- This note has been there since r3530. Sure the bug was fixed time ago? |
2025 | 2025 | |
2026 | | - if ( $this->isCssJsSubpage || $this->mTitle->isCssOrJsPage() ) { |
2027 | | - $level = 'user'; |
2028 | | - if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { |
| 2026 | + if ( $this->isCssJsSubpage || !$this->mTitle->isWikitextPage() ) { |
| 2027 | + if( $this->mTitle->isCssJsSubpage() ) { |
| 2028 | + $level = 'user'; |
| 2029 | + } elseif( $this->mTitle->isCssOrJsPage() ) { |
2029 | 2030 | $level = 'site'; |
| 2031 | + } else { |
| 2032 | + $level = false; |
2030 | 2033 | } |
2031 | 2034 | |
2032 | 2035 | # Used messages to make sure grep find them: |
2033 | 2036 | # Messages: usercsspreview, userjspreview, sitecsspreview, sitejspreview |
2034 | | - if (preg_match( "/\\.css$/", $this->mTitle->getText() ) ) { |
2035 | | - $previewtext = "<div id='mw-{$level}csspreview'>\n" . wfMsg( "{$level}csspreview" ) . "\n</div>"; |
2036 | | - $class = "mw-code mw-css"; |
2037 | | - } elseif (preg_match( "/\\.js$/", $this->mTitle->getText() ) ) { |
2038 | | - $previewtext = "<div id='mw-{$level}jspreview'>\n" . wfMsg( "{$level}jspreview" ) . "\n</div>"; |
2039 | | - $class = "mw-code mw-js"; |
2040 | | - } else { |
2041 | | - throw new MWException( 'A CSS/JS (sub)page but which is not css nor js!' ); |
| 2037 | + if( $level ) { |
| 2038 | + if (preg_match( "/\\.css$/", $this->mTitle->getText() ) ) { |
| 2039 | + $previewtext = "<div id='mw-{$level}csspreview'>\n" . wfMsg( "{$level}csspreview" ) . "\n</div>"; |
| 2040 | + $class = "mw-code mw-css"; |
| 2041 | + } elseif (preg_match( "/\\.js$/", $this->mTitle->getText() ) ) { |
| 2042 | + $previewtext = "<div id='mw-{$level}jspreview'>\n" . wfMsg( "{$level}jspreview" ) . "\n</div>"; |
| 2043 | + $class = "mw-code mw-js"; |
| 2044 | + } else { |
| 2045 | + throw new MWException( 'A CSS/JS (sub)page but which is not css nor js!' ); |
| 2046 | + } |
2042 | 2047 | } |
2043 | 2048 | |
2044 | 2049 | $parserOptions->setTidy( true ); |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -1943,6 +1943,17 @@ |
1944 | 1944 | } |
1945 | 1945 | |
1946 | 1946 | /** |
| 1947 | + * Does that page contain wikitext, or it is JS, CSS or whatever? |
| 1948 | + * |
| 1949 | + * @return Bool |
| 1950 | + */ |
| 1951 | + public function isWikitextPage() { |
| 1952 | + $retval = !$this->isCssOrJsPage() && !$this->isCssJsSubpage(); |
| 1953 | + wfRunHooks( 'TitleIsWikitextPage', array( $this, &$retval ) ); |
| 1954 | + return $retval; |
| 1955 | + } |
| 1956 | + |
| 1957 | + /** |
1947 | 1958 | * Could this page contain custom CSS or JavaScript, based |
1948 | 1959 | * on the title? |
1949 | 1960 | * |
Index: trunk/phase3/includes/WikiPage.php |
— | — | @@ -716,8 +716,7 @@ |
717 | 717 | && $user->getStubThreshold() == 0 |
718 | 718 | && $this->exists() |
719 | 719 | && empty( $oldid ) |
720 | | - && !$this->mTitle->isCssOrJsPage() |
721 | | - && !$this->mTitle->isCssJsSubpage(); |
| 720 | + && $this->mTitle->isWikitextPage(); |
722 | 721 | } |
723 | 722 | |
724 | 723 | /** |