Example usage for com.liferay.portal.kernel.theme ThemeDisplay getLanguageId

List of usage examples for com.liferay.portal.kernel.theme ThemeDisplay getLanguageId

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.theme ThemeDisplay getLanguageId.

Prototype

public String getLanguageId() 

Source Link

Document

Returns the current language's code.

Usage

From source file:com.liferay.journal.web.internal.display.context.JournalDisplayContext.java

License:Open Source License

public JournalArticleDisplay getArticleDisplay() throws Exception {
    if (_articleDisplay != null) {
        return _articleDisplay;
    }/*from  w  ww. ja va 2  s .c o m*/

    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    int page = ParamUtil.getInteger(_liferayPortletRequest, "page");

    _articleDisplay = JournalArticleLocalServiceUtil.getArticleDisplay(getArticle(), null, null,
            themeDisplay.getLanguageId(), page,
            new PortletRequestModel(_liferayPortletRequest, _liferayPortletResponse), themeDisplay);

    return _articleDisplay;
}

From source file:com.liferay.portlet.configuration.web.internal.portlet.PortletConfigurationPortlet.java

License:Open Source License

protected String getPortletTitle(PortletRequest portletRequest, Portlet portlet,
        PortletPreferences portletPreferences) {

    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    String portletTitle = PortletConfigurationUtil.getPortletTitle(portletPreferences,
            themeDisplay.getLanguageId());

    if (Validator.isNull(portletTitle)) {
        ServletContext servletContext = (ServletContext) portletRequest.getAttribute(WebKeys.CTX);

        portletTitle = _portal.getPortletTitle(portlet, servletContext, themeDisplay.getLocale());
    }//  w  w w  .  j a  v a  2  s. c om

    return portletTitle;
}

From source file:com.liferay.portlet.configuration.web.internal.portlet.PortletConfigurationPortlet.java

License:Open Source License

protected void updateScope(ActionRequest actionRequest, Portlet portlet) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    String oldScopeName = getOldScopeName(actionRequest, portlet);

    PortletPreferences portletPreferences = actionRequest.getPreferences();

    String[] scopes = StringUtil.split(ParamUtil.getString(actionRequest, "scope"));

    String scopeType = scopes[0];

    portletPreferences.setValue("lfrScopeType", scopeType);

    String scopeLayoutUuid = StringPool.BLANK;

    if ((scopes.length > 1) && scopeType.equals("layout")) {
        scopeLayoutUuid = scopes[1];//from  ww  w. ja  v a 2s .co  m
    }

    portletPreferences.setValue("lfrScopeLayoutUuid", scopeLayoutUuid);

    String portletTitle = getPortletTitle(actionRequest, portlet, portletPreferences);

    Tuple newScopeTuple = getNewScope(actionRequest);

    String newScopeName = (String) newScopeTuple.getObject(1);

    String newPortletTitle = _portal.getNewPortletTitle(portletTitle, oldScopeName, newScopeName);

    if (!newPortletTitle.equals(portletTitle)) {
        portletPreferences.setValue("portletSetupTitle_" + themeDisplay.getLanguageId(), newPortletTitle);
        portletPreferences.setValue("portletSetupUseCustomTitle", Boolean.TRUE.toString());
    }

    portletPreferences.store();
}

From source file:com.liferay.users.admin.web.internal.theme.contributor.UsersTemplateContextContributor.java

License:Open Source License

@Override
public void prepare(Map<String, Object> contextObjects, HttpServletRequest request) {

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    User user = themeDisplay.getUser();//from  w ww .ja  v a 2s .co m

    contextObjects.put("is_default_user", user.isDefaultUser());

    try {
        Contact contact = user.getContact();

        contextObjects.put("is_female", !contact.isMale());
        contextObjects.put("is_male", contact.isMale());
        contextObjects.put("user_birthday", contact.getBirthday());
    } catch (PortalException pe) {
        _log.error(pe, pe);
    }

    contextObjects.put("is_setup_complete", user.isSetupComplete());
    contextObjects.put("language", themeDisplay.getLanguageId());
    contextObjects.put("language_id", user.getLanguageId());
    contextObjects.put("user_comments", user.getComments());
    contextObjects.put("user_email_address", user.getEmailAddress());
    contextObjects.put("user_first_name", user.getFirstName());
    contextObjects.put("user_greeting", HtmlUtil.escape(user.getGreeting()));
    contextObjects.put("user_id", user.getUserId());
    contextObjects.put("user_initialized", true);
    contextObjects.put("user_last_login_ip", user.getLastLoginIP());
    contextObjects.put("user_last_name", user.getLastName());
    contextObjects.put("user_login_ip", user.getLoginIP());
    contextObjects.put("user_middle_name", user.getMiddleName());
    contextObjects.put("user_name", user.getFullName());

    Group group = themeDisplay.getSiteGroup();

    if (group.isUser()) {
        try {
            User user2 = _userLocalService.getUserById(group.getClassPK());

            contextObjects.put("user2", user2);
        } catch (PortalException pe) {
            _log.error(pe, pe);
        }
    }

    contextObjects.put("w3c_language_id", LocaleUtil.toW3cLanguageId(themeDisplay.getLanguageId()));
}