01: /*
02: JSPWiki - a JSP-based WikiWiki clone.
03:
04: Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
05:
06: This program is free software; you can redistribute it and/or modify
07: it under the terms of the GNU Lesser General Public License as published by
08: the Free Software Foundation; either version 2.1 of the License, or
09: (at your option) any later version.
10:
11: This program is distributed in the hope that it will be useful,
12: but WITHOUT ANY WARRANTY; without even the implied warranty of
13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: GNU Lesser General Public License for more details.
15:
16: You should have received a copy of the GNU Lesser General Public License
17: along with this program; if not, write to the Free Software
18: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19: */
20: package com.ecyrd.jspwiki.plugin;
21:
22: import com.ecyrd.jspwiki.*;
23: import java.util.*;
24:
25: /**
26: * Plugin for displaying pages that are not linked to in other pages.
27: * Uses the ReferenceManager.
28: * <p>
29: * Parameters: none. <BR>
30: * From AbstractReferralPlugin:<BR>
31: * separator: How to separate generated links; default is a wikitext line break,
32: * producing a vertical list.<BR>
33: * maxwidth: maximum width, in chars, of generated links.
34: *
35: * @author Janne Jalkanen
36: */
37: public class UnusedPagesPlugin extends AbstractReferralPlugin {
38: /**
39: * If set to "true", attachments are excluded from display. Value is {@value}.
40: */
41: public static final String PARAM_EXCLUDEATTS = "excludeattachments";
42:
43: /**
44: * {@inheritDoc}
45: */
46: public String execute(WikiContext context, Map params)
47: throws PluginException {
48: ReferenceManager refmgr = context.getEngine()
49: .getReferenceManager();
50: Collection links = refmgr.findUnreferenced();
51: //
52: // filter out attachments if "excludeattachments" was requested:
53: //
54: String prop = (String) params.get(PARAM_EXCLUDEATTS);
55: if (TextUtil.isPositive(prop)) {
56: // remove links to attachments (recognizable by a slash in it)
57: // FIXME: In 3.0, this assumption is going to fail. FIXME3.0
58: Iterator iterator = links.iterator();
59: while (iterator.hasNext()) {
60: String link = (String) iterator.next();
61: if (link.indexOf("/") != -1) {
62: iterator.remove();
63: }
64: }
65: }
66:
67: super .initialize(context, params);
68:
69: TreeSet sortedSet = new TreeSet();
70:
71: sortedSet.addAll(links);
72:
73: filterCollection(links);
74: String wikitext = wikitizeCollection(sortedSet, m_separator,
75: ALL_ITEMS);
76:
77: return makeHTML(context, wikitext);
78: }
79:
80: }
|