diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/permissions/SimplePermission.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/permissions/SimplePermission.java index ab6df594e..a68384e87 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/permissions/SimplePermission.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/permissions/SimplePermission.java @@ -76,6 +76,7 @@ public class SimplePermission extends Permission { NAMESPACE + "UseAdvancedDataToolsPages"); public static final SimplePermission USE_SPARQL_QUERY_PAGE = new SimplePermission( NAMESPACE + "UseSparqlQueryPage"); + // ---------------------------------------------------------------------- // These instances are "catch all" permissions to cover poorly defined diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ViewLabelsServlet.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ViewLabelsServlet.java new file mode 100644 index 000000000..d00b5cd07 --- /dev/null +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ViewLabelsServlet.java @@ -0,0 +1,246 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +package edu.cornell.mannlib.vitro.webapp.controller.freemarker; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import com.hp.hpl.jena.query.QuerySolution; +import com.hp.hpl.jena.query.ResultSet; +import com.hp.hpl.jena.rdf.model.Literal; +import com.hp.hpl.jena.vocabulary.RDFS; + +import edu.cornell.mannlib.vitro.webapp.beans.Individual; +import edu.cornell.mannlib.vitro.webapp.beans.Property; +import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; +import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet; +import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ExceptionResponseValues; +import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues; +import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues; +import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils; +import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo; +import edu.cornell.mannlib.vitro.webapp.i18n.selection.SelectedLocale; +import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.DataPropertyStatementTemplateModel; + +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +/*Servlet to view all labels in various languages for individual*/ + +public class ViewLabelsServlet extends FreemarkerHttpServlet{ + private static final Log log = LogFactory.getLog(ViewLabelsServlet.class.getName()); + + @Override + protected ResponseValues processRequest(VitroRequest vreq) { + Map body = new HashMap(); + String subjectUri = vreq.getParameter("subjectUri"); + body.put("subjectUri", subjectUri); + try { + //Get all language codes/labels in the system, and this list is sorted by language name + List> locales = this.getLocales(vreq); + //Get code to label hashmap - we use this to get the language name for the language code returned in the rdf literal + HashMap localeCodeToNameMap = this.getFullCodeToLanguageNameMap(locales); + //the labels already added by the user + ArrayList existingLabels = this.getExistingLabels(subjectUri, vreq); + //existing labels keyed by language name and each of the list of labels is sorted by language name + HashMap> existingLabelsByLanguageName = this.getLabelsSortedByLanguageName(existingLabels, localeCodeToNameMap, vreq, subjectUri); + //Get available locales for the drop down for adding a new label, also sorted by language name + HashSet existingLanguageNames = new HashSet(existingLabelsByLanguageName.keySet()); + body.put("labelsSortedByLanguageName", existingLabelsByLanguageName); + Individual subject = vreq.getWebappDaoFactory().getIndividualDao().getIndividualByURI(subjectUri); + + + if( subject != null && subject.getName() != null ){ + body.put("subjectName", subject.getName()); + }else{ + body.put("subjectName", null); + } + + } catch (Throwable e) { + log.error(e, e); + return new ExceptionResponseValues(e); + } + + String template = "viewLabelsForIndividual.ftl"; + + return new TemplateResponseValues(template, body); + } + //Languages sorted by language name + private HashMap> getLabelsSortedByLanguageName(List labels, Map localeCodeToNameMap, + VitroRequest vreq, String subjectUri) { + + + //Iterate through the labels and create a hashmap + HashMap> labelsHash= new HashMap>(); + + for(Literal l: labels) { + String languageTag = l.getLanguage(); + String languageName = ""; + if(languageTag == "") { + languageName = "untyped"; + } + else if(localeCodeToNameMap.containsKey(languageTag)) { + languageName = localeCodeToNameMap.get(languageTag); + } else { + log.warn("This language tag " + languageTag + " does not have corresponding name in the system and was not processed"); + } + + if(languageName != "") { + if(!labelsHash.containsKey(languageName)) { + labelsHash.put(languageName, new ArrayList()); + } + ArrayList labelsList = (ArrayList)labelsHash.get(languageName); + //This should put the label in the list + //Create label information instance with the required information + //To generate link + + + labelsList.add(new LabelInformation( + l, languageTag, languageName)); + } + } + + //Sort each label list + LabelInformationComparator lic = new LabelInformationComparator(); + for(String languageName: labelsHash.keySet()) { + List labelInfo = labelsHash.get(languageName); + Collections.sort(labelInfo, lic); + } + return labelsHash; + + } + + + public static class LabelInformationComparator implements Comparator { + + public int compare(LabelInformation l1, LabelInformation l2) { + return l1.getLabelStringValue().compareTo(l2.getLabelStringValue()); + } + } + + + + @Override + public void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + doGet(request, response); + } + + //get locales + public List> getLocales(VitroRequest vreq) { + List selectables = SelectedLocale.getSelectableLocales(vreq); + if (selectables.isEmpty()) { + return Collections.emptyList(); + } + List> list = new ArrayList>(); + Locale currentLocale = SelectedLocale.getCurrentLocale(vreq); + for (Locale locale : selectables) { + try { + list.add(buildLocaleMap(locale, currentLocale)); + } catch (FileNotFoundException e) { + log.warn("Can't show the Locale selector for '" + locale + + "': " + e); + } + } + + return list; + } + + //copied from locale selection data getter but don't need all this information + private HashMap buildLocaleMap(Locale locale, + Locale currentLocale) throws FileNotFoundException { + HashMap map = new HashMap(); + //Replacing the underscore with a hyphen because that is what is represented in the actual literals + map.put("code", locale.toString().replace("_", "-")); + map.put("label", locale.getDisplayName(currentLocale)); + return map; + } + + public HashMap getFullCodeToLanguageNameMap(List> localesList) { + HashMap codeToLanguageMap = new HashMap(); + for(Map locale: localesList) { + String code = (String) locale.get("code"); + String label = (String) locale.get("label"); + if(!codeToLanguageMap.containsKey(code)) { + codeToLanguageMap.put(code, label); + } + else { + log.warn("Language code " + code + " for " + label + " was not associated in map becayse label already exists"); + } + } + return codeToLanguageMap; + } + + private ArrayList getExistingLabels(String subjectUri, VitroRequest vreq) { + String queryStr = QueryUtils.subUriForQueryVar(LABEL_QUERY, "subject", subjectUri); + log.debug("queryStr = " + queryStr); + + ArrayList labels = new ArrayList(); + try { + //We want to get the labels for all the languages, not just the display language + ResultSet results = QueryUtils.getLanguageNeutralQueryResults(queryStr, vreq); + while (results.hasNext()) { + QuerySolution soln = results.nextSolution(); + Literal nodeLiteral = soln.get("label").asLiteral(); + labels.add(nodeLiteral); + + + } + } catch (Exception e) { + log.error(e, e); + } + return labels; + } + + //Class used to store the information needed for the template, such as the labels, their languages, their edit links + public class LabelInformation { + private Literal labelLiteral = null; + + private String languageCode; //languageCode + private String languageName; + public LabelInformation(Literal inputLiteral, String inputLanguageCode, String inputLanguageName) { + this.labelLiteral = inputLiteral; + + this.languageCode = inputLanguageCode; + this.languageName = inputLanguageName; + } + + + public Literal getLabelLiteral() { + return this.labelLiteral; + } + + public String getLabelStringValue() { + return this.labelLiteral.getString(); + } + + + public String getLanguageCode() { + return this.languageCode; + } + + public String getLanguageName() { + return this.languageName; + } + } + + private static String LABEL_QUERY = "" + + "PREFIX rdfs: \n" + + "SELECT DISTINCT ?label WHERE { \n" + + " ?subject rdfs:label ?label \n" + + "} ORDER BY ?label"; + +} \ No newline at end of file diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/FoafNameToRdfsLabelPreprocessor.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/FoafNameToRdfsLabelPreprocessor.java index 9baa9b4ac..b97386a46 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/FoafNameToRdfsLabelPreprocessor.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/FoafNameToRdfsLabelPreprocessor.java @@ -4,63 +4,118 @@ package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocess import javax.servlet.http.HttpServletRequest; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import com.hp.hpl.jena.query.Query; +import com.hp.hpl.jena.query.QueryExecution; +import com.hp.hpl.jena.query.QueryExecutionFactory; +import com.hp.hpl.jena.query.QueryFactory; +import com.hp.hpl.jena.query.QuerySolution; +import com.hp.hpl.jena.query.QuerySolutionMap; +import com.hp.hpl.jena.query.ResultSet; +import com.hp.hpl.jena.query.Syntax; import com.hp.hpl.jena.rdf.model.Literal; import com.hp.hpl.jena.rdf.model.Model; +import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.Property; import com.hp.hpl.jena.rdf.model.ResIterator; import com.hp.hpl.jena.rdf.model.Resource; +import com.hp.hpl.jena.rdf.model.ResourceFactory; import com.hp.hpl.jena.rdf.model.Statement; +import com.hp.hpl.jena.shared.Lock; import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; public class FoafNameToRdfsLabelPreprocessor implements ModelChangePreprocessor { private static final String FOAF = "http://xmlns.com/foaf/0.1/"; + private Log log = LogFactory.getLog(FoafNameToRdfsLabelPreprocessor.class); @Override public void preprocess(Model retractionsModel, Model additionsModel, HttpServletRequest request) { - Property firstNameP = additionsModel.getProperty(FOAF+"firstName"); - Property lastNameP = additionsModel.getProperty(FOAF+"lastName"); - //middle name is optional - Property middleNameP = additionsModel.getProperty(FOAF+"middleName"); - + updateModelWithLabel(additionsModel); + } + + private String getSparqlQuery() { + String queryStr = "SELECT ?subject ?firstName ?middleName ?lastName where {" + + "?subject ?individualVcard ." + + "?individualVcard ?fullName ." + + "?fullName ?firstName ." + + "?fullName ?lastName ." + + "OPTIONAL {?fullName ?middleName .}" + + "}"; + return queryStr; + } + + private void updateModelWithLabel(Model additionsModel) { + Model changesModel = ModelFactory.createDefaultModel(); + String queryStr = getSparqlQuery(); Property rdfsLabelP = additionsModel.getProperty(VitroVocabulary.LABEL); - - ResIterator subs = - additionsModel.listSubjectsWithProperty(firstNameP); - while( subs.hasNext() ){ - Resource sub = subs.nextResource(); - Statement fname = sub.getProperty( firstNameP ); - Statement lname = sub.getProperty( lastNameP ); - Statement mname = sub.getProperty(middleNameP); - if( fname != null && lname != null && fname.getString() != null && lname.getString() != null ){ - //Check if there are languages associated with first name and last name and add the language - //attribute to the label - //This preprocessor is used in multiple places, including for managing labels - Literal firstNameLiteral = fname.getLiteral(); - Literal lastNameLiteral = lname.getLiteral(); - - String firstNameLanguage = firstNameLiteral.getLanguage(); - String lastNameLanguage = lastNameLiteral.getLanguage(); - //Start creating string for new label - String newLabel = lname.getString() + ", " + fname.getString(); - //Middle name handling - if(mname != null && mname.getString() != null) { - newLabel += " " + mname.getString(); - } - - if(firstNameLanguage != null && lastNameLanguage != null && firstNameLanguage.equals(lastNameLanguage)) { - //create a literal with the appropriate value and the language - Literal labelWithLanguage = additionsModel.createLiteral(newLabel, firstNameLanguage); - additionsModel.add(sub, rdfsLabelP, labelWithLanguage); - } else { - additionsModel.add(sub, rdfsLabelP, newLabel ); - } - } - } - + Query query = null; + QueryExecution qe = null; + + additionsModel.getLock().enterCriticalSection(Lock.READ); + try { + query = QueryFactory.create(queryStr); + qe = QueryExecutionFactory.create( + query, additionsModel); + ResultSet res = qe.execSelect(); + while( res.hasNext() ){ + String newLabel = ""; + Resource subject = null; + QuerySolution qs = res.nextSolution(); + subject = qs.getResource("subject"); + //Get first and last names, and middle names if they exist + if(qs.getLiteral("firstName") != null && qs.getLiteral("lastName") != null) { + Literal firstNameLiteral = qs.getLiteral("firstName"); + Literal lastNameLiteral = qs.getLiteral("lastName"); + String firstNameLanguage = firstNameLiteral.getLanguage(); + String lastNameLanguage = lastNameLiteral.getLanguage(); + newLabel = lastNameLiteral.getString() + ", " + firstNameLiteral.getString(); + + if(qs.getLiteral("middleName") != null) { + Literal middleNameLiteral = qs.getLiteral("middleName"); + newLabel += " " + middleNameLiteral.getString(); + } + + if(subject != null && + firstNameLanguage != null && lastNameLanguage != null + && firstNameLanguage.equals(lastNameLanguage)) { + //create a literal with the appropriate value and the language + Literal labelWithLanguage = changesModel.createLiteral(newLabel, firstNameLanguage); + changesModel.add(subject, rdfsLabelP, labelWithLanguage); + } else { + changesModel.add(subject, rdfsLabelP, newLabel ); + } + } + + + } + + } catch(Throwable th){ + log.error("An error occurred in executing query:" + queryStr); + } finally { + if (qe != null) { + qe.close(); + } + additionsModel.getLock().leaveCriticalSection(); + } + + //Write changes model to additions model + additionsModel.getLock().enterCriticalSection(Lock.WRITE); + try { + additionsModel.add(changesModel); + }catch(Throwable th){ + log.error("An error occurred in writing model", th); + } finally { + + additionsModel.getLock().leaveCriticalSection(); + } + + } } diff --git a/webapp/web/WEB-INF/web.xml b/webapp/web/WEB-INF/web.xml index 2b246330a..245f6116c 100644 --- a/webapp/web/WEB-INF/web.xml +++ b/webapp/web/WEB-INF/web.xml @@ -625,12 +625,12 @@ - ManageLabelsForIndividualController - edu.cornell.mannlib.vitro.webapp.controller.freemarker.ManageLabelsForIndividualController + ViewLabelsServlet + edu.cornell.mannlib.vitro.webapp.controller.freemarker.ViewLabelsServlet - ManageLabelsForIndividualController - /manageLabels + ViewLabelsServlet + /viewLabels diff --git a/webapp/web/i18n/all.properties b/webapp/web/i18n/all.properties index e7239855e..480e49341 100644 --- a/webapp/web/i18n/all.properties +++ b/webapp/web/i18n/all.properties @@ -873,3 +873,5 @@ manage_labels_capitalized = Manage Labels manage_labels_intro = In the case where multiple labels exist in the same language, please use the remove link to delete the labels you do not want displayed on the profile page for a given language. processing_icon = processing selection_in_process = Your selection is being processed. +view_labels_capitalized = View Labels +view_labels_for = View Labels for \ No newline at end of file diff --git a/webapp/web/js/individual/manageLabelsForIndividual.js b/webapp/web/js/individual/manageLabelsForIndividual.js index f80513fa9..f8664ba95 100644 --- a/webapp/web/js/individual/manageLabelsForIndividual.js +++ b/webapp/web/js/individual/manageLabelsForIndividual.js @@ -24,6 +24,8 @@ var manageLabels = { this.addLabelForm = $('#addLabelForm'); this.showFormButtonWrapper = $('#showAddForm'); this.showFormButton = $("#showAddFormButton"); + //button to return to profile - div with only cancel + this.showCancelOnlyButton = $("#showCancelOnly"); this.addLabelCancel = this.addLabelForm.find(".cancel"); this.submit = this.addLabelForm.find('input#submit'); this.labelLanguage = this.addLabelForm.find("#newLabelLanguage"); @@ -37,20 +39,28 @@ var manageLabels = { if(this.submissionErrorsExist == "false") { //hide the form to add label this.addLabelForm.hide(); + //If the number of available locales is zero, then hide the ability to show the form as well if(this.numberAvailableLocales == 0) { manageLabels.showFormButtonWrapper.hide(); + this.showCancelOnlyButton.show(); + } else { + //if the add label button is visible, don't need cancel only link + this.showCancelOnlyButton.hide(); } } else { //Display the form this.onShowAddForm(); + //Also make sure the save button is enabled in case there is a value selected for the drop down if(this.labelLanguage.val() != "") { disableSubmit = false; } } + + if(disableSubmit) { //disable submit until user selects a language @@ -235,6 +245,8 @@ var manageLabels = { //Re-show the add button and the form if they were hidden before if(availableLocalesList.length > 0 && manageLabels.showFormButtonWrapper.is(":hidden")) { manageLabels.showFormButtonWrapper.show(); + //hide the cancel only button + manageLabels.showCancelOnlyButton.hide(); } //Now replace dropdown with this new list diff --git a/webapp/web/templates/freemarker/body/individual/manageLabelsForIndividual.ftl b/webapp/web/templates/freemarker/body/individual/manageLabelsForIndividual.ftl index 63f520a79..ec0b78a2a 100644 --- a/webapp/web/templates/freemarker/body/individual/manageLabelsForIndividual.ftl +++ b/webapp/web/templates/freemarker/body/individual/manageLabelsForIndividual.ftl @@ -1,6 +1,7 @@ <#-- $This file is distributed under the terms of the license in /doc/license.txt$ --> <#include "manageLabelsForIndividualTerms.ftl" > <#-- Custom form for managing labels for individuals --> +<#--This is used both for editing and for viewLabelsServlet--> <#import "manageLabelsForIndividualMacros.ftl" as m > <#assign requiredHint = " *" /> <#assign subjectUri = editConfiguration.subjectUri/> @@ -66,7 +67,9 @@ ${i18n().or} ${returnText} - + <#include "manageLabelsForIndividualAddForm.ftl" > diff --git a/webapp/web/templates/freemarker/body/individual/manageLabelsForIndividualMacros.ftl b/webapp/web/templates/freemarker/body/individual/manageLabelsForIndividualMacros.ftl index b8258891d..28a1a1b6f 100644 --- a/webapp/web/templates/freemarker/body/individual/manageLabelsForIndividualMacros.ftl +++ b/webapp/web/templates/freemarker/body/individual/manageLabelsForIndividualMacros.ftl @@ -1,39 +1,41 @@ <#-- $This file is distributed under the terms of the license in /doc/license.txt$ --> <#--LabelsSorted is a hash keyed by language name where the value is a list of LabelInformation class objects--> -<#macro displayExistingLabelsForLanguage lang labelsSorted editable editGenerator displayRemoveLink=true> +<#macro displayExistingLabelsForLanguage lang labelsSorted editable editGenerator="" displayRemoveLink=true> <#--get label information for this language--> - <#assign labelList = labelsSorted[lang] /> - <#--Reset for every language--> - <#assign labelSeq = []/> - - <#list labelList as labelObject> - <#assign labelLiteral = labelObject.labelLiteral /> - <#assign labelStringValue = labelObject.labelStringValue /> - <#--Try label as label literal--> - <#assign label = labelLiteral /> - <#assign labelLang = labelObject.languageName /> - <#assign languageCode = labelObject.languageCode /> - <#assign labelEditLink = labelObject.editLinkURL /> - <#if label?? && ( label?index_of("@") > -1 ) > - <#assign labelStr = label?substring(0, label?index_of("@")) > - <#assign tagOrTypeStr = label?substring(label?index_of("@")) > - <#elseif label?? && ( label?index_of("^^") > -1 ) > - <#assign labelStr = label?substring(0, label?index_of("^^")) > - <#assign tagOrTypeStr = label?substring(label?index_of("^^")) > - <#assign tagOrTypeStr = tagOrTypeStr?replace("^^http","^^ - <#assign tagOrTypeStr = tagOrTypeStr?replace("#string","#string>") > - <#else> - <#assign labelStr = label > - <#assign tagOrTypeStr = "" > - - <@displayLabel labelSeq labelStr languageCode labelEditLink tagOrTypeStr editGenerator editable displayRemoveLink/> - - <#assign labelSeq = labelSeq + [labelStr]> - + <#if labelsSorted?keys?seq_contains(lang) > + <#assign labelList = labelsSorted[lang] /> + <#--Reset for every language--> + <#assign labelSeq = []/> + + <#list labelList as labelObject> + <#assign labelLiteral = labelObject.labelLiteral /> + <#assign labelStringValue = labelObject.labelStringValue /> + <#--Try label as label literal--> + <#assign label = labelLiteral /> + <#assign labelLang = labelObject.languageName /> + <#assign languageCode = labelObject.languageCode /> + <#assign labelEditLink = labelObject.editLinkURL /> + <#if label?? && ( label?index_of("@") > -1 ) > + <#assign labelStr = label?substring(0, label?index_of("@")) > + <#assign tagOrTypeStr = label?substring(label?index_of("@")) > + <#elseif label?? && ( label?index_of("^^") > -1 ) > + <#assign labelStr = label?substring(0, label?index_of("^^")) > + <#assign tagOrTypeStr = label?substring(label?index_of("^^")) > + <#assign tagOrTypeStr = tagOrTypeStr?replace("^^http","^^ + <#assign tagOrTypeStr = tagOrTypeStr?replace("#string","#string>") > + <#else> + <#assign labelStr = label > + <#assign tagOrTypeStr = "" > + + <@displayLabel labelSeq labelStr languageCode labelEditLink tagOrTypeStr editGenerator editable displayRemoveLink/> + + <#assign labelSeq = labelSeq + [labelStr]> + + <#--ignore 'untyped' and display everything--> -<#macro displayExistingTypedLabels langList labelsSorted editable editGenerator displayRemoveLink=true> +<#macro displayExistingTypedLabels langList labelsSorted editable editGenerator="" displayRemoveLink=true> <#list langList as lang> diff --git a/webapp/web/templates/freemarker/body/individual/viewLabelsForIndividual.ftl b/webapp/web/templates/freemarker/body/individual/viewLabelsForIndividual.ftl new file mode 100644 index 000000000..9907cb355 --- /dev/null +++ b/webapp/web/templates/freemarker/body/individual/viewLabelsForIndividual.ftl @@ -0,0 +1,46 @@ +<#-- $This file is distributed under the terms of the license in /doc/license.txt$ --> +<#-- $This file is distributed under the terms of the license in /doc/license.txt$ --> +<#include "manageLabelsForIndividualTerms.ftl" > +<#-- Custom form for managing labels for individuals --> +<#--This is used both for editing and for viewLabelsServlet--> +<#import "manageLabelsForIndividualMacros.ftl" as m > +<#assign requiredHint = " *" /> +<#assign labelStr = "" > +<#assign languageTag = "" > +<#assign labelSeq = [] > +<#assign editable = "false"/> +<#assign displayRemoveLink = "false"/> + +<#if subjectName?? > +

${i18n().view_labels_for} ${editConfiguration.pageData.subjectName}

+<#else> +

${i18n().view_labels_capitalized}

+ + + +
+ +
    + <#if editConfiguration.pageData.labelsSortedByLanguageName?has_content> + <#--List of labelInformation objects as value where key = language name --> + <#assign labelsSorted = editConfiguration.pageData.labelsSortedByLanguageName /> + <#--Keys would be the actual names of languages--> + <#assign labelLanguages = labelsSorted?keys?sort /> + + <#--What we need here is printing out the labels by the language Name and not language code, starting with untyped first--> + <@m.displayExistingLabelsForLanguage "untyped" labelsSorted editable ""/> + <@m.displayExistingTypedLabels labelLanguages labelsSorted editable ""/> + + +
+ +
+ + + + +${stylesheets.add('')} + +${scripts.add('', + '')} + diff --git a/webapp/web/templates/freemarker/lib/lib-properties.ftl b/webapp/web/templates/freemarker/lib/lib-properties.ftl index c54bd9b16..c49e00577 100644 --- a/webapp/web/templates/freemarker/lib/lib-properties.ftl +++ b/webapp/web/templates/freemarker/lib/lib-properties.ftl @@ -233,18 +233,22 @@ name will be used as the label. --> <@editingLinks "label" "" label editable /> <#elseif editable || (labelCount > 1)> <#--We display the link even when the user is not logged in case of multiple labels--> - <#if editable> - <#assign imageAlt = "${i18n().manage}" /> - <#assign linkTitle = "${i18n().manage_list_of_labels}"> - <#else> - <#assign linkTitle = "${i18n().view_list_of_labels}"> - <#assign imageAlt = "${i18n().view}" /> - + <#assign labelLink = ""/> <#-- Manage labels now goes to generator --> <#assign individualUri = individual.uri!""/> <#assign individualUri = (individualUri?url)/> + <#if editable> + <#assign imageAlt = "${i18n().manage}" /> + <#assign linkTitle = "${i18n().manage_list_of_labels}"> + <#assign labelLink= "${urls.base}/editRequestDispatch?subjectUri=${individualUri}&editForm=edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.ManageLabelsGenerator&predicateUri=${labelPropertyUri}"> + <#else> + <#assign linkTitle = "${i18n().view_list_of_labels}"> + <#assign imageAlt = "${i18n().view}" /> + <#assign labelLink= "${urls.base}/viewLabels?subjectUri=${individualUri}"> + + - ${imageAlt}