1 10 11 package org.mmbase.applications.media.urlcomposers; 12 13 import org.mmbase.module.core.*; 14 import org.mmbase.applications.media.Format; 15 import java.util.*; 16 17 18 32 public class MarkupURLComposer extends FragmentURLComposer { 33 34 39 protected MMObjectNode getTemplate() { 40 return (MMObjectNode) getInfo().get("template"); 41 } 42 43 52 53 public boolean canCompose() { 54 MMObjectNode template = getTemplate(); 55 if (template == null) return false; 56 Format sourceFormat = Format.get(source.getIntValue("format")); 57 if (getFormat() == Format.SMIL && !( sourceFormat == Format.RM || sourceFormat == Format.RA)) return false; 58 return true; 59 } 60 61 protected StringBuffer getURLBuffer() { 62 MMObjectNode template = getTemplate(); 63 if (template != null) { 64 String url = template.getStringValue("url"); 65 StringBuffer buf = new StringBuffer (url + "fragment=" + fragment.getNumber() + "&format=" + Format.get(source.getIntValue("format")) + "&source=" + source.getNumber()); 66 if (url.indexOf("://") < 0) { 67 if (! url.startsWith("/")) { 68 buf.insert(0, Config.templatesDir); 69 } 70 buf.insert(0, "http://" + Config.host); 71 } 72 return buf; 73 } else { 74 return new StringBuffer ("[Could not compose]"); } 76 77 } 78 public String getGUIIndicator(Map options) { 79 Locale locale = (Locale) options.get("locale"); 80 Format sourceFormat = Format.get(source.getIntValue("format")); 81 return super.getGUIIndicator(options) + " (" + sourceFormat.getGUIIndicator(locale) + ")"; 82 } 83 84 85 public String getDescription(Map options) { 86 Locale locale = (Locale) options.get("locale"); 87 ResourceBundle m = ResourceBundle.getBundle("org.mmbase.applications.media.urlcomposers.resources.markupurlcomposer", locale); 88 String url = getURL() + "&language=" + locale.getLanguage(); 89 MMObjectNode template = getTemplate(); 90 if (template.getStringValue("mimetype").equals("text/html")) { 91 return template.getStringValue("name") + "<br />" + template.getStringValue("description") + "<br />" + m.getString("object") + ":<br /><nobr><object data='" + url + "' type='text/html'></object></nobr>"; 92 } else { 93 return template.getStringValue("name") + "<br />" + template.getStringValue("description"); 94 } 95 } 96 97 98 101 102 public Format getFormat() { 103 MMObjectNode template = getTemplate(); 104 if (template == null) return Format.HTML; 105 String mimetype = template.getStringValue("mimetype"); 106 if (mimetype.equals("application/smil")) { 107 return Format.SMIL; 108 } else { 109 return Format.HTML; 110 } 111 } 112 } 113 | Popular Tags |