1 31 32 package org.opencms.editors.htmlarea; 33 34 import org.opencms.jsp.CmsJspActionElement; 35 import org.opencms.main.OpenCms; 36 import org.opencms.util.CmsStringUtil; 37 import org.opencms.workplace.editors.CmsEditorDisplayOptions; 38 import org.opencms.workplace.editors.CmsSimplePageEditor; 39 import org.opencms.workplace.galleries.A_CmsGallery; 40 41 import java.util.ArrayList ; 42 import java.util.Collections ; 43 import java.util.HashMap ; 44 import java.util.Iterator ; 45 import java.util.List ; 46 import java.util.Map ; 47 import java.util.Properties ; 48 49 64 public class CmsHtmlAreaEditor extends CmsSimplePageEditor { 65 66 67 private static final String EDITOR_TYPE = "htmlarea"; 68 69 74 public CmsHtmlAreaEditor(CmsJspActionElement jsp) { 75 76 super(jsp); 77 } 78 79 82 public String buildGalleryButtons(CmsEditorDisplayOptions options, int buttonStyle, Properties displayOptions) { 83 84 StringBuffer result = new StringBuffer (); 85 Iterator i = OpenCms.getWorkplaceManager().getGalleries().keySet().iterator(); 86 87 while (i.hasNext()) { 88 String galleryType = (String )i.next(); 89 String galleryName = CmsStringUtil.substitute(galleryType, "gallery", ""); 90 if (options.showElement("gallery." + galleryName, displayOptions)) { 91 result.append("config.registerButton(\""); 93 result.append(galleryType); 94 result.append("\", \""); 95 result.append(key(org.opencms.workplace.editors.Messages.getGalleryKey(galleryName))); 96 result.append("\", __editor.imgURL(\"../../editors/htmlarea/images/opencms/"); 97 result.append(galleryType); 98 result.append(".gif\"), false, function(e) { openGallery(\'"); 99 result.append(galleryType); 100 result.append("\'); });\n"); 101 } 102 } 103 104 return result.toString(); 105 } 106 107 114 public String buildGalleryButtonRow(CmsEditorDisplayOptions options, Properties displayOptions) { 115 116 StringBuffer result = new StringBuffer (); 117 Map galleryMap = OpenCms.getWorkplaceManager().getGalleries(); 118 List galleries = new ArrayList (galleryMap.size()); 119 Map typeMap = new HashMap (galleryMap.size()); 120 121 Iterator i = galleryMap.keySet().iterator(); 122 while (i.hasNext()) { 123 String key = (String )i.next(); 124 A_CmsGallery currGallery = (A_CmsGallery)galleryMap.get(key); 125 galleries.add(currGallery); 126 typeMap.put(currGallery, key); 128 } 129 130 Collections.sort(galleries); 132 133 for (int k=0; k<galleries.size(); k++) { 134 A_CmsGallery currGallery = (A_CmsGallery)galleries.get(k); 135 String galleryType = (String )typeMap.get(currGallery); 136 if (options.showElement("gallery." + CmsStringUtil.substitute(galleryType, "gallery", ""), displayOptions)) { 137 if (result.length() == 0) { 139 result.append(", \"separator\""); 140 } 141 result.append(", \"" + galleryType + "\""); 142 } 143 } 144 return result.toString(); 145 } 146 147 150 public String getEditorResourceUri() { 151 152 return getSkinUri() + "editors/" + EDITOR_TYPE + "/"; 153 } 154 155 } 156 | Popular Tags |