1 31 32 package org.opencms.workplace.galleries; 33 34 import org.opencms.file.CmsFile; 35 import org.opencms.file.CmsResource; 36 import org.opencms.file.types.CmsResourceTypePlain; 37 import org.opencms.i18n.CmsEncoder; 38 import org.opencms.jsp.CmsJspActionElement; 39 import org.opencms.main.CmsException; 40 import org.opencms.main.CmsLog; 41 import org.opencms.util.CmsStringUtil; 42 43 import javax.servlet.http.HttpServletRequest ; 44 import javax.servlet.http.HttpServletResponse ; 45 import javax.servlet.jsp.PageContext ; 46 47 import org.apache.commons.logging.Log; 48 49 59 public class CmsHtmlGallery extends A_CmsGallery { 60 61 62 public static final String URI_GALLERY = PATH_GALLERIES + "html_fs.jsp"; 63 64 65 private static final Log LOG = CmsLog.getLog(CmsHtmlGallery.class); 66 67 68 private static final Integer ORDER_GALLERY = new Integer (40); 69 70 73 public CmsHtmlGallery() { 74 75 } 77 78 83 public CmsHtmlGallery(CmsJspActionElement jsp) { 84 85 super(jsp); 86 } 87 88 95 public CmsHtmlGallery(PageContext context, HttpServletRequest req, HttpServletResponse res) { 96 97 this(new CmsJspActionElement(context, req, res)); 98 } 99 100 105 public String applyButton() { 106 107 if (MODE_VIEW.equals(getParamDialogMode())) { 108 return button(null, null, "apply_in.png", "button.paste", 0); 110 } else if (MODE_WIDGET.equals(getParamDialogMode())) { 111 String content = ""; 113 try { 114 CmsResource res = getCms().readResource(getParamResourcePath()); 115 CmsFile file = getCms().readFile(getCms().getSitePath(res)); 116 content = new String (file.getContents()); 117 content = CmsStringUtil.escapeJavaScript(content); 119 } catch (CmsException e) { 120 if (LOG.isErrorEnabled()) { 122 LOG.error(org.opencms.db.Messages.get().getBundle().key( 123 org.opencms.db.Messages.ERR_READ_RESOURCE_1, 124 getParamResourcePath())); 125 } 126 } 127 content = CmsEncoder.escapeXml(content); 128 return button("javascript:pasteContent('" + content + "')", null, "apply.png", Messages.GUI_BUTTON_PASTE_0, 0); 130 } else { 131 return button("javascript:pasteContent()", null, "apply.png", Messages.GUI_BUTTON_PASTE_0, 0); 133 } 134 } 135 136 141 public String buildGalleryItemPreview() { 142 143 StringBuffer html = new StringBuffer (16); 144 try { 145 if (CmsStringUtil.isNotEmpty(getParamResourcePath())) { 146 CmsResource res = getCms().readResource(getParamResourcePath()); 147 if (res != null) { 148 html.append("<p><div id=\"icontent\" width=\"100%\" height=\"100%\">"); 149 html.append(getJsp().getContent(getParamResourcePath())); 150 html.append("</div></p>"); 151 } 152 } 153 } catch (CmsException e) { 154 LOG.error(e); 156 } 157 return html.toString(); 158 } 159 160 163 public int getGalleryItemsTypeId() { 164 165 return CmsResourceTypePlain.getStaticTypeId(); 166 } 167 168 173 public Integer getOrder() { 174 175 return ORDER_GALLERY; 176 } 177 178 181 public String getPreviewBodyStyle() { 182 183 return new String (" class=\"dialog\" unselectable=\"on\""); 184 } 185 186 189 public String getPreviewDivStyle() { 190 191 return new String ("style=\"width: 100%; margin-top: 5px\""); 192 } 193 194 197 public String previewButton() { 198 199 return ""; 200 } 201 202 205 public String targetSelectBox() { 206 207 return ""; 208 } 209 } | Popular Tags |