Changeset 37098


Ignore:
Timestamp:
2023-01-04T21:04:04+13:00 (3 weeks ago)
Author:
davidb
Message:

Addition clause/case added in to handle 'excerptid-text' CGI arg

File:
1 edited

Legend:

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

    r36169 r37098  
    343343        // if the user has specified they want only a part of the full page then subdivide it
    344344        boolean subdivide = false;
    345         String excerptID = null;
    346         String excerptTag = null;
     345        String excerptID     = null;
     346        String excerptIDText = null;
     347        String excerptTag    = null;
    347348        Element cgi_param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
     349
     350        // **** Now that the number of cases handled has risen to 3, the following would be worth refactoring ****
    348351        if (cgi_param_list != null)
    349352        {
     
    353356                subdivide = true;
    354357            }
     358            if ((excerptIDText = (String) params.get(GSParams.EXCERPT_ID_TEXT)) != null)
     359            {
     360                subdivide = true;
     361            }
    355362            if ((excerptTag = (String) params.get(GSParams.EXCERPT_TAG)) != null)
    356363            {
     
    361368        if (subdivide)
    362369        {
    363             Node subdivided_page = subdivide(transformed_page, excerptID, excerptTag);
     370                Node subdivided_page = subdivide(transformed_page, excerptID, excerptIDText, excerptTag);
    364371            if (subdivided_page != null)
    365372            {
     
    372379    }
    373380
    374     protected Node subdivide(Node transformed_page, String excerptID, String excerptTag)
     381        protected Node subdivide(Node transformed_page, String excerptID, String excerptIDText, String excerptTag)
    375382    {
    376383        if (excerptID != null)
     
    379386            modifyNodesByTagRecursive(selectedElement, "a");
    380387            return selectedElement;
     388        }
     389        if (excerptIDText != null)
     390        {
     391            Node selectedElement = getNodeByIdRecursive(transformed_page, excerptIDText);
     392
     393            String selectedTextString = selectedElement.getTextContent();
     394            Document forexcerptid_doc = XMLConverter.newDOM();
     395            Node selectedElementChildTextNode = forexcerptid_doc.createTextNode(selectedTextString);
     396
     397            return selectedElementChildTextNode;
    381398        }
    382399        else if (excerptTag != null)
Note: See TracChangeset for help on using the changeset viewer.