コード例 #1
0
  @Override
  public void clear(Portlet portlet, boolean resetRemotePortletBag) {
    String rootPortletId = portlet.getRootPortletId();

    Map<String, InvokerPortlet> portletInstances = _pool.remove(rootPortletId);

    if (portletInstances != null) {
      InvokerPortlet rootInvokerPortletInstance = portletInstances.remove(rootPortletId);

      if (rootInvokerPortletInstance != null) {
        rootInvokerPortletInstance.destroy();
      }

      portletInstances.clear();
    }

    PortletApp portletApp = portlet.getPortletApp();

    if (resetRemotePortletBag && portletApp.isWARFile()) {
      PortletBag portletBag = PortletBagPool.remove(rootPortletId);

      if (portletBag != null) {
        portletBag.destroy();
      }
    }
  }
コード例 #2
0
  protected String getDetails() {
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    ResourceBundle resourceBundle = TagResourceBundleUtil.getResourceBundle(pageContext);

    String details = null;

    if (_alt != null) {
      details = " alt=\"" + LanguageUtil.get(resourceBundle, _alt) + "\"";
    } else if (isLabel()) {
      details = " alt=\"\"";
    } else {
      StringBundler sb = new StringBundler(5);

      sb.append(" alt=\"");
      sb.append(LanguageUtil.get(resourceBundle, getProcessedMessage()));
      sb.append("\" title=\"");
      sb.append(LanguageUtil.get(resourceBundle, getProcessedMessage()));
      sb.append("\"");

      details = sb.toString();
    }

    if (Validator.isNull(_src) || !themeDisplay.isThemeImagesFastLoad() || isAUIImage()) {

      return details;
    }

    SpriteImage spriteImage = null;
    String spriteFileName = null;
    String spriteFileURL = null;

    String imageFileName = StringUtil.replace(_src, "common/../", "");

    if (imageFileName.contains(Http.PROTOCOL_DELIMITER)) {
      String portalURL = PortalUtil.getPortalURL(request);

      if (imageFileName.startsWith(portalURL)) {
        imageFileName = imageFileName.substring(portalURL.length());
      } else {
        URL imageURL = null;

        try {
          imageURL = new URL(imageFileName);

          imageFileName = imageURL.getPath();
        } catch (MalformedURLException murle) {
        }
      }
    }

    Theme theme = themeDisplay.getTheme();

    String contextPath = theme.getContextPath();

    String imagesPath = contextPath.concat(theme.getImagesPath());

    if (imageFileName.startsWith(imagesPath)) {
      spriteImage = theme.getSpriteImage(imageFileName);

      if (spriteImage != null) {
        spriteFileName = spriteImage.getSpriteFileName();

        if (BrowserSnifferUtil.isIe(request) && (BrowserSnifferUtil.getMajorVersion(request) < 7)) {

          spriteFileName = StringUtil.replace(spriteFileName, ".png", ".gif");
        }

        String cdnBaseURL = themeDisplay.getCDNBaseURL();

        spriteFileURL = cdnBaseURL.concat(spriteFileName);
      }
    }

    if (spriteImage == null) {
      Portlet portlet = (Portlet) request.getAttribute("liferay-portlet:icon_portlet:portlet");

      if (portlet == null) {
        portlet = (Portlet) request.getAttribute(WebKeys.RENDER_PORTLET);
      }

      if (portlet != null) {
        PortletApp portletApp = portlet.getPortletApp();

        spriteImage = portletApp.getSpriteImage(imageFileName);

        if (spriteImage != null) {
          spriteFileName = spriteImage.getSpriteFileName();

          if (BrowserSnifferUtil.isIe(request)
              && (BrowserSnifferUtil.getMajorVersion(request) < 7)) {

            spriteFileName = StringUtil.replace(spriteFileName, ".png", ".gif");
          }

          String cdnBaseURL = themeDisplay.getCDNBaseURL();

          spriteFileURL = cdnBaseURL.concat(spriteFileName);
        }
      }
    }

    if (spriteImage != null) {
      String themeImagesPath = themeDisplay.getPathThemeImages();

      _src = themeImagesPath.concat("/spacer.png");

      StringBundler sb = new StringBundler(10);

      sb.append(details);
      sb.append(" style=\"background-image: url('");
      sb.append(spriteFileURL);
      sb.append("'); background-position: 50% -");
      sb.append(spriteImage.getOffset());
      sb.append("px; background-repeat: no-repeat; height: ");
      sb.append(spriteImage.getHeight());
      sb.append("px; width: ");
      sb.append(spriteImage.getWidth());
      sb.append("px;\"");

      details = sb.toString();
    }

    return details;
  }