SpecialCite.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. if (!defined('MEDIAWIKI')) die();
  3. /**
  4. * A special page extension that adds a special page that generates citations
  5. * for pages.
  6. *
  7. * @addtogroup Extensions
  8. *
  9. * @link http://www.mediawiki.org/wiki/Extension:Cite/Special:Cite.php Documentation
  10. *
  11. * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
  12. * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
  13. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
  14. */
  15. $wgExtensionCredits['specialpage'][] = array(
  16. 'name' => 'Cite',
  17. 'svn-date' => '$LastChangedDate: 2008-10-30 16:12:17 +0000 (Thu, 30 Oct 2008) $',
  18. 'svn-revision' => '$LastChangedRevision: 42818 $',
  19. 'author' => 'Ævar Arnfjörð Bjarmason',
  20. 'description' => 'adds a [[Special:Cite|citation]] special page & toolbox link', // kept for b/c
  21. 'descriptionmsg' => 'cite_article_desc',
  22. 'url' => 'http://www.mediawiki.org/wiki/Extension:Cite/Special:Cite.php'
  23. );
  24. $dir = dirname(__FILE__) . '/';
  25. # Internationalisation file
  26. $wgExtensionMessagesFiles['SpecialCite'] = $dir . 'SpecialCite.i18n.php';
  27. $wgExtensionAliasesFiles['SpecialCite'] = $dir . 'SpecialCite.i18n.alias.php';
  28. $wgHooks['SkinTemplateBuildNavUrlsNav_urlsAfterPermalink'][] = 'wfSpecialCiteNav';
  29. $wgHooks['SkinTemplateToolboxEnd'][] = 'wfSpecialCiteToolbox';
  30. $wgSpecialPages['Cite'] = 'SpecialCite';
  31. $wgAutoloadClasses['SpecialCite'] = $dir . 'SpecialCite_body.php';
  32. function wfSpecialCiteNav( &$skintemplate, &$nav_urls, &$oldid, &$revid ) {
  33. wfLoadExtensionMessages( 'SpecialCite' );
  34. if ( $skintemplate->mTitle->isContentPage() && $revid !== 0 )
  35. $nav_urls['cite'] = array(
  36. 'text' => wfMsg( 'cite_article_link' ),
  37. 'href' => $skintemplate->makeSpecialUrl( 'Cite', "page=" . wfUrlencode( "{$skintemplate->thispage}" ) . "&id=$revid" )
  38. );
  39. return true;
  40. }
  41. function wfSpecialCiteToolbox( &$skin ) {
  42. wfLoadExtensionMessages( 'SpecialCite' );
  43. if ( isset( $skin->data['nav_urls']['cite'] ) )
  44. if ( $skin->data['nav_urls']['cite']['href'] == '' ) {
  45. ?><li id="t-iscite"><?php echo $skin->msg( 'cite_article_link' ); ?></li><?php
  46. } else {
  47. ?><li id="t-cite"><?php
  48. ?><a href="<?php echo htmlspecialchars( $skin->data['nav_urls']['cite']['href'] ) ?>"><?php
  49. echo $skin->msg( 'cite_article_link' );
  50. ?></a><?php
  51. ?></li><?php
  52. }
  53. return true;
  54. }