private void _getFolders(CommandArgument commandArgument, Document document, Node rootNode)
      throws Exception {

    Element foldersElement = document.createElement("Folders");

    rootNode.appendChild(foldersElement);

    if (commandArgument.getCurrentFolder().equals(StringPool.SLASH)) {
      getRootFolders(commandArgument, document, foldersElement);
    } else {
      Group group = commandArgument.getCurrentGroup();

      List<Layout> layouts =
          LayoutLocalServiceUtil.getLayouts(
              group.getGroupId(), false, LayoutConstants.DEFAULT_PARENT_LAYOUT_ID);

      if (("/" + commandArgument.getCurrentGroupName() + "/")
          .equals(commandArgument.getCurrentFolder())) {

        for (Layout layout : layouts) {
          Element folderElement = document.createElement("Folder");

          foldersElement.appendChild(folderElement);

          folderElement.setAttribute("name", "~" + _getLayoutName(layout).replace('/', '>'));
        }
      } else {
        String layoutName = _getLayoutName(commandArgument.getCurrentFolder());

        Layout layout = null;

        for (int i = 0; i < layouts.size(); i++) {
          layout = _getLayout(layoutName, layouts.get(i));

          if (layout != null) {
            break;
          }
        }

        if (layout != null) {
          List<Layout> layoutChildren = layout.getChildren();

          for (int i = 0; i < layoutChildren.size(); i++) {
            layout = layoutChildren.get(i);

            Element folderElement = document.createElement("Folder");

            foldersElement.appendChild(folderElement);

            folderElement.setAttribute("name", "~" + _getLayoutName(layout).replace('/', '>'));
          }
        }
      }
    }
  }
Example #2
0
  protected void visitLayouts(Element element, List<Layout> layouts, ThemeDisplay themeDisplay)
      throws PortalException, SystemException {

    for (Layout layout : layouts) {
      visitLayout(element, layout, themeDisplay);

      visitArticles(element, layout, themeDisplay);

      visitLayouts(element, layout.getChildren(), themeDisplay);
    }
  }
  public List<Layout> getAllChildren() throws SystemException {
    List<Layout> layouts = new ArrayList<Layout>();

    Iterator<Layout> itr = getChildren().iterator();

    while (itr.hasNext()) {
      Layout layout = itr.next();

      layouts.add(layout);
      layouts.addAll(layout.getChildren());
    }

    return layouts;
  }
  private Layout _getLayout(String layoutName, Layout layout) throws Exception {

    String friendlyURL = layout.getFriendlyURL();

    if (layoutName.equals(friendlyURL)) {
      return layout;
    }

    List<Layout> layoutChildren = layout.getChildren();

    if (layoutChildren.size() == 0) {
      return null;
    } else {
      for (Layout layoutChild : layoutChildren) {
        Layout currentLayout = _getLayout(layoutName, layoutChild);

        if (currentLayout != null) {
          return currentLayout;
        }
      }
    }

    return null;
  }
  private void _getFiles(CommandArgument commandArgument, Document document, Node rootNode)
      throws Exception {

    if (commandArgument.getCurrentFolder().equals(StringPool.SLASH)) {
      return;
    }

    Element filesElement = document.createElement("Files");

    rootNode.appendChild(filesElement);

    Group group = commandArgument.getCurrentGroup();

    List<Layout> layouts =
        LayoutLocalServiceUtil.getLayouts(
            group.getGroupId(), false, LayoutConstants.DEFAULT_PARENT_LAYOUT_ID);

    if (("/" + commandArgument.getCurrentGroupName() + "/")
        .equals(commandArgument.getCurrentFolder())) {

      for (Layout layout : layouts) {
        Element fileElement = document.createElement("File");

        filesElement.appendChild(fileElement);

        fileElement.setAttribute("name", _getLayoutName(layout));
        fileElement.setAttribute("desc", _getLayoutName(layout));
        fileElement.setAttribute("size", StringPool.BLANK);
        fileElement.setAttribute(
            "url", PortalUtil.getLayoutURL(layout, commandArgument.getThemeDisplay(), false));
      }
    } else {
      String layoutName = _getLayoutName(commandArgument.getCurrentFolder());

      Layout layout = null;

      for (int i = 0; i < layouts.size(); i++) {
        layout = _getLayout(layoutName, layouts.get(i));

        if (layout != null) {
          break;
        }
      }

      if (layout == null) {
        return;
      }

      List<Layout> layoutChildren = layout.getChildren();

      for (int i = 0; i < layoutChildren.size(); i++) {
        layout = layoutChildren.get(i);

        Element fileElement = document.createElement("File");

        filesElement.appendChild(fileElement);

        fileElement.setAttribute("name", _getLayoutName(layout));
        fileElement.setAttribute("desc", _getLayoutName(layout));
        fileElement.setAttribute("size", getSize());
        fileElement.setAttribute(
            "url", PortalUtil.getLayoutURL(layout, commandArgument.getThemeDisplay(), false));
      }
    }
  }