1 18 19 package org.apache.roller.ui.authoring.tags; 20 21 import java.util.HashMap ; 22 import java.util.Map ; 23 24 import javax.servlet.jsp.JspException ; 25 import javax.servlet.jsp.tagext.TagSupport ; 26 import org.apache.commons.lang.StringUtils; 27 28 import org.apache.commons.logging.Log; 29 import org.apache.commons.logging.LogFactory; 30 import org.apache.roller.model.PluginManager; 31 32 import org.apache.roller.model.Roller; 33 import org.apache.roller.model.RollerFactory; 34 import org.apache.roller.pojos.WeblogEntryData; 35 import org.apache.roller.ui.core.RollerContext; 36 import org.apache.roller.util.Utilities; 37 import org.apache.struts.util.RequestUtils; 38 39 43 public class ShowEntryContentTag extends TagSupport { 44 static final long serialVersionUID = 3166731504235428544L; 45 private static Log mLogger = 46 LogFactory.getFactory().getInstance(ShowEntrySummaryTag.class); 47 48 private String name = null; 49 private String property = null; 50 private String scope = "request"; 51 52 private boolean stripHtml = false; 53 private int maxLength = -1; 54 private boolean singleEntry = false; 55 56 59 public int doStartTag() throws JspException { 60 Roller roller = RollerFactory.getRoller(); 61 WeblogEntryData entry = (WeblogEntryData) 62 RequestUtils.lookup(pageContext, name, property, scope); 63 if (StringUtils.isNotEmpty(entry.getText())) { 64 String xformed = entry.getText();; 65 try { 66 if (entry.getPlugins() != null) { 67 RollerContext rctx = 68 RollerContext.getRollerContext(); 69 try { 70 PluginManager ppmgr = roller.getPagePluginManager(); 71 Map plugins = ppmgr.getWeblogEntryPlugins( 72 entry.getWebsite()); 73 xformed = ppmgr.applyWeblogEntryPlugins( 74 plugins, entry, entry.getText()); 75 } catch (Exception e) { 76 mLogger.error(e); 77 } 78 } 79 80 if (stripHtml) { 81 xformed = Utilities.escapeHTML( Utilities.removeHTML(xformed), false ); 83 } 84 85 if (maxLength != -1) { 86 xformed = Utilities.truncateNicely(xformed, maxLength, maxLength, "..."); 87 } 88 89 xformed = StringUtils.replace(xformed, "&#", "&#"); 92 93 pageContext.getOut().println(xformed); 94 95 } catch (Throwable e) { 96 throw new JspException ("ERROR applying plugin to entry", e); 97 } 98 } 99 return TagSupport.SKIP_BODY; 100 } 101 102 105 public String getName() { 106 return name; 107 } 108 109 112 public void setName(String name) { 113 this.name = name; 114 } 115 116 119 public String getProperty() { 120 return property; 121 } 122 125 public void setProperty(String property) { 126 this.property = property; 127 } 128 129 132 public String getScope() { 133 return scope; 134 } 135 138 public void setScope(String scope) { 139 this.scope = scope; 140 } 141 } 142 | Popular Tags |