[ Index ] |
PHP Cross Reference of MediaWiki-1.24.0 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Syntax highlighting extension for MediaWiki using GeSHi 4 * Copyright (C) 2005 Brion Vibber <[email protected]> 5 * http://www.mediawiki.org/ 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License along 18 * with this program; if not, write to the Free Software Foundation, Inc., 19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * http://www.gnu.org/copyleft/gpl.html 21 */ 22 23 /** 24 * @file 25 * @ingroup Extensions 26 * @author Brion Vibber 27 * 28 * This extension wraps the GeSHi highlighter: http://qbnz.com/highlighter/ 29 * 30 * A language is specified like: <source lang="c">void main() {}</source> 31 * If you forget, or give an unsupported value, the extension spits out 32 * some help text and a list of all supported languages. 33 */ 34 35 if( !defined( 'MEDIAWIKI' ) ) { 36 die(); 37 } 38 39 $wgExtensionCredits['parserhook']['SyntaxHighlight_GeSHi'] = array( 40 'path' => __FILE__, 41 'name' => 'SyntaxHighlight', 42 'author' => array( 'Brion Vibber', 'Tim Starling', 'Rob Church', 'Niklas Laxström' ), 43 'descriptionmsg' => 'syntaxhighlight-desc', 44 'url' => 'https://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi', 45 ); 46 47 // Change these in LocalSettings.php 48 $wgSyntaxHighlightDefaultLang = null; 49 $wgSyntaxHighlightKeywordLinks = false; 50 51 $dir = __DIR__ . '/'; 52 $wgMessagesDirs['SyntaxHighlight_GeSHi'] = __DIR__ . '/i18n'; 53 $wgExtensionMessagesFiles['SyntaxHighlight_GeSHi'] = $dir . 'SyntaxHighlight_GeSHi.i18n.php'; 54 55 $wgAutoloadClasses['SyntaxHighlight_GeSHi'] = $dir . 'SyntaxHighlight_GeSHi.class.php'; 56 $wgAutoloadClasses['ResourceLoaderGeSHiModule'] = $dir . 'ResourceLoaderGeSHiModule.php'; 57 $wgAutoloadClasses['ResourceLoaderGeSHiLocalModule'] = $dir . 'ResourceLoaderGeSHiLocalModule.php'; 58 59 $wgHooks['ExtensionTypes'][] = 'SyntaxHighlight_GeSHi::extensionTypes'; 60 $wgHooks['ResourceLoaderRegisterModules'][] = 'SyntaxHighlight_GeSHi::resourceLoaderRegisterModules'; 61 $wgHooks['ContentGetParserOutput'][] = 'SyntaxHighlight_GeSHi::renderHook'; 62 63 // Module to load MediaWiki:Geshi.css. 64 $wgResourceModules['ext.geshi.local'] = array( 'class' => 'ResourceLoaderGeSHiLocalModule' ); 65 // More modules are defined by SyntaxHighlight_GeSHi::resourceLoaderRegisterModules, 66 // one for each supported language. The general name template is 'ext.geshi.language.<lang>'. 67 68 /** 69 * Map content models to the corresponding language names to be used with the highlighter. 70 * Pages with one of the given content models will automatically be highlighted. 71 */ 72 $wgSyntaxHighlightModels = array( 73 CONTENT_MODEL_CSS => 'css', 74 CONTENT_MODEL_JAVASCRIPT => 'javascript', 75 ); 76 77 /** 78 * Register parser hook 79 * 80 * @param $parser Parser 81 * @return bool 82 */ 83 $wgHooks['ParserFirstCallInit'][] = function ( &$parser ) { 84 $parser->setHook( 'source', array( 'SyntaxHighlight_GeSHi', 'parserHook' ) ); 85 $parser->setHook( 'syntaxhighlight', array( 'SyntaxHighlight_GeSHi', 'parserHook' ) ); 86 return true; 87 };
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 14:03:12 2014 | Cross-referenced by PHPXref 0.7.1 |