Index: trunk/extensions/Click/Click.php |
— | — | @@ -3,14 +3,14 @@ |
4 | 4 | /** |
5 | 5 | * Click Extension |
6 | 6 | * |
7 | | - * dds a parser function to display an image with a link that leads to a page other than the image description page. |
| 7 | + * Adds a parser function to display an image with a link that leads to a page other than the image description page. |
8 | 8 | * |
9 | 9 | * @addtogroup Extensions |
10 | 10 | * |
11 | 11 | * @link http://www.mediawiki.org/wiki/Extension:Click |
12 | 12 | * |
13 | 13 | * @author MinuteElectron <minuteelectron@googlemail.com> |
14 | | - * @copyright Copyright � 2008 MinuteElectron. |
| 14 | + * @copyright Copyright � 2008 MinuteElectron and Danny B. |
15 | 15 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
16 | 16 | */ |
17 | 17 | |
— | — | @@ -21,9 +21,9 @@ |
22 | 22 | $wgExtensionCredits[ 'parserhook' ][] = array( |
23 | 23 | 'name' => 'Click', |
24 | 24 | 'description' => 'Adds a parser function to display an image with a link that leads to a page other than the image description page.', |
25 | | - 'author' => 'MinuteElectron', |
| 25 | + 'author' => array( 'MinuteElectron', 'Danny B.' ), |
26 | 26 | 'url' => 'http://www.mediawiki.org/wiki/Extension:Click', |
27 | | - 'version' => '1.3', |
| 27 | + 'version' => '1.4', |
28 | 28 | ); |
29 | 29 | |
30 | 30 | // Setup function. |
— | — | @@ -35,14 +35,14 @@ |
36 | 36 | function efClickParserFunction_Setup() { |
37 | 37 | global $wgParser; |
38 | 38 | // Register parser function hook. |
39 | | - $wgParser->setFunctionHook( 'Click', 'efClickParserFunction_Render' ); |
| 39 | + $wgParser->setFunctionHook( 'click', 'efClickParserFunction_Render' ); |
40 | 40 | // Return true so things don't break. |
41 | 41 | return true; |
42 | 42 | } |
43 | 43 | |
44 | 44 | function efClickParserFunction_Magic( &$magicWords, $langCode ) { |
45 | 45 | // Register parser function magic word. |
46 | | - $magicWords[ 'Click' ] = array( 0, 'Click' ); |
| 46 | + $magicWords[ 'click' ] = array( 0, 'click' ); |
47 | 47 | // Return true so things don't break. |
48 | 48 | return true; |
49 | 49 | } |
— | — | @@ -51,11 +51,11 @@ |
52 | 52 | |
53 | 53 | // Width and alt-text are interchangable. |
54 | 54 | // No need to escape here, automatically done by Xml class functions. |
55 | | - if( preg_match( '#^[0|1|2|3|4|5|6|7|8|9]*px$#', $widthalt ) ) { |
| 55 | + if( preg_match( '#^[0-9]+px$#', $widthalt ) ) { |
56 | 56 | // First value width, second alt. |
57 | 57 | $width = $widthalt; |
58 | 58 | $alt = $altwidth; |
59 | | - } elseif( preg_match( '#^[0|1|2|3|4|5|6|7|8|9]*px$#', $altwidth ) ) { |
| 59 | + } elseif( preg_match( '#^[0-9]+px$#', $altwidth ) ) { |
60 | 60 | // First value alt, second width. |
61 | 61 | $alt = $widthalt; |
62 | 62 | $width = $altwidth; |
— | — | @@ -68,9 +68,15 @@ |
69 | 69 | // Open hyperlink, default to a on-wiki page, but if it doesn't exist and |
70 | 70 | // is a valid external URL then use it. |
71 | 71 | $targettitle = Title::newFromText( $target ); |
| 72 | + // Link title attribute (full page name). |
| 73 | + if( $targettitle->getNamespace() !== 0 ) { |
| 74 | + $title = $targettitle->getNsText() . ':' . $targettitle->getText(); |
| 75 | + } else { |
| 76 | + $title = $targettitle->getText(); |
| 77 | + } |
72 | 78 | if( is_object( $targettitle ) && $targettitle->exists() ) { |
73 | 79 | // Internal link, open hyperlink and register internal link. |
74 | | - $r = Xml::openElement( 'a', array( 'href' => $targettitle->getLocalUrl(), 'title' => $alt ) ); |
| 80 | + $r = Xml::openElement( 'a', array( 'href' => $targettitle->getLocalUrl(), 'title' => $title ) ); |
75 | 81 | $parser->mOutput->addLink( $targettitle ); |
76 | 82 | } else { |
77 | 83 | // Internal page doesn't exist, test if external. |
— | — | @@ -84,11 +90,11 @@ |
85 | 91 | } |
86 | 92 | if( $ext ) { |
87 | 93 | // External link, open hyperlink with escaped href and register external link. |
88 | | - $r = Xml::openElement( 'a', array( 'href' => htmlspecialchars( $target ), 'title' => $alt ) ); |
| 94 | + $r = Xml::openElement( 'a', array( 'href' => $target, 'title' => $target ) ); |
89 | 95 | $parser->mOutput->addExternalLink( $target ); |
90 | 96 | } elseif( is_object( $targettitle ) ) { |
91 | 97 | // Valid internal link after all (but to non-existant page), open hyperlink and register internal link. |
92 | | - $r = Xml::openElement( 'a', array( 'class' => 'new', 'href' => $targettitle->getLocalUrl( 'action=edit&redlink=1' ), 'title' => $alt ) ); |
| 98 | + $r = Xml::openElement( 'a', array( 'class' => 'new', 'href' => $targettitle->getLocalUrl( 'action=edit&redlink=1' ), 'title' => wfMsg( 'red-link-title', $title ) ) ); |
93 | 99 | $parser->mOutput->addLink( $targettitle ); |
94 | 100 | } |
95 | 101 | } |