-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bibwiki.php
87 lines (71 loc) · 3.16 KB
/
Bibwiki.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
if (!defined('MEDIAWIKI'))
die();
/**
* Bibwiki - bibliography management extension for Mediawiki
*
* @addtogroup Extensions
* @package Bibwiki
*
* @link http://www.plaschg.net/bibwiki Homepage
* @link http://www.plaschg.net/bibwiki/docs Code documentation
* @author Wolfgang Plaschg <[email protected]>
* @copyright Copyright (C) 2007 Wolfgang Plaschg
*
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
*/
# Alert the user that this is not a valid entry point to MediaWiki if they try to access the skin file directly.
if (!defined('MEDIAWIKI')) {
echo <<<EOT
To install Bibwiki, put the following line in LocalSettings.php:
include_once( "$IP/extensions/<Your Bibwiki folder>/Bibwiki.php" );
EOT;
exit( 1 );
}
require_once(dirname(__FILE__)."/BibMarkup.php");
$wgAutoloadClasses['Bibliography'] = dirname(__FILE__) . '/Bibwiki.body.php'; # Tell MediaWiki to load the extension body.
$wgExtensionMessagesFiles['Bibliography'] = dirname(__FILE__) . '/Bibwiki.i18n.php';
$wgSpecialPages['Bibliography'] = 'Bibliography'; # Let MediaWiki know about your new special page.
$wgHooks['LanguageGetSpecialPageAliases'][] = 'BibliographyLocalizedPageName'; # Add any aliases for the special page.
$wgHooks['LoadAllMessages'][] = 'Bibliography::loadMessages'; # Load the internationalization messages for your special page.
$wgHooks['RenderPageTitle'][] = 'wfRenderPageTitle';
$wgExtensionCredits['specialpage'][] = array(
'name' => 'Bibwiki',
'author' =>'Wolfgang Plaschg, OSBiB by Mark Grimshaw, BibCite.php based on Cite.php by Ævar Arnfjörð Bjarmason',
'url' => 'http://www.plaschg.net/bibwiki',
'description' => 'Extension for managing BibTeX Databases'
);
define("NS_BIB", 222);
define("NS_BIB_TALK", 223);
$wgExtraNamespaces[NS_BIB] = "Bib";
$wgExtraNamespaces[NS_BIB_TALK] = "BibTalk";
$wgContentNamespaces[] = NS_BIB;
function BibliographyLocalizedPageName(&$specialPageArray, $code) {
# The localized title of the special page is among the messages of the extension:
wfLoadExtensionMessages(wfMsg('bibliography'));
# Convert from title in text form to DBKey and put it into the alias array:
$title = Title::newFromText(wfMsg('bibliography'));
$specialPageArray[wfMsg('bibliography')][] = wfMsg('bibliography');
return true;
}
function wfRenderPageTitle(&$skin) {
global $wgScript, $wgUser, $wgContLang;
/*
$title = $skin->data['title'];
$f = "";
if (strstr($title, "/") !== false) {
$split = explode("/", $title, 2);
$f = strtolower($split[0]);
$key = $split[1];
print $wgUser->getSkin()->makeKnownLink( $wgContLang->specialPage( "Bibliography" ), $key, "startkey=".$key . "&f=".$f );
}
*/
if (strpos($skin->data['title'], "Bib:") === 0) {
$key = str_replace("Bib:", "", $skin->data['title']);
print $wgUser->getSkin()->makeKnownLink( $wgContLang->specialPage( wfMsg("bibliography") ), $skin->data['title'], "startkey=".$key );
}
else
#print $skin->data['title'];
print $wgUser->getSkin()->makeKnownLink( $wgContLang->specialPage( wfMsg("bibliography") ), $skin->data['title'], "startkey=".$skin->data['title'] );
return true;
}