Browse Source

Use Drupal functions in XSLT to generate URLs.

Also, use imagecache_external!
pull/126/head
Adam Vessey 13 years ago
parent
commit
c1615e4875
  1. 10
      fedora_repository.module
  2. 4
      formClass.inc
  3. 28
      xsl/sparql_to_html.xsl

10
fedora_repository.module

@ -2458,3 +2458,13 @@ function fedora_repository_render_image($pid, $dsid, $imagecache_preset = 'fedor
return _fedora_repository_render_image($tn_path, $imagecache_preset); return _fedora_repository_render_image($tn_path, $imagecache_preset);
} }
/**
* Convenience function used in XSLT callback...
*
* @param $string string
* A string containing some markup to convert to a domnode.
*/
function fedora_repository_string_to_domnode($string) {
return DOMDocument::loadXML($string);
}

4
formClass.inc

@ -330,8 +330,8 @@ class formClass {
'#default_value' => variable_get('fedora_repository_use_imagecache_external_in_collection_view', FALSE), '#default_value' => variable_get('fedora_repository_use_imagecache_external_in_collection_view', FALSE),
'#description' => t('If enabled, the default collection list view (or ' . '#description' => t('If enabled, the default collection list view (or ' .
'anywhere the function "@function" is used) will try to use ' . 'anywhere the function "@function" is used) will try to use ' .
'imagecache_external, defaulting to the "@preset" preset. Note that ' . 'imagecache_external, defaulting to the "@preset" preset. XSLTs may ' .
'this means it will NOT (currently) work with collections rendered via "@xsl".', 'be updated to use this function.',
array( array(
'@function' => '_fedora_repository_render_image()', '@function' => '_fedora_repository_render_image()',
'@preset' => 'fedora_repository_collection_thumbnail', '@preset' => 'fedora_repository_collection_thumbnail',

28
xsl/sparql_to_html.xsl

@ -1,11 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:s="http://www.w3.org/2001/sw/DataAccess/rf1/result" version="1.0" xmlns:php="http://php.net/xsl" exclude-result-prefixes="php"> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:s="http://www.w3.org/2001/sw/DataAccess/rf1/result" version="1.0" xmlns:php="http://php.net/xsl" exclude-result-prefixes="php">
<!-- Red and White XSLT --> <!-- Red and White XSLT -->
<xsl:variable name="BASEURL" select="$baseUrl"/> <xsl:param name="BASEURL" select="$baseUrl"/>
<xsl:variable name="PATH" select="$path"/> <xsl:param name="PATH" select="$path"/>
<xsl:variable name="thisPid" select="$collectionPid"/> <xsl:param name="thisPid" select="$collectionPid"/>
<xsl:param name="page" select="$hitPage"/>
<xsl:param name="COLLECTION_TITLE" select="$collectionTitle"/>
<xsl:param name="imagecache_preset">fedora_repository_collection_thumbnail</xsl:param>
<xsl:variable name="size" select="20"/> <xsl:variable name="size" select="20"/>
<xsl:variable name="page" select="$hitPage"/>
<xsl:variable name="start" select="((number($page) - 1) * number($size)) + 1"/> <xsl:variable name="start" select="((number($page) - 1) * number($size)) + 1"/>
<xsl:variable name="end" select="($start - 1) + number($size)"/> <xsl:variable name="end" select="($start - 1) + number($size)"/>
<xsl:variable name="cellsPerRow" select="4"/> <xsl:variable name="cellsPerRow" select="4"/>
@ -42,7 +45,7 @@
<li class="pager-previous"> <li class="pager-previous">
<a> <a>
<xsl:attribute name="href"> <xsl:attribute name="href">
<xsl:value-of select="concat($BASEURL, '/fedora/repository/', $thisPid, '/-/Collection/', $page - 1)"/> <xsl:value-of select="php:functionString('url', concat('fedora/repository/', $thisPid, '/-/Collection/', $page - 1))"/>
</xsl:attribute> </xsl:attribute>
&lt;Prev &lt;Prev
</a> </a>
@ -53,7 +56,7 @@
<li class="pager-next"> <li class="pager-next">
<a> <a>
<xsl:attribute name="href"> <xsl:attribute name="href">
<xsl:value-of select="concat($BASEURL, '/fedora/repository/', $thisPid, '/-/Collection/', $page + 1)"/> <xsl:value-of select="php:functionString('url', concat('fedora/repository/', $thisPid, '/-/Collection/', $page + 1))"/>
</xsl:attribute> </xsl:attribute>
Next> Next>
</a> </a>
@ -64,7 +67,7 @@
<li class="pager-previous"> <li class="pager-previous">
<a> <a>
<xsl:attribute name="href"> <xsl:attribute name="href">
<xsl:value-of select="concat($BASEURL, '/fedora/repository/', $thisPid, '/-/Collection/', $page - 1)"/> <xsl:value-of select="php:functionString('url', concat('fedora/repository/', $thisPid, '/-/Collection/', $page - 1))"/>
</xsl:attribute> </xsl:attribute>
&lt;Prev &lt;Prev
</a>&#160; </a>&#160;
@ -72,7 +75,7 @@
<li class="pager-next"> <li class="pager-next">
<a> <a>
<xsl:attribute name="href"> <xsl:attribute name="href">
<xsl:value-of select="concat($BASEURL, '/fedora/repository/', $thisPid, '/-/Collection/', $page + 1)"/> <xsl:value-of select="php:functionString('url', concat('fedora/repository/', $thisPid, '/-/Collection/', $page + 1))"/>
</xsl:attribute> </xsl:attribute>
Next> Next>
</a> </a>
@ -101,12 +104,12 @@
<xsl:variable name="linkUrl"> <xsl:variable name="linkUrl">
<xsl:choose> <xsl:choose>
<xsl:when test="($CONTENTMODEL='islandora:collectionCModel')"> <xsl:when test="($CONTENTMODEL='islandora:collectionCModel')">
<xsl:value-of select="concat($BASEURL, '/fedora/repository/', $PID, '/-/collection')"/> <xsl:value-of select="php:functionString('url', concat('fedora/repository/', $PID, '/-/collection'))"/>
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
<!--the below is an example of going straight to a datastream instead of the details page. <!--the below is an example of going straight to a datastream instead of the details page.
<xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/>/OBJ/<xsl:value-of select="s:title"/>--> <xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/>/OBJ/<xsl:value-of select="s:title"/>-->
<xsl:value-of select="concat($BASEURL, '/fedora/repository/', $PID)"/> <xsl:value-of select="php:functionString('url', concat('fedora/repository/', $PID))"/>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
<xsl:value-of select="s:content"/> <xsl:value-of select="s:content"/>
@ -116,10 +119,11 @@
<xsl:attribute name="href"> <xsl:attribute name="href">
<xsl:value-of select="$linkUrl"/> <xsl:value-of select="$linkUrl"/>
</xsl:attribute> </xsl:attribute>
<img> <xsl:copy-of select="php:function('fedora_repository_string_to_domnode', php:functionString('fedora_repository_render_image', $PID, 'TN', $imagecache_preset))"/>
<!-- <img>
<xsl:attribute name="src"><xsl:value-of select="concat($BASEURL, '/fedora/repository/', $PID, '/TN')"/></xsl:attribute> <xsl:attribute name="src"><xsl:value-of select="concat($BASEURL, '/fedora/repository/', $PID, '/TN')"/></xsl:attribute>
<xsl:attribute name="alt"><xsl:value-of select="$newTitle" disable-output-escaping="yes"/></xsl:attribute> <xsl:attribute name="alt"><xsl:value-of select="$newTitle" disable-output-escaping="yes"/></xsl:attribute>
</img> </img> -->
</a><br clear="all" /> </a><br clear="all" />
<a> <a>
<xsl:attribute name="href"><xsl:value-of select="$linkUrl"/> <xsl:attribute name="href"><xsl:value-of select="$linkUrl"/>

Loading…
Cancel
Save