Changeset 30542


Ignore:
Timestamp:
2016-05-18T11:41:49+12:00 (5 years ago)
Author:
Georgiy Litvinov
Message:

Added checkFileExistence method for xslt checks. Fixed invisible group button in case badly configured group description.

Location:
main/trunk/greenstone3
Files:
3 edited

Legend:

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

    r30477 r30542  
    554554        return new Locale(display_lang).getDisplayLanguage(new Locale(lang));
    555555    }
     556   
     557    public static boolean checkFileExistence(String site_name, String filePath){
     558
     559        String gsdl3_home = GlobalProperties.getGSDL3Home();
     560        //Remove leading file separator
     561        filePath = filePath.replaceAll("^/+", "");
     562        //Remove duplicates and replace by separator for current platform
     563        filePath = filePath.replaceAll("/+", File.separator);
     564        //Create full path to check
     565        String fullPath = GSFile.siteHome(gsdl3_home, site_name) + File.separator + filePath;
     566        File file = new File(fullPath);
     567        if (file.exists() && file.isFile()) {
     568            return true;
     569        }
     570        return false;
     571    }
     572   
    556573    public static String uriEncode(String input)
    557574    {
  • main/trunk/greenstone3/web/interfaces/default/transform/gslib.xsl

    r30540 r30542  
    204204    <xsl:variable name="desc"><xsl:value-of select="description"/></xsl:variable>
    205205    <xsl:variable name="group_href"><xsl:value-of select="$library_name"/>?a=p&amp;sa=home&amp;group=<xsl:value-of select="/page/pageRequest/paramList/param[@name='group']/@value"/>/<xsl:value-of select="@name"/></xsl:variable>
     206   
    206207    <xsl:choose>
    207       <xsl:when test="backgroundImage">
     208      <xsl:when test="util:checkFileExistence($site_name, backgroundImage)">
    208209        <a href="{$group_href}" title="{$desc}">
    209210          <img class="groupLinkImage">
    210211            <xsl:attribute name="alt"><xsl:value-of select="displayItem[@name='name']"/></xsl:attribute>
    211             <xsl:attribute name="src">sites/<xsl:value-of select="$site_name"/>/images/<xsl:value-of select="backgroundImage"/></xsl:attribute>
     212            <xsl:attribute name="src">sites/<xsl:value-of select="$site_name"/>/<xsl:value-of select="backgroundImage"/></xsl:attribute>
    212213          </img>
    213214        </a>
     
    217218          <div class="groupLink ui-corner-all">
    218219            <div class="groupLinkText ui-widget-content ui-corner-top">
    219                 <xsl:value-of select="title"/>
     220                <xsl:choose>
     221                    <xsl:when test="boolean(title)">
     222                        <xsl:value-of select="title"/>
     223                    </xsl:when>
     224                    <xsl:otherwise>
     225                        <xsl:value-of select="@name"/>
     226                    </xsl:otherwise>
     227                </xsl:choose>
    220228            </div>
    221229            <div style="height:15px;" class="ui-state-default ui-corner-bottom"><xsl:text> </xsl:text></div>
  • main/trunk/greenstone3/web/sites/localsite/groupConfig.xml

    r30540 r30542  
    11<?xml version="1.0" encoding="UTF-8"?>
    2 
     2<!-- Collection groups configuration file
     3        Uncomment hierarchy and groupDescription elements to make collection groups work.
     4    Describe your structure inside hiearchy tag as shown in example below.
     5    Describe your groups in groupDescriptions element as shown below.
     6    Without group tag with @name in groupDescriptions group will be invisible(but available).
     7    If your collection not described in hierarchy element it will be visible after described
     8    groups and collections at home page.
     9        First level - home page
     10            Second level - inside first group
     11                Third level - inside second group
     12                   
     13    -->
    314<groupConfig>
    4        
     15    <!--
    516    <hierarchy>
    6 <!--   
    717        <group name="group2">
    818            <collection name="solr-jdbm-demo" />
    9 
    1019        </group>
    1120        <group name="group1">
    12            
    1321            <group name="group3">
    1422                <collection name="solr-jdbm-demo" />
     
    1624                    <collection name="solr-jdbm-demo" />
    1725                    <group name="group1">
    18 
    1926                    </group>
    2027                </group>
    2128            </group>
    2229        </group>
    23         <collection name="test-webeditor" />
    24 -->
     30        <collection name="lucene-jdbm-demo" />
    2531    </hierarchy>
    2632    <groupDescriptions>
    27 <!--   
    2833        <group name="group1">
    29             <title>Group of collections</title>
    30             <description>some description</description>
    31             <shortDescription>Short description</shortDescription>
    32            
    3334        </group>
    3435        <group name="group2">
    35             <title>Group 2 of collections</title>
    36             <description>second full description</description>
    37             <shortDescription>second short description</shortDescription>
     36            <title>Group 2 title</title>
     37            <description>Second group full description example</description>
     38            <shortDescription>Second group short description example</shortDescription>
    3839           
    3940        </group>
    4041        <group name="group3">
    41             <title>Group 3 of collections</title>
    42             <description>3 full description</description>
    43             <shortDescription>3 short description</shortDescription>
    44             <backgroundImage>Group3.jpg</backgroundImage>
     42            <title>Group 3 title</title>
     43            <description>Group 3 full description example </description>
     44            <shortDescription>Group 3 short description example</shortDescription>
     45            <backgroundImage>/images/Group3.jpg</backgroundImage>
    4546        </group>
    46 -->
    4747    </groupDescriptions>
     48    -->
    4849</groupConfig>
Note: See TracChangeset for help on using the changeset viewer.