[Home]WikiPatches/UploadUrlWithBracketText

UseModWiki | WikiPatches | RecentChanges | Preferences

I did the following to get upload-URLs to work as BracketText-links and as numbered (is that what you call it?) bracket links:
@@ -1640,6 +1688,7 @@
     }
     if ($BracketText) {  # Links like [URL text of link]
       s/\[$UrlPattern\s+([^\]]+?)\]/&StoreBracketUrl($1, $2, $useImage)/geos;
+      s/\[$UploadPattern\s+([^\]]+?)\]/&StoreBracketUpload($1, $2, $useImage)/geos;
       s/\[$InterLinkPattern\s+([^\]]+?)\]/&StoreBracketInterPage($1, $2,
                                                              $useImage)/geos;
       if ($WikiLinks && $BracketWiki) {  # Local bracket-links
@@ -1649,9 +1698,13 @@
       }
     }
     s/\[$UrlPattern\]/&StoreBracketUrl($1, "", 0)/geo;
+    s/\[$UploadPattern\]/&StoreBracketUpload($1, "", 0)/geo;
     s/\[$InterLinkPattern\]/&StoreBracketInterPage($1, "", 0)/geo;
     s/\b$UrlPattern/&StoreUrl($1, $useImage)/geo;
     s/\b$InterLinkPattern/&StoreInterPage($1, $useImage)/geo;
+    if ($UseUpload) {
+      s/$UploadPattern/&StoreUpload($1)/geo;
+    }
     if ($WikiLinks) {
       s/$AnchoredLinkPattern/&StoreRaw(&GetPageOrEditAnchoredLink($1,
                              $2, ""))/geo if $NamedAnchors;
@@ -1965,6 +1969,20 @@
   return &StoreRaw("<a href=\"$url\">$text</a>");
 }
 
+sub StoreBracketUpload {
+  my ($url, $text, $useImage) = @_;
+
+  if ($text eq "") {
+    $text = &GetBracketUrlIndex($url);
+  }
+  if ($BracketImg && $useImage && &ImageAllowed($text)) {
+    $text = "<img src=\"$text\">";
+  } else {
+    $text = "[$text]";
+  }
+  return &StoreRaw("<a href=\"$UploadUrl/$url\">$text</a>");
+}
+
 sub StoreBracketLink {
   my ($name, $text) = @_;
 

UseModWiki | WikiPatches | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited July 3, 2014 7:56 pm by MarkusLude (diff)
Search: