4d3158d2fa6558a524f2032fbd8cb8e4557bf68b
[phpeclipse.git] / archive / org.plog4u.wiki / src / org / plog4u / wiki / macro / QuoteMacro.java
1 /*
2  * This file is part of "SnipSnap Radeox Rendering Engine".
3  *
4  * Copyright (c) 2002 Stephan J. Schmidt, Matthias L. Jugel
5  * All Rights Reserved.
6  *
7  * Please visit http://radeox.org/ for updates and contact.
8  *
9  * --LICENSE NOTICE--
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with this library; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23  * --LICENSE NOTICE--
24  */
25
26 package org.plog4u.wiki.macro;
27
28 import java.io.IOException;
29 import java.io.Writer;
30
31
32 //import org.apache.commons.logging.Log;
33 //import org.apache.commons.logging.LogFactory;
34 import org.plog4u.wiki.filter.ICachableMacro;
35 import org.plog4u.wiki.filter.INoParserBodyFilterMacro;
36 import org.radeox.macro.LocalePreserved;
37 import org.radeox.macro.parameter.MacroParameter;
38
39 /*
40  * Macro to display quotations from other sources. The
41  * output is wrapped usually in <blockquote> to look like
42  * a quotation.
43  *
44  * @author stephan
45  * @team sonicteam
46  */
47
48 public class QuoteMacro extends LocalePreserved implements INoParserBodyFilterMacro, ICachableMacro {
49 //  private static Log log = LogFactory.getLog(QuoteMacro.class);
50
51   private String[] paramDescription =
52       {"?1: source",
53        "?2: displayed description, default is Source"};
54
55   public String[] getParamDescription() {
56     return paramDescription;
57   }
58
59   public QuoteMacro() {
60   }
61
62   public String getLocaleKey() {
63     return "macro.quote";
64   }
65   public void execute(Writer writer, MacroParameter params)
66       throws IllegalArgumentException, IOException {
67
68     writer.write("<blockquote>");
69     writer.write(params.getContent());
70     String source = "Source"; // i18n
71     if (params.getLength() == 2) {
72       source = params.get(1);
73     }
74     // if more than one was present, we
75     // should show a description for the link
76     if (params.getLength() > 0) {
77       writer.write("<a href=\""+params.get(0)+"\">");
78       writer.write(source);
79       writer.write("</a>");
80     }
81     writer.write("</blockquote>");
82     return;
83   }
84 }