NIHVIVO-161 Fix links so a non-Person with no photo will have the usual "Image +" link. Add "thumbnail" class to the link, so it is available for special CSS, if desired.
This commit is contained in:
parent
14eb8a1311
commit
c613eb6d7c
1 changed files with 50 additions and 48 deletions
|
@ -181,7 +181,7 @@ public class PropertyEditLinks extends TagSupport{
|
||||||
if( links != null){
|
if( links != null){
|
||||||
for( LinkStruct ln : links ){
|
for( LinkStruct ln : links ){
|
||||||
if( ln != null ){
|
if( ln != null ){
|
||||||
out.print( makeElement( ln ) + '\n' );
|
out.print( ln.makeElement() + '\n' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -482,8 +482,14 @@ public class PropertyEditLinks extends TagSupport{
|
||||||
|
|
||||||
if (contains(accesses, EditLinkAccess.ADDNEW)) {
|
if (contains(accesses, EditLinkAccess.ADDNEW)) {
|
||||||
log.debug("permission to ADD main image to " + subjectUri);
|
log.debug("permission to ADD main image to " + subjectUri);
|
||||||
return new LinkStruct[] { getImageLink(subjectUri, contextPath,
|
boolean isPerson = entity.isVClass("http://xmlns.com/foaf/0.1/Person");
|
||||||
"edit", "upload an image", "add") };
|
if (isPerson) {
|
||||||
|
return new LinkStruct[] { getImageLink(subjectUri,
|
||||||
|
contextPath, "edit", "upload an image", "add") };
|
||||||
|
} else {
|
||||||
|
return new LinkStruct[] { getImageLink(subjectUri,
|
||||||
|
contextPath, "add", "upload an image", "add") };
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
log.debug("NO permission to ADD main image to " + subjectUri);
|
log.debug("NO permission to ADD main image to " + subjectUri);
|
||||||
return empty_array;
|
return empty_array;
|
||||||
|
@ -542,31 +548,6 @@ public class PropertyEditLinks extends TagSupport{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String makeElement( LinkStruct ln ){
|
|
||||||
String element =
|
|
||||||
"<a class=\"image " + ln.getType() + "\" href=\"" + ln.getHref() +
|
|
||||||
"\" title=\"" + (ln.getMouseoverText()==null ? ln.getType() : ln.getMouseoverText()) + "\">" ;
|
|
||||||
|
|
||||||
if( "true".equalsIgnoreCase(getIcons()) ){
|
|
||||||
String contextPath=((HttpServletRequest)pageContext.getRequest()).getContextPath();
|
|
||||||
String imagePath=null;
|
|
||||||
if (contextPath==null) {
|
|
||||||
imagePath = ICON_DIR + ln.getType() + ".gif";
|
|
||||||
log.debug("image path when context path null: \""+imagePath+"\".");
|
|
||||||
} else if (contextPath.equals("")) {
|
|
||||||
imagePath = ICON_DIR + ln.getType() + ".gif";
|
|
||||||
log.debug("image path when context path blank: \""+imagePath+"\".");
|
|
||||||
} else {
|
|
||||||
imagePath = contextPath + ICON_DIR + ln.getType() + ".gif";
|
|
||||||
log.debug("image path when non-zero context path (\""+contextPath+"\"): \""+imagePath+"\".");
|
|
||||||
}
|
|
||||||
element += "<img src=\"" + imagePath+ "\" alt=\"" + ln.getType() + "\"/>";
|
|
||||||
} else {
|
|
||||||
element += ln.getText() ;
|
|
||||||
}
|
|
||||||
return element + "</a>\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final EditLinkAccess[] NO_ACCESS = {};
|
public static final EditLinkAccess[] NO_ACCESS = {};
|
||||||
public static final EditLinkAccess[] ACCESS_TEMPLATE = {};
|
public static final EditLinkAccess[] ACCESS_TEMPLATE = {};
|
||||||
|
|
||||||
|
@ -647,44 +628,65 @@ public class PropertyEditLinks extends TagSupport{
|
||||||
String href;
|
String href;
|
||||||
String type;
|
String type;
|
||||||
String mouseoverText;
|
String mouseoverText;
|
||||||
String text; // Defaults to be the same as type
|
|
||||||
|
|
||||||
public String getHref() {
|
|
||||||
return href;
|
|
||||||
}
|
|
||||||
public void setHref(String href) {
|
public void setHref(String href) {
|
||||||
this.href = href;
|
this.href = href;
|
||||||
}
|
}
|
||||||
public String getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
public void setType(String type) {
|
public void setType(String type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMouseoverText() {
|
|
||||||
return mouseoverText;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMouseoverText(String s) {
|
public void setMouseoverText(String s) {
|
||||||
mouseoverText = s;
|
mouseoverText = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setText(String text) {
|
public String makeElement(){
|
||||||
this.text = text;
|
String element =
|
||||||
|
"<a class=\"image " + type + "\" href=\"" + href +
|
||||||
|
"\" title=\"" + (mouseoverText==null ? type : mouseoverText) + "\">" ;
|
||||||
|
|
||||||
|
if( "true".equalsIgnoreCase(getIcons()) ){
|
||||||
|
String contextPath=((HttpServletRequest)pageContext.getRequest()).getContextPath();
|
||||||
|
String imagePath=null;
|
||||||
|
if (contextPath==null) {
|
||||||
|
imagePath = ICON_DIR + type + ".gif";
|
||||||
|
log.debug("image path when context path null: \""+imagePath+"\".");
|
||||||
|
} else if (contextPath.equals("")) {
|
||||||
|
imagePath = ICON_DIR + type + ".gif";
|
||||||
|
log.debug("image path when context path blank: \""+imagePath+"\".");
|
||||||
|
} else {
|
||||||
|
imagePath = contextPath + ICON_DIR + type + ".gif";
|
||||||
|
log.debug("image path when non-zero context path (\""+contextPath+"\"): \""+imagePath+"\".");
|
||||||
|
}
|
||||||
|
element += "<img src=\"" + imagePath+ "\" alt=\"" + type + "\"/>";
|
||||||
|
} else {
|
||||||
|
element += type ;
|
||||||
|
}
|
||||||
|
return element + "</a>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getText() {
|
|
||||||
return (text == null) ? type: text;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class ImageLinkStruct extends LinkStruct {
|
||||||
|
String text;
|
||||||
|
|
||||||
|
public void setText(String text) {
|
||||||
|
this.text = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String makeElement() {
|
||||||
|
String element = "<a class=\"image thumbnail " + type + "\" href=\"" + href + "\"";
|
||||||
|
element += " title=\"" + mouseoverText + "\">";
|
||||||
|
element += text;
|
||||||
|
element += "</a>\n";
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private LinkStruct[] empty_array = {};
|
private LinkStruct[] empty_array = {};
|
||||||
|
|
||||||
private LinkStruct getImageLink(String subjectUri, String contextPath,
|
private LinkStruct getImageLink(String subjectUri, String contextPath,
|
||||||
String action, String mouseOverText, String text) {
|
String action, String mouseOverText, String text) {
|
||||||
LinkStruct ls = new LinkStruct();
|
ImageLinkStruct ls = new ImageLinkStruct();
|
||||||
String url = makeRelativeHref(contextPath + "uploadImages",
|
String url = makeRelativeHref(contextPath + "uploadImages",
|
||||||
"entityUri", subjectUri, "action", action);
|
"entityUri", subjectUri, "action", action);
|
||||||
ls.setHref(url);
|
ls.setHref(url);
|
||||||
|
|
Loading…
Add table
Reference in a new issue