Changeset 24219

Show
Ignore:
Timestamp:
01.07.2011 21:05:19 (8 years ago)
Author:
ak19
Message:

Thanks to Sam, Veronica and Dr Bainbridge, can finally commit the changes necessary for ticket 449.

Location:
main/trunk
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/plugins/BasePlugin.pm

    r23832 r24219  
    13001300        my ($pre_doc_ext) = ($file_extended_ext =~ m/^(.*)\..*$/); 
    13011301        my ($doc_ext) = ($tail_filename =~ m/^.*\.(.*)$/); 
    1302         my $start_doclink = "<a href=\"_httpprefix_/collect/[collection]/index/assoc/{Or}{[parent(Top):assocfilepath],[assocfilepath]}/$url_tail_filename\">"; 
     1302 
     1303##      my $start_doclink = "<a href=\"_httpprefix_/collect/[collection]/index/assoc/{Or}{[parent(Top):assocfilepath],[assocfilepath]}/$url_tail_filename\">"; 
     1304        my $start_doclink = "<a href=\'_httpprefix_/collect/[collection]/index/assoc/[assocfilepath]/$url_tail_filename\'>"; 
     1305        my $start_doclink_gs3 = "<a href=\'_httpprefix_/collect/[collection]/index/assoc/[assocfilepath]/$url_tail_filename\'>"; 
     1306 
    13031307        my $srcicon = "_icon".$doc_ext."_"; 
    13041308        my $end_doclink = "</a>"; 
    1305  
     1309         
    13061310        my $assoc_form = "$start_doclink\{If\}{$srcicon,$srcicon,$doc_ext\}$end_doclink"; 
     1311 
     1312        $doc_obj->add_utf8_metadata ($cursection, "equivDocLink", $start_doclink); 
     1313        $doc_obj->add_utf8_metadata ($cursection, "equivDocIcon", $srcicon); 
     1314        $doc_obj->add_utf8_metadata ($cursection, "/equivDocLink", $end_doclink); 
    13071315 
    13081316        if (defined $pre_doc_ext && $pre_doc_ext ne "") { 
     
    13131321        # for multiple metadata such as [mp3.assoclink] 
    13141322        $doc_obj->add_utf8_metadata ($cursection, "$doc_ext.assoclink", $assoc_form);  
    1315          
     1323 
    13161324        $equiv_form .= " $assoc_form";   
    13171325        } 
  • main/trunk/greenstone2/perllib/plugins/DSpacePlugin.pm

    r23561 r24219  
    323323 
    324324    my @gsdlassocfile_tobe  
    325         = map { &util::filename_cat($dir,$_->{'file'}).":".$_->{'mimetype'}.":" } @$assoc_file_mimes; 
     325        = map { &util::filename_cat($dir,$_->{'file'}) .":".$_->{'mimetype'}.":" } @$assoc_file_mimes if @$assoc_file_mimes; 
    326326    $self->{'saved_metadata'}->{'gsdlassocfile_tobe'} = \@gsdlassocfile_tobe; 
    327327 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/Action.java

    r24198 r24219  
    105105            meta_names.add(metadata.toString()); 
    106106        } 
    107  
    108         // The XSL tranform for 
    109         //   gsf:link type="source"  
    110         // makes use of 'assocfilepath' so need to make sure it's asked for 
    111  
    112         NodeList link_nodes = format.getElementsByTagName("gsf:link"); 
    113             for (int i=0; i<link_nodes.getLength(); i++) { 
    114                 Element elem = (Element)link_nodes.item(i); 
    115                 String type = elem.getAttribute("type"); 
    116             if (type.equals("source") || type.equals("sourcelinkfile")) { 
    117             meta_names.add("assocfilepath"); 
    118             } 
    119         } 
    120  
     107     
     108    // The XSL tranform for 
     109    //   gsf:link type="source"  
     110    // makes use of 'assocfilepath' so need to make sure it's asked for 
     111     
     112    NodeList link_nodes = format.getElementsByTagName("gsf:link"); 
     113    for (int i=0; i<link_nodes.getLength(); i++) { 
     114        Element elem = (Element)link_nodes.item(i); 
     115        String type = elem.getAttribute("type"); 
     116        if (type.equals("source")) { 
     117        meta_names.add("assocfilepath"); 
     118        } else if (type.equals("sourcelinkfile")) { 
     119        meta_names.add("assocfilepath"); 
     120        //meta_names.add("srclinkFile"); 
     121        } 
     122    } 
     123 
     124 
     125    // get all the metadata necessary for when the user has used "gsf:equivlink" 
     126    // so that we can build up the equivlink from the metadata components it needs 
     127    link_nodes = format.getElementsByTagName("gsf:equivlinkgs3");  
     128    if(link_nodes != null) {       
     129 
     130        String[] equivlink_metanames = {"equivDocIcon", "equivDocLink", "/equivDocLink"}; 
     131 
     132        for(int i = 0; i < equivlink_metanames.length; i++) { 
     133        StringBuffer metadata = new StringBuffer(); 
     134        metadata.append("all"); // this means the attr multiple = true; 
     135        metadata.append(GSConstants.META_RELATION_SEP); 
     136         
     137        metadata.append(GSConstants.META_SEPARATOR_SEP); 
     138        metadata.append(','); // attr separator = "," 
     139        metadata.append(GSConstants.META_SEPARATOR_SEP); 
     140        metadata.append(GSConstants.META_RELATION_SEP); 
     141         
     142        // the name of the metadata we're retrieving 
     143        metadata.append(equivlink_metanames[i]); 
     144        meta_names.add(metadata.toString()); 
     145        } 
     146    } 
    121147    } 
    122148 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/XSLTUtil.java

    r24117 r24219  
    9797    } 
    9898 
     99    /** Generates links to equivalent documents for a document with a default document icon/type.  
     100     * Links are generated from the parameters: a list of document icons which are each in turn embedded  
     101     * in the matching starting link tag in the list of docStartLinks (these starting links link to the  
     102     * equivalent documents in another format). Each link's start tag is closed with the corresponding  
     103     * closing tag in the docEndLinks list. Parameter token is the list separator. Parameter divider is  
     104     * the string that should separate each final link generated from the next. 
     105     * Returns a string that represents a sequence of links to equivalent documents, where the anchor is 
     106     * a document icon. */ 
     107    public static String getEquivDocLinks(String token, String docIconsString, String docStartLinksString,  
     108                      String docEndLinksString, String divider) 
     109    { 
     110    String [] docIcons = StringUtils.split(docIconsString, token, -1); 
     111    String [] startLinks = StringUtils.split(docStartLinksString, token, -1); 
     112    String [] endLinks = StringUtils.split(docEndLinksString, token, -1); 
     113 
     114    StringBuffer buffer = new StringBuffer(); 
     115    for(int i = 0; i < docIcons.length; i++) { 
     116        if(i > 0) { 
     117        buffer.append(divider); 
     118        } 
     119        buffer.append(startLinks[i]+docIcons[i]+endLinks[i]); 
     120    } 
     121     
     122    return buffer.toString(); 
     123    } 
     124 
    99125     
    100126    public static String tidyWhitespace(String original) { 
  • main/trunk/greenstone3/web/interfaces/default/transform/config_format.xsl

    r24198 r24219  
    7777    </xsl:choose> 
    7878  </xsl:template> 
    79    
     79 
     80  <!-- calls a template in icons.xsl in order to avoid xsl vs xslt issue --> 
     81  <xsl:template match="gsf:equivlinkgs3"> 
     82    <xslt:call-template name="equivDocLinks"> 
     83      <xslt:with-param name="count" select="0"/> 
     84    </xslt:call-template> 
     85  </xsl:template> 
     86 
     87  <!-- Another way: build all the equivalent document links for the current document in one go. No looping necessary: handled in function call. --> 
     88  <!--<xsl:template match="gsf:equivlinkgs3"> 
     89    <xslt:variable name="docicon" select="metadataList/metadata[contains(@name, 'equivDocIcon')]"/>  
     90    <xslt:variable name="docStartlink" select="metadataList/metadata[contains(@name, 'all_*,*_equivDocLink')]"/>     
     91    <xslt:variable name="docEndlink" select="metadataList/metadata[contains(@name, '/equivDocLink')]"/> 
     92 
     93    <xslt:variable name="equivDocLinks" select="java:org.greenstone.gsdl3.util.XSLTUtil.getEquivDocLinks(',',$docicon, $docStartlink, $docEndlink, ' ')" /> 
     94    <xslt:value-of disable-output-escaping="yes" select="$equivDocLinks"/> 
     95  </xsl:template>--> 
     96 
     97<!-- 
     98In the collection's format statement, could have the following javascript+XSLT in place of 
     99the gsf:equivlinkgs3 element (which resolves to the XSLT in config_format.xsl and icons.xsl). 
     100<xsl:text disable-output-escaping="yes">&lt;script&gt;var equivDocIcon= [ &quot; 
     101</xsl:text> 
     102<gsf:metadata name="equivDocIcon" separator="&quot;, &quot;" multiple="true"/> 
     103<xsl:text disable-output-escaping="yes">&quot;];var equivDocStartLink= [ &quot; 
     104</xsl:text> 
     105<gsf:metadata name="equivDocLink" separator="&quot;,&quot;" multiple="true"/> 
     106<xsl:text disable-output-escaping="yes">&quot;];var equivDocEndLink= [ &quot; 
     107</xsl:text> 
     108<gsf:metadata name="/equivDocLink" separator="&quot;,&quot;" multiple="true"/> 
     109<xsl:text disable-output-escaping="yes">&quot;];for (var i=0; i&lt;equivDocIcon.length; i++) { document.write(equivDocStartLink[i]+ equivDocIcon[i] + equivDocEndLink[i]); }&lt;/script&gt; 
     110</xsl:text> 
     111--> 
     112 
    80113  <xsl:template match="gsf:metadata[@format]"> 
    81114    <xslt:value-of disable-output-escaping="yes"><xsl:attribute name="select">java:org.greenstone.gsdl3.util.XSLTUtil.<xsl:value-of select="@format"/>(metadataList/metadata[@name='<xsl:apply-templates select="." mode="get-metadata-name"/>'], /page/@lang )</xsl:attribute></xslt:value-of> 
  • main/trunk/greenstone3/web/interfaces/default/transform/icons.xsl

    r23972 r24219  
    119119  </xsl:template> 
    120120 
     121  <!-- builds up links to available document types equivalent to the default source 
     122       document with as anchor the equivalent documents' doctype icons. --> 
     123  <xsl:template name="equivDocLinks"> 
     124    <xsl:param name="count"/> 
     125 
     126      <xsl:variable name="docicon" select="metadataList/metadata[contains(@name, 'equivDocIcon')]"/>     
     127      <xsl:variable name="docStartlink" select="metadataList/metadata[contains(@name, 'all_*,*_equivDocLink')]"/>    
     128      <xsl:variable name="docEndlink" select="metadataList/metadata[contains(@name, '/equivDocLink')]"/> 
     129 
     130      <xsl:variable name="equivDocIcon" select="java:org.greenstone.gsdl3.util.XSLTUtil.getNumberedItem($docicon, $count)" /> 
     131      <xsl:variable name="equivStartlink" select="java:org.greenstone.gsdl3.util.XSLTUtil.getNumberedItem($docStartlink, $count)" /> 
     132      <xsl:variable name="equivEndlink" select="java:org.greenstone.gsdl3.util.XSLTUtil.getNumberedItem($docEndlink, $count)" /> 
     133 
     134      <xsl:if test="$equivDocIcon != ''"> 
     135        <xsl:value-of disable-output-escaping="yes" select="$equivStartlink"/> 
     136        <xsl:value-of disable-output-escaping="yes" select="$equivDocIcon"/> 
     137        <xsl:value-of disable-output-escaping="yes" select="$equivEndlink"/> 
     138 
     139        <!-- recursively call this template to get multiple entries --> 
     140        <xsl:call-template name="equivDocLinks"> 
     141          <xsl:with-param name="count"><xsl:value-of select="$count + 1"/></xsl:with-param> 
     142        </xsl:call-template> 
     143      </xsl:if> 
     144 
     145  </xsl:template> 
     146 
    121147</xsl:stylesheet> 
    122148