2005-11-26 23:22:24 +00:00
|
|
|
<?php
|
|
|
|
if (!defined('MEDIAWIKI')) die();
|
|
|
|
/**
|
|
|
|
* A special page extension that adds a special page that generates citations
|
|
|
|
* for pages.
|
|
|
|
*
|
|
|
|
* @package MediaWiki
|
|
|
|
* @subpackage Extensions
|
|
|
|
*
|
2005-12-25 19:40:11 +00:00
|
|
|
* @link http://meta.wikimedia.org/wiki/Cite/SpecialCite.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
|
|
|
|
*/
|
|
|
|
|
|
|
|
$wgExtensionFunctions[] = 'wfSpecialCite';
|
|
|
|
$wgExtensionCredits['specialpage'][] = array(
|
|
|
|
'name' => 'Cite',
|
2006-08-28 01:08:30 +00:00
|
|
|
'author' => 'Ævar Arnfjörð Bjarmason',
|
2005-11-26 23:22:24 +00:00
|
|
|
'description' => 'adds a [[Special:Cite|citation]] special page & toolbox link',
|
2005-12-25 19:40:11 +00:00
|
|
|
'url' => 'http://meta.wikimedia.org/wiki/Cite/SpecialCite.php'
|
2005-11-26 23:22:24 +00:00
|
|
|
);
|
|
|
|
|
2006-07-15 15:17:32 +00:00
|
|
|
# Internationalisation file
|
2006-07-03 13:11:35 +00:00
|
|
|
require_once( 'SpecialCite.i18n.php' );
|
|
|
|
|
2005-11-26 23:22:24 +00:00
|
|
|
$wgHooks['SkinTemplateBuildNavUrlsNav_urlsAfterPermalink'][] = 'wfSpecialCiteNav';
|
|
|
|
$wgHooks['MonoBookTemplateToolboxEnd'][] = 'wfSpecialCiteToolbox';
|
|
|
|
|
2006-06-29 08:07:00 +00:00
|
|
|
if ( !function_exists( 'extAddSpecialPage' ) ) {
|
|
|
|
require( dirname(__FILE__) . '/../ExtensionFunctions.php' );
|
|
|
|
}
|
|
|
|
extAddSpecialPage( dirname(__FILE__) . '/SpecialCite_body.php', 'Cite', 'SpecialCite' );
|
2005-11-26 23:22:24 +00:00
|
|
|
|
2006-06-29 08:07:00 +00:00
|
|
|
function wfSpecialCite() {
|
2006-07-03 13:11:35 +00:00
|
|
|
# Add messages
|
2006-07-16 21:43:23 +00:00
|
|
|
global $wgMessageCache, $wgSpecialCiteMessages;
|
|
|
|
foreach( $wgSpecialCiteMessages as $key => $value ) {
|
|
|
|
$wgMessageCache->addMessages( $wgSpecialCiteMessages[$key], $key );
|
|
|
|
}
|
2005-11-26 23:22:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function wfSpecialCiteNav( &$skintemplate, &$nav_urls, &$oldid, &$revid ) {
|
2005-11-28 03:05:00 +00:00
|
|
|
if ( $skintemplate->mTitle->getNamespace() === NS_MAIN && $revid !== 0 )
|
|
|
|
$nav_urls['cite'] = array(
|
|
|
|
'text' => wfMsg( 'cite_article_link' ),
|
|
|
|
'href' => $skintemplate->makeSpecialUrl( 'Cite', "page=" . wfUrlencode( "{$skintemplate->thispage}" ) . "&id=$revid" )
|
|
|
|
);
|
|
|
|
|
2005-11-26 23:22:24 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function wfSpecialCiteToolbox( &$monobook ) {
|
|
|
|
if ( isset( $monobook->data['nav_urls']['cite'] ) )
|
|
|
|
if ( $monobook->data['nav_urls']['cite']['href'] == '' ) {
|
2005-11-27 02:55:12 +00:00
|
|
|
?><li id="t-iscite"><?php echo $monobook->msg( 'cite_article_link' ); ?></li><?php
|
2005-11-26 23:22:24 +00:00
|
|
|
} else {
|
2005-11-28 03:05:00 +00:00
|
|
|
?><li id="t-cite"><?php
|
|
|
|
?><a href="<?php echo htmlspecialchars( $monobook->data['nav_urls']['cite']['href'] ) ?>"><?php
|
|
|
|
echo $monobook->msg( 'cite_article_link' );
|
|
|
|
?></a><?php
|
|
|
|
?></li><?php
|
2005-11-26 23:22:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2006-06-29 08:07:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
?>
|