Patch by ireas for bug 20218: adding title attribute for toolbox link, making code nicer using MediaWiki classes

This commit is contained in:
Tobias 2009-09-23 19:55:45 +00:00
parent b6cb2d45d9
commit 22d58ec055
2 changed files with 31 additions and 21 deletions

View file

@ -10,6 +10,7 @@ $messages = array();
$messages['en'] = array(
'cite_article_desc' => 'Adds a [[Special:Cite|citation]] special page and toolbox link',
'cite_article_link' => 'Cite this page',
'cite_article_link_title' => 'Information how to cite this page',
'cite' => 'Cite',
'cite_page' => 'Page:',
'cite_submit' => 'Cite',

View file

@ -9,6 +9,7 @@ if (!defined('MEDIAWIKI')) die();
* @link http://www.mediawiki.org/wiki/Extension:Cite/Special:Cite.php Documentation
*
* @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
* @author Ireas <ireas@rkrahl.de>
* @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
*/
@ -16,7 +17,7 @@ if (!defined('MEDIAWIKI')) die();
$wgExtensionCredits['specialpage'][] = array(
'path' => __FILE__,
'name' => 'Cite',
'author' => 'Ævar Arnfjörð Bjarmason',
'author' => 'Ævar Arnfjörð Bjarmason, Ireas',
'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'
@ -35,26 +36,34 @@ $wgAutoloadClasses['SpecialCite'] = $dir . 'SpecialCite_body.php';
function wfSpecialCiteNav( &$skintemplate, &$nav_urls, &$oldid, &$revid ) {
wfLoadExtensionMessages( 'SpecialCite' );
if ( $skintemplate->mTitle->isContentPage() && $revid !== 0 )
// check whether were in the right namespace, the $revid has the correct type and is not empty
// (what would mean that the current page doesnt exist)
if ( $skintemplate->mTitle->isContentPage() && $revid !== 0 && !empty( $revid ) )
$nav_urls['cite'] = array(
'text' => wfMsg( 'cite_article_link' ),
'href' => $skintemplate->makeSpecialUrl( 'Cite', "page=" . wfUrlencode( "{$skintemplate->thispage}" ) . "&id=$revid" )
'args' => "page=" . wfUrlencode( "{$skintemplate->thispage}" ) . "&id=$revid"
);
return true;
}
/**
* call the function that adds the cite link in the toolbar
*/
function wfSpecialCiteToolbox( &$skin ) {
if ( isset( $skin->data['nav_urls']['cite'] ) ) {
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
echo Xml::tags(
'li',
array( 'id' => 't-cite' ),
$skin->skin->link(
SpecialPage::getTitleFor( 'Cite' ),
wfMsg( 'cite_article_link' ),
array(
'title' => wfMsg( 'cite_article_link_title' )
),
$skin->data['nav_urls']['cite']['args']
)
);
}
return true;