Multi-lingual support for menus (#91)
This commit is contained in:
parent
6aa34ee9ca
commit
a3cd382117
4 changed files with 31 additions and 6 deletions
|
@ -17,6 +17,7 @@ import javax.servlet.ServletException;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.MenuDaoJena;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
@ -461,7 +462,7 @@ public class FreemarkerHttpServlet extends VitroHttpServlet {
|
|||
|
||||
protected MainMenu getDisplayModelMenu(VitroRequest vreq){
|
||||
String url = vreq.getRequestURI().substring(vreq.getContextPath().length());
|
||||
return vreq.getWebappDaoFactory().getMenuDao().getMainMenu(url);
|
||||
return vreq.getWebappDaoFactory().getMenuDao().getMainMenu(vreq, url);
|
||||
}
|
||||
|
||||
// NIHVIVO-3307: we need this here instead of FreemarkerConfiguration.java so that updates to
|
||||
|
|
|
@ -3,10 +3,19 @@ package edu.cornell.mannlib.vitro.webapp.dao;
|
|||
|
||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.menu.MainMenu;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
|
||||
public interface MenuDao {
|
||||
/**
|
||||
* @param url - url of request for setting active menu items. This should start with a / and not have the context path.
|
||||
* These values will be checked against urlMapping. ex. /people or /home
|
||||
*/
|
||||
public MainMenu getMainMenu( String url);
|
||||
|
||||
/**
|
||||
* @param req - the ServletRequest for the current request
|
||||
* @param url - url of request for setting active menu items. This should start with a / and not have the context path.
|
||||
* These values will be checked against urlMapping. ex. /people or /home
|
||||
*/
|
||||
public MainMenu getMainMenu(ServletRequest req, String url);
|
||||
}
|
||||
|
|
|
@ -5,9 +5,11 @@ package edu.cornell.mannlib.vitro.webapp.dao.jena;
|
|||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.filter.LanguageFilteringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.apache.jena.ontology.OntModel;
|
||||
import org.apache.jena.query.Query;
|
||||
import org.apache.jena.query.QueryExecution;
|
||||
import org.apache.jena.query.QueryExecutionFactory;
|
||||
|
@ -23,6 +25,8 @@ import edu.cornell.mannlib.vitro.webapp.dao.MenuDao;
|
|||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.menu.MainMenu;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
|
||||
public class MenuDaoJena extends JenaBaseDao implements MenuDao {
|
||||
|
||||
private static final Log log = LogFactory.getLog(MenuDaoJena.class);
|
||||
|
@ -68,6 +72,10 @@ public class MenuDaoJena extends JenaBaseDao implements MenuDao {
|
|||
return getMenu( getOntModelSelector().getDisplayModel(), url );
|
||||
}
|
||||
|
||||
public MainMenu getMainMenu( ServletRequest req, String url ) {
|
||||
OntModel displayModel = LanguageFilteringUtils.wrapOntModelInALanguageFilter(getOntModelSelector().getDisplayModel(), req );
|
||||
return getMenu(displayModel, url) ;
|
||||
}
|
||||
|
||||
protected MainMenu getMenu(Model displayModel, String url){
|
||||
//setup query parameters
|
||||
|
|
|
@ -5,6 +5,8 @@ package stubs.edu.cornell.mannlib.vitro.webapp.dao;
|
|||
import edu.cornell.mannlib.vitro.webapp.dao.MenuDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.menu.MainMenu;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
|
||||
/**
|
||||
* A minimal implementation of the MenuDao.
|
||||
*
|
||||
|
@ -35,6 +37,11 @@ public class MenuDaoStub implements MenuDao {
|
|||
return this.mainMenu;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MainMenu getMainMenu(ServletRequest req, String url) {
|
||||
return this.mainMenu;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Un-implemented methods
|
||||
// ----------------------------------------------------------------------
|
||||
|
|
Loading…
Add table
Reference in a new issue