2005-11-26 23:22:24 +00:00
|
|
|
|
<?php
|
2010-04-17 21:07:37 +00:00
|
|
|
|
if ( !defined( 'MEDIAWIKI' ) ) die();
|
2005-11-26 23:22:24 +00:00
|
|
|
|
/**
|
|
|
|
|
* A special page extension that adds a special page that generates citations
|
|
|
|
|
* for pages.
|
|
|
|
|
*
|
2010-06-06 15:12:22 +00:00
|
|
|
|
* @file
|
|
|
|
|
* @ingroup Extensions
|
2005-11-26 23:22:24 +00:00
|
|
|
|
*
|
2008-07-09 15:09:55 +00:00
|
|
|
|
* @link http://www.mediawiki.org/wiki/Extension:Cite/Special:Cite.php Documentation
|
2005-11-26 23:22:24 +00:00
|
|
|
|
*
|
2006-08-28 01:08:30 +00:00
|
|
|
|
* @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
|
|
|
|
|
* @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
|
2005-11-26 23:22:24 +00:00
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
$wgExtensionCredits['specialpage'][] = array(
|
2009-04-27 03:15:19 +00:00
|
|
|
|
'path' => __FILE__,
|
2005-11-26 23:22:24 +00:00
|
|
|
|
'name' => 'Cite',
|
2009-09-23 20:54:53 +00:00
|
|
|
|
'author' => 'Ævar Arnfjörð Bjarmason',
|
2008-01-31 14:38:12 +00:00
|
|
|
|
'descriptionmsg' => 'cite_article_desc',
|
2007-12-16 18:38:50 +00:00
|
|
|
|
'url' => 'http://www.mediawiki.org/wiki/Extension:Cite/Special:Cite.php'
|
2005-11-26 23:22:24 +00:00
|
|
|
|
);
|
|
|
|
|
|
2010-04-17 21:07:37 +00:00
|
|
|
|
$dir = dirname( __FILE__ ) . '/';
|
2006-07-15 15:17:32 +00:00
|
|
|
|
# Internationalisation file
|
2008-07-09 15:09:55 +00:00
|
|
|
|
$wgExtensionMessagesFiles['SpecialCite'] = $dir . 'SpecialCite.i18n.php';
|
2009-05-24 22:12:11 +00:00
|
|
|
|
$wgExtensionAliasesFiles['SpecialCite'] = $dir . 'SpecialCite.alias.php';
|
2006-07-03 13:11:35 +00:00
|
|
|
|
|
2005-11-26 23:22:24 +00:00
|
|
|
|
$wgHooks['SkinTemplateBuildNavUrlsNav_urlsAfterPermalink'][] = 'wfSpecialCiteNav';
|
2008-10-30 16:12:17 +00:00
|
|
|
|
$wgHooks['SkinTemplateToolboxEnd'][] = 'wfSpecialCiteToolbox';
|
2005-11-26 23:22:24 +00:00
|
|
|
|
|
2008-05-01 12:48:22 +00:00
|
|
|
|
$wgSpecialPages['Cite'] = 'SpecialCite';
|
|
|
|
|
$wgAutoloadClasses['SpecialCite'] = $dir . 'SpecialCite_body.php';
|
2005-11-26 23:22:24 +00:00
|
|
|
|
|
2007-05-01 17:40:30 +00:00
|
|
|
|
function wfSpecialCiteNav( &$skintemplate, &$nav_urls, &$oldid, &$revid ) {
|
2009-09-23 19:55:45 +00:00
|
|
|
|
// check whether we’re in the right namespace, the $revid has the correct type and is not empty
|
|
|
|
|
// (what would mean that the current page doesn’t exist)
|
2011-04-04 15:26:54 +00:00
|
|
|
|
if ( $skintemplate->getTitle()->isContentPage() && $revid !== 0 && !empty( $revid ) )
|
2005-11-28 03:05:00 +00:00
|
|
|
|
$nav_urls['cite'] = array(
|
2009-09-23 19:55:45 +00:00
|
|
|
|
'args' => "page=" . wfUrlencode( "{$skintemplate->thispage}" ) . "&id=$revid"
|
2005-11-28 03:05:00 +00:00
|
|
|
|
);
|
2008-01-09 20:52:38 +00:00
|
|
|
|
|
2005-11-26 23:22:24 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-23 19:55:45 +00:00
|
|
|
|
/**
|
2009-09-23 20:54:53 +00:00
|
|
|
|
* add the cite link to the toolbar
|
2009-09-23 19:55:45 +00:00
|
|
|
|
*/
|
2008-10-30 16:12:17 +00:00
|
|
|
|
function wfSpecialCiteToolbox( &$skin ) {
|
2010-04-26 10:34:29 +00:00
|
|
|
|
global $wgUser;
|
|
|
|
|
|
2009-09-23 19:55:45 +00:00
|
|
|
|
if ( isset( $skin->data['nav_urls']['cite'] ) ) {
|
2010-04-26 10:34:29 +00:00
|
|
|
|
echo Html::rawElement(
|
2010-04-17 21:07:37 +00:00
|
|
|
|
'li',
|
|
|
|
|
array( 'id' => 't-cite' ),
|
2009-09-23 19:55:45 +00:00
|
|
|
|
$skin->skin->link(
|
|
|
|
|
SpecialPage::getTitleFor( 'Cite' ),
|
|
|
|
|
wfMsg( 'cite_article_link' ),
|
2010-04-26 10:34:29 +00:00
|
|
|
|
# Used message keys: 'tooltip-cite-article', 'accesskey-cite-article'
|
|
|
|
|
$wgUser->getSkin()->tooltipAndAccessKeyAttribs( 'cite-article' ),
|
2009-09-23 19:55:45 +00:00
|
|
|
|
$skin->data['nav_urls']['cite']['args']
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
2008-01-09 20:52:38 +00:00
|
|
|
|
|
2005-11-26 23:22:24 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|