mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CiteThisPage
synced 2024-11-28 01:10:00 +00:00
Implements #7908 : add reference text as a tooltip in the reference link.
Patch by Dirk Beetstra <djbeetstra@hotmail.com>.
This commit is contained in:
parent
04be9456d3
commit
553bb17c85
|
@ -47,6 +47,9 @@ $wgCiteMessages['en'] = array(
|
|||
'cite_reference_link' => '<sup id="$1" class="reference">[[#$2|<nowiki>[</nowiki>$3<nowiki>]</nowiki>]]</sup>',
|
||||
'cite_references_link_one' => '<li id="$1">[[#$2|↑]] $3</li>',
|
||||
'cite_references_link_many' => '<li id="$1">↑ $2 $3</li>',
|
||||
'cite_scriptline_prefix' => '<script type = "text/javascript">/*<![CDATA[*/',
|
||||
'cite_scriptline' => 'var ref=document.getElementById("$1");ref.title="$2";',
|
||||
'cite_scriptline_suffix' => '/*]]>*/</script>',
|
||||
'cite_references_link_many_format' => '[[#$1|<sup>$2</sup>]]',
|
||||
# An item from this set is passed as $3 in the message above
|
||||
'cite_references_link_many_format_backlink_labels' => 'a b c d e f g h i j k l m n o p q r s t u v w x y z',
|
||||
|
|
49
Cite.php
49
Cite.php
|
@ -345,16 +345,57 @@ function wfCite() {
|
|||
*/
|
||||
function referencesFormat() {
|
||||
$ent = array();
|
||||
|
||||
foreach ( $this->mRefs as $k => $v )
|
||||
$varlist = "";
|
||||
foreach ( $this->mRefs as $k => $v ) {
|
||||
$ent[] = $this->referencesFormatEntry( $k, $v );
|
||||
$varlist .= $this->referencesTagName($k, $v);
|
||||
}
|
||||
|
||||
$prefix = wfMsgForContentNoTrans( 'cite_references_prefix' );
|
||||
$suffix = wfMsgForContentNoTrans( 'cite_references_suffix' );
|
||||
$varprefix = wfMsgForContentNoTrans( 'cite_scriptline_prefix' );
|
||||
$varsuffix = wfMsgForContentNoTrans( 'cite_scriptline_suffix' );
|
||||
$content = implode( "\n", $ent );
|
||||
|
||||
// Live hack: parse() adds two newlines on WM, can't reproduce it locally -ævar
|
||||
return rtrim( $this->parse( $prefix . $content . $suffix ), "\n" );
|
||||
return rtrim( $this->parse( $prefix . $content . $suffix ), "\n" ) . $varprefix . " " . $varlist . " " . $varsuffix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a scriptline for the tooltip of the reference
|
||||
*
|
||||
* @param string $key The key of the reference
|
||||
* @param mixed $val The value of the reference, string for anonymous
|
||||
* references, array for user-supplied
|
||||
* @return string javascript
|
||||
*/
|
||||
function referencesTagName($key, $val) {
|
||||
// Anonymous reference
|
||||
if ( ! is_array( $val ) )
|
||||
return wfMsgForContentNoTrans(
|
||||
'cite_scriptline',
|
||||
$this->refKey($key),
|
||||
str_replace(array("\"", "\'"), "", strip_tags($this->parse($val)))
|
||||
);
|
||||
// Named references with only 1 occurence
|
||||
else if ( $val['count'] === 0 ) {
|
||||
return wfMsgForContentNoTrans(
|
||||
'cite_scriptline',
|
||||
$this->refKey($key,0),
|
||||
str_replace(array("\"", "\'"), "", strip_tags($this->parse($val['text'])))
|
||||
);
|
||||
// Named references with >1 occurrences
|
||||
} else {
|
||||
$links = "";
|
||||
for ( $i = 0; $i <= $val['count']; ++$i ) {
|
||||
$links .= wfMsgForContentNoTrans(
|
||||
'cite_scriptline',
|
||||
$this->refKey($key, $i),
|
||||
str_replace(array("\"", "\'"), "", strip_tags($this->parse($val['text'])))
|
||||
);
|
||||
}
|
||||
return $links;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -362,7 +403,7 @@ function wfCite() {
|
|||
*
|
||||
* @param string $key The key of the reference
|
||||
* @param mixed $val The value of the reference, string for anonymous
|
||||
* references, array for user-suppplied
|
||||
* references, array for user-supplied
|
||||
* @return string Wikitext
|
||||
*/
|
||||
function referencesFormatEntry( $key, $val ) {
|
||||
|
|
Loading…
Reference in a new issue