You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.4 KiB

  1. <?php
  2. /**
  3. * Refbase entry renderer using simple hyperlink and tooltip
  4. */
  5. class RefbaseRendererLink extends RefbaseRenderer {
  6. /// Object generating citations
  7. private $citationCreator;
  8. /**
  9. * Constructor (simply inherit from parent)
  10. */
  11. public function __construct( $citationType ) {
  12. parent::__construct();
  13. $this->citationCreator = new RefbaseCitationCreator( $citationType );
  14. }
  15. /**
  16. * List fields required to build template
  17. */
  18. public function getFieldList() {
  19. $citeList = $this->citationCreator->getFieldList();
  20. return array_unique( array_merge( array( 'serial' ), $citeList ) );
  21. }
  22. /**
  23. * Render output: add wiki link to refbase page, include citation in tooltip
  24. */
  25. public function render( $entry, & $cite, $options ) {
  26. $citekey = $options['citekey'];
  27. $cite = "";
  28. // Simply link to refbase, and add tooltip
  29. // (form string [URL <span title="CITATION"> KEY </span>] )
  30. // Display the key (cite_key or serial number as wiki text)
  31. $wikiText = $citekey;
  32. // Add full citation as a tooltip
  33. $toolTip = "";
  34. $this->citationCreator->createCitation( $entry, $toolTip );
  35. // Link to refbase page for current entry
  36. $link = $this->refbaseURL . "show.php?record=" . $entry['serial'];
  37. // Build full string
  38. $cite .= "[" . $link . " ";
  39. $cite .= Html::openElement( 'span', array( 'title' => "\"" . $toolTip . "\"" ) );
  40. $cite .= $wikiText . Html::closeElement( 'span' ) . "]";
  41. return true;
  42. }
  43. }