r56832 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r56831‎ | r56832 | r56833 >
Date:19:55, 23 September 2009
Author:churchofemacs
Status:resolved
Tags:
Comment:
Patch by ireas for bug 20218: adding title attribute for toolbox link, making code nicer using MediaWiki classes
Modified paths:
  • /trunk/extensions/Cite/SpecialCite.i18n.php (modified) (history)
  • /trunk/extensions/Cite/SpecialCite.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Cite/SpecialCite.i18n.php
@@ -8,12 +8,13 @@
99 $messages = array();
1010
1111 $messages['en'] = array(
12 - 'cite_article_desc' => 'Adds a [[Special:Cite|citation]] special page and toolbox link',
13 - 'cite_article_link' => 'Cite this page',
14 - 'cite' => 'Cite',
15 - 'cite_page' => 'Page:',
16 - 'cite_submit' => 'Cite',
17 - 'cite_text' => '', # Do not translate this
 12+ 'cite_article_desc' => 'Adds a [[Special:Cite|citation]] special page and toolbox link',
 13+ 'cite_article_link' => 'Cite this page',
 14+ 'cite_article_link_title' => 'Information how to cite this page',
 15+ 'cite' => 'Cite',
 16+ 'cite_page' => 'Page:',
 17+ 'cite_submit' => 'Cite',
 18+ 'cite_text' => '', # Do not translate this
1819 );
1920
2021 /** Message documentation (Message documentation)
Index: trunk/extensions/Cite/SpecialCite.php
@@ -9,6 +9,7 @@
1010 * @link http://www.mediawiki.org/wiki/Extension:Cite/Special:Cite.php Documentation
1111 *
1212 * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
 13+ * @author Ireas <ireas@rkrahl.de>
1314 * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
1415 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
1516 */
@@ -16,7 +17,7 @@
1718 $wgExtensionCredits['specialpage'][] = array(
1819 'path' => __FILE__,
1920 'name' => 'Cite',
20 - 'author' => 'Ævar Arnfjörð Bjarmason',
 21+ 'author' => 'Ævar Arnfjörð Bjarmason, Ireas',
2122 'description' => 'adds a [[Special:Cite|citation]] special page & toolbox link', // kept for b/c
2223 'descriptionmsg' => 'cite_article_desc',
2324 'url' => 'http://www.mediawiki.org/wiki/Extension:Cite/Special:Cite.php'
@@ -35,27 +36,35 @@
3637
3738 function wfSpecialCiteNav( &$skintemplate, &$nav_urls, &$oldid, &$revid ) {
3839 wfLoadExtensionMessages( 'SpecialCite' );
39 - if ( $skintemplate->mTitle->isContentPage() && $revid !== 0 )
 40+ // check whether we’re in the right namespace, the $revid has the correct type and is not empty
 41+ // (what would mean that the current page doesn’t exist)
 42+ if ( $skintemplate->mTitle->isContentPage() && $revid !== 0 && !empty( $revid ) )
4043 $nav_urls['cite'] = array(
41 - 'text' => wfMsg( 'cite_article_link' ),
42 - 'href' => $skintemplate->makeSpecialUrl( 'Cite', "page=" . wfUrlencode( "{$skintemplate->thispage}" ) . "&id=$revid" )
 44+ 'args' => "page=" . wfUrlencode( "{$skintemplate->thispage}" ) . "&id=$revid"
4345 );
4446
4547 return true;
4648 }
4749
 50+/**
 51+ * call the function that adds the cite link in the toolbar
 52+ */
4853 function wfSpecialCiteToolbox( &$skin ) {
49 - wfLoadExtensionMessages( 'SpecialCite' );
50 - if ( isset( $skin->data['nav_urls']['cite'] ) )
51 - if ( $skin->data['nav_urls']['cite']['href'] == '' ) {
52 - ?><li id="t-iscite"><?php echo $skin->msg( 'cite_article_link' ); ?></li><?php
53 - } else {
54 - ?><li id="t-cite"><?php
55 - ?><a href="<?php echo htmlspecialchars( $skin->data['nav_urls']['cite']['href'] ) ?>"><?php
56 - echo $skin->msg( 'cite_article_link' );
57 - ?></a><?php
58 - ?></li><?php
59 - }
 54+ if ( isset( $skin->data['nav_urls']['cite'] ) ) {
 55+ wfLoadExtensionMessages( 'SpecialCite' );
 56+ echo Xml::tags(
 57+ 'li',
 58+ array( 'id' => 't-cite' ),
 59+ $skin->skin->link(
 60+ SpecialPage::getTitleFor( 'Cite' ),
 61+ wfMsg( 'cite_article_link' ),
 62+ array(
 63+ 'title' => wfMsg( 'cite_article_link_title' )
 64+ ),
 65+ $skin->data['nav_urls']['cite']['args']
 66+ )
 67+ );
 68+ }
6069
6170 return true;
6271 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r56836Follow-up on r56832: fixing some minor issues avar brought to attention about...churchofemacs20:54, 23 September 2009

Status & tagging log