summaryrefslogtreecommitdiff
path: root/extensions/Cite/Cite.php
blob: 0f957659fd0a60e5e24031c2f9ccf180b9d7a382 (plain)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
if ( ! defined( 'MEDIAWIKI' ) )
	die();
/**#@+
 * A parser extension that adds two tags, <ref> and <references> for adding
 * citations to pages
 *
 * @file
 * @ingroup Extensions
 *
 * @link http://www.mediawiki.org/wiki/Extension:Cite/Cite.php Documentation
 *
 * @bug 4579
 *
 * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
 * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 */

$wgHooks['ParserFirstCallInit'][] = 'wfCite';
$wgHooks['BeforePageDisplay'][] = 'wfCiteBeforePageDisplay';


$wgExtensionCredits['parserhook'][] = array(
	'path' => __FILE__,
	'name' => 'Cite',
	'author' => 'Ævar Arnfjörð Bjarmason',
	'descriptionmsg' => 'cite-desc',
	'url' => 'https://www.mediawiki.org/wiki/Extension:Cite/Cite.php'
);
$wgParserTestFiles[] = dirname( __FILE__ ) . "/citeParserTests.txt";
$wgParserTestFiles[] = dirname( __FILE__ ) . "/citeCatTreeParserTests.txt";
$wgExtensionMessagesFiles['Cite'] = dirname( __FILE__ ) . "/Cite.i18n.php";
$wgAutoloadClasses['Cite'] = dirname( __FILE__ ) . "/Cite_body.php";
$wgSpecialPageGroups['Cite'] = 'pagetools';

define( 'CITE_DEFAULT_GROUP', '' );
/**
 * The emergency shut-off switch.  Override in local settings to disable
 * groups; or remove all references from this file to enable unconditionally
 */
$wgAllowCiteGroups = true;

/**
 * An emergency optimisation measure for caching cite <references /> output.
 */
$wgCiteCacheReferences = false;

/**
 * Enables experimental popups
 */
$wgCiteEnablePopups = false;

/**
 * Performs the hook registration.
 * Note that several extensions (and even core!) try to detect if Cite is
 * installed by looking for wfCite().
 *
 * @param $parser Parser
 *
 * @return bool
 */
function wfCite( $parser ) {
	return Cite::setHooks( $parser );
}

// Resources
$citeResourceTemplate = array(
	'localBasePath' => dirname(__FILE__) . '/modules',
	'remoteExtPath' => 'Cite/modules'
);

$wgResourceModules['ext.cite'] = $citeResourceTemplate + array(
	'styles' => array(),
	'scripts' => 'ext.cite/ext.cite.js',
	'position' => 'bottom',
	'dependencies' => array(
		'jquery.tooltip',
	),
);

$wgResourceModules['jquery.tooltip'] = $citeResourceTemplate + array(
	'styles' => 'jquery.tooltip/jquery.tooltip.css',
	'scripts' => 'jquery.tooltip/jquery.tooltip.js',
	'position' => 'bottom',
);

/* Add RTL fix for the cite <sup> elements */
$wgResourceModules['ext.rtlcite'] = $citeResourceTemplate + array(
	'styles' => 'ext.rtlcite/ext.rtlcite.css',
	'position' => 'top',
);

/**
 * @param $out OutputPage
 * @param $sk Skin
 * @return bool
 */
function wfCiteBeforePageDisplay( $out, &$sk ) {
	global $wgCiteEnablePopups;

	if ( $wgCiteEnablePopups ) {
		$out->addModules( 'ext.cite' );
	}

	/* RTL support quick-fix module */
	$out->addModuleStyles( 'ext.rtlcite' );
	return true;
}

/**#@-*/