<%@ taglib uri="/WEB-INF/jspwiki.tld" prefix="wiki" %> <%@ page import="com.ecyrd.jspwiki.*" %> <%@ page import="com.ecyrd.jspwiki.attachment.*" %> <%@ page import="com.ecyrd.jspwiki.auth.*" %> <%@ page import="com.ecyrd.jspwiki.auth.permissions.*" %> <%@ page import="java.security.Permission" %> <%@ page import="javax.servlet.jsp.jstl.fmt.*" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%! // FIXME: this should better be something like a wiki:Pagination TLD tag // FIXME: how to i18n // // 0 20 40 60 // 0 20 40 60 80 next // previous 20 40 *60* 80 100 next // previous 40 60 80 100 120 /* makePagination : return html string with pagination links * (eg: previous 1 2 3 next) * startitem : cursor * itemcount : total number of items * pagesize : number of items per page * maxpages : number of pages directly accessible via a pagination link * linkAttr : html attributes of the generated links: use '%s' to replace with item offset */ String wiki_Pagination( int startitem, int itemcount, int pagesize, int maxpages, String linkAttr, PageContext pageContext ) { if( itemcount <= pagesize ) return null; int maxs = pagesize * maxpages; int mids = pagesize * ( maxpages / 2 ); StringBuffer pagination = new StringBuffer(); pagination.append( "" ); pagination.append( LocaleSupport.getLocalizedMessage(pageContext, "info.pagination.total", new Object[]{new Integer(itemcount)} ) ); pagination.append( "" ); return pagination.toString(); } // linkAttr : use '%s' to replace with cursor offset // eg : // linkAttr = "href='#' title='%s' onclick='$(start).value= %s; updateSearchResult();'"; void appendLink( StringBuffer sb, String linkAttr, int linkFrom, int pagesize, String linkText, PageContext pageContext ) { String title = LocaleSupport.getLocalizedMessage(pageContext, "info.pagination.showall"); //if( linkFrom > -1 ) title = "Show page from " + (linkFrom+1) + " to "+ (linkFrom+pagesize) ; if( linkFrom > -1 ) title = LocaleSupport.getLocalizedMessage(pageContext, "info.pagination.show", new Object[]{new Integer(linkFrom+1), new Integer(linkFrom+pagesize) } ); sb.append( "" + linkText + "  " ); } ; %> <% int pagesize = 20; //default #revisions shown per page int maxpages = 9; //max #paginations links -- choose odd figure int itemcount = 0; //number of page versions WikiContext wikiContext = WikiContext.findContext(pageContext); WikiPage wikiPage = wikiContext.getPage(); int attCount = wikiContext.getEngine().getAttachmentManager() .listAttachments( wikiContext.getPage() ).size(); String attTitle = LocaleSupport.getLocalizedMessage(pageContext, "attach.tab"); if( attCount != 0 ) attTitle += " (" + attCount + ")"; String creationDate =""; String creationAuthor =""; //FIXME -- seems not to work correctly for attachments !! WikiPage firstPage = wikiContext.getEngine().getPage( wikiPage.getName(), 1 ); if( firstPage != null ) { creationAuthor = firstPage.getAuthor(); } try { itemcount = wikiPage.getVersion(); /* highest version */ } catch( Exception e ) { /* dont care */ } int startitem = itemcount; String parm_start = (String)request.getParameter( "start" ); if( parm_start != null ) startitem = Integer.parseInt( parm_start ) ; if( startitem > itemcount ) startitem = itemcount; if( startitem < -1 ) startitem = 0; String parm_pagesize = (String)request.getParameter( "pagesize" ); if( parm_pagesize != null ) pagesize = Integer.parseInt( parm_pagesize ) ; if( startitem > -1 ) startitem = ( (startitem/pagesize) * pagesize ); String linkAttr = "href='#' onclick='location.href= $(\"moreinfo\").href + \"&start=%s\"; ' "; String pagination = wiki_Pagination(startitem, itemcount, pagesize, maxpages, linkAttr, pageContext); %> <%--FIXME --%> <%-- part 1 : normal wiki pages --%> <%-- --%> " accesskey="i" >

1 [RSS]

<%--<%= creationDate %>--%> <%= creationAuthor %>

  

') && Wiki.submitOnce(this) );">


<%-- if( itemcount > 1 ) { --%> <%= (pagination == null) ? "" : pagination %>
<% if( ( startitem == -1 ) || ( ( currentPage.getVersion() >= startitem ) && ( currentPage.getVersion() < startitem + pagesize ) ) ) { %> <% } %>
<%-- Kb--%> | <% String changeNote = (String)currentPage.getAttribute( WikiPage.CHANGENOTE ); changeNote = (changeNote != null) ? TextUtil.replaceEntities( changeNote ) : "" ; %> <%= changeNote %>
<%= (pagination == null) ? "" : pagination %> <%-- } /* itemcount > 1 */ --%>
">
<%-- end of .tabs --%>
<%-- part 2 : attachments --%> <% int MAXATTACHNAMELENGTH = 30; String progressId = wikiContext.getEngine().getProgressManager().getNewProgressIdentifier(); %> <%-- --%> " accesskey="i" >

<%-- Do NOT change the order of wikiname and content, otherwise the servlet won't find its parts. --%>

') && Wiki.submitOnce(this) );" >
<%-- FIXME why not add pagination here - no need for large amounts of attach versions on one page --%>

<%----%> <%-- --%> <%-- --%> <% String name = att.getName(); //att.getFileName(); int dot = name.lastIndexOf("."); String attachtype = ( dot != -1 ) ? name.substring(dot+1) : ""; String sname = name; if( sname.length() > MAXATTACHNAMELENGTH ) sname = sname.substring(0,MAXATTACHNAMELENGTH) + "..."; %> <%----%> <%--FIXME classs parameter throws java exception --%> <%-- // FIXME: This needs to be added, once we figure out what is going on. --%> <%-- --%>
<%= attachtype %>
<%= sname %>   <% String changeNote = (String)att.getAttribute(WikiPage.CHANGENOTE); if( changeNote != null ) { %><%=changeNote%><% } %>
<%-- end of .tabs --%>