001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.wiki.asset;
016    
017    import com.liferay.portal.kernel.trash.BaseTrashRenderer;
018    import com.liferay.portal.kernel.util.HtmlUtil;
019    import com.liferay.portal.theme.ThemeDisplay;
020    import com.liferay.portal.util.PortletKeys;
021    import com.liferay.portal.util.WebKeys;
022    import com.liferay.portlet.trash.util.TrashUtil;
023    import com.liferay.portlet.wiki.model.WikiNode;
024    
025    import java.util.Locale;
026    
027    import javax.portlet.RenderRequest;
028    import javax.portlet.RenderResponse;
029    
030    /**
031     * @author Eudaldo Alonso
032     */
033    public class WikiNodeTrashRenderer extends BaseTrashRenderer {
034    
035            public static final String TYPE = "wiki_node";
036    
037            public WikiNodeTrashRenderer(WikiNode node) {
038                    _node = node;
039            }
040    
041            @Override
042            public String getIconPath(ThemeDisplay themeDisplay) {
043                    return themeDisplay.getPathThemeImages() + "/common/all_pages.png";
044            }
045    
046            public String getPortletId() {
047                    return PortletKeys.WIKI;
048            }
049    
050            public String getSummary(Locale locale) {
051                    return HtmlUtil.stripHtml(_node.getDescription());
052            }
053    
054            public String getTitle(Locale locale) {
055                    if (!_node.isInTrash()) {
056                            return _node.getName();
057                    }
058    
059                    return TrashUtil.stripTrashNamespace(_node.getName());
060            }
061    
062            public String getType() {
063                    return TYPE;
064            }
065    
066            public String render(
067                            RenderRequest renderRequest, RenderResponse renderResponse,
068                            String template)
069                    throws Exception {
070    
071                    renderRequest.setAttribute(WebKeys.WIKI_NODE, _node);
072    
073                    return "/html/portlet/wiki/trash/node.jsp";
074            }
075    
076            private WikiNode _node;
077    
078    }