if(tokens.length == 1) {
if(accessLevel >= ModuleHelper.VIEW_ONLY)
return new ManageContents(accessLevel, page, user);
else
return new Error401();
} else if(tokens.length == 2 && tokens[1].equals("add")) {
if(accessLevel >= ModuleHelper.ADD)
return new ContentTypes(page);
else
return new Error401();
} else if(tokens.length == 2 && tokens[1].equals("new")) {
String contentType = ClaymusMain.getRequest().getParameter("type");
if(contentType == null)
return null;
final ContentType contentData = ContentData.getContentType(contentType);
if(contentData == null)
return null;
if(! contentData.hasEditor())
return null;
if(accessLevel >= ModuleHelper.ADD)
return new ContentType() {
@Override
public String getName() {
return page.getTitle() != null
? page.getTitle() + " \u00BB Add Content \u00BB " + contentData.getName()
: "(no title)" + " \u00BB Add Content \u00BB " + contentData.getName();
}
@Override
protected String getHTML() {
String html = "<div class='claymus-h1'>" + getName() + "</div>";
html += contentData.getEditor();
return html;
}
};
else
return new Error401();
} else if(tokens.length == 2 && tokens[1].equals("edit")) {
String encoded = ClaymusMain.getRequest().getParameter("key");
if(encoded == null)
return null;
final Content content = ContentData.getContent(KeyFactory.stringToKey(encoded));
if(content == null)
return null;
if(page.getId() != content.getPageId())
return null;
if(accessLevel >= ModuleHelper.ADD_EDIT || (accessLevel == ModuleHelper.ADD && content.getOwner().equals(user)))
return new ContentType() {
@Override
public String getName() {
return page.getTitle() != null
? page.getTitle() + " \u00BB Edit Content \u00BB " + content.getName()
: "(no title)" + " \u00BB Edit Content \u00BB " + content.getName();
}
@Override
protected String getHTML() {
String html = "<div class='claymus-h1'>" + getName() + "</div>";
html += content.getEditor();
return html;
}
};
else
return new Error401();
} else {
return null;
}