Ignore:
Timestamp:
2017-01-13T03:52:38+13:00 (7 years ago)
Author:
Georgiy Litvinov
Message:

XSLT part of hierarchy view in cross collection search

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/web/interfaces/default/transform/pages/query.xsl

    r30812 r31286  
    191191                    </input>
    192192                    <input type="hidden" name="rt" value="rd"/>
    193 
     193                   
    194194                    <xsl:variable name="ns">s1.</xsl:variable>
     195                    <xsl:choose>
     196                        <xsl:when test="/page/pageResponse/hierarchy">
     197                            <xsl:call-template name="hierarchy">
     198                                <xsl:with-param name="ns" select="$ns" />
     199                            </xsl:call-template>
     200                        </xsl:when>
     201                        <xsl:otherwise>
    195202                    <xsl:for-each select="paramList/param">
    196203                        <xsl:choose>
     
    207214                        </xsl:choose>
    208215                    </xsl:for-each>
     216                        </xsl:otherwise>
     217                    </xsl:choose>
    209218                    <br/>
    210219                    <input type="submit">
     
    216225            </form>
    217226        </xsl:for-each>
     227    </xsl:template>
     228
     229    <xsl:template name="hierarchy">
     230        <xsl:param name="ns" />
     231        <div class="paramLabel">
     232            <xsl:value-of
     233                select="paramList/param[@name='collection']/displayItem[@name='name']/text()" />
     234        </div>
     235        <div class="paramValue">
     236            <select multiple="" name="s1.collection" size='10'>
     237                <xsl:for-each select="/page/pageResponse/hierarchy/*">
     238                    <xsl:call-template name="hierarchy-display">
     239                        <xsl:with-param name="padding">
     240                            0
     241                        </xsl:with-param>
     242                    </xsl:call-template>
     243                </xsl:for-each>
     244            </select>
     245            <script type="text/javascript">
     246                <xsl:text disable-output-escaping="yes">
     247                function selectChildren(group) {
     248                var value = $(group).attr("value");
     249                var name = value.substring(5);
     250                $("option[class^='"+name+"']").prop({selected: true});
     251                }
     252            </xsl:text>
     253            </script>
     254        </div>
     255        <br class="clear" />
     256        <xsl:for-each select="paramList/param[@type='integer']">
     257            <xsl:call-template name="param-display">
     258                <xsl:with-param name="ns" select="$ns" />
     259            </xsl:call-template>
     260        </xsl:for-each>
     261        <xsl:for-each select="paramList/param[@type='string']">
     262            <xsl:call-template name="param-display">
     263                <xsl:with-param name="ns" select="$ns" />
     264            </xsl:call-template>
     265        </xsl:for-each>
     266    </xsl:template>
     267
     268    <xsl:template name="hierarchy-display">
     269        <xsl:param name="padding" />
     270        <xsl:param name="path" />
     271        <xsl:choose>
     272            <xsl:when test="name(.) = 'group'">
     273                <option>
     274                    <xsl:attribute name="style">
     275                            <xsl:text>padding-left: </xsl:text>
     276                            <xsl:value-of select="concat($padding,'px')" />
     277                        </xsl:attribute>
     278                    <xsl:attribute name="disabled">
     279                            <xsl:text>disabled</xsl:text>
     280                        </xsl:attribute>
     281                    <xsl:attribute name="value">
     282                            <xsl:text>group</xsl:text>
     283                            <xsl:value-of select="$path" />
     284                            <xsl:text>_</xsl:text>
     285                            <xsl:value-of select="@name" />
     286                        </xsl:attribute>
     287                    <xsl:attribute name="onclick">
     288                            <xsl:text>selectChildren(this)</xsl:text>
     289                        </xsl:attribute>
     290                    <xsl:value-of select="@title"></xsl:value-of>
     291                    <xsl:for-each select="./*">
     292                        <xsl:call-template name="hierarchy-display">
     293                            <xsl:with-param name="padding">
     294                                <xsl:value-of select="$padding + 20" />
     295                            </xsl:with-param>
     296                            <xsl:with-param name="path">
     297                                <xsl:value-of select="$path" />
     298                                <xsl:text>_</xsl:text>
     299                                <xsl:value-of select="../@name" />
     300                            </xsl:with-param>
     301                        </xsl:call-template>
     302                    </xsl:for-each>
     303                </option>
     304            </xsl:when>
     305            <xsl:otherwise>
     306                <option>
     307                    <xsl:attribute name="style">
     308                            <xsl:text>padding-left: </xsl:text>
     309                            <xsl:value-of select="$padding" />
     310                            <xsl:text>px</xsl:text>
     311                        </xsl:attribute>
     312                    <xsl:attribute name="class">
     313                            <xsl:value-of select="$path" />
     314                        </xsl:attribute>
     315                    <xsl:attribute name="value">
     316                        <xsl:value-of select="current()/@name"></xsl:value-of>
     317                    </xsl:attribute>
     318                    <xsl:value-of
     319                        select="/page/pageResponse/service[@name = 'TextQuery']/paramList/param[@name = 'collection']/option[@name = current()/@name]/displayItem[@name = 'name']/text()"></xsl:value-of>
     320                </option>
     321            </xsl:otherwise>
     322        </xsl:choose>
    218323    </xsl:template>
    219324
Note: See TracChangeset for help on using the changeset viewer.