001    /**
002     * Copyright (c) 2000-2013 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    /**
027     * @author Eudaldo Alonso
028     */
029    public class WikiNodeTrashRenderer extends BaseTrashRenderer {
030    
031            public static final String TYPE = "wiki_node";
032    
033            public WikiNodeTrashRenderer(WikiNode node) {
034                    _node = node;
035            }
036    
037            @Override
038            public String getClassName() {
039                    return WikiNode.class.getName();
040            }
041    
042            @Override
043            public long getClassPK() {
044                    return _node.getPrimaryKey();
045            }
046    
047            @Override
048            public String getIconPath(ThemeDisplay themeDisplay) {
049                    return themeDisplay.getPathThemeImages() + "/common/all_pages.png";
050            }
051    
052            @Override
053            public String getPortletId() {
054                    return PortletKeys.WIKI;
055            }
056    
057            @Override
058            public String getSummary(Locale locale) {
059                    return HtmlUtil.stripHtml(_node.getDescription());
060            }
061    
062            @Override
063            public String getTitle(Locale locale) {
064                    if (!_node.isInTrash()) {
065                            return _node.getName();
066                    }
067    
068                    return TrashUtil.getOriginalTitle(_node.getName());
069            }
070    
071            @Override
072            public String getType() {
073                    return TYPE;
074            }
075    
076            private WikiNode _node;
077    
078    }