xlawrence    2005/06/24 14:12:21 CEST

  Modified files:
    core/src/webapp/jsp/jahia/htmleditors/fckeditor 
                                                    fckeditor_htmleditor.jsp 
                                                    utils.jsp 
  Log:
  - Fixed bug when using the editor with metadatas
  
  Revision  Changes    Path
  1.9       +10 -7     
jahia/core/src/webapp/jsp/jahia/htmleditors/fckeditor/fckeditor_htmleditor.jsp
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/webapp/jsp/jahia/htmleditors/fckeditor/fckeditor_htmleditor.jsp.diff?r1=1.8&r2=1.9&f=h
  1.7       +50 -19    
jahia/core/src/webapp/jsp/jahia/htmleditors/fckeditor/utils.jsp
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/webapp/jsp/jahia/htmleditors/fckeditor/utils.jsp.diff?r1=1.6&r2=1.7&f=h
  
  
  
  Index: fckeditor_htmleditor.jsp
  ===================================================================
  RCS file: 
/home/cvs/repository/jahia/core/src/webapp/jsp/jahia/htmleditors/fckeditor/fckeditor_htmleditor.jsp,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- fckeditor_htmleditor.jsp  22 Jun 2005 08:09:10 -0000      1.8
  +++ fckeditor_htmleditor.jsp  24 Jun 2005 12:12:21 -0000      1.9
  @@ -44,7 +44,9 @@
   //ParamBean  jParams  = (ParamBean) engineMap.get( "jParams" );
   final ParamBean   jParams   = (ParamBean) request.getAttribute( 
"org.jahia.params.ParamBean" ); // for jahia405
   final Boolean  isSelectedField = (Boolean) engineMap.get( "isSelectedField" 
);
  -final ContentPage thePage = 
ServicesRegistry.getInstance().getJahiaPageService().lookupContentPage( 
theField.getPageID(), true);
  +
  +final int pageID = (theField.getPageID() > 0) ? theField.getPageID() : 
jParams.getPageID();
  +final ContentPage thePage = 
ServicesRegistry.getInstance().getJahiaPageService().lookupContentPage( pageID, 
true);
   final JahiaPageDefinition pageTemplate = thePage.getPageTemplate(jParams);
   
   String theOldField = theField.getValue();
  @@ -92,10 +94,14 @@
       jahiaPath.append(request.getServletPath());
   }
   
  +StringBuffer buff = new StringBuffer();
   final String currentLanguageCode = 
jParams.getLocale().toString().substring(0, 2);
  -String urlPage = pageTemplate.getSourcePath();
  -urlPage = request.getContextPath() + urlPage.substring(0, 
urlPage.lastIndexOf("/"));
  -final String fckUrl = request.getContextPath() + 
"/jsp/jahia/htmleditors/fckeditor/";
  +final String sourcePath = pageTemplate.getSourcePath();
  +final String urlPage = 
buff.append(request.getContextPath()).append(sourcePath.substring(0, 
sourcePath.lastIndexOf("/"))).toString();
  +buff.delete(0, buff.length());
  +
  +final String fckUrl = 
buff.append(request.getContextPath()).append("/jsp/jahia/htmleditors/fckeditor/").toString();
  +buff.delete(0, buff.length());
   
   String pageContent = "null";
   String files = "null";
  @@ -209,7 +215,6 @@
   
           oFCKeditor = new FCKeditor( 'jahiaEditor', '100%', '400' ) ;
           oFCKeditor.BasePath  = sBasePath;
  -        //oFCKeditor.Config['CustomConfigurationsPath'] = 
'<%=urlPage%>/Global/fck_config.js' ;
           oFCKeditor.Config.basePath = "<%=fckUrl%>";
           oFCKeditor.Config.webdavPath = "<%=new 
StringBuffer().append(request.getContextPath()).append("/webdav/site/").append(jParams.getSiteKey()).toString()%>";
   
  @@ -221,8 +226,6 @@
           oFCKeditor.Config.LinkBrowserURL = sBasePath + 
"editor/plugins/JahiaLinker/dialog.html";
           oFCKeditor.Config.PagesList = pagesList;
   
  -        //oFCKeditor.Config.StylesXmlPath = 
'<%=urlPage%>/Global/fckstyles.xml';
  -        //oFCKeditor.Config.EditorAreaCSS = 
'<%=urlPage%>/Global/wysiwygpro.css';
           oFCKeditor.Config["AutoDetectLanguage"] = false ;
           oFCKeditor.Config["DefaultLanguage"] = "<%=currentLanguageCode%>";
           oFCKeditor.ReplaceTextarea();
  
  
  
  Index: utils.jsp
  ===================================================================
  RCS file: 
/home/cvs/repository/jahia/core/src/webapp/jsp/jahia/htmleditors/fckeditor/utils.jsp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- utils.jsp 22 Jun 2005 08:09:10 -0000      1.6
  +++ utils.jsp 24 Jun 2005 12:12:21 -0000      1.7
  @@ -1,5 +1,6 @@
   <%@ page import="java.util.*" %>
   <%@ page import="java.text.*"%>
  +<%@ page import="org.apache.commons.lang.ArrayUtils" %>
   <%@ page import="org.jahia.data.*" %>
   <%@ page import="org.jahia.data.fields.*" %>
   <%@ page import="org.jahia.data.viewhelper.sitemap.*" %>
  @@ -27,9 +28,11 @@
           "html",
           "img", "txt", "video", "sound"};
   
  +final String[] defaultFileExt = {"jpg", "jpeg", "jpe", "gif", "bmp", "png", 
"tif", "tiff"};
  +
   int counterOperations = 1;
   final String[] pathSearch = {"users", "shared", "private", "public"};
  -final String[] pathReplace = {"utilisateurs", "partage", "priv&eacute;", 
"publique"};
  +final String[] pathReplace = {"utilisateurs", "partag&eacute;", 
"priv&eacute;", "publique"};
   final ArrayList excludeList = new ArrayList();
   final StringBuffer buff = new StringBuffer();
   
  @@ -63,27 +66,53 @@
           final Iterator iter = sortedResources.iterator();
           String expand;
           while (iter.hasNext()) {
  +            boolean isValideExt = false;
               final DAVFileAccess curDf = (DAVFileAccess)iter.next();
  -            if (!excludeList.contains(curDf.getName().toLowerCase()) &&
  +            String pathDisplay = curDf.getName();
  +            if (! excludeList.contains(pathDisplay.toLowerCase()) &&
                       curDf.hasPermission(DAVFileAccess.READ)) {
  -                String pathDisplay = curDf.getName();
  -                if (lang.equals("fr")) {
  -                    for (int i = 0; i < pathSearch.length; i++) {
  -                        if (pathDisplay.equals(pathSearch[i])) {
  -                            pathDisplay = pathReplace[i];
  +                
  +                if (! curDf.isCollection()) {
  +                    final String path = curDf.getPath();
  +                    final String fileExt; 
  +                    if (path.lastIndexOf(".") > 0) {
  +                        fileExt = path.substring(path.lastIndexOf(".") + 1);
  +                        pathDisplay = path.substring(path.lastIndexOf("/") + 
1);
  +                        
  +                    } else {
  +                        fileExt = "";
  +                    }
  +                    
  +                    if (ArrayUtils.contains(defaultFileExt, fileExt)) {
  +                        isValideExt = true;
  +                    }
  +                    
  +                } else {
  +                    if (curDf.getChildren().size() > 0) {
  +                        System.out.println("Size: 
"+curDf.getChildren().size());
  +                        isValideExt = true;
  +                        if (lang.equals("fr")) {
  +                            for (int i = 0; i < pathSearch.length; i++) {
  +                                if (pathDisplay.equals(pathSearch[i])) {
  +                                    pathDisplay = pathReplace[i];
  +                                }
  +                            }
                           }
                       }
                   }
  -                expand = curDf.getPath();
  -                expand = expand.replaceAll("'", "\\\'");
  -                expand = expand.replaceAll("\"", "&quot;");
  -                
  -                pathDisplay = pathDisplay.replaceAll("'", "\\\'");
  -                
  -                
buff.append("[").append(level).append(",").append(counterOperations)
  -                
.append(",\'").append(pathDisplay).append("\','").append(expand)
  -                .append("'],");
  -                counterOperations++;
  +                if (isValideExt) {
  +                    expand = curDf.getPath();
  +                    expand = expand.replaceAll("'", "\\\'");
  +                    expand = expand.replaceAll("\"", "&quot;");
  +                    
  +                    pathDisplay = pathDisplay.replaceAll("'", "\\\'");
  +                    
  +                    
buff.append("[").append(level).append(",").append(counterOperations)
  +                    
.append(",\'").append(pathDisplay).append("\','").append(expand)
  +                    .append("'],");
  +                    
  +                    counterOperations++;
  +                }
                   buff.append(expandOne(curDf, level + 1, lang));
               }
           }
  @@ -176,7 +205,9 @@
       excludeList.add("actions");
       excludeList.add("mygroups");
       excludeList.add("groups");
  -    final DAVFileAccess df = 
JahiaWebdavBaseService.getInstance().getDAVFileAccess(jParams, "/");
  +    excludeList.add("content");
  +    final DAVFileAccess df = JahiaWebdavBaseService.getInstance().
  +            getDAVFileAccess(jParams, "/");
       buff.append(expandOne(df, 1, lang));
       buff.deleteCharAt(buff.length() - 1);
       buff.append("]");
  @@ -190,7 +221,7 @@
       try {
           final ParamBean jParams = jData.params();
           buff.append("[[0,0,\'root\','/'],");
  -        final int defaultLevel = SiteMapViewHelper.DEFAULT_LEVEL;
  +        final int defaultLevel = SiteMapViewHelper.DISPLAY_ALL_LEVEL;
           final JahiaSiteMapService siteMapService = 
ServicesRegistry.getInstance().getJahiaSiteMapService();
           final ContentPage theContentPage = 
ServicesRegistry.getInstance().getJahiaPageService().
                   lookupContentPage(jParams.getSite().getHomePageID(), false);
  

Reply via email to