Commit ef24ae04 authored by Bill Lynch's avatar Bill Lynch Committed by bill

Initial checkin


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@256 b35dd754-fafc-0310-a699-88a17e54d16e
parent 3ae2484c
This diff is collapsed.
/**
* $RCSfile$
* $Revision
* $Date$
*
* Copyright (C) 1999-2004 Jive Software. All rights reserved.
*
* This software is the proprietary information of Jive Software. Use is subject to license terms.
*/
package org.jivesoftware.admin;
import org.jivesoftware.util.StringUtils;
import java.util.Collection;
import java.util.ArrayList;
public class AdminPageBean {
private String title;
private Collection breadcrumbs;
private String pageID;
private String subPageID;
private String extraParams;
private Collection scripts;
public AdminPageBean() {
}
/**
* Returns the title of the page with HTML escaped.
*/
public String getTitle() {
if (title != null) {
return StringUtils.escapeHTMLTags(title);
}
else {
return title;
}
}
/**
* Sets the title of the admin console page.
*/
public void setTitle(String title) {
this.title = title;
}
/**
* Returns a collection of breadcrumbs. Use the Collection API to get/set/remove crumbs.
*/
public Collection getBreadcrumbs() {
if (breadcrumbs == null) {
breadcrumbs = new ArrayList();
}
return breadcrumbs;
}
/**
* Returns the page ID (corresponds to sidebar ID's).
*/
public String getPageID() {
return pageID;
}
/**
* Sets the ID of the page (corresponds to sidebar ID's).
* @param pageID
*/
public void setPageID(String pageID) {
this.pageID = pageID;
}
/**
* Returns the subpage ID (corresponds to sidebar ID's).
*/
public String getSubPageID() {
return subPageID;
}
/**
* Sets the subpage ID (corresponds to sidebar ID's).
* @param subPageID
*/
public void setSubPageID(String subPageID) {
this.subPageID = subPageID;
}
/**
* Returns a string of extra parameters for the URLs - these might be specific IDs for resources.
*/
public String getExtraParams() {
return extraParams;
}
/**
* Sets the string of extra parameters for the URLs.
*/
public void setExtraParams(String extraParams) {
this.extraParams = extraParams;
}
/**
* Returns a collection of scripts. Use the Collection API to get/set/remove scripts.
*/
public Collection getScripts() {
if (scripts == null) {
scripts = new ArrayList();
}
return scripts;
}
/**
* A simple model of a breadcrumb. A bread crumb is a link with a display name.
*/
public static class Breadcrumb {
private String name;
private String url;
/**
* Creates a crumb given a name an URL.
*/
public Breadcrumb(String name, String url) {
this.name = name;
this.url = url;
}
/**
* Returns the name, with HTML escaped.
*/
public String getName() {
if (name != null) {
return StringUtils.escapeHTMLTags(name);
}
else {
return name;
}
}
/**
* Returns the URL.
*/
public String getUrl() {
return url;
}
}
}
This diff is collapsed.
/**
* $RCSfile$
* $Revision
* $Date$
*
* Copyright (C) 1999-2004 Jive Software. All rights reserved.
*
* This software is the proprietary information of Jive Software. Use is subject to license terms.
*/
package org.jivesoftware.admin;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspTagException;
public class SubSidebarTag extends SidebarTag {
private SidebarTag parent;
private String body;
/**
* Returns the body content of this tag.
*/
public String getBody() {
return body;
}
/**
* Sets the body content of this tag.
*/
public void setBody(String body) {
this.body = body;
}
/**
* Looks for the parent SidebarTag class, throws an error if not found. If found,
* {@link #EVAL_BODY_BUFFERED} is returned.
*
* @return {@link #EVAL_BODY_BUFFERED} if no errors.
* @throws javax.servlet.jsp.JspException if a parent SidebarTag is not found.
*/
public int doStartTag() throws JspException {
// The I18nTag should be our parent Tag
parent = (SidebarTag)findAncestorWithClass(this, SidebarTag.class);
// If I18nTag was not our parent, throw Exception
if (parent == null) {
throw new JspTagException("SubSidebarTag with out a parent which is expected to be a SidebarTag");
}
return EVAL_BODY_BUFFERED;
}
/**
* Sets the 'body' property to be equal to the body content of this tag. Calls the
* {@link SidebarTag#setSubSidebar(SubSidebarTag)} method of the parent tag.
* @return {@link #EVAL_PAGE}
* @throws JspException if an error occurs.
*/
public int doEndTag() throws JspException {
setBody(bodyContent.getString());
parent.setSubSidebar(this);
return EVAL_PAGE;
}
}
\ No newline at end of file
/**
* $RCSfile$
* $Revision
* $Date$
*
* Copyright (C) 1999-2004 Jive Software. All rights reserved.
*
* This software is the proprietary information of Jive Software. Use is subject to license terms.
*/
package org.jivesoftware.admin;
import org.jivesoftware.util.StringUtils;
import javax.servlet.jsp.tagext.BodyTagSupport;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.ServletRequest;
import java.util.Collection;
import java.util.Iterator;
import java.io.IOException;
public class TabsTag extends BodyTagSupport {
private String bean;
private String role;
private String minEdition;
private String css;
private String currentcss;
/**
* The name of the request attribute which holds a {@link AdminPageBean} instance.
*/
public String getBean() {
return bean;
}
/**
* Sets the name of the request attribute to hold a {@link AdminPageBean} instance.
*/
public void setBean(String bean) {
this.bean = bean;
}
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
public String getMinEdition() {
return minEdition;
}
public void setMinEdition(String minEdition) {
this.minEdition = minEdition;
}
/**
* Returns the value of the CSS class to be used for tab decoration. If not set will return a blank string.
*/
public String getCss() {
return clean(css);
}
/**
* Sets the CSS used for tab decoration.
*/
public void setCss(String css) {
this.css = css;
}
/**
* Returns the value of the CSS class to be used for the currently selected LI (tab). If not set will
* return a blank string.
*/
public String getCurrentcss() {
return clean(currentcss);
}
/**
* Sets the CSS class value for the currently selected tab.
*/
public void setCurrentcss(String currentcss) {
this.currentcss = currentcss;
}
/**
* Does nothing, returns {@link #EVAL_BODY_BUFFERED} always.
*/
public int doStartTag() throws JspException {
return EVAL_BODY_BUFFERED;
}
/**
* Gets the {@link AdminPageBean} instance from the request. If it doesn't exist then execution is stopped
* and nothing is printed. If it exists, retrieve values from it and render the tabs. The body content
* of the tag is assumed to have an A tag in it with tokens to replace (see class description).
*
* @return {@link #EVAL_PAGE} after rendering the tabs.
* @throws JspException if an exception occurs while rendering the tabs.
*/
public int doEndTag() throws JspException {
ServletRequest request = pageContext.getRequest();
String beanName = getBean();
// Get the page data bean from the request:
AdminPageBean pageInfo = (AdminPageBean)request.getAttribute(beanName);
// If the page info bean is not in the request then no tab will be selected - so, it'll fail gracefully
String pageID = null;
if (pageInfo != null) {
pageID = pageInfo.getPageID();
}
// Get root items from the data model:
Collection items = AdminConsole.getItems();
if (items.size() > 0) {
JspWriter out = pageContext.getOut();
// Build up the output in a buffer (is probably faster than a bunch of out.write's)
StringBuffer buf = new StringBuffer();
buf.append("<ul>");
String body = getBodyContent().getString();
// For each root item, print out an LI
AdminConsole.Item root = AdminConsole.getRootByChildID(pageID);
for (Iterator iter=items.iterator(); iter.hasNext(); ) {
AdminConsole.Item item = (AdminConsole.Item)iter.next();
String value = body;
if (value != null) {
value = StringUtils.replace(value, "[id]", clean(item.getId()));
value = StringUtils.replace(value, "[url]", clean(item.getUrl()));
value = StringUtils.replace(value, "[name]", clean(item.getName()));
value = StringUtils.replace(value, "[description]", clean(item.getDescription()));
}
String css = getCss();
if (item.equals(root)) {
css = getCurrentcss();
}
buf.append("<li class=\"").append(css).append("\">");
buf.append(value);
buf.append("</li>");
}
buf.append("</ul>");
try {
out.write(buf.toString());
}
catch (IOException ioe) {
throw new JspException(ioe.getMessage());
}
}
return EVAL_PAGE;
}
/**
* Cleans the given string - if it's null, it's converted to a blank string. If it has ' then those are
* converted to double ' so HTML isn't screwed up.
*
* @param in the string to clean
* @return a cleaned version - not null and with escaped characters.
*/
private String clean(String in) {
return (in == null ? "" : StringUtils.replace(in, "'", "\\'"));
}
}
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>Tag Library for Jive Forums 4.0</shortname>
<uri>http://www.jivesoftware.com/</uri>
<info>Tab Library for Jive Messenger Admin Console</info>
<tag>
<name>tabs</name>
<tagclass>org.jivesoftware.admin.TabsTag</tagclass>
<bodycontent>JSP</bodycontent>
<info />
<attribute>
<name>css</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>currentcss</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>bean</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>role</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>minEdition</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<tag>
<name>sidebar</name>
<tagclass>org.jivesoftware.admin.SidebarTag</tagclass>
<bodycontent>JSP</bodycontent>
<info />
<attribute>
<name>css</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>currentcss</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>headercss</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>bean</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>role</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>minEdition</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<tag>
<name>subsidebar</name>
<tagclass>org.jivesoftware.admin.SubSidebarTag</tagclass>
<bodycontent>JSP</bodycontent>
<info />
<attribute>
<name>css</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>currentcss</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>role</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>minEdition</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment