Search in sources :

Example 1 with FolderType

use of it.vige.rubia.theme.FolderType in project rubia-forums by flashboss.

the class ThemeHelper method getFolderType.

/**
 * @param topic
 *            the topic to find
 *
 * @return the folder type
 */
public String getFolderType(Topic topic) {
    // Getting ResourceBundle with current Locale
    FacesContext ctx = getCurrentInstance();
    UIViewRoot uiRoot = ctx.getViewRoot();
    Locale locale = uiRoot.getLocale();
    ClassLoader ldr = currentThread().getContextClassLoader();
    ResourceBundle bundle = getBundle("ResourceJSF", locale, ldr);
    String topicType = null;
    int topicStatus = topic.getStatus();
    FolderType folderType = theme.getFolderType(topic.getType(), topicStatus, topic.getReplies() >= hotThreshold);
    try {
        if (topicStatus != Constants.TOPIC_MOVED) {
            try {
                topicType = bundle.getString(folderType.type);
            } catch (MissingResourceException e) {
                topicType = "";
            }
        } else {
            topicType = bundle.getString("Topic_Moved");
        }
    } catch (Exception e) {
        return "";
    }
    return topicType;
}
Also used : JSFUtil.getDefaultLocale(it.vige.rubia.ui.JSFUtil.getDefaultLocale) JSFUtil.getSelectedLocale(it.vige.rubia.ui.JSFUtil.getSelectedLocale) Locale(java.util.Locale) FacesContext(javax.faces.context.FacesContext) MissingResourceException(java.util.MissingResourceException) ResourceBundle(java.util.ResourceBundle) UIViewRoot(javax.faces.component.UIViewRoot) MissingResourceException(java.util.MissingResourceException) FolderType(it.vige.rubia.theme.FolderType)

Example 2 with FolderType

use of it.vige.rubia.theme.FolderType in project rubia-forums by flashboss.

the class ThemeHelper method getFolderTypeURL.

/**
 * @param topic
 *            the topic to find
 * @param isAnonymous
 *            true if you want search the guest folder url
 *
 * @return the folder type url
 */
public String getFolderTypeURL(Topic topic, boolean isAnonymous) {
    String folderTypeURL = getURL("resourceFolderURL");
    FolderType folderType = theme.getFolderType(topic.getType(), topic.getStatus(), topic.getReplies() >= hotThreshold);
    if (!isAnonymous) {
        Date lastPostDate = topic.getLastPostDate();
        Date lastLoginDate = getUserLastLoginDate(userModule, userProfileModule);
        if (lastPostDate == null || lastLoginDate == null || lastPostDate.compareTo(lastLoginDate) <= 0) {
            folderTypeURL = folderType.getFolder();
        } else {
            folderTypeURL = folderType.getFolderNew();
        }
    } else {
        folderTypeURL = folderType.getFolder();
    }
    return folderTypeURL;
}
Also used : Date(java.util.Date) JSFUtil.getUserLastLoginDate(it.vige.rubia.ui.JSFUtil.getUserLastLoginDate) FolderType(it.vige.rubia.theme.FolderType)

Aggregations

FolderType (it.vige.rubia.theme.FolderType)2 JSFUtil.getDefaultLocale (it.vige.rubia.ui.JSFUtil.getDefaultLocale)1 JSFUtil.getSelectedLocale (it.vige.rubia.ui.JSFUtil.getSelectedLocale)1 JSFUtil.getUserLastLoginDate (it.vige.rubia.ui.JSFUtil.getUserLastLoginDate)1 Date (java.util.Date)1 Locale (java.util.Locale)1 MissingResourceException (java.util.MissingResourceException)1 ResourceBundle (java.util.ResourceBundle)1 UIViewRoot (javax.faces.component.UIViewRoot)1 FacesContext (javax.faces.context.FacesContext)1