View Javadoc

1   /*
2    * Copyright 2004-2006 the Seasar Foundation and the Others.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
13   * either express or implied. See the License for the specific language
14   * governing permissions and limitations under the License.
15   */
16  package org.seasar.tuigwaa.plugin.basic;
17  
18  import org.seasar.tuigwaa.cms.core.CmsRequest;
19  import org.seasar.tuigwaa.cms.core.CmsResponse;
20  import org.seasar.tuigwaa.cms.core.Resource;
21  import org.seasar.tuigwaa.cms.core.wiki.WikiContext;
22  import org.seasar.tuigwaa.plugin.AbstractPlugin;
23  import org.seasar.tuigwaa.plugin.PluginException;
24  import org.seasar.tuigwaa.plugin.PluginRequest;
25  
26  import com.isenshi.util.HtmlBuffer;
27  
28  /***
29   * @author someda
30   */
31  public class PagePlugin extends AbstractPlugin {
32  
33  	public String doHTMLView(CmsRequest request, CmsResponse response,
34  			PluginRequest prequest) throws PluginException {
35  
36  		String name = prequest.getName();
37  		Resource resource = request.getPage().getResource();
38  
39  		HtmlBuffer buf = new HtmlBuffer();
40  
41  		if (name.equals("page")) {
42  			buf.appendBody(resource.getPageName());
43  		} else if (name.equals("fpage")) {
44  			buf.appendBody(resource.getPath());
45  		} else if ("pageinfo".equals(name)) {
46  			String mainPagePath = request.getMainPagePath();
47  			WikiContext ctx = getConfiguration().getWikiContext();
48  			resource = ctx.getResource(request, mainPagePath);
49  
50  			if (resource != null) { //resource is NULL, when preview.
51  				buf.appendStartTag("div");
52  				buf.appendAttribute("id", "pageinfo");
53  				buf.appendBody(getMessage("pageinfo.version") + ":"
54  						+ resource.getVersion());
55  				buf.appendBr();
56  				buf.appendBody(getMessage("pageinfo.creation.date") + ":"
57  						+ resource.getCreationDate());
58  				buf.appendBr();
59  				buf.appendBody(getMessage("pageinfo.creation.user") + ":"
60  						+ resource.getCreationUser());
61  				buf.appendBr();
62  				buf.appendBody(getMessage("pageinfo.update.date") + ":"
63  						+ resource.getModificationDate());
64  				buf.appendBr();
65  				buf.appendBody(getMessage("pageinfo.update.user") + ":"
66  						+ resource.getModificationUser());
67  				buf.appendBr();
68  				buf.endTag();
69  			}
70  		}
71  		return buf.toString();
72  	}
73  
74  }