Package freenet.clients.http.bookmark

Examples of freenet.clients.http.bookmark.Bookmark


        pageMaker.getInfobox("infobox-error", error, content, "bookmark-url-decode-error", false).
          addChild("#", NodeL10n.getBase().getString("BookmarkEditorToadlet.urlDecodeError"));
        writeHTMLReply(ctx, 200, "OK", pageNode.generate());
        return;
      }
      Bookmark bookmark;

      if(bookmarkPath.endsWith("/"))
        bookmark = bookmarkManager.getCategoryByPath(bookmarkPath);
      else
        bookmark = bookmarkManager.getItemByPath(bookmarkPath);

      if(bookmark == null) {
        pageMaker.getInfobox("infobox-error", error, content, "bookmark-does-not-exist", false).
          addChild("#", NodeL10n.getBase().getString("BookmarkEditorToadlet.bookmarkDoesNotExist", new String[]{"bookmark"}, new String[]{bookmarkPath}));
        this.writeHTMLReply(ctx, 200, "OK", pageNode.generate());
        return;
      } else
        if("del".equals(action)) {

          String[] bm = new String[]{"bookmark"};
          String[] path = new String[]{bookmarkPath};
          String queryTitle = NodeL10n.getBase().getString("BookmarkEditorToadlet." + ((bookmark instanceof BookmarkItem) ? "deleteBookmark" : "deleteCategory"));
          HTMLNode infoBoxContent = pageMaker.getInfobox("infobox-query", queryTitle, content, "bookmark-delete", false);

          String query = NodeL10n.getBase().getString("BookmarkEditorToadlet." + ((bookmark instanceof BookmarkItem) ? "deleteBookmarkConfirm" : "deleteCategoryConfirm"), bm, path);
          infoBoxContent.addChild("p").addChild("#", query);

          HTMLNode confirmForm = ctx.addFormChild(infoBoxContent, "", "confirmDeleteForm");
          confirmForm.addChild("input", new String[]{"type", "name", "value"}, new String[]{"hidden", "bookmark", bookmarkPath});
          confirmForm.addChild("input", new String[]{"type", "name", "value"}, new String[]{"submit", "cancel", NodeL10n.getBase().getString("Toadlet.cancel")});
          confirmForm.addChild("input", new String[]{"type", "name", "value"}, new String[]{"submit", "confirmdelete", NodeL10n.getBase().getString("BookmarkEditorToadlet.confirmDelete")});

        } else if("cut".equals(action))
          cutedPath = bookmarkPath;
        else if("paste".equals(action) && cutedPath != null) {

          bookmarkManager.moveBookmark(cutedPath, bookmarkPath);
          bookmarkManager.storeBookmarks();
          cutedPath = null;

        } else if("edit".equals(action) || "addItem".equals(action) || "addCat".equals(action) || "share".equals(action)) {
          boolean isNew = "addItem".equals(action) || "addCat".equals(action);
          String header;
          if("edit".equals(action))
            header = NodeL10n.getBase().getString("BookmarkEditorToadlet.edit" + ((bookmark instanceof BookmarkItem) ? "Bookmark" : "Category") + "Title");
          else if("addItem".equals(action))
            header = NodeL10n.getBase().getString("BookmarkEditorToadlet.addNewBookmark");
          else if("share".equals(action))
            header = NodeL10n.getBase().getString("BookmarkEditorToadlet.share");
          else
            header = NodeL10n.getBase().getString("BookmarkEditorToadlet.addNewCategory");

          HTMLNode actionBoxContent = pageMaker.getInfobox("infobox-query", header, content, "bookmark-action", false);

          HTMLNode form = ctx.addFormChild(actionBoxContent, "", "editBookmarkForm");

          form.addChild("label", "for", "name", (NodeL10n.getBase().getString("BookmarkEditorToadlet.nameLabel") + ' '));
          form.addChild("input", new String[]{"type", "id", "name", "size", "value"}, new String[]{"text", "name", "name", "20", !isNew ? bookmark.getVisibleName() : ""});

          form.addChild("br");
          if(("edit".equals(action) && bookmark instanceof BookmarkItem) || "addItem".equals(action) || "share".equals(action)) {
            BookmarkItem item = isNew ? null : (BookmarkItem) bookmark;
            String key = !isNew ? item.getKey() : "";
View Full Code Here


    }

    String bookmarkPath = req.getPartAsStringFailsafe("bookmark", MAX_BOOKMARK_PATH_LENGTH);
    try {

      Bookmark bookmark;
      if(bookmarkPath.endsWith("/"))
        bookmark = bookmarkManager.getCategoryByPath(bookmarkPath);
      else
        bookmark = bookmarkManager.getItemByPath(bookmarkPath);
      if(bookmark == null && !req.isPartSet("cancelCut")) {
        pageMaker.getInfobox("infobox-error", NodeL10n.getBase().getString("BookmarkEditorToadlet.error"), content, "bookmark-error", false).
          addChild("#", NodeL10n.getBase().getString("BookmarkEditorToadlet.bookmarkDoesNotExist", new String[]{"bookmark"}, new String[]{bookmarkPath}));
        this.writeHTMLReply(ctx, 200, "OK", pageNode.generate());
        return;
      }


      String action = req.getPartAsStringFailsafe("action", MAX_ACTION_LENGTH);

      if(req.isPartSet("confirmdelete")) {
        bookmarkManager.removeBookmark(bookmarkPath);
        bookmarkManager.storeBookmarks();
        pageMaker.getInfobox("infobox-success", NodeL10n.getBase().getString("BookmarkEditorToadlet.deleteSucceededTitle"), content, "bookmark-successful-delete", false).
          addChild("p", NodeL10n.getBase().getString("BookmarkEditorToadlet.deleteSucceeded"));

      } else if(req.isPartSet("cancelCut"))
        cutedPath = null;
      else if("edit".equals(action) || "addItem".equals(action) || "addCat".equals(action)) {

        String name = "unnamed";
        if(req.isPartSet("name"))
          name = req.getPartAsStringFailsafe("name", MAX_NAME_LENGTH);

        if("edit".equals(action)) {
          bookmarkManager.renameBookmark(bookmarkPath, name);
          boolean hasAnActivelink = req.isPartSet("hasAnActivelink");
          if(bookmark instanceof BookmarkItem) {
            BookmarkItem item = (BookmarkItem) bookmark;
            item.update(new FreenetURI(req.getPartAsStringFailsafe("key", MAX_KEY_LENGTH)), hasAnActivelink, req.getPartAsStringFailsafe("descB", MAX_KEY_LENGTH), req.getPartAsStringFailsafe("explain", MAX_EXPLANATION_LENGTH));
            sendBookmarkFeeds(req, item, req.getPartAsStringFailsafe("publicDescB", MAX_KEY_LENGTH));
          }
          bookmarkManager.storeBookmarks();

          pageMaker.getInfobox("infobox-success", NodeL10n.getBase().getString("BookmarkEditorToadlet.changesSavedTitle"), content, "bookmark-error", false).
            addChild("p", NodeL10n.getBase().getString("BookmarkEditorToadlet.changesSaved"));

        } else if("addItem".equals(action) || "addCat".equals(action)) {

          Bookmark newBookmark = null;
          if("addItem".equals(action)) {
            FreenetURI key = new FreenetURI(req.getPartAsStringFailsafe("key", MAX_KEY_LENGTH));
            /* TODO:
             * <nextgens> I suggest you implement a HTTPRequest.getBoolean(String name) using Fields.stringtobool
             * <nextgens> HTTPRequest.getBoolean(String name, boolean default) even
View Full Code Here

TOP

Related Classes of freenet.clients.http.bookmark.Bookmark

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.