1 16 17 package org.apache.jetspeed.portal.portlets; 18 19 20 import org.apache.jetspeed.capability.CapabilityMap; 21 import org.apache.jetspeed.util.MimeType; 22 import org.apache.jetspeed.services.rundata.JetspeedRunData; 23 import org.apache.ecs.*; 24 25 26 34 public class LinkPortlet extends AbstractPortlet 35 { 36 37 public static final String L_IMAGE = "image"; 39 public static final String L_NAME = "anchor"; 41 public static final String L_URL = "link"; 43 public static final String L_DESC = "description"; 45 public static final String EXT_LINK_IMG = "exlink.gif"; 47 48 49 55 public org.apache.ecs.ConcreteElement getContent(org.apache.turbine.util.RunData data) 56 { 57 58 CapabilityMap cap = ((JetspeedRunData)data).getCapability(); 59 60 if (cap.getPreferredType().getCode().equals(MimeType.HTML.getCode())) 62 { 63 String link; 64 String image; 65 String name; 66 String desc; 67 String res = ""; 68 String cstr = ""; 69 int contains = 0; 70 int i = 0; 71 72 do 73 { 74 if (i>0) 75 cstr=String.valueOf(i); 76 77 link = getPortletConfig().getInitParameter(L_URL+cstr); 78 79 if ((link!=null) && (link.length()>0)) 81 { 82 83 if (i==0) 85 res = "<ul>"; 86 87 image = getPortletConfig().getInitParameter(L_IMAGE+cstr); 88 name = getPortletConfig().getInitParameter(L_NAME+cstr); 89 desc = getPortletConfig().getInitParameter(L_DESC+cstr); 90 91 if ((desc==null) || (desc.length()<1)) 93 desc = "follow this link"; 94 95 res += "<li>"; 97 98 res += "<A HREF=\""+link+"\" TARGET=\"_new\"><IMG SRC=\"images/"+EXT_LINK_IMG+"\" BORDER=\"0\" ALT=\""+name+"\"></A>"; 100 101 res += "<A HREF=\""+link+"\">"; 103 104 if ((image != null) && (image.length()>0)) 106 res += " <IMG SRC=\""+image+"\" HSPACES=\"5\" ALT=\""+name+"\" BORDER=\"0\"> "; 107 108 res += name+"</A> <SMALL>"+desc+"</SMALL></li>"; 110 contains++; 111 } 112 else 113 link = null; 114 115 i++; 116 } 117 while (link != null); 118 { 119 } 120 121 if (contains > 0) 123 res += "</ul>"; 124 125 return(new StringElement(res)); 126 } 127 128 129 130 return new org.apache.jetspeed.util.JetspeedClearElement( " " ); 131 } 132 133 } 134 | Popular Tags |