Changeset 4860


Ignore:
Timestamp:
2003-07-02T16:41:24+12:00 (21 years ago)
Author:
kjdon
Message:

we now look for stylesheets in teh collection before the site - note this only works for local sites

Location:
trunk/gsdl3/src/java/org/greenstone/gsdl3
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/core/TransformingReceptionist.java

    r4691 r4860  
    118118    String action = request.getAttribute("action");
    119119    String subaction = request.getAttribute("subaction");
    120     String xslt_file = getXSLTFileName(action, subaction);
     120   
     121    Element cgi_param_list = (Element)GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
     122    String collection = "";
     123    if (cgi_param_list != null) {
     124        HashMap params = GSXML.extractParams(cgi_param_list, false);
     125        collection = (String)params.get(GSCGI.COLLECTION_ARG);
     126        if (collection == null) collection = "";
     127    }
     128   
     129    String xslt_file = getXSLTFileName(action, subaction, collection);
    121130    if (xslt_file==null) {
    122131        // cant transform the page - return null or the original?
     
    133142       
    134143        // need to transform the format info
    135         String stylesheet_file = GSFile.stylesheetFile((String)this.config_params.get(GSConstants.GSDL3_HOME), (String)this.config_params.get(GSConstants.SITE_NAME), (String)this.config_params.get(GSConstants.INTERFACE_NAME), "config_format.xsl");
     144        String stylesheet_file = GSFile.stylesheetFile((String)this.config_params.get(GSConstants.GSDL3_HOME), (String)this.config_params.get(GSConstants.SITE_NAME), (String)this.config_params.get(GSConstants.INTERFACE_NAME), "",  "config_format.xsl");
    136145        Document stylesheet = this.converter.getDOM(new File(stylesheet_file));
    137146        Document format_doc = this.converter.newDOM();
     
    145154   
    146155    // there is a thing called a URIResolver which you can set for a transformer or transformer factory. may be able to use this instead of this absoluteIncludepaths hack
    147     GSXSLT.absoluteIncludePaths(style_doc, (String)this.config_params.get(GSConstants.GSDL3_HOME), (String)this.config_params.get(GSConstants.SITE_NAME), (String)this.config_params.get(GSConstants.INTERFACE_NAME));
     156    GSXSLT.absoluteIncludePaths(style_doc, (String)this.config_params.get(GSConstants.GSDL3_HOME), (String)this.config_params.get(GSConstants.SITE_NAME), (String)this.config_params.get(GSConstants.INTERFACE_NAME), collection);
    148157    // put the page into a document - this is necessary for xslt to get the paths right if you have paths relative to the document root eg /page.
    149158    Document doc = this.converter.newDOM();
     
    152161    }
    153162
    154     protected String getXSLTFileName(String action, String subaction) {
     163    protected String getXSLTFileName(String action, String subaction,
     164                     String collection) {
    155165
    156166    String name = null;
     
    164174    }
    165175    // now find the absolute path
    166     String stylesheet = GSFile.stylesheetFile((String)this.config_params.get(GSConstants.GSDL3_HOME), (String)this.config_params.get(GSConstants.SITE_NAME), (String)this.config_params.get(GSConstants.INTERFACE_NAME), name);
     176    String stylesheet = GSFile.stylesheetFile((String)this.config_params.get(GSConstants.GSDL3_HOME), (String)this.config_params.get(GSConstants.SITE_NAME), (String)this.config_params.get(GSConstants.INTERFACE_NAME), collection, name);
    167177    if (stylesheet==null) {
    168178        System.out.println("cant find stylesheet for "+name);
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/util/GSFile.java

    r4700 r4860  
    148148    }
    149149   
    150    
     150
    151151    /** returns the absolute path to a stylesheet
    152152     * stylesheets are looked for in the following order
     153     * collect-specific,
    153154     * site-specific, interface-specific, default
    154155     * returns null  if the file cannot be found
     
    158159                    String site_name,
    159160                    String interface_name,
     161                    String collection,
    160162                    String filename) {
    161     // try site one first
     163
    162164    String site_home = siteHome(gsdl3_home, site_name);
    163     File stylesheet = new File(site_home +File.separatorChar+
     165    // try collection first
     166    File stylesheet = null;
     167    if (!collection.equals("")) {
     168       
     169        String coll_home = collectionBaseDir(site_home, collection);
     170        stylesheet = new File(coll_home +File.separatorChar+
     171                  "transform"+File.separatorChar+filename);
     172        if (stylesheet.exists()) {
     173        return stylesheet.getPath();
     174        }
     175    }
     176    // try site one next
     177   
     178    stylesheet = new File(site_home +File.separatorChar+
    164179                   "transform"+File.separatorChar+filename);
    165180    if (stylesheet.exists()) {
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/util/GSXSLT.java

    r4704 r4860  
    4242                        String gsdl3_home,
    4343                        String site_name,
    44                         String interface_name) {
     44                        String interface_name,
     45                        String collection) {
    4546   
    4647   
     
    5051        String name = child.getNodeName();
    5152        if (name.equals("xsl:import") || name.equals("xsl:include")) {
    52         ((Element)child).setAttribute("href", GSFile.stylesheetFile(gsdl3_home, site_name, interface_name, ((Element)child).getAttribute("href")));
     53        ((Element)child).setAttribute("href", GSFile.stylesheetFile(gsdl3_home, site_name, interface_name, collection, ((Element)child).getAttribute("href")));
    5354        }
    5455        child = child.getNextSibling();
Note: See TracChangeset for help on using the changeset viewer.