mediawiki-extensions-Cite/SpecialCite.php

62 lines
2.1 KiB
PHP
Raw Normal View History

<?php
if (!defined('MEDIAWIKI')) die();
/**
* A special page extension that adds a special page that generates citations
* for pages.
*
* @addtogroup Extensions
*
2008-07-09 15:09:55 +00:00
* @link http://www.mediawiki.org/wiki/Extension:Cite/Special:Cite.php Documentation
*
* @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
*/
$wgExtensionCredits['specialpage'][] = array(
'path' => __FILE__,
'name' => 'Cite',
'author' => 'Ævar Arnfjörð Bjarmason',
'description' => 'adds a [[Special:Cite|citation]] special page & toolbox link', // kept for b/c
'descriptionmsg' => 'cite_article_desc',
'url' => 'http://www.mediawiki.org/wiki/Extension:Cite/Special:Cite.php'
);
2008-07-09 15:09:55 +00:00
$dir = dirname(__FILE__) . '/';
# Internationalisation file
2008-07-09 15:09:55 +00:00
$wgExtensionMessagesFiles['SpecialCite'] = $dir . 'SpecialCite.i18n.php';
$wgExtensionAliasesFiles['SpecialCite'] = $dir . 'SpecialCite.alias.php';
$wgHooks['SkinTemplateBuildNavUrlsNav_urlsAfterPermalink'][] = 'wfSpecialCiteNav';
$wgHooks['SkinTemplateToolboxEnd'][] = 'wfSpecialCiteToolbox';
2008-05-01 12:48:22 +00:00
$wgSpecialPages['Cite'] = 'SpecialCite';
$wgAutoloadClasses['SpecialCite'] = $dir . 'SpecialCite_body.php';
function wfSpecialCiteNav( &$skintemplate, &$nav_urls, &$oldid, &$revid ) {
2008-01-10 20:27:47 +00:00
wfLoadExtensionMessages( 'SpecialCite' );
if ( $skintemplate->mTitle->isContentPage() && $revid !== 0 )
$nav_urls['cite'] = array(
'text' => wfMsg( 'cite_article_link' ),
'href' => $skintemplate->makeSpecialUrl( 'Cite', "page=" . wfUrlencode( "{$skintemplate->thispage}" ) . "&id=$revid" )
);
return true;
}
function wfSpecialCiteToolbox( &$skin ) {
2008-01-10 20:27:47 +00:00
wfLoadExtensionMessages( 'SpecialCite' );
if ( isset( $skin->data['nav_urls']['cite'] ) )
if ( $skin->data['nav_urls']['cite']['href'] == '' ) {
?><li id="t-iscite"><?php echo $skin->msg( 'cite_article_link' ); ?></li><?php
} else {
?><li id="t-cite"><?php
?><a href="<?php echo htmlspecialchars( $skin->data['nav_urls']['cite']['href'] ) ?>"><?php
echo $skin->msg( 'cite_article_link' );
?></a><?php
?></li><?php
}
return true;
}