1 package org.jahia.deprecated.taglibs.button; 2 3 import javax.servlet.jsp.JspException ; 4 5 import org.jahia.data.JahiaData; 6 import org.jahia.data.containers.JahiaContainerList; 7 import org.jahia.deprecated.taglibs.container.ContainerListTag; 8 import org.jahia.exceptions.JahiaException; 9 import org.jahia.services.usermanager.JahiaUser; 10 11 12 18 public class AddContainerButtonTag extends AbstractButtonTag { 19 20 private JahiaContainerList containerList = null; 21 private String title = "Add"; 22 private String style = ""; 23 24 public void setTitle(String title) { 25 this.title = title; 26 } 27 28 public void setStyle(String style) { 29 this.style = style; 30 } 31 32 public String getTitle() { 33 return this.title; 34 } 35 36 public String getStyle() { 37 return this.style; 38 } 39 40 public boolean testRights (JahiaData jData) { 41 ContainerListTag parent = (ContainerListTag) findAncestorWithClass(this,ContainerListTag.class); 43 if (parent != null) { 44 if (parent.isDeclarationPass()) { 45 return false; 46 } 47 this.containerList = parent.getContainerList(); 48 } 49 if (this.containerList != null) { 50 JahiaUser user = jData.params().getUser(); 51 if (jData.gui().isEditMode()) { 52 return ( this.containerList.checkWriteAccess(user) 53 || ( !this.containerList.getContainers().hasMoreElements() 55 && jData.page().checkWriteAccess(user) ) ); 56 } 57 } 58 return false; 59 } 60 61 public String getLauncher(JahiaData jData) throws JahiaException { 62 return "javascript:" + jData.gui().html().drawAddContainerLauncher(this.containerList); 64 } 65 66 public int doEndTag() throws JspException { 67 containerList = null; 70 title = "Add"; 71 style = ""; 72 return EVAL_PAGE; 73 } 74 75 } 76 | Popular Tags |