Index: trunk/extensions/Tidy.php |
— | — | @@ -0,0 +1,51 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * An extension that adds a tidy tab on each page |
| 5 | + * |
| 6 | + * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com> |
| 7 | + * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason |
| 8 | + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
| 9 | + */ |
| 10 | + |
| 11 | +$wgExtensionFunctions[] = 'wfTidy'; |
| 12 | +$wgExtensionCredits['other'][] = array( |
| 13 | + 'name' => 'Tidy', |
| 14 | + 'author' => 'Ævar Arnfjörð Bjarmason', |
| 15 | + 'description' => 'Adds a tidy tab on each page allowing for quick viewing of pages with HTML tidy' |
| 16 | +); |
| 17 | + |
| 18 | + |
| 19 | +function wfTidy() { |
| 20 | + global $wgMessageCache, $wgHooks; |
| 21 | + |
| 22 | + $wgMessageCache->addMessage( 'tidy', 'Tidy' ); |
| 23 | + |
| 24 | + $wgHooks['SkinTemplateContentActions'][] = 'wfTidyHook'; |
| 25 | + $wgHooks['UnknownAction'][] = 'wfTidyActionHook'; |
| 26 | +} |
| 27 | + |
| 28 | +function wfTidyHook( &$content_actions ) { |
| 29 | + global $wgRequest, $wgTitle; |
| 30 | + |
| 31 | + $action = $wgRequest->getText( 'tidy' ); |
| 32 | + |
| 33 | + if ( $wgTitle->getNamespace() != NS_SPECIAL ) { |
| 34 | + $content_actions['tidy'] = array( |
| 35 | + 'class' => $action == 'tidy' ? 'selected' : false, |
| 36 | + 'text' => wfMsg( 'tidy' ), |
| 37 | + 'href' => $wgTitle->getLocalUrl( 'action=tidy' ) |
| 38 | + ); |
| 39 | + } |
| 40 | + |
| 41 | + return true; |
| 42 | +} |
| 43 | + |
| 44 | +function wfTidyActionHook( $action, &$wgArticle ) { |
| 45 | + global $wgUseTidy; |
| 46 | + |
| 47 | + $wgUseTidy = true; |
| 48 | + |
| 49 | + $wgArticle->purge(); |
| 50 | + |
| 51 | + return false; |
| 52 | +} |
Property changes on: trunk/extensions/Tidy.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 53 | + native |
Added: svn:keywords |
2 | 54 | + Author Date Id Revision |