xlawrence    2005/06/13 15:04:37 CEST

  Modified files:
    core/src/webapp/jsp/jahia/htmleditors/fckeditor/editor/plugins/JahiaLinker 
                                                                               
utils.js 
    core/src/webapp/jsp/jahia/htmleditors/fckeditor 
                                                    fckeditor_htmleditor.jsp 
                                                    utils.jsp 
  Log:
  Added NPE check for null page titles
  
  Revision  Changes    Path
  1.6       +38 -14    
jahia/core/src/webapp/jsp/jahia/htmleditors/fckeditor/editor/plugins/JahiaLinker/utils.js
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/webapp/jsp/jahia/htmleditors/fckeditor/editor/plugins/JahiaLinker/utils.js.diff?r1=1.5&r2=1.6&f=h
  1.6       +4 -3      
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.5&r2=1.6&f=h
  1.4       +80 -106   
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.3&r2=1.4&f=h
  
  
  
  Index: utils.js
  ===================================================================
  RCS file: 
/home/cvs/repository/jahia/core/src/webapp/jsp/jahia/htmleditors/fckeditor/editor/plugins/JahiaLinker/utils.js,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- utils.js  7 Jun 2005 16:46:23 -0000       1.5
  +++ utils.js  13 Jun 2005 13:04:37 -0000      1.6
  @@ -44,23 +44,47 @@
     
     if (groups || state != "active") {
       
  -     var message = "WARNING !!!\n\n";
  -     if (state == "markForDeleted") {
  -        message += "- You have selected a page which is marked for 
deletion.";
  -        message += "Once publication is made, this page will no longer be 
accessible (Result: 404 Error for all users).\n\n";
  +    var message;
  +    if (urlValue.indexOf("/lang/fr") > -1) {
  +    
  +        message = "ATTENTION !!!\n\n";
  +        if (state == "markForDeleted") {
  +            message += "- Vous avez s�lectionn�; une page qui va �tre 
supprim�e. ";
  +            message += "Une fois valid�e, la page ne sera plus accessible 
(R�sultat: Erreur 404 pour tous les utilisateurs).\n\n";
  +        
  +        } else if (state != "active") {
  +            message += "- Vous avez s�lectionn� une page non publi�e. ";
  +            message += "Le contenu ne sera pas accessible en mode 'En ligne' 
avant validation (R�sultat: Erreur 404 si la page n'a jamais �t� valid�e).\n\n";
  +        }
  +     
  +        if (groups) {
  +            message += "- Vous avez s�lectionn� une page non accessible 
pour le(s) groupe(s) '"+ groups +"', ";
  +            message += "mais qui ont acc�s au champ que vous �ditez 
(R�sultat: Erreur 403 pour les utilisateurs appartenant au(x) groupe(s) '"+ 
groups +"').\n\n";
  +        }
  +     
  +        message += "Continuer quand m�me ?";
           
  -     } else if (state != "active") {
  -        message += "- You have selected a page which is in state '"+ state 
+"'.";
  -        message += "The content will not be accessible in 'Live' mode until 
publication is made (Result: 404 Error if the page has never been 
published).\n\n";
  -     }
  +    } else {
  +        
  +        message = "WARNING !!!\n\n";
  +        if (state == "markForDeleted") {
  +            message += "- You have selected a page which is marked for 
deletion.";
  +            message += "Once publication is made, this page will no longer 
be accessible (Result: 404 Error for all users).\n\n";
  +        
  +        } else if (state != "active") {
  +            message += "- You have selected a page which is in state '"+ 
state +"'.";
  +            message += "The content will not be accessible in 'Live' mode 
until publication is made (Result: 404 Error if the page has never been 
published).\n\n";
  +        }
        
  -     if (groups) {
  -        message += "- The page you have selected cannot be seen by groups 
'"+ groups +"', ";
  -        message += "which however have access to the field you are editing 
(Result: 403 Error for users belonging to '"+ groups +"').\n\n";
  -     }
  +        if (groups) {
  +            message += "- The page you have selected cannot be seen by 
groups '"+ groups +"', ";
  +            message += "which however have access to the field you are 
editing (Result: 403 Error for users belonging to '"+ groups +"').\n\n";
  +        }
        
  -     message += "Continue anyway ?";
  -     if (!confirm(message)) return;  
  +        message += "Continue anyway ?";  
  +    }   
  +    
  +    if (!confirm(message)) return;  
     }
         
     try {
  
  
  
  Index: fckeditor_htmleditor.jsp
  ===================================================================
  RCS file: 
/home/cvs/repository/jahia/core/src/webapp/jsp/jahia/htmleditors/fckeditor/fckeditor_htmleditor.jsp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- fckeditor_htmleditor.jsp  7 Jun 2005 09:49:12 -0000       1.5
  +++ fckeditor_htmleditor.jsp  13 Jun 2005 13:04:37 -0000      1.6
  @@ -92,15 +92,16 @@
       jahiaPath.append(request.getServletPath());
   }
   
  -String currentLanguageCode = jParams.getLocale().toString();
  +String currentLanguageCode = jParams.getLocale().toString().substring(0, 2);
   String urlPage = pageTemplate.getSourcePath();
  -urlPage = request.getContextPath() + 
urlPage.substring(0,urlPage.lastIndexOf("/"));
  +urlPage = request.getContextPath() + urlPage.substring(0, 
urlPage.lastIndexOf("/"));
   String fckUrl = request.getContextPath() + 
"/jsp/jahia/htmleditors/fckeditor/";
   
   String pageContent = "null";
   String files = "null";
   try {
  -    pageContent = getSitemapToJs(jData, jahiaPath.toString(), theField, 
engineMap);
  +    pageContent = getSitemapToJs(jData, jahiaPath.toString(), theField, 
engineMap, 
  +            currentLanguageCode);
       if (pageContent != null && !pageContent.equals("")) {
           pageContent = pageContent.trim();
           if (!pageContent.startsWith("[")) {
  
  
  
  Index: utils.jsp
  ===================================================================
  RCS file: 
/home/cvs/repository/jahia/core/src/webapp/jsp/jahia/htmleditors/fckeditor/utils.jsp,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- utils.jsp 7 Jun 2005 09:49:12 -0000       1.3
  +++ utils.jsp 13 Jun 2005 13:04:37 -0000      1.4
  @@ -10,7 +10,6 @@
   <%@ page import="org.jahia.services.htmleditors.*" %>
   <%@ page import="org.jahia.services.sitemap.*" %>
   <%@ page import="org.jahia.services.webdav.*" %>
  -<%@ page import="org.jahia.services.workflow.*" %>
   <%@ page import="org.jahia.services.version.*" %>
   <%@ page import="org.jahia.utils.*" %>
   <%@ page import="org.jahia.engines.shared.*" %>
  @@ -157,14 +156,15 @@
           String getcontentlength = curObj.getProperty("DAV:", 
"getcontentlength").toString();
           int size = Integer.parseInt(getcontentlength);
           if (size < 1024) {
  -            fileSize = Long.toString(size) + " octets";
  +            fileSize = new StringBuffer().append(size).append(" 
octets").toString();
               
           } else {
               final double fileSizeKo = size / 1024;
               DecimalFormat df = new DecimalFormat();
               df.setMaximumFractionDigits(2);
               df.setMinimumIntegerDigits(1);
  -            fileSize = df.format(fileSizeKo) + " ko";
  +            fileSize = new 
StringBuffer().append(df.format(fileSizeKo)).append(" ko").
  +                    toString();
           }
       }
       return fileSize;
  @@ -183,115 +183,89 @@
       return html.toString();
   }
   
  -public String getSitemapToJs(JahiaData jData, String jahiaPath, JahiaField 
theField, 
  -        HashMap engineMap) throws JahiaException {
  -    ParamBean jParams = jData.params();
  +public String getSitemapToJs(JahiaData jData, String jahiaPath, JahiaField 
theField,
  +        HashMap engineMap, String currentLanguageCode) throws JahiaException 
{
       StringBuffer buff = new StringBuffer();
  -    buff.append("[[0,0,\'root\','/'],");
  -    int pageInfosFlag;
  -    int defaultLevel = SiteMapViewHelper.DEFAULT_LEVEL;
  -    String languageCode = jParams.getLocale().toString();
  -    JahiaSiteMapService siteMapService = 
ServicesRegistry.getInstance().getJahiaSiteMapService();
  -    ContentPage theContentPage = 
ServicesRegistry.getInstance().getJahiaPageService().
  -            lookupContentPage(jParams.getSite().getHomePageID(), false);
  -    
  -    if (jData.gui().isNormalMode()) {
  -        pageInfosFlag = ContentPage.ACTIVE_PAGE_INFOS;
  -    } else {
  -        pageInfosFlag = ContentPage.ACTIVE_PAGE_INFOS | 
ContentPage.STAGING_PAGE_INFOS;
  -    }
  -    
  -    SiteMapViewHelper siteMapViewHelper = 
siteMapService.getTreeSiteMapViewHelper(
  -            jParams.getUser(), theContentPage, jParams.getSessionID(), 
pageInfosFlag, 
  -            languageCode, defaultLevel);
  -    if (siteMapViewHelper == null) {
  -        return "";
  -    }
  -    TreeSiteMapViewHelper treeJahiaSiteMap = 
(TreeSiteMapViewHelper)siteMapViewHelper;
  -    
  -    ArrayList shouldDrawLineSegment = new ArrayList();
  -    for (int level = 0; level < treeJahiaSiteMap.getMaxLevel(); level++) {
  -        shouldDrawLineSegment.add(level, new Boolean(true));
  -    }
  -    
  -    boolean reachablePage = false;
  -    
  -    for (int i = 0; i < treeJahiaSiteMap.size(); i++) {
  -        ContentPage contentPage = treeJahiaSiteMap.getContentPage(i);
  -        if (contentPage == null) {
  -            continue;
  -        }
  -        reachablePage = contentPage.isReachable(jParams.getOperationMode(), 
  -                
jParams.getEntryLoadRequest().getFirstLocale(true).toString(), 
jParams.getUser());
  -        String templateName = 
contentPage.getPageTemplate(jData.params()).getSourcePath();
  -        templateName = templateName.substring(templateName.lastIndexOf("/") 
+ 1);
  -        if (reachablePage && !templateName.equals("listeContacts.jsp") &&
  -                !templateName.equals("email.jsp") &&
  -                !templateName.equals("listeBoxCommun.jsp") &&
  -                !templateName.equals("listPopup.jsp") &&
  -                !templateName.equals("popup.jsp")) {
  -            final String pageTitle2 = treeJahiaSiteMap.getPageTitle(i, 
  -                    jParams.getLocale().toString());
  -            final JahiaPage thePage = contentPage.getPage(jParams);
  -            
  -            if (thePage != null) {
  -                final int pageId = thePage.getID();
  +    try {
  +        ParamBean jParams = jData.params();
  +        buff.append("[[0,0,\'root\','/'],");
  +        int pageInfosFlag;
  +        int defaultLevel = SiteMapViewHelper.DEFAULT_LEVEL;
  +        JahiaSiteMapService siteMapService = 
ServicesRegistry.getInstance().getJahiaSiteMapService();
  +        ContentPage theContentPage = 
ServicesRegistry.getInstance().getJahiaPageService().
  +                lookupContentPage(jParams.getSite().getHomePageID(), false);
  +        
  +        if (jData.gui().isNormalMode()) {
  +            pageInfosFlag = ContentPage.ACTIVE_PAGE_INFOS;
  +        } else {
  +            pageInfosFlag = ContentPage.ACTIVE_PAGE_INFOS | 
ContentPage.STAGING_PAGE_INFOS;
  +        }
  +        
  +        SiteMapViewHelper siteMapViewHelper = 
siteMapService.getTreeSiteMapViewHelper(
  +                jParams.getUser(), theContentPage, jParams.getSessionID(), 
pageInfosFlag,
  +                currentLanguageCode, defaultLevel);
  +        if (siteMapViewHelper == null) {
  +            return "";
  +        }
  +        TreeSiteMapViewHelper treeJahiaSiteMap = 
(TreeSiteMapViewHelper)siteMapViewHelper;
  +        
  +        ArrayList shouldDrawLineSegment = new ArrayList();
  +        for (int level = 0; level < treeJahiaSiteMap.getMaxLevel(); level++) 
{
  +            shouldDrawLineSegment.add(level, new Boolean(true));
  +        }
  +        
  +        for (int i = 0; i < treeJahiaSiteMap.size(); i++) {
  +            ContentPage contentPage = treeJahiaSiteMap.getContentPage(i);
  +            if (contentPage == null) {
  +                continue;
  +            }
  +            String templateName = 
contentPage.getPageTemplate(jData.params()).getSourcePath();
  +            templateName = 
templateName.substring(templateName.lastIndexOf("/") + 1);
  +            if (! templateName.equals("listeContacts.jsp") &&
  +                    !templateName.equals("email.jsp") &&
  +                    !templateName.equals("listeBoxCommun.jsp") &&
  +                    !templateName.equals("listPopup.jsp") &&
  +                    !templateName.equals("popup.jsp")) {
  +                
  +                String pageTitle = treeJahiaSiteMap.getPageTitle(i,
  +                        currentLanguageCode);
                   
  -                StringBuffer pageUrl = new StringBuffer();
  -                
pageUrl.append(jahiaPath).append("/site/").append(jParams.getSiteKey())
  -                .append("/lang/").append(jParams.getLocale().toString())
  -                .append("/pid/").append(pageId);
  +                final JahiaPage thePage = contentPage.getPage(jParams);
                   
  -                buff.append("[").append((treeJahiaSiteMap.getPageLevel(i) + 
1))
  -                .append(",").append((i + 1)).append(",\'")
  -                .append(pageTitle2.replaceAll("'", "\\\\'"))
  -                .append("\','").append(pageUrl.toString().replaceAll("'", 
"\\\\'"))
  -                .append("\',\'").append(getPageState(pageId, jParams))
  -                .append("\',\'")
  -                
.append(BigText_Field.getInstance().getFieldGroupsNotHavingAccessOnPageAsString(
  -                        pageId, theField, jParams, engineMap)).append("'],");
  +                if (thePage != null) {
  +                    final int pageId = thePage.getID();
  +                    
  +                    if (pageTitle.equals("N/A")) {
  +                        if ("fr".equals(currentLanguageCode)) {
  +                            pageTitle = new StringBuffer().append("Pas de 
titre [pid = ").
  +                                    append(pageId).append("]").toString();
  +                        } else {
  +                            pageTitle = new StringBuffer().append("No title 
[pid = ").
  +                                    append(pageId).append("]").toString();
  +                        }
  +                    }
  +                    
  +                    StringBuffer pageUrl = new StringBuffer();
  +                    
pageUrl.append(jahiaPath).append("/lang/").append(currentLanguageCode)
  +                    .append("/pid/").append(pageId);
  +                    
  +                    
buff.append("[").append((treeJahiaSiteMap.getPageLevel(i) + 1))
  +                    .append(",").append((i + 1)).append(",\'")
  +                    .append(pageTitle.replaceAll("'", "\\\\'"))
  +                    
.append("\','").append(pageUrl.toString().replaceAll("'", "\\\\'"))
  +                    .append("\',\'")
  +                    .append(BigText_Field.getInstance().getPageState(pageId, 
currentLanguageCode))
  +                    .append("\',\'")
  +                    
.append(BigText_Field.getInstance().getFieldGroupsNotHavingAccessOnPageAsString(
  +                            pageId, theField, jParams, 
engineMap)).append("'],");
  +                }
               }
           }
  +        buff = buff.deleteCharAt(buff.length()-1);
  +        buff.append("]");
  +    } catch (Exception e) {
  +        e.printStackTrace();
       }
  -    buff = buff.deleteCharAt(buff.length()-1);
  -    buff.append("]");
       return buff.toString();
   }
  -
  -/**
  - * Returns a String representing the state of a page. The String returned is
  - * the name of a CSS class which will be used by the editor to format the 
page
  - * title according to the CSS class. Thus, you should not modify the return 
  - * values of this method, without changing the CSS class names of the 
JahiaLinker
  - * plugin (jahia-linker.css).
  - *
  - * @param pageId The pageId to get the state of
  - * @param jParams ParamBean instance of the current request
  - * 
  - * @return A String representing the state of the page and a CSS class name
  - * @throws JahiaException If Something goes wrong
  - */
  -private String getPageState (int pageId, ParamBean jParams) 
  -throws JahiaException {
  -    ContentPage page = ContentPage.getPage(pageId);
  -    if (page == null) { return "staging"; }
  -    
  -    Map languagesStates = 
WorkflowService.getInstance().getLanguagesStates(page);
  -    int state = 
((Integer)languagesStates.get(jParams.getLocale().toString()))
  -        .intValue();
  -    
  -    if (page.isMarkedForDelete()) { return "markForDeleted"; }
  -    
  -    switch (state) {
  -        case EntryLoadRequest.ACTIVE_WORKFLOW_STATE:
  -            return "active";
  -            
  -        case EntryLoadRequest.WAITING_WORKFLOW_STATE:
  -            return "waiting";
  -            
  -        default:
  -            return "staging";
  -    }
  -}
  -
   %>
  \ No newline at end of file
  

Reply via email to