-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGoogleCodePrettify.php
73 lines (64 loc) · 2.31 KB
/
GoogleCodePrettify.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
# Alert the user that this is not a valid entry point to MediaWiki if they try to access the file directly.
if (!defined('MEDIAWIKI')) {
echo <<<EOT
To install GoogleCodePrettify extension, put the following line in LocalSettings.php:
require_once( "\$IP/extensions/GoogleCodePrettify/GoogleCodePrettify.php" );
EOT;
exit(1);
}
$dir = dirname( __FILE__ ) . '/';
$wgAutoloadClasses['GoogleCodePrettify'] = $dir. 'GoogleCodePrettify.body.php';
$wgExtensionMessagesFiles['GoogleCodePrettify'] = $dir. 'GoogleCodePrettify.i18n.php';
if (! isset($wgGoogleCodePrettifyAdditionalLanguages)) {
$wgGoogleCodePrettifyAdditionalLanguages = array(
'css',
'sql',
'yaml'
);
}
if (! isset($wgGoogleCodePrettifyAllowSourceTag)) {
$wgGoogleCodePrettifyAllowSourceTag = false;
}
function efGoogleCodePrettify_Scripts() {
global $wgGoogleCodePrettifyAdditionalLanguages;
$scripts = array('google-code-prettify/prettify.js');
foreach ($wgGoogleCodePrettifyAdditionalLanguages as $language) {
$scripts[] = "google-code-prettify/lang-$language.js";
}
$scripts[] = 'init.js';
return $scripts;
}
/**
* Register parser hook
*/
function efGoogleCodePrettify_Setup( &$parser ) {
global $wgGoogleCodePrettifyAllowSourceTag;
global $wgGoogleCodePrettifyAllowShlTag;
if ($wgGoogleCodePrettifyAllowSourceTag) {
$parser->setHook('source', array('GoogleCodePrettify', 'parserHook'));
}
if ($wgGoogleCodePrettifyAllowShlTag) {
$parser->setHook('shl', array('GoogleCodePrettify', 'parserHook'));
}
$parser->setHook('syntaxhighlight', array('GoogleCodePrettify', 'parserHook'));
return true;
}
$wgExtensionCredits['other'][] = array(
'path' => __FILE__,
'name' => 'GoogleCodePrettify',
'author' => 'Akzhan Abdulin',
'url' => 'http://www.mediawiki.org/wiki/Extension:GoogleCodePrettify',
'version' => '0.4',
'descriptionmsg' => 'google-code-prettify-description'
);
// Register parser hook
$wgHooks['ParserFirstCallInit'][] = 'efGoogleCodePrettify_Setup';
// Register before display hook
$wgHooks['BeforePageDisplay'][] = 'GoogleCodePrettify::beforePageDisplay';
$wgResourceModules['ext.GoogleCodePrettify'] = array(
'localBasePath' => dirname(__FILE__),
'remoteExtPath' => 'GoogleCodePrettify',
'styles' => array('google-code-prettify/prettify.css'),
'scripts' => efGoogleCodePrettify_Scripts()
);