001    /**
002     * Copyright (c) 2000-present 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.portlet.trash.util.TrashUtil;
022    import com.liferay.portlet.wiki.model.WikiNode;
023    
024    import java.util.Locale;
025    
026    import javax.portlet.PortletRequest;
027    import javax.portlet.PortletResponse;
028    
029    /**
030     * @author Eudaldo Alonso
031     */
032    public class WikiNodeTrashRenderer extends BaseTrashRenderer {
033    
034            public static final String TYPE = "wiki_node";
035    
036            public WikiNodeTrashRenderer(WikiNode node) {
037                    _node = node;
038            }
039    
040            @Override
041            public String getClassName() {
042                    return WikiNode.class.getName();
043            }
044    
045            @Override
046            public long getClassPK() {
047                    return _node.getPrimaryKey();
048            }
049    
050            @Override
051            public String getIconCssClass() {
052                    return "icon-copy";
053            }
054    
055            @Override
056            public String getIconPath(ThemeDisplay themeDisplay) {
057                    return themeDisplay.getPathThemeImages() + "/common/all_pages.png";
058            }
059    
060            @Override
061            public String getPortletId() {
062                    return PortletKeys.WIKI;
063            }
064    
065            @Override
066            public String getSummary(
067                    PortletRequest portletRequest, PortletResponse portletResponse) {
068    
069                    return HtmlUtil.stripHtml(_node.getDescription());
070            }
071    
072            @Override
073            public String getTitle(Locale locale) {
074                    if (!_node.isInTrash()) {
075                            return _node.getName();
076                    }
077    
078                    return TrashUtil.getOriginalTitle(_node.getName());
079            }
080    
081            @Override
082            public String getType() {
083                    return TYPE;
084            }
085    
086            private final WikiNode _node;
087    
088    }