Skip to content

Instantly share code, notes, and snippets.

@aschweer
Created May 10, 2012 21:30
Show Gist options
  • Save aschweer/2656032 to your computer and use it in GitHub Desktop.
Save aschweer/2656032 to your computer and use it in GitHub Desktop.
Rendering the front page search above the community list, DSpace home page
<?xml version="1.0" encoding="UTF-8"?>
<!--
The contents of this file are subject to the license and copyright
detailed in the LICENSE and NOTICE files at the root of the source
tree and available online at
http://www.dspace.org/license/
-->
<!--
TODO: Describe this XSL file
Author: Alexey Maslov
-->
<xsl:stylesheet xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
xmlns:dri="http://di.tamu.edu/DRI/1.0/"
xmlns:mets="http://www.loc.gov/METS/"
xmlns:xlink="http://www.w3.org/TR/xlink/"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:dim="http://www.dspace.org/xmlns/dspace/dim"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:mods="http://www.loc.gov/mods/v3"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="i18n dri mets xlink xsl dim xhtml mods dc">
<xsl:import href="../dri2xhtml-alt/dri2xhtml.xsl"/>
<xsl:import href="lib/xsl/core/global-variables.xsl"/>
<xsl:import href="lib/xsl/core/page-structure.xsl"/>
<xsl:import href="lib/xsl/core/navigation.xsl"/>
<xsl:import href="lib/xsl/core/elements.xsl"/>
<xsl:import href="lib/xsl/core/forms.xsl"/>
<xsl:import href="lib/xsl/core/attribute-handlers.xsl"/>
<xsl:import href="lib/xsl/core/utils.xsl"/>
<xsl:import href="lib/xsl/aspect/general/choice-authority-control.xsl"/>
<xsl:import href="lib/xsl/aspect/administrative/administrative.xsl"/>
<xsl:import href="lib/xsl/aspect/artifactbrowser/item-list.xsl"/>
<xsl:import href="lib/xsl/aspect/artifactbrowser/item-view.xsl"/>
<xsl:import href="lib/xsl/aspect/artifactbrowser/community-list.xsl"/>
<xsl:import href="lib/xsl/aspect/artifactbrowser/collection-list.xsl"/>
<xsl:output indent="yes"/>
<!-- this is called when the front page is put together. intercept the call for normal rendering of community browser that has a front page search sibling (need to match on the sibling or this will break the separate community list page) -->
<xsl:template match="dri:div[@id='aspect.artifactbrowser.CommunityBrowser.div.comunity-browser'][../dri:div[@id='aspect.discovery.SiteViewer.div.front-page-search']]">
<!-- render front page search first -->
<xsl:apply-templates select="../dri:div[@id='aspect.discovery.SiteViewer.div.front-page-search']" mode="do-render"/>
<!-- then render community list - the mode is used to call the real template -->
<xsl:apply-templates select="." mode="do-render"/>
</xsl:template>
<!-- remove the original front page search box -->
<xsl:template match="dri:div[@id='aspect.discovery.SiteViewer.div.front-page-search']">
<!-- do nothing unless we're in "do-render" mode (to avoid duplicates) -->
</xsl:template>
<!-- put the front page search back in - copied from lib/xsl/core/elements.xsl in dri2html-alt theme -->
<xsl:template match="dri:div[@id='aspect.discovery.SiteViewer.div.front-page-search']" mode="do-render">
<xsl:apply-templates select="dri:head"/>
<xsl:apply-templates select="@pagination">
<xsl:with-param name="position">top</xsl:with-param>
</xsl:apply-templates>
<form>
<xsl:call-template name="standardAttributes">
<xsl:with-param name="class">ds-interactive-div</xsl:with-param>
</xsl:call-template>
<xsl:attribute name="action"><xsl:value-of select="@action"/></xsl:attribute>
<xsl:attribute name="method"><xsl:value-of select="@method"/></xsl:attribute>
<xsl:if test="@method='multipart'">
<xsl:attribute name="method">post</xsl:attribute>
<xsl:attribute name="enctype">multipart/form-data</xsl:attribute>
</xsl:if>
<xsl:attribute name="onsubmit">javascript:tSubmit(this);</xsl:attribute>
<!--For Item Submission process, disable ability to submit a form by pressing 'Enter'-->
<xsl:if test="starts-with(@n,'submit')">
<xsl:attribute name="onkeydown">javascript:return disableEnterKey(event);</xsl:attribute>
</xsl:if>
<xsl:apply-templates select="*[not(name()='head')]"/>
</form>
<!-- JS to scroll form to DIV parent of "Add" button if jump-to -->
<xsl:if test="/dri:document/dri:meta/dri:pageMeta/dri:metadata[@element='page'][@qualifier='jumpTo']">
<script type="text/javascript">
<xsl:text>var button = document.getElementById('</xsl:text>
<xsl:value-of select="translate(@id,'.','_')"/>
<xsl:text>').elements['</xsl:text>
<xsl:value-of select="concat('submit_',/dri:document/dri:meta/dri:pageMeta/dri:metadata[@element='page'][@qualifier='jumpTo'],'_add')"/>
<xsl:text>'];</xsl:text>
<xsl:text>
if (button != null) {
var n = button.parentNode;
for (; n != null; n = n.parentNode) {
if (n.tagName == 'DIV') {
n.scrollIntoView(false);
break;
}
}
}
</xsl:text>
</script>
</xsl:if>
<xsl:apply-templates select="@pagination">
<xsl:with-param name="position">bottom</xsl:with-param>
</xsl:apply-templates>
</xsl:template>
<!-- put the community list back in - copied from lib/xsl/core/elements.xsl in dri2html-alt theme -->
<xsl:template match="dri:div[@id='aspect.artifactbrowser.CommunityBrowser.div.comunity-browser']" mode="do-render">
<xsl:apply-templates select="dri:head"/>
<xsl:apply-templates select="@pagination">
<xsl:with-param name="position">top</xsl:with-param>
</xsl:apply-templates>
<div>
<xsl:call-template name="standardAttributes">
<xsl:with-param name="class">ds-static-div</xsl:with-param>
</xsl:call-template>
<xsl:choose>
<!-- does this element have any children -->
<xsl:when test="child::node()">
<xsl:apply-templates select="*[not(name()='head')]"/>
</xsl:when>
<!-- if no children are found we add a space to eliminate self closing tags -->
<xsl:otherwise>
&#160;
</xsl:otherwise>
</xsl:choose>
</div>
<xsl:apply-templates select="@pagination">
<xsl:with-param name="position">bottom</xsl:with-param>
</xsl:apply-templates>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment