Changeset 35391


Ignore:
Timestamp:
2021-09-14T14:17:21+12:00 (3 years ago)
Author:
kjdon
Message:

getInterfaceText now uses a custom classloader, which looks in web/interfaces/interface_name/resources - this allows you to put your interface_xxx.properties file directly into your interface - useful when developing a custom interface, as it keeps the files together inside the interface

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/XSLTUtil.java

    r33720 r35391  
    237237    public static String getInterfaceText(String interface_name, String dictionary_name, String lang, String key, String args_str)
    238238    {
    239         String[] args = null;
     239          // now we allow looking for files in the interface's resources folder
     240          CustomClassLoader my_loader = new CustomClassLoader(XSLTUtil.class.getClassLoader(), GSFile.interfaceResourceDir(GlobalProperties.getGSDL3Home(), interface_name));
     241                String[] args = null;
    240242        if (args_str != null && !args_str.equals(""))
    241243        {
     
    244246
    245247        // try the specified dictionary first
    246         Dictionary dict = new Dictionary(dictionary_name, lang);
     248        Dictionary dict = new Dictionary(dictionary_name, lang, my_loader);
    247249        String result = dict.get(key, args);
    248250        if (result == null) {
     
    285287  public static String getInterfaceTextWithArgs(String interface_name, String lang, String key, String[] args)
    286288  {
    287     Dictionary dict = new Dictionary("interface_" + interface_name, lang);
     289    // now we allow looking for files in the interface's resources folder
     290    CustomClassLoader my_loader = new CustomClassLoader(XSLTUtil.class.getClassLoader(), GSFile.interfaceResourceDir(GlobalProperties.getGSDL3Home(), interface_name));
     291    Dictionary dict = new Dictionary("interface_" + interface_name, lang, my_loader);
    288292   
    289     // do we need this?? values can have __INTERFACE_NAME__ but would keys ever have it???
    290     key = key.replaceAll("__INTERFACE_NAME__", interface_name);
    291293    String result = dict.get(key, args);
    292294    if (result == null)
    293       { // not found - TODO delete this???
    294     //if not found, search a separate subdirectory named by the interface name
     295      {  
     296    //if not found, search a separate subdirectory named by the interface name. this is used for eg the flax interface. this could be replaced by new class loader option?
    295297    String sep_interface_dir = interface_name + File.separatorChar + lang + File.separatorChar + "interface";
    296298    dict = new Dictionary(sep_interface_dir, lang);
Note: See TracChangeset for help on using the changeset viewer.