123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- use strict;
- use v5.10;
- AddModuleDescription('no-question-mark.pl', 'No Questionmarks Extension');
- our ($q, $OpenPageName, $ScriptName, %IndexHash, $FootnoteNumber, $UsePathInfo);
- sub GetPageOrEditLink {
- my ($id, $text, $bracket, $free) = @_;
- $id = FreeToNormal($id);
- my ($class, $resolved, $title, $exists) = ResolveId($id);
- if (!$text && $resolved && $bracket) {
- $text = BracketLink(++$FootnoteNumber);
- $class .= ' number';
- $title = $id;
- $title =~ s/_/ /g if $free;
- }
- $text = "[$id]" if not $text and $bracket;
- $text = $id if not $text;
- $text =~ s/_/ /g;
- if ($resolved) {
- return ScriptLink(UrlEncode($resolved), $text, $class, undef, $title);
- } else {
- return GetEditLink($id, $text);
- }
- }
- sub GetDownloadLink {
- my ($name, $image, $revision, $alt) = @_;
- $alt = $name unless $alt;
- $alt =~ s/_/ /g;
- my $id = FreeToNormal($name);
-
- return GetEditLink($id, ($image ? T('image') : T('download')) . ':' . $name, 1)
- unless $IndexHash{$id};
- my $action;
- if ($revision) {
- $action = "action=download;id=" . UrlEncode($id) . ";revision=$revision";
- } elsif ($UsePathInfo) {
- $action = "download/" . UrlEncode($id);
- } else {
- $action = "action=download;id=" . UrlEncode($id);
- }
- if ($image) {
- if ($UsePathInfo and not $revision) {
- $action = $ScriptName . '/' . $action;
- } else {
- $action = $ScriptName . '?' . $action;
- }
- my $result = $q->img({-src=>$action, -alt=>$alt, -class=>'upload'});
- $result = ScriptLink(UrlEncode($id), $result, 'image') unless $id eq $OpenPageName;
- return $result;
- } else {
- return ScriptLink($action, $alt, 'upload');
- }
- }
|