Example usage for com.liferay.portal.kernel.util PortalUtil getStaticResourceURL

List of usage examples for com.liferay.portal.kernel.util PortalUtil getStaticResourceURL

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util PortalUtil getStaticResourceURL.

Prototype

public static String getStaticResourceURL(HttpServletRequest httpServletRequest, String uri) 

Source Link

Usage

From source file:com.liferay.frontend.editor.ckeditor.web.internal.editor.configuration.BaseCKEditorConfigContributor.java

License:Open Source License

@Override
public void populateConfigJSONObject(JSONObject jsonObject, Map<String, Object> inputEditorTaglibAttributes,
        ThemeDisplay themeDisplay, RequestBackedPortletURLFactory requestBackedPortletURLFactory) {

    jsonObject.put("allowedContent", Boolean.TRUE);

    String cssClasses = GetterUtil
            .getString(inputEditorTaglibAttributes.get("liferay-ui:input-editor:cssClasses"));

    jsonObject.put("bodyClass", "html-editor " + HtmlUtil.escape(cssClasses));

    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();

    jsonArray.put(HtmlUtil.escape(PortalUtil.getStaticResourceURL(themeDisplay.getRequest(),
            themeDisplay.getPathThemeCss() + "/clay.css")));
    jsonArray.put(HtmlUtil.escape(PortalUtil.getStaticResourceURL(themeDisplay.getRequest(),
            themeDisplay.getPathThemeCss() + "/main.css")));

    jsonObject.put("contentsCss", jsonArray);

    String contentsLanguageDir = getContentsLanguageDir(inputEditorTaglibAttributes);

    jsonObject.put("contentsLangDirection", HtmlUtil.escapeJS(contentsLanguageDir));

    String contentsLanguageId = getContentsLanguageId(inputEditorTaglibAttributes);

    contentsLanguageId = contentsLanguageId.replace("iw", "he");
    contentsLanguageId = contentsLanguageId.replace("_", "-");

    jsonObject.put("contentsLanguage", contentsLanguageId);

    jsonObject.put("height", 265);

    String languageId = getLanguageId(themeDisplay);

    languageId = languageId.replace("iw", "he");
    languageId = languageId.replace("_", "-");

    jsonObject.put("language", languageId);

    boolean resizable = GetterUtil
            .getBoolean((String) inputEditorTaglibAttributes.get("liferay-ui:input-editor:resizable"));

    if (resizable) {
        jsonObject.put("resize_dir", "vertical");
    }//from   w w  w  .  ja v a 2s .  c o m

    jsonObject.put("resize_enabled", resizable);
}

From source file:com.liferay.frontend.editor.tinymce.web.internal.editor.configuration.BaseTinyMCEEditorConfigContributor.java

License:Open Source License

@Override
public void populateConfigJSONObject(JSONObject jsonObject, Map<String, Object> inputEditorTaglibAttributes,
        ThemeDisplay themeDisplay, RequestBackedPortletURLFactory requestBackedPortletURLFactory) {

    StringBundler sb = new StringBundler(3);

    sb.append(HtmlUtil.escape(PortalUtil.getStaticResourceURL(themeDisplay.getRequest(),
            themeDisplay.getPathThemeCss() + "/clay.css")));
    sb.append(StringPool.COMMA);//from ww  w  .  j a  v a2  s. c  o  m
    sb.append(HtmlUtil.escape(PortalUtil.getStaticResourceURL(themeDisplay.getRequest(),
            themeDisplay.getPathThemeCss() + "/main.css")));

    jsonObject.put("content_css", sb.toString());

    jsonObject.put("convert_urls", Boolean.FALSE);
    jsonObject.put("extended_valid_elements", _EXTENDED_VALID_ELEMENTS);

    ItemSelector itemSelector = getItemSelector();

    String filebrowserImageBrowseUrl = jsonObject.getString("filebrowserImageBrowseUrl");

    String itemSelectedEventName = itemSelector.getItemSelectedEventName(filebrowserImageBrowseUrl);

    List<ItemSelectorCriterion> itemSelectorCriteria = itemSelector
            .getItemSelectorCriteria(filebrowserImageBrowseUrl);

    ImageItemSelectorCriterion imageItemSelectorCriterion = new ImageItemSelectorCriterion();

    imageItemSelectorCriterion.setDesiredItemSelectorReturnTypes(
            Arrays.<ItemSelectorReturnType>asList(new URLItemSelectorReturnType()));

    itemSelectorCriteria.add(imageItemSelectorCriterion);

    PortletURL itemSelectorURL = itemSelector.getItemSelectorURL(requestBackedPortletURLFactory,
            itemSelectedEventName,
            itemSelectorCriteria.toArray(new ItemSelectorCriterion[itemSelectorCriteria.size()]));

    jsonObject.put("filebrowserImageBrowseUrl", itemSelectorURL.toString());

    jsonObject.put("invalid_elements", "script");

    String contentsLanguageId = (String) inputEditorTaglibAttributes
            .get("liferay-ui:input-editor:contentsLanguageId");

    jsonObject.put("language", getTinyMCELanguage(contentsLanguageId));

    jsonObject.put("menubar", Boolean.FALSE);
    jsonObject.put("mode", "textareas");
    jsonObject.put("relative_urls", Boolean.FALSE);
    jsonObject.put("remove_script_host", Boolean.FALSE);

    String namespace = GetterUtil
            .getString(inputEditorTaglibAttributes.get("liferay-ui:input-editor:namespace"));

    String name = GetterUtil.getString(inputEditorTaglibAttributes.get("liferay-ui:input-editor:name"));

    jsonObject.put("selector", "#" + namespace + name);

    jsonObject.put("toolbar", "bold italic underline | alignleft aligncenter alignright | " + "preview print");
    jsonObject.put("toolbar_items_size", "small");
}