Improved rendering
[phpeclipse.git] / archive / org.plog4u.wiki / src / org / plog4u / wiki / filter / WikipediaFilter.java
index 0645fb9..af37725 100644 (file)
@@ -701,95 +701,95 @@ public class WikipediaFilter extends FilterSupport implements CacheFilter, IWiki
     result.append("</a></span>");
   }
 
-  public static void handleSnipLink(StringBuffer result, RenderEngine wikiEngine, String name) {
-    if (name != null) {
-      int index = name.indexOf("http://");
-      // Configuration probably wrote [http://radeox.org] instead of http://radeox.org
-      if (index != -1) {
-        createExternalLink(result, wikiEngine, name.substring(index));
-        // show error
-        // fResult.append("<div class=\"error\">Do not surround URLs with [...].</div>");
-      } else {
-        // trim the name and unescape it
-        name = Encoder.unescape(name.trim());
-        //                Is there an alias like [alias|link] ?
-        int pipeIndex = name.indexOf('|');
-        String alias = "";
-        if (-1 != pipeIndex) {
-          alias = name.substring(0, pipeIndex);
-          name = name.substring(pipeIndex + 1);
-        }
-
-        int hashIndex = name.lastIndexOf('#');
-
-        String hash = "";
-        if (-1 != hashIndex && hashIndex != name.length() - 1) {
-          hash = name.substring(hashIndex + 1);
-          name = name.substring(0, hashIndex);
-        }
-
-        int colonIndex = name.indexOf(':');
-        // typed link ?
-        if (-1 != colonIndex) {
-          // for now throw away the fType information
-          name = name.substring(colonIndex + 1);
-        }
-
-        int atIndex = name.lastIndexOf('@');
-        // InterWiki link ?
-        if (-1 != atIndex) {
-          String extSpace = name.substring(atIndex + 1);
-          // known extarnal space ?
-          InterWiki interWiki = InterWiki.getInstance();
-          if (interWiki.contains(extSpace)) {
-            name = name.substring(0, atIndex);
-            Writer writer = new StringBufferWriter(result);
-            try {
-              if (-1 != hashIndex) {
-                interWiki.expand(writer, extSpace, name, hash);
-              } else {
-                interWiki.expand(writer, extSpace, name, "");
-              }
-            } catch (IOException e) {
-//              log.debug("InterWiki " + extSpace + " not found.");
-            }
-          } else {
-            result.append("&#91;<span class=\"error\">");
-            result.append(name);
-            result.append("?</span>&#93;");
-          }
-        } else {
-          // internal link
-          if (wikiEngine != null && wikiEngine instanceof WikiRenderEngine) {
-            if (((WikiRenderEngine) wikiEngine).exists(name)) {
-              String view = name;
-              if (-1 != pipeIndex) {
-                view = alias;
-              }
-              // Do not add hash if an alias was given
-              if (-1 != hashIndex) {
-                ((WikiRenderEngine) wikiEngine).appendLink(result, name, view, hash);
-              } else {
-                ((WikiRenderEngine) wikiEngine).appendLink(result, name, view);
-              }
-            } else if (((WikiRenderEngine) wikiEngine).showCreate()) {
-              ((WikiRenderEngine) wikiEngine).appendCreateLink(result, name, name);
-              // links with "create" are not cacheable because
-              // a missing wiki could be created
-              // TODO is this ok?
-              //  fContext.getRenderContext().setCacheable(false);
-            } else {
-              // cannot display/create wiki, so just display the text
-              result.append(name);
-            }
-          } else {
-            // cannot display/create wiki, so just display the text
-            result.append(name);
-          }
-        }
-      }
-    }
-  }
+//  public static void handleSnipLink(StringBuffer result, RenderEngine wikiEngine, String name) {
+//    if (name != null) {
+//      int index = name.indexOf("http://");
+//      // Configuration probably wrote [http://radeox.org] instead of http://radeox.org
+//      if (index != -1) {
+//        createExternalLink(result, wikiEngine, name.substring(index));
+//        // show error
+//        // fResult.append("<div class=\"error\">Do not surround URLs with [...].</div>");
+//      } else {
+//        // trim the name and unescape it
+//        name = Encoder.unescape(name.trim());
+//        //                Is there an alias like [alias|link] ?
+//        int pipeIndex = name.indexOf('|');
+//        String alias = "";
+//        if (-1 != pipeIndex) {
+//          alias = name.substring(0, pipeIndex);
+//          name = name.substring(pipeIndex + 1);
+//        }
+//
+//        int hashIndex = name.lastIndexOf('#');
+//
+//        String hash = "";
+//        if (-1 != hashIndex && hashIndex != name.length() - 1) {
+//          hash = name.substring(hashIndex + 1);
+//          name = name.substring(0, hashIndex);
+//        }
+//
+//        int colonIndex = name.indexOf(':');
+//        // typed link ?
+//        if (-1 != colonIndex) {
+//          // for now throw away the fType information
+//          name = name.substring(colonIndex + 1);
+//        }
+//
+//        int atIndex = name.lastIndexOf('@');
+//        // InterWiki link ?
+//        if (-1 != atIndex) {
+//          String extSpace = name.substring(atIndex + 1);
+//          // known extarnal space ?
+//          InterWiki interWiki = InterWiki.getInstance();
+//          if (interWiki.contains(extSpace)) {
+//            name = name.substring(0, atIndex);
+//            Writer writer = new StringBufferWriter(result);
+//            try {
+//              if (-1 != hashIndex) {
+//                interWiki.expand(writer, extSpace, name, hash);
+//              } else {
+//                interWiki.expand(writer, extSpace, name, "");
+//              }
+//            } catch (IOException e) {
+////              log.debug("InterWiki " + extSpace + " not found.");
+//            }
+//          } else {
+//            result.append("&#91;<span class=\"error\">");
+//            result.append(name);
+//            result.append("?</span>&#93;");
+//          }
+//        } else {
+//          // internal link
+//          if (wikiEngine != null && wikiEngine instanceof WikiRenderEngine) {
+//            if (((WikiRenderEngine) wikiEngine).exists(name)) {
+//              String view = name;
+//              if (-1 != pipeIndex) {
+//                view = alias;
+//              }
+//              // Do not add hash if an alias was given
+//              if (-1 != hashIndex) {
+//                ((WikiRenderEngine) wikiEngine).appendLink(result, name, view, hash);
+//              } else {
+//                ((WikiRenderEngine) wikiEngine).appendLink(result, name, view);
+//              }
+//            } else if (((WikiRenderEngine) wikiEngine).showCreate()) {
+//              ((WikiRenderEngine) wikiEngine).appendCreateLink(result, name, name);
+//              // links with "create" are not cacheable because
+//              // a missing wiki could be created
+//              // TODO is this ok?
+//              //  fContext.getRenderContext().setCacheable(false);
+//            } else {
+//              // cannot display/create wiki, so just display the text
+//              result.append(name);
+//            }
+//          } else {
+//            // cannot display/create wiki, so just display the text
+//            result.append(name);
+//          }
+//        }
+//      }
+//    }
+//  }
 
   public static void handleWikipediaLink(StringBuffer result, RenderEngine wikiEngine, String name, String suffix) {
     if (name != null) {