KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > gui > HTMLToolBox


1 //
2
// ____.
3
// __/\ ______| |__/\. _______
4
// __ .____| | \ | +----+ \
5
// _______| /--| | | - \ _ | : - \_________
6
// \\______: :---| : : | : | \________>
7
// |__\---\_____________:______: :____|____:_____\
8
// /_____|
9
//
10
// . . . i n j a h i a w e t r u s t . . .
11
//
12

13 //
14
// HTMLToolBox
15
// EV 15.12.2000
16
// NK 14.05.2001 Prefix each popup window's name with the session id
17
// to resolve session conflict beetween different sites
18
// opened in different explorer
19
// NK 22.05.2001 Container and field update popup's names are composed with their id too !!!
20
// This is needed when to close and reopen the update popup with data. ( resolv refresh problem with JahiaOpenWindow() javascript function )
21
//
22

23 package org.jahia.gui;
24
25 import java.util.HashMap JavaDoc;
26
27 import org.jahia.content.ContentObject;
28 import org.jahia.data.containers.JahiaContainer;
29 import org.jahia.data.containers.JahiaContainerList;
30 import org.jahia.data.fields.JahiaField;
31 import org.jahia.engines.selectpage.SelectPage_Engine;
32 import org.jahia.exceptions.JahiaException;
33 import org.jahia.params.ParamBean;
34 import org.jahia.registries.ServicesRegistry;
35 import org.jahia.services.containers.ContentContainer;
36 import org.jahia.services.containers.ContentContainerList;
37 import org.jahia.services.fields.ContentField;
38 import org.jahia.services.lock.LockKey;
39 import org.jahia.services.lock.LockService;
40 import org.jahia.services.pages.ContentPage;
41 import org.jahia.services.pages.JahiaPage;
42 import org.jahia.services.pages.JahiaPageDefinition;
43 import javax.servlet.jsp.JspWriter JavaDoc;
44 import java.io.IOException JavaDoc;
45 import org.jahia.data.beans.ContainerListBean;
46 import org.jahia.data.beans.ContainerBean;
47 import org.jahia.data.beans.FieldBean;
48 import org.jahia.data.beans.PageBean;
49 import java.util.Map JavaDoc;
50 import java.util.ResourceBundle JavaDoc;
51 import java.util.Locale JavaDoc;
52 import java.util.MissingResourceException JavaDoc;
53 import java.util.Iterator JavaDoc;
54 import org.jahia.data.beans.ActionURIBean;
55 import org.jahia.resourcebundle.JahiaResourceBundle;
56 import org.jahia.bin.Jahia;
57
58 public class HTMLToolBox {
59
60     private static final org.apache.log4j.Logger logger =
61         org.apache.log4j.Logger.getLogger(HTMLToolBox.class);
62
63     private static final int JS_WINDOW_WIDTH = 640;
64     private static final int JS_WINDOW_HEIGHT = 600;
65
66     private ParamBean jParams;
67     private GuiBean gui;
68
69
70
71     /***
72         * constructor
73         * EV 15.12.2000
74         *
75         */

76     public HTMLToolBox( GuiBean guiBean, ParamBean params ) {
77         this.gui = guiBean;
78         this.jParams = params;
79     } // end constructor
80

81     private static String JavaDoc previousSessionID = "";
82     private static String JavaDoc previousCleanSessionID = "";
83     /**
84      * Utility method to clean session ID to be used in javascript code mostly
85      * Basically what it does is removed all non alpha numeric characters in the
86      * session ID. This uses a unicode method so it WILL allow unicode allowed
87      * alpha numeric character which might NOT work with Javascript flawlessly.
88      *
89      * This method also uses a very simple "cache" system that allows us not
90      * to have to parse the whole string if called repeteadly with the same
91      * session ID.
92      * @param sessionID the session ID to test for non alpha numeric characters
93      * @return the "cleaned" session ID.
94      */

95     public static String JavaDoc cleanSessionID(String JavaDoc sessionID) {
96         if (sessionID.equals(previousSessionID)) {
97             return previousCleanSessionID;
98         }
99         StringBuffer JavaDoc result = new StringBuffer JavaDoc();
100         for (int i=0; i < sessionID.length(); i++) {
101             char curChar = sessionID.charAt(i);
102             if (Character.isLetterOrDigit(curChar)) {
103                 result.append(curChar);
104             }
105         }
106         previousSessionID = sessionID;
107         previousCleanSessionID = result.toString();
108         return result.toString();
109     }
110
111     //---------------------------------------------------------------- drawLogin
112
/**
113      *
114      * @return
115      * @throws JahiaException
116      */

117     public String JavaDoc drawLoginLauncher()
118             throws JahiaException {
119         // BEGIN [added by Pascal Aubry for CAS authentication]
120
if (Jahia.usesSso()) {
121             return "window.location = '" + Jahia.getSsoValve().getRedirectUrl(jParams) + "'";
122         }
123         // END [added by Pascal Aubry for CAS authentication]
124
String JavaDoc popupLoginURL = gui.drawPopupLoginUrl();
125             return (popupLoginURL.equals("")) ? "" :
126                     "OpenJahiaWindow('" + popupLoginURL + "','Login',260,300)";
127     }
128
129     /**
130      *
131      * @param destinationPageID
132      * @return
133      * @throws JahiaException
134      */

135     public String JavaDoc drawLoginLauncher( int destinationPageID)
136             throws JahiaException {
137         // BEGIN [added by Pascal Aubry for CAS authentication]
138
if (Jahia.usesSso()) {
139             return "window.location = '" + Jahia.getSsoValve().getRedirectUrl(jParams) + "'";
140         }
141         // END [added by Pascal Aubry for CAS authentication]
142
String JavaDoc popupLoginURL = gui.drawPopupLoginUrl(destinationPageID);
143         return (popupLoginURL.equals("")) ? "" :
144                 "OpenJahiaWindow('" + popupLoginURL + "','Login',260,300)";
145     }
146
147     public String JavaDoc drawLoginButton()
148             throws JahiaException {
149         return drawButton( drawLoginLauncher(), "login" );
150     }
151
152     public String JavaDoc drawLoginButton( int destinationPageID )
153             throws JahiaException {
154         return drawButton( drawLoginLauncher( destinationPageID ), "login" );
155     }
156
157     //--------------------------------------------------------------- drawLogout
158
/**
159      *
160      * @return
161      * @throws JahiaException
162      */

163     public String JavaDoc drawLogoutLauncher()
164             throws JahiaException {
165         return gui.drawLogoutUrl();
166     }
167
168     /**
169      *
170      * @param destinationPageID
171      * @return
172      * @throws JahiaException
173      */

174     public String JavaDoc drawLogoutLauncher( int destinationPageID )
175             throws JahiaException {
176         return gui.drawLogoutUrl();
177     }
178
179     public String JavaDoc drawLogoutButton()
180             throws JahiaException {
181         return drawLinkButton( gui.drawLogoutUrl(), "logout" );
182     }
183
184     public String JavaDoc drawLogoutButton( int destinationPageID )
185             throws JahiaException {
186         return drawLinkButton( gui.drawLogoutUrl(), "logout" );
187     }
188
189     //---------------------------------------------------------- drawUpdateField
190
/**
191      *
192      * @param contentField
193      * @return
194      * @throws JahiaException
195      */

196     public String JavaDoc drawUpdateFieldLauncher(ContentField contentField)
197             throws JahiaException {
198         return drawUpdateFieldLauncher(contentField, false);
199     }
200
201     /**
202      *
203      * @param theField
204      * @return
205      * @throws JahiaException
206      * @deprecated
207      */

208     public String JavaDoc drawUpdateFieldLauncher( JahiaField theField )
209             throws JahiaException {
210         if ( theField == null ){
211             return "";
212         }
213         ContentField contentField = theField.getContentField();
214         return drawUpdateFieldLauncher(contentField, false);
215     }
216
217     /**
218      *
219      * @param theField
220      * @return
221      * @throws JahiaException
222      * @deprecated
223      */

224     public String JavaDoc drawUpdateFieldButton( JahiaField theField )
225             throws JahiaException {
226         return drawButton( drawUpdateFieldLauncher(theField), "update" );
227     }
228
229     private String JavaDoc drawUpdateFieldLauncher(ContentField contentField, boolean checkLock)
230             throws JahiaException {
231         StringBuffer JavaDoc name = new StringBuffer JavaDoc("updateField_");
232         if ( contentField != null ){
233             name.append(contentField.getID());
234         }
235         name.append(cleanSessionID(jParams.getSessionID()));
236         return drawLauncher( gui.drawUpdateFieldUrl(contentField) , name.toString() );
237     }
238
239     // -------------------------------------------------------- drawAddContainer
240
/**
241      *
242      * @param contentContainerList
243      * @return
244      */

245     public String JavaDoc drawAddContainerLauncher(JahiaContainerList jahiaContainerList) {
246         return drawAddContainerLauncher(jahiaContainerList, JS_WINDOW_WIDTH, JS_WINDOW_HEIGHT, false);
247     }
248
249     /**
250      *
251      * @param jahiaContainerList
252      * @param width
253      * @param height
254      */

255     public String JavaDoc drawAddContainerLauncher(JahiaContainerList jahiaContainerList, int width, int height) {
256         return drawAddContainerLauncher(jahiaContainerList, width, height, false);
257     }
258
259     /**
260      *
261      * @param jahiaContainerList
262      * @param width
263      * @param height
264      * @return
265      * @deprecated
266      */

267     private String JavaDoc drawAddContainerLauncher(JahiaContainerList jahiaContainerList, int width, int height, boolean checkLock) {
268         String JavaDoc launcher = "";
269         try {
270             StringBuffer JavaDoc name = new StringBuffer JavaDoc("addContainer_");
271             name.append(jahiaContainerList.getID());
272             name.append(cleanSessionID(jParams.getSessionID()));
273             String JavaDoc addContainerURL = gui.drawAddContainerUrl(jahiaContainerList);
274             launcher = addContainerURL.equals("") ? "" :
275                        "OpenJahiaScrollableWindow('" + addContainerURL + "','" + name.toString() + "'," + width + "," + height + ")";
276             // #ifdef LOCK
277
if (checkLock) {
278                 LockService lockRegistry = ServicesRegistry.getInstance().getLockService();
279                 LockKey lockKey = LockKey.composeLockKey(LockKey.ADD_CONTAINER_TYPE, jahiaContainerList.getID(), jahiaContainerList.getPageID());
280                 if (!lockRegistry.canRelease(lockKey, jParams.getUser(), jParams.getSessionID())) {
281                     launcher = "";
282                 }
283             }
284             // #endif
285
} catch (JahiaException je) {
286             logger.error("Cannot draw add container launcher", je);
287             launcher = "";
288         }
289         return launcher;
290     }
291
292     //------------------------------------------------------ drawUpdateContainer
293
/**
294      *
295      * @param contentContainerList
296      * @return
297      * @throws JahiaException
298      */

299     public String JavaDoc drawUpdateContainerLauncher(ContentContainer contentContainer)
300             throws JahiaException {
301         return drawUpdateContainerLauncher(contentContainer, JS_WINDOW_WIDTH, JS_WINDOW_HEIGHT, false);
302     }
303
304     /**
305      *
306      * @param contentContainer
307      * @param width
308      * @param height
309      * @return
310      * @throws JahiaException
311      */

312     public String JavaDoc drawUpdateContainerLauncher(ContentContainer contentContainer, int width, int height)
313             throws JahiaException {
314         return drawUpdateContainerLauncher(contentContainer, width, height, false);
315     }
316
317     /**
318      *
319      * @param theContainer
320      * @return
321      * @throws JahiaException
322      * @deprecated
323      */

324     public String JavaDoc drawUpdateContainerLauncher( JahiaContainer theContainer )
325             throws JahiaException {
326         if (theContainer != null) {
327             ContentContainer contentContainer = theContainer.
328                                                 getContentContainer();
329             return drawUpdateContainerLauncher(contentContainer,
330                                                JS_WINDOW_WIDTH,
331                                                JS_WINDOW_HEIGHT, false);
332         } else {
333             return "";
334         }
335     }
336
337     /**
338      *
339      * @param theContainer
340      * @param width
341      * @param height
342      * @return
343      * @throws JahiaException
344      * @deprecated
345      */

346     public String JavaDoc drawUpdateContainerLauncher( JahiaContainer theContainer, int width, int height )
347             throws JahiaException {
348         ContentContainer contentContainer = theContainer.getContentContainer();
349         return drawUpdateContainerLauncher(contentContainer, width, height, false);
350     }
351
352     /**
353      *
354      * @param theContainer
355      * @return
356      * @throws JahiaException
357      * @deprecated
358      */

359     public String JavaDoc drawUpdateContainerButton( JahiaContainer theContainer )
360             throws JahiaException {
361         return drawButton( drawUpdateContainerLauncher(theContainer), "update" );
362     }
363
364     private String JavaDoc drawUpdateContainerLauncher(ContentContainer contentContainer, int width, int height, boolean checkLock)
365             throws JahiaException {
366         StringBuffer JavaDoc name = new StringBuffer JavaDoc("updateContainer_");
367         if ( contentContainer != null ) {
368             name.append(contentContainer.getID());
369         }
370         name.append(cleanSessionID(jParams.getSessionID()));
371         String JavaDoc updateContainerURL = gui.drawUpdateContainerUrl(contentContainer);
372         String JavaDoc out = updateContainerURL.equals("") ? "" :
373                      "OpenJahiaScrollableWindow('" + updateContainerURL + "','" + name.toString() + "'," + width + "," + height + ")";
374         // #ifdef LOCK
375
if (checkLock) {
376             LockService lockRegistry = ServicesRegistry.getInstance().getLockService();
377             LockKey lockKey = LockKey.composeLockKey(LockKey.UPDATE_CONTAINER_TYPE, contentContainer.getID(), contentContainer.getPageID());
378             if (!lockRegistry.canRelease(lockKey, jParams.getUser(), jParams.getSessionID())) {
379                 out = "";
380             }
381         }
382         // #endif
383
return out;
384     }
385
386     //------------------------------------------------------ drawDeleteContainer
387
/**
388      *
389      * @param contentContainer
390      * @return
391      * @throws JahiaException
392      */

393     public String JavaDoc drawDeleteContainerLauncher(ContentContainer contentContainer)
394             throws JahiaException {
395         return drawDeleteContainerLauncher(contentContainer, false);
396     }
397
398     /**
399      *
400      * @param theContainer
401      * @return
402      * @throws JahiaException
403      * @deprecated
404      */

405     public String JavaDoc drawDeleteContainerLauncher( JahiaContainer theContainer )
406             throws JahiaException {
407         if ( theContainer == null ){
408             return "";
409         }
410         ContentContainer contentContainer = theContainer.getContentContainer();
411         return drawDeleteContainerLauncher(contentContainer, false);
412     }
413
414     /**
415      *
416      * @param theContainer
417      * @return
418      * @throws JahiaException
419      * @deprecated
420      */

421     public String JavaDoc drawDeleteContainerButton( JahiaContainer theContainer )
422             throws JahiaException {
423         return drawButton( drawDeleteContainerLauncher(theContainer), "delete" );
424     }
425
426     private String JavaDoc drawDeleteContainerLauncher(ContentContainer contentContainer, boolean checkLock)
427             throws JahiaException {
428         StringBuffer JavaDoc name = new StringBuffer JavaDoc("deleteContainer_");
429         if (contentContainer != null) {
430             name.append(contentContainer.getID());
431         }
432         name.append(cleanSessionID(jParams.getSessionID()));
433         String JavaDoc deleteContainerURL = gui.drawDeleteContainerUrl(contentContainer);
434         String JavaDoc out = deleteContainerURL.equals("") ? "" :
435                      "OpenJahiaScrollableWindow('" + deleteContainerURL + "','" + name.toString() + "'," + JS_WINDOW_WIDTH + "," + JS_WINDOW_HEIGHT +")";
436         // #ifdef LOCK
437
if (checkLock) {
438             LockService lockRegistry = ServicesRegistry.getInstance().getLockService();
439             LockKey lockKey = LockKey.composeLockKey(LockKey.DELETE_CONTAINER_TYPE, contentContainer.getID(), contentContainer.getPageID());
440             if (!lockRegistry.canRelease(lockKey, jParams.getUser(), jParams.getSessionID())) {
441                 out = "";
442             }
443         }
444         // #endif
445
return out;
446     }
447
448     // --------------------------------------------- drawContainerListProperties
449
/**
450      * @param contentContainerList
451      * @return
452      * @throws JahiaException
453      */

454     public String JavaDoc drawContainerListPropertiesLauncher(ContentContainerList contentContainerList)
455             throws JahiaException {
456         return drawContainerListPropertiesLauncher(contentContainerList, false);
457     }
458
459     /**
460      * @param theContainerList
461      * @return
462      * @throws JahiaException
463      * @deprecated
464      */

465     public synchronized String JavaDoc drawContainerListPropertiesLauncher( JahiaContainerList theContainerList )
466             throws JahiaException {
467         if (theContainerList.getID() == 0) {
468
469             /*
470             // FIXME : not handled correcly yet ( create duplicate container list in some situation
471             //
472             // create it
473             int parentACLID = 0;
474             if ( theContainerList.getParentEntryID() == 0 ){
475                 ContentPage page = ContentPage.getPage(theContainerList.getPageID(),false);
476                 parentACLID = page.getAclID();
477             } else {
478                 ContentObject contentContainer = ContentContainer
479                         .getContainer(theContainerList.getParentEntryID());
480                 parentACLID = contentContainer.getAclID();
481             }
482             ServicesRegistry.getInstance().getJahiaContainersService()
483                     .saveContainerListInfo(theContainerList,parentACLID);
484
485             ContentPage contentPage =
486                     ContentPage.getPage(theContainerList.getPageID(),false);
487             JahiaContentContainerFacade contentContainerFacade =
488                     new JahiaContentContainerFacade (0,
489                                                      contentPage.getJahiaID(),
490                                                      theContainerList.getPageID(),
491                                                      theContainerList.getID(),
492                                                      theContainerList.getctndefid(),
493                                                      //contentPage.getAclID(),
494                                                      0,
495                                                      jParams,
496                                                      jParams.getSite().getLanguageSettingsAsLocales(false) );
497             JahiaContainer theContainer = null;
498             if ( contentContainerFacade.getContainers().hasMoreElements() ){
499                 theContainer = (JahiaContainer)
500                                contentContainerFacade.getContainers().nextElement();
501             }
502
503             if ( theContainer != null ){
504                 //create default acl for container list edit view field
505                 JahiaField aField = null;
506                 Enumeration fList = theContainer.getFields();
507                 while (fList.hasMoreElements()) {
508                     aField = (JahiaField) fList.nextElement();
509                     JahiaFieldDefinition theDef = aField.getDefinition();
510                     if (theDef != null) {
511
512                         // create the ACL object...
513                         JahiaBaseACL newAcl = null;
514                         newAcl = new JahiaBaseACL();
515                         newAcl.create(theContainerList.getAclID());
516                         theContainerList.setProperty("view_field_acl_" + theDef.getName(),
517                                 String.valueOf(newAcl.getID()));
518                     }
519                 }
520             } */

521             return "";
522         }
523         ContentContainerList contentContainerList = ContentContainerList.getContainerList(theContainerList.getID());
524         return drawContainerListPropertiesLauncher(contentContainerList, false);
525     }
526
527     /**
528      * @param theContainerList
529      * @return
530      * @throws JahiaException
531      * @deprecated
532      */

533     public String JavaDoc drawContainerListPropertiesButton( JahiaContainerList theContainerList )
534             throws JahiaException {
535         return drawButton( drawContainerListPropertiesLauncher( theContainerList ), "list properties" );
536     }
537
538     private String JavaDoc drawContainerListPropertiesLauncher(ContentContainerList contentContainerList, boolean checkLock)
539             throws JahiaException {
540         StringBuffer JavaDoc name = new StringBuffer JavaDoc("containerListProperties_");
541         if ( contentContainerList != null ){
542             name.append(contentContainerList.getID());
543         }
544         name.append(cleanSessionID(jParams.getSessionID()));
545         String JavaDoc containerListPropertiesURL = gui.drawContainerListPropertiesUrl(contentContainerList);
546         String JavaDoc out = "";
547         if (!"".equals(containerListPropertiesURL)) {
548             out = "OpenJahiaWindow('" + containerListPropertiesURL + "', '" + name.toString() + "', " + JS_WINDOW_WIDTH + ", " + JS_WINDOW_HEIGHT + ")";
549         }
550         /*
551          * We allow to display the properties buttons even there arent' any childs
552          * to set rights
553         if (contentContainerList.getChilds(jParams.getUser(), jParams.getEntryLoadRequest(), jParams.EDIT).size() == 0) {
554             out = "";
555         }*/

556
557         // #ifdef LOCK
558
if (checkLock) {
559             LockService lockRegistry = ServicesRegistry.getInstance().getLockService();
560             LockKey lockKey = LockKey.composeLockKey(LockKey.UPDATE_CONTAINERLIST_TYPE, contentContainerList.getID(), contentContainerList.getPageID());
561             if (!lockRegistry.canRelease(lockKey, jParams.getUser(), jParams.getSessionID())) {
562                 out = "";
563             }
564         }
565         // #endif
566
return out;
567     }
568
569     public String JavaDoc drawWorkflowLauncher()
570         throws JahiaException {
571
572         StringBuffer JavaDoc name = new StringBuffer JavaDoc("workflow_");
573         if ( jParams.getPage() != null ){
574                 name.append(jParams.getPage().getID());
575         }
576         name.append(cleanSessionID(jParams.getSessionID()));
577         String JavaDoc workflowURL = gui.drawWorkflowUrl();
578         return ("".equals(workflowURL)) ? "" : "OpenJahiaScrollableWindow('" + workflowURL + "','" + name.toString() + "'," + JS_WINDOW_WIDTH + "," + JS_WINDOW_HEIGHT +")";
579     }
580
581     /**
582      * @param basePage
583      */

584     public String JavaDoc drawWorkflowLauncher(int basePage) throws JahiaException {
585         StringBuffer JavaDoc name = new StringBuffer JavaDoc("workflow_");
586
587         name.append(basePage);
588         name.append(cleanSessionID(jParams.getSessionID()));
589
590         String JavaDoc workflowURL = gui.drawWorkflowUrl();
591         return ("".equals(workflowURL)) ? "" : "OpenJahiaScrollableWindow('" + workflowURL + "','" + name.toString()
592                 + "'," + JS_WINDOW_WIDTH + "," + JS_WINDOW_HEIGHT + ")";
593     }
594     
595     /**
596      * Returns the link for the workflow engine with parameters.
597      *
598      * @param basePage the base page Id
599      * @param engineUrlParams parameters to be appended to the workflow engine
600      * URL
601      * @return the link for the workflow engine with parameters
602      */

603     public String JavaDoc drawWorkflowLauncher(int basePage, String JavaDoc engineUrlParams)
604       throws JahiaException
605     {
606       String JavaDoc workflowURL = gui.drawWorkflowUrl();
607   
608       return workflowURL.length() == 0 ? "" : new StringBuffer JavaDoc(64).append(
609         "OpenJahiaScrollableWindow('").append(workflowURL)
610         .append(engineUrlParams).append("','").append("workflow_").append(
611           basePage).append(cleanSessionID(jParams.getSessionID())).append(
612           "'," + JS_WINDOW_WIDTH + "," + JS_WINDOW_HEIGHT + ")").toString();
613     }
614     
615     //------------------------------------------------------- drawPageProperties
616
/**
617      *
618      * @return
619      * @throws JahiaException
620      */

621     public String JavaDoc drawPagePropertiesLauncher()
622             throws JahiaException {
623         return drawPagePropertiesLauncher(false);
624     }
625
626     private String JavaDoc drawPagePropertiesLauncher(boolean checkLock)
627             throws JahiaException {
628         StringBuffer JavaDoc name = new StringBuffer JavaDoc("pageProperties_");
629         if ( jParams.getPage() != null ){
630             name.append(jParams.getPage().getID());
631         }
632         name.append(cleanSessionID(jParams.getSessionID()));
633         String JavaDoc out = gui.drawPagePropertiesUrl().equals("") ? "" :
634                      "OpenJahiaScrollableWindow('" + gui.drawPagePropertiesUrl() + "','" + name.toString() + "'," + JS_WINDOW_WIDTH + "," + JS_WINDOW_HEIGHT +")";
635         // #ifdef LOCK
636
if (checkLock) {
637             LockService lockRegistry = ServicesRegistry.getInstance().getLockService();
638             LockKey lockKey = LockKey.composeLockKey(LockKey.UPDATE_PAGE_TYPE, jParams.getPageID(), jParams.getPageID());
639             if (!lockRegistry.canRelease(lockKey, jParams.getUser(), jParams.getSessionID())) {
640                 out = "";
641             }
642         }
643         // #endif
644
return out;
645     }
646
647     /**
648      *
649      * @return
650      * @throws JahiaException
651      */

652     public String JavaDoc drawPagePropertiesButton()
653             throws JahiaException {
654         return drawButton( drawPagePropertiesLauncher(), "page properties" );
655     }
656
657     // drawUpdateTemplateLauncher
658
public String JavaDoc drawUpdateTemplateLauncher( JahiaPageDefinition theTemplate )
659         throws JahiaException {
660                 StringBuffer JavaDoc name = new StringBuffer JavaDoc("updateTemplate_");
661                 if ( theTemplate != null ){
662                         name.append(theTemplate.getID());
663                 }
664                 name.append(cleanSessionID(jParams.getSessionID()));
665                 return drawLauncher( gui.drawUpdateTemplateUrl(theTemplate) , name.toString() );
666     }
667
668     /**
669      * Construct the select page URL.
670      *
671      * @param operation
672      * The select page operation.
673      * @param parentPageID
674      * The container parent page ID for new container creation.
675      * @param pageID
676      * The current page ID for update. N.B. This parameter is used
677      * when the user will change a DIRECT Jahia page to a link type
678      * (URL or page link). The DIRECT type cannot be changed to a
679      * link type on it's self page. Set to -1 for page creation.
680      * @return The select page URL.
681      * @throws JahiaException
682      */

683     public String JavaDoc drawSelectPageLauncher(String JavaDoc operation, int parentPageID, int pageID) throws JahiaException {
684         StringBuffer JavaDoc name = new StringBuffer JavaDoc("selectPage_");
685         if ( jParams.getPage() != null ){
686             name.append(jParams.getPage().getID());
687         }
688         HashMap JavaDoc params = new HashMap JavaDoc();
689         params.put(SelectPage_Engine.OPERATION, operation);
690         params.put(SelectPage_Engine.PARENT_PAGE_ID, new Integer JavaDoc(parentPageID));
691         params.put(SelectPage_Engine.PAGE_ID, new Integer JavaDoc(pageID));
692         name.append(cleanSessionID(jParams.getSessionID()));
693         String JavaDoc selectPageURL = SelectPage_Engine.getInstance().renderLink(jParams, params);
694         return "".equals(selectPageURL) ? "" : "OpenJahiaScrollableWindow('" + selectPageURL + "','" + name.toString()
695                 + "'," + JS_WINDOW_WIDTH + "," + JS_WINDOW_HEIGHT + ")";
696     }
697
698     // drawSearchLauncher
699
public String JavaDoc drawSearchLauncher()
700         throws JahiaException {
701             //return drawLauncher(
702
return gui.drawSearchUrl();
703     }
704
705     // drawAdministrationLauncher
706
// MJ 21.03.2001
707
public String JavaDoc drawAdministrationLauncher()
708         throws JahiaException {
709             return gui.drawAdministrationLauncher();
710     }
711
712     public String JavaDoc drawMySettingsLauncher ()
713             throws JahiaException {
714         return gui.drawMySettingsUrl ();
715     }
716     
717     public String JavaDoc drawMySettingsLauncher(Object JavaDoc params) throws JahiaException
718     {
719       return gui.drawMySettingsUrl(params);
720     }
721
722     public String JavaDoc drawNewUserRegistrationLauncher ()
723             throws JahiaException {
724         return gui.drawNewUserRegistrationUrl ();
725     }
726     
727     public String JavaDoc drawNewUserRegistrationLauncher(Object JavaDoc params)
728       throws JahiaException
729     {
730       return gui.drawNewUserRegistrationUrl(params);
731     }
732
733     // drawSiteMapLauncher
734
public String JavaDoc drawSiteMapLauncher()
735         throws JahiaException {
736             //return drawLauncher(
737
return gui.drawSiteMapUrl();
738     }
739
740     // drawAddContainerButton
741
public String JavaDoc drawAddContainerButton( JahiaContainerList theContainerList )
742         throws JahiaException { return drawButton( drawAddContainerLauncher(theContainerList), "add" ); }
743
744     // drawUpdateTemplateButton
745
public String JavaDoc drawUpdateTemplateButton( JahiaPageDefinition theTemplate )
746         throws JahiaException { return drawButton( drawUpdateTemplateLauncher(theTemplate), "template" ); }
747
748
749     // drawSearchButton
750
// DJ 03.01.2001
751
public String JavaDoc drawSearchButton ()
752         throws JahiaException {
753             String JavaDoc html = "";
754             String JavaDoc theUrl="";
755 // theUrl += "OpenJahiaWindow('";
756
theUrl += drawSearchLauncher();
757 // theUrl += "','search!'," + JS_WINDOW_WIDTH + "," + JS_WINDOW_HEIGHT + ")";
758
html += "<form method=\"POST\" action=\"" + theUrl + "\">\n";
759             html += "<input type=\"text\" name=\"search\" size=15 value=\"\">\n";
760             html += "<input type=submit value=\"Search\">";
761 // html += "<input type="Button"
762
html += "</form>";
763
764 // return drawButton( drawSearchLauncher(), html ) ;
765
return html;
766         }
767
768
769     // drawSiteMapButton
770
public String JavaDoc drawSiteMapButton()
771         throws JahiaException { return drawButton( drawSiteMapLauncher(), "site map" ); }
772
773     /**
774      *
775      * @param contentObject
776      * @param lockKey
777      * @return
778      * @throws JahiaException
779      */

780     public String JavaDoc drawReleaseLockObjectLauncher(ContentObject contentObject, LockKey lockKey)
781             throws JahiaException {
782         // #ifdef LOCK
783
String JavaDoc launcher = "";
784         if (!ParamBean.EDIT.equals(jParams.getOperationMode())) {
785             return null;
786         }
787         // Draw launcher without controling the lock.
788
if (contentObject instanceof ContentContainerList) {
789             if (LockKey.ADD_CONTAINER_TYPE.equals(lockKey.getType())) {
790                 ContentContainerList contentContainerList = (ContentContainerList) contentObject;
791                 JahiaContainerList jahiaContainerList = contentContainerList.getJahiaContainerList(jParams, jParams.getEntryLoadRequest());
792                 launcher = drawAddContainerLauncher(jahiaContainerList, JS_WINDOW_WIDTH, JS_WINDOW_HEIGHT, false);
793             } else if (LockKey.UPDATE_CONTAINERLIST_TYPE.equals(lockKey.getType())) {
794                 launcher = drawContainerListPropertiesLauncher((ContentContainerList)contentObject, false);
795             }
796         } else if (contentObject instanceof ContentField) {
797             if (LockKey.UPDATE_FIELD_TYPE.equals(lockKey.getType())) {
798                 launcher = drawUpdateFieldLauncher((ContentField)contentObject, false);
799             }
800         } else if (contentObject instanceof ContentContainer) {
801             if (LockKey.UPDATE_CONTAINER_TYPE.equals(lockKey.getType())) {
802                 launcher = drawUpdateContainerLauncher((ContentContainer)contentObject, JS_WINDOW_WIDTH, JS_WINDOW_HEIGHT, false);
803             } else if (LockKey.DELETE_CONTAINER_TYPE.equals(lockKey.getType())) {
804                 launcher = drawDeleteContainerLauncher((ContentContainer)contentObject, false);
805             }
806         } else if (contentObject instanceof ContentPage) {
807             if (LockKey.UPDATE_PAGE_TYPE.equals(lockKey.getType())) {
808                 launcher = drawPagePropertiesLauncher(false);
809             }
810         }
811         LockService lockRegistry = ServicesRegistry.getInstance().getLockService();
812         if (lockRegistry.isAlreadyAcquired(lockKey)) {
813             if (lockRegistry.canRelease(lockKey, jParams.getUser(), jParams.getSessionID())) {
814                 return jParams.composeReleaseLockURL(lockKey);
815             } else {
816                 return "javascript:" + launcher;
817             }
818         }
819         // #endif
820
return null;
821     }
822
823
824     public String JavaDoc drawLockEngineLauncher(LockKey lockKey)
825             throws JahiaException {
826         String JavaDoc out = "";
827         // #ifdef LOCK
828
StringBuffer JavaDoc name = new StringBuffer JavaDoc("lock_");
829         if (jParams.getPage() != null) {
830             name.append(jParams.getPage().getID());
831         }
832         name.append(cleanSessionID(jParams.getSessionID()));
833         String JavaDoc lockURL = gui.drawLockUrl(lockKey);
834         out = "".equals(lockURL) ? "" :
835               "javascript:OpenJahiaScrollableWindow('" + lockURL + "','" + name.toString() + "'," +
836               JS_WINDOW_WIDTH + "," + JS_WINDOW_HEIGHT + ")";
837         // #endif
838
return out;
839     }
840
841    /***
842     * drawLauncher
843     * EV 15.12.2000
844     *
845     */

846     private String JavaDoc drawLauncher( String JavaDoc url, String JavaDoc windowName )
847     throws JahiaException
848     {
849         String JavaDoc html = "";
850         // if url = "", this means that the engine didn't grant authorisation to render
851
if (!url.equals("")) {
852             html += "OpenJahiaScrollableWindow('";
853             html += url;
854             html += "','" + windowName + "'," + JS_WINDOW_WIDTH + "," + JS_WINDOW_HEIGHT + ")";
855         }
856         return html;
857     } // end drawLauncher
858

859
860
861     /***
862         * drawButton
863         * EV 15.12.2000
864         *
865         */

866     private String JavaDoc drawButton( String JavaDoc launcher, String JavaDoc buttonLabel )
867     throws JahiaException
868     {
869         String JavaDoc html = "";
870         // if launcher = "", this means that the engine didn't grant authorisation to render
871
if (!launcher.equals("")) {
872             html += "<a HREF=\"javascript:";
873             html += launcher;
874             html += "\">" + buttonLabel + "</a>";
875         }
876         return html;
877     } // end drawButton
878

879
880
881     /***
882         * drawLinkButton - Draw a link but without javascript!
883         *
884         */

885     private String JavaDoc drawLinkButton( String JavaDoc launcher, String JavaDoc buttonLabel )
886     throws JahiaException
887     {
888         String JavaDoc html = "";
889         // if launcher = "", this means that the engine didn't grant authorisation to render
890
if (!launcher.equals("")) {
891             html += "<a HREF=\"";
892             html += launcher;
893             html += "\">" + buttonLabel + "</a>";
894         }
895         return html;
896     } // end drawButton
897

898
899         /**
900          * Generate an html anchor composed by the fieldID
901          *
902          */

903         public String JavaDoc drawAnchor(JahiaField theField){
904
905                 if ( theField == null ){
906                         return "";
907                 }
908
909                 StringBuffer JavaDoc anchor = new StringBuffer JavaDoc("<A NAME=");
910                 anchor.append("field_");
911                 anchor.append(theField.getID());
912                 anchor.append("></A>");
913
914                 return anchor.toString();
915         }
916
917
918         /**
919          * Generate an html anchor composed by the container list ID
920          *
921          */

922         public String JavaDoc drawAnchor(JahiaContainerList cList){
923
924                 if ( cList == null ){
925                         return "";
926                 }
927
928                 StringBuffer JavaDoc anchor = new StringBuffer JavaDoc("<A NAME=");
929                 anchor.append("cList_");
930                 anchor.append(cList.getID());
931                 anchor.append("></A>");
932
933                 return anchor.toString();
934         }
935
936
937         /**
938          * Generate an html anchor composed by all the container ID
939          *
940          */

941         public String JavaDoc drawAnchor(JahiaContainer container){
942
943                 if ( container == null ){
944                         return "";
945                 }
946
947                 StringBuffer JavaDoc anchor = new StringBuffer JavaDoc("<A NAME=");
948                 anchor.append("container_");
949                 anchor.append(container.getID());
950                 anchor.append("></A>");
951
952                 return anchor.toString();
953         }
954
955
956         /**
957          * Generate an html anchor composed by the page ID
958          *
959          */

960         public String JavaDoc drawAnchor(JahiaPage page){
961
962                 if ( page == null ){
963                         return "";
964                 }
965
966                 StringBuffer JavaDoc anchor = new StringBuffer JavaDoc("<A NAME=");
967                 anchor.append("page_");
968                 anchor.append(page.getID());
969                 anchor.append("></A>");
970
971                 return anchor.toString();
972         }
973
974         /*
975             Action menu drawing methods
976         */

977
978        /**
979         * Generates the HTML for the beginning of an action menu, including the
980         * box around the object if the useFieldSet boolean is true
981         * @param contentObject the content object for which to generate the
982         * action menu
983         * @param lockIcon the name of the lock icon. If null a default name
984         * of "lock.gif" is used.
985         * @param actionIcon the name of the action icon. If null a default name
986         * of "action.gif" is used.
987         * @param useFieldSet use to specify when an HTML field set box should
988         * be generated around the content object
989         * @param namePostFix a name to append to the resource names to be able
990         * to generate access to varied resource for creating different menus for
991         * the same type of objects. Example could be "Text", or "_portlet", etc
992         * @param resourceBundle the name of the resource bundle in which to
993         * retrieve the resources.
994         * @param out the output JspWriter in which the HTML output will be
995         * generated.
996         * @throws IOException thrown if there was an error while writing to
997         * the output (such as a socket that's been disconnected).
998         */

999        public void drawBeginActionMenu (Object JavaDoc contentObject, String JavaDoc lockIcon,
1000                                        String JavaDoc actionIcon,
1001                                        boolean useFieldSet,
1002                                        String JavaDoc namePostFix,
1003                                        String JavaDoc resourceBundle,
1004                                        String JavaDoc labelKey,
1005                                        JspWriter JavaDoc out)
1006           throws IOException JavaDoc {
1007           if (!ParamBean.EDIT.equals(jParams.getOperationMode())) {
1008               // if we are not in edit mode we don't display the GUI
1009
return;
1010           }
1011           if (contentObject instanceof ContainerListBean) {
1012               ContainerListBean containerListBean = (ContainerListBean)
1013                                                     contentObject;
1014               beginContainerListMenu(containerListBean, lockIcon, actionIcon, useFieldSet, namePostFix, resourceBundle, labelKey, out);
1015           } else if (contentObject instanceof ContainerBean) {
1016               ContainerBean containerBean = (ContainerBean) contentObject;
1017               beginContainerMenu(containerBean, lockIcon, actionIcon, useFieldSet, namePostFix, resourceBundle, labelKey, out);
1018           } else if (contentObject instanceof FieldBean) {
1019               FieldBean fieldBean = (FieldBean) contentObject;
1020               beginFieldMenu(fieldBean, lockIcon, actionIcon, useFieldSet, namePostFix, resourceBundle, labelKey, out);
1021           } else if (contentObject instanceof PageBean) {
1022               PageBean pageBean = (PageBean) contentObject;
1023               beginPageMenu(pageBean, lockIcon, actionIcon, useFieldSet, namePostFix, resourceBundle, labelKey, out);
1024           } else {
1025               logger.error("Expected Container list, container, field or page when generating menu for object ");
1026           }
1027       }
1028
1029       /**
1030        * Generates the HTML for the end of the action menu, closing the
1031        * box around the content object if we started one.
1032        * @param contentObject the content object for which to generate the
1033        * action menu
1034        * @param lockIcon the name of the lock icon. If null a default name
1035        * of "lock.gif" is used.
1036        * @param actionIcon the name of the action icon. If null a default name
1037        * of "action.gif" is used.
1038        * @param useFieldSet use to specify when an HTML field set box should
1039        * be generated around the content object
1040        * @param namePostFix a name to append to the resource names to be able
1041        * to generate access to varied resource for creating different menus for
1042        * the same type of objects. Example could be "Text", or "_portlet", etc
1043        * @param resourceBundle the name of the resource bundle in which to
1044        * retrieve the resources.
1045        * @param out the output JspWriter in which the HTML output will be
1046        * generated.
1047        * @throws IOException thrown if there was an error while writing to
1048        * the output (such as a socket that's been disconnected).
1049        */

1050       public void drawEndActionMenu (Object JavaDoc contentObject, String JavaDoc lockIcon,
1051                                      String JavaDoc actionIcon,
1052                                      boolean useFieldSet,
1053                                      String JavaDoc namePostFix,
1054                                      String JavaDoc resourceBundle,
1055                                      String JavaDoc labelKey,
1056                                      JspWriter JavaDoc out)
1057           throws IOException JavaDoc {
1058           if (!ParamBean.EDIT.equals(jParams.getOperationMode())) {
1059               // if we are not in edit mode we don't display the GUI
1060
return;
1061           }
1062           Map JavaDoc actionURIBeans = null;
1063           if (contentObject instanceof ContainerListBean) {
1064               ContainerListBean containerListBean = (ContainerListBean)
1065                                                     contentObject;
1066               actionURIBeans = containerListBean.getActionURIBeans();
1067           } else if (contentObject instanceof ContainerBean) {
1068               ContainerBean containerBean = (ContainerBean) contentObject;
1069               actionURIBeans = containerBean.getActionURIBeans();
1070
1071           } else if (contentObject instanceof FieldBean) {
1072               FieldBean fieldBean = (FieldBean) contentObject;
1073               actionURIBeans = fieldBean.getActionURIBeans();
1074
1075           } else if (contentObject instanceof PageBean) {
1076               PageBean pageBean = (PageBean) contentObject;
1077               actionURIBeans = pageBean.getActionURIBeans();
1078
1079           } else {
1080               logger.error("Expected Container list, container, field or page when generating menu for object ");
1081               return;
1082           }
1083           endMenu(actionURIBeans, useFieldSet, out);
1084       }
1085
1086       private void beginContainerListMenu (ContainerListBean containerListBean,
1087                                            String JavaDoc lockIcon, String JavaDoc actionIcon,
1088                                            boolean useFieldSet,
1089                                            String JavaDoc namePostFix,
1090                                            String JavaDoc resourceBundle,
1091                                            String JavaDoc labelKey,
1092                                            JspWriter JavaDoc out)
1093           throws IOException JavaDoc {
1094           Map JavaDoc actionURIBeans = containerListBean.getActionURIBeans();
1095           beginMenu(actionURIBeans, "contentContainerList",
1096                     containerListBean.getId(),
1097                     containerListBean.getContainerDefinitionID(),
1098                     containerListBean.getParentContainerID(),
1099                     containerListBean.getPageID(),
1100                     containerListBean.isCompletelyLocked(),
1101                     containerListBean.isPartiallyLocked(), lockIcon, actionIcon,
1102                     useFieldSet, namePostFix, resourceBundle, labelKey, out);
1103       }
1104
1105       private void beginContainerMenu (ContainerBean containerBean,
1106                                        String JavaDoc lockIcon, String JavaDoc actionIcon,
1107                                        boolean useFieldSet,
1108                                        String JavaDoc namePostFix,
1109                                        String JavaDoc resourceBundle,
1110                                        String JavaDoc labelKey,
1111                                        JspWriter JavaDoc out)
1112           throws IOException JavaDoc {
1113           Map JavaDoc actionURIBeans = containerBean.getActionURIBeans();
1114           beginMenu(actionURIBeans, "contentContainer", containerBean.getId(),
1115                     containerBean.getDefinition().getID(),
1116                     containerBean.getContainerListID(),
1117                     containerBean.getPageID(),
1118                     containerBean.isCompletelyLocked(),
1119                     containerBean.isPartiallyLocked(), lockIcon, actionIcon,
1120                     useFieldSet, namePostFix, resourceBundle, labelKey, out);
1121       }
1122
1123       private void beginFieldMenu (FieldBean fieldBean, String JavaDoc lockIcon,
1124                                    String JavaDoc actionIcon,
1125                                    boolean useFieldSet,
1126                                    String JavaDoc namePostFix,
1127                                    String JavaDoc resourceBundle,
1128                                    String JavaDoc labelKey,
1129                                    JspWriter JavaDoc out)
1130           throws IOException JavaDoc {
1131           Map JavaDoc actionURIBeans = fieldBean.getActionURIBeans();
1132           beginMenu(actionURIBeans, "contentField", fieldBean.getId(),
1133                     fieldBean.getDefinition().getID(),
1134                     fieldBean.getContainerID(), /* we only put the container here because we have the page in the next attribute */
1135                     fieldBean.getPageID(),
1136                     fieldBean.isCompletelyLocked(),
1137                     fieldBean.isPartiallyLocked(), lockIcon, actionIcon,
1138                     useFieldSet, namePostFix, resourceBundle, labelKey, out);
1139       }
1140
1141       private void beginPageMenu (PageBean pageBean, String JavaDoc lockIcon,
1142                                   String JavaDoc actionIcon,
1143                                   boolean useFieldSet,
1144                                   String JavaDoc namePostFix,
1145                                   String JavaDoc resourceBundle,
1146                                   String JavaDoc labelKey,
1147                                   JspWriter JavaDoc out)
1148           throws IOException JavaDoc {
1149           Map JavaDoc actionURIBeans = pageBean.getActionURIBeans();
1150           beginMenu(actionURIBeans, "contentPage", pageBean.getId(),
1151                     pageBean.getTemplateID(),
1152                     pageBean.getId(), /* here we cheat, we make the page it's own parent */
1153                     pageBean.getId(),
1154                     pageBean.isCompletelyLocked(),
1155                     pageBean.isPartiallyLocked(), lockIcon, actionIcon,
1156                     useFieldSet, namePostFix, resourceBundle, labelKey, out);
1157       }
1158
1159       private void beginMenu (Map JavaDoc actionURIBeans,
1160                               String JavaDoc typeName,
1161                               int idInType,
1162                               int definitionID,
1163                               int parentID,
1164                               int pageID,
1165                               boolean completelyLocked,
1166                               boolean partiallyLocked,
1167                               String JavaDoc lockIcon,
1168                               String JavaDoc actionIcon,
1169                               boolean useFieldSet,
1170                               String JavaDoc namePostFix,
1171                               String JavaDoc resourceBundle,
1172                               String JavaDoc labelKey,
1173                               JspWriter JavaDoc out)
1174           throws IOException JavaDoc {
1175           if (actionURIBeans.isEmpty()) {
1176               return;
1177           }
1178           if (useFieldSet) {
1179               if (completelyLocked) {
1180                   out.println(
1181                       "<fieldset style=\"padding: 5px;border: 1px solid #FF0000;\">");
1182               } else if (partiallyLocked) {
1183                   out.println(
1184                       "<fieldset style=\"padding: 5px;border: 1px solid #FF8000;\">");
1185               } else {
1186                   out.println("<fieldset style=\"padding: 5px;\">");
1187               }
1188
1189               out.println("<legend align=\"right\">");
1190           }
1191           out.println(" <a class=\"admin-menu-link\" HREF=\"\" onclick=\"return buttonClick(event, '" +
1192                       buildUniqueContentID(typeName,idInType,definitionID,parentID,pageID) + "');\"");
1193           out.println(" onmouseover=\"buttonMouseover(event, '" +
1194                       buildUniqueContentID(typeName,idInType,definitionID,parentID,pageID) + "');\">");
1195           out.print(" <span class=\"");
1196           if (completelyLocked) {
1197               out.print("lockIcon\"");
1198               if (lockIcon != null) {
1199                   out.print(" style=\"background-image: url('" + lockIcon + "');background-repeat: no-repeat;padding-right:7px;\"&nbsp;>");
1200               } else {
1201                   out.println("><img class=\"lockIcon\" SRC=\"" +
1202                           getURLImageContext() + "/lock.gif" + "\" alt=\"" +
1203                           getResource(resourceBundle, typeName + "Operations") + "\"");
1204                   out.println(" border=\"0\"/>");
1205               }
1206           } else {
1207               out.print("actionIcon\"");
1208               if (actionIcon != null) {
1209                   out.println(" style=\"background-image: url('" + actionIcon + "');background-repeat: no-repeat;padding-right:7px;\">&nbsp;");
1210               } else {
1211                   out.println("><img class=\"actionIcon\" SRC=\"" +
1212                           getURLImageContext() + "/action.gif" + "\" alt=\"" +
1213                           getResource(resourceBundle, typeName + "Operations") + "\"");
1214                   out.println(" border=\"0\"/>");
1215               }
1216           }
1217           out.println("</span>");
1218           if (labelKey != null) {
1219               out.println(getResource(resourceBundle, labelKey));
1220           }
1221           out.println("</a>");
1222           if (useFieldSet) {
1223               out.println("</legend>");
1224           }
1225
1226           out.println("<div id=\"" + buildUniqueContentID(typeName,idInType,definitionID,parentID,pageID) +
1227               "\" class=\"menu\" style=\"left: 161px; top: 265px; visibility: hidden;\">");
1228           Iterator JavaDoc actionURIIter = actionURIBeans.entrySet().iterator();
1229           while (actionURIIter.hasNext()) {
1230               Map.Entry JavaDoc curEntry = (Map.Entry JavaDoc) actionURIIter.next();
1231               ActionURIBean curActionURIBean = (ActionURIBean) curEntry.getValue();
1232               if (curActionURIBean.isAuthorized()) {
1233                   out.println("<a class=\"menuItem\" HREF=\"javascript:" +
1234                               curActionURIBean.getLauncherUri() + "\">");
1235                   out.print(" <span class='");
1236                   if (curActionURIBean.isLocked()) {
1237                       out.println("lockgreyIcon'>");
1238                       out.println(" <img class=\"lockgreyIcon\" SRC=\"" + getURLImageContext() +
1239                               "/lock_grey.gif\" alt=\"\" border=\"0\"/>");
1240                   } else {
1241                       out.println(curActionURIBean.getName() + "Icon'>");
1242                       out.println(" <img class=\"" + curActionURIBean.getName() + "Icon\" SRC=\"" +
1243                               getURLImageContext() + "/" + curActionURIBean.getName() +
1244                               ".gif\" alt=\"\" border=\"0\"/>");
1245                   }
1246                   out.println("&nbsp;</span>" +
1247                           getResource(resourceBundle, curActionURIBean.getName() + namePostFix));
1248                   out.println("</a>");
1249               }
1250           }
1251           out.println("</div>");
1252       }
1253
1254       private void endMenu (Map JavaDoc actionURIBeans, boolean useFieldSet,
1255                             JspWriter JavaDoc out)
1256           throws IOException JavaDoc {
1257           if (actionURIBeans.isEmpty()) {
1258               return;
1259           }
1260           if (useFieldSet) {
1261               out.println("</fieldset>");
1262           }
1263       }
1264
1265       private String JavaDoc getResource (String JavaDoc resourceBundle,
1266                                   String JavaDoc resourceName) {
1267           ResourceBundle JavaDoc res = null;
1268           String JavaDoc resValue = null;
1269
1270           Locale JavaDoc locale = jParams.getLocale();
1271           try {
1272               res = ResourceBundle.getBundle(resourceBundle, locale);
1273               resValue = JahiaResourceBundle.getString(res, resourceName,
1274                   locale);
1275           } catch (MissingResourceException JavaDoc mre) {
1276               logger.warn("Error accessing resource " + resourceName +
1277                           " in bundle " + resourceBundle + " for locale " +
1278                           locale + ":" + mre.getMessage());
1279           }
1280           return resValue;
1281       }
1282
1283       private String JavaDoc getURLImageContext () {
1284           return jParams.getRequest().getContextPath() +
1285               "/jsp/jahia/engines/images/actions";
1286       }
1287
1288       private String JavaDoc buildUniqueContentID (String JavaDoc typeName,
1289                                            int idInType,
1290                                            int definitionID,
1291                                            int parentID,
1292                                            int pageID) {
1293           StringBuffer JavaDoc result = new StringBuffer JavaDoc(typeName);
1294           result.append("_");
1295           result.append(idInType);
1296           result.append("_");
1297           result.append(definitionID);
1298           result.append("_");
1299           result.append(parentID);
1300           result.append("_");
1301           result.append(pageID);
1302           return result.toString();
1303       }
1304
1305
1306   } // end HTMLToolBox
1307
Popular Tags