forked from liferay/liferay-portal
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LPS-94408 Uses vertical card on configuration
- Loading branch information
Showing
3 changed files
with
85 additions
and
21 deletions.
There are no files selected for viewing
81 changes: 81 additions & 0 deletions
81
...eray/journal/content/web/internal/servlet/taglib/clay/JournalDDMTemplateVerticalCard.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/** | ||
* Copyright (c) 2000-present Liferay, Inc. All rights reserved. | ||
* | ||
* This library is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU Lesser General Public License as published by the Free | ||
* Software Foundation; either version 2.1 of the License, or (at your option) | ||
* any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | ||
* details. | ||
*/ | ||
|
||
package com.liferay.journal.content.web.internal.servlet.taglib.clay; | ||
|
||
import com.liferay.dynamic.data.mapping.model.DDMTemplate; | ||
import com.liferay.frontend.taglib.clay.servlet.taglib.soy.VerticalCard; | ||
import com.liferay.portal.kernel.language.LanguageUtil; | ||
import com.liferay.portal.kernel.theme.ThemeDisplay; | ||
import com.liferay.portal.kernel.util.HtmlUtil; | ||
import com.liferay.portal.kernel.util.WebKeys; | ||
|
||
import java.util.Date; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
|
||
/** | ||
* @author Eudaldo Alonso | ||
*/ | ||
public class JournalDDMTemplateVerticalCard implements VerticalCard { | ||
|
||
public JournalDDMTemplateVerticalCard( | ||
DDMTemplate ddmTemplate, HttpServletRequest request) { | ||
|
||
_ddmTemplate = ddmTemplate; | ||
_request = request; | ||
} | ||
|
||
@Override | ||
public String getIcon() { | ||
return "page-template"; | ||
} | ||
|
||
@Override | ||
public String getImageSrc() { | ||
ThemeDisplay themeDisplay = (ThemeDisplay)_request.getAttribute( | ||
WebKeys.THEME_DISPLAY); | ||
|
||
return HtmlUtil.escapeAttribute( | ||
_ddmTemplate.getTemplateImageURL(themeDisplay)); | ||
} | ||
|
||
@Override | ||
public String getSubtitle() { | ||
Date createDate = _ddmTemplate.getModifiedDate(); | ||
|
||
String modifiedDateDescription = LanguageUtil.getTimeDescription( | ||
_request, System.currentTimeMillis() - createDate.getTime(), true); | ||
|
||
return LanguageUtil.format( | ||
_request, "modified-x-ago", modifiedDateDescription); | ||
} | ||
|
||
@Override | ||
public String getTitle() { | ||
ThemeDisplay themeDisplay = (ThemeDisplay)_request.getAttribute( | ||
WebKeys.THEME_DISPLAY); | ||
|
||
return HtmlUtil.escape(_ddmTemplate.getName(themeDisplay.getLocale())); | ||
} | ||
|
||
@Override | ||
public boolean isSelectable() { | ||
return false; | ||
} | ||
|
||
private final DDMTemplate _ddmTemplate; | ||
private final HttpServletRequest _request; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters