Modified filelink[] tag output to include a class and title attribute, similar to...
authorAdrian Oldham <adriann@visualthought.com.au>
Sun, 29 Apr 2007 04:34:50 +0000 (04:34 +0000)
committeradriann <adriann@45cb6cf1-00bc-42d2-bb5a-07f51df49f94>
Sun, 29 Apr 2007 04:34:50 +0000 (04:34 +0000)
site/cgi-bin/modules/BSE/Formatter.pm

index 80108d79c5d473516943825681102c4480eb7ff1..77d273947fe1bc4cc2e1dd74f829d76fa4c4654e 100644 (file)
@@ -321,7 +321,7 @@ sub popimage {
 }
 
 sub filelink {
-  my ($self, $fileid, $text) = @_;
+  my ($self, $fileid, $text, $type) = @_;
 
   my ($file) = grep $_->{name} eq $fileid, @{$self->{files}}
     or return "** unknown file $fileid **";
@@ -331,8 +331,16 @@ sub filelink {
     return escape_html($title);
   }
   else {
+    my $title_attrib = "Filename: " . escape_html($file->{displayName});
+    my $class_text = '';
+    if ($type) {
+      my $class = $self->tag_class($type);
+      if ($class) {
+        $class_text = qq/ class="$class"/; 
+      }
+    }
     my $url = "/cgi-bin/user.pl?download_file=1&file=$file->{id}";
-    return qq!<a href="! . escape_html($url) . qq!">! .
+    return qq!<a href="! . escape_html($url) . qq!" title="$title_attrib"$class_text>! .
       escape_html($title) . "</a>";
   }
 }
@@ -362,9 +370,9 @@ sub replace {
     and return 1;
   $$rpart =~ s#formlink\[(\w+)\]# $self->formlink($1, 'formlink', undef) #ige
     and return 1;
-  $$rpart =~ s#filelink\[\s*(\w+)\s*\|([^\]\[]+)\]# $self->filelink($1, $2) #ige
+  $$rpart =~ s#filelink\[\s*(\w+)\s*\|([^\]\[]+)\]# $self->filelink($1, $2, 'filelink') #ige
       and return 1;
-  $$rpart =~ s#filelink\[\s*(\w+)\s*\]# $self->filelink($1) #ige
+  $$rpart =~ s#filelink\[\s*(\w+)\s*\]# $self->filelink($1, undef, 'filelink') #ige
       and return 1;
   $$rpart =~ s#popimage\[([^\[\]]+)\]# $self->popimage($1) #ige
     and return 1;