Changeset 36904


Ignore:
Timestamp:
2022-11-14T12:41:12+13:00 (3 weeks ago)
Author:
kjdon
Message:

some work for tk labels. now looks in site metadata folder for tk.mds if it can't find it in the collection. added choose-tklabels-single-field template - use this on instead of choose-tklabels when you have a comma separated list of tk labels in single field, rather than individual tk.xxx metadata fields. pass in the metadata field name that contains the csv as the label-metadata parameter

Location:
main/trunk/greenstone3/web/interfaces/default
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/web/interfaces/default/js/utility_scripts.js

    r36269 r36904  
    236236}
    237237
    238 function loadTKMetadataSet(lang) {
     238function loadTKMetadataSetOld(lang) {
    239239   tkMetadataSetStatus = "loading";
    240240   $.ajax({
     
    256256         tkMetadataSetStatus = "no-metadata-set-for-this-collection";
    257257         console.log("No TK Label Metadata-set found for this collection");
     258      }
     259   });
     260};
     261function loadTKMetadataSet(lang, type) {
     262   tkMetadataSetStatus = "loading";
     263   $.ajax({
     264       url: gs.variables["tkMetadataURL_"+type],
     265       async: false,
     266      success: function(xml) {
     267         tkMetadataSetStatus = "loaded";
     268         let parser = new DOMParser();
     269         let tkmds = parser.parseFromString(xml, "text/xml");
     270         tkMetadataElements = tkmds.querySelectorAll("Element");
     271         if (document.readyState === "complete") {
     272            addTKLabelsToImages(lang);
     273         } else {
     274            window.onload = function() {
     275               addTKLabelsToImages(lang);
     276            }
     277         }
     278      },
     279      error: function() {
     280         tkMetadataSetStatus = "no-metadata-set-for-this-"+type;
     281         console.log("No TK Label Metadata-set found for this "+type);
    258282      }
    259283   });
  • main/trunk/greenstone3/web/interfaces/default/transform/layouts/header.xsl

    r36268 r36904  
    721721  <xsl:template name="quick-search-area">
    722722
    723     <gsf:variable name="tkMetadataURL"><xsl:value-of select="$library_name"/>/sites/<xsl:value-of select="$site_name"/>/collect/<xsl:value-of select="$collNameChecked"/>/metadata/tk.mds</gsf:variable>
     723    <gsf:variable name="tkMetadataURL_collection"><xsl:value-of select="$library_name"/>/sites/<xsl:value-of select="$site_name"/>/collect/<xsl:value-of select="$collNameChecked"/>/metadata/tk.mds</gsf:variable>
     724    <gsf:variable name="tkMetadataURL_site"><xsl:value-of select="$library_name"/>/sites/<xsl:value-of select="$site_name"/>/metadata/tk.mds</gsf:variable>
    724725
    725726    <xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@type='query']">
     
    863864  </xsl:template>
    864865
    865 <xsl:template name="choose-tklabels">
    866     <script type="text/javascript">
    867             <xsl:text disable-output-escaping="yes">
    868                 $(document).ready(function() {
    869                     if (tkMetadataSetStatus == "needs-to-be-loaded") {
    870                         loadTKMetadataSet("</xsl:text><xsl:value-of select="$lang"/><xsl:text disable-output-escaping="yes">");
    871                     }
    872                 })
    873             </xsl:text>
    874         </script>
    875 
     866  <xsl:template name="js-for-loading-tk-metadata-set">
     867    <script type="text/javascript">
     868      <xsl:text disable-output-escaping="yes">
     869    $(document).ready(function() {
     870      if (tkMetadataSetStatus == "needs-to-be-loaded") {
     871        loadTKMetadataSet("</xsl:text><xsl:value-of select="$lang"/><xsl:text disable-output-escaping="yes">", "collection");
     872      }
     873          if (tkMetadataSetStatus == "no-metadata-set-for-this-collection") {
     874        loadTKMetadataSet("</xsl:text><xsl:value-of select="$lang"/><xsl:text disable-output-escaping="yes">", "site");
     875      }
     876    })
     877      </xsl:text>
     878    </script>
     879  </xsl:template>
     880 
     881  <xsl:template name="choose-tklabels-single-field">
     882    <xsl:param name="label-metadata">tk.Labels</xsl:param>
     883    <xsl:call-template name="js-for-loading-tk-metadata-set"/>
     884    <xsl:variable name="labels-csv"><xsl:value-of select="metadataList/metadata[@name=$label-metadata]"/></xsl:variable>
     885    <gsf:div class="tklabels">
     886      <xsl:if test="util:csvContains($labels-csv, 'tk.Attribution')">
     887        <gsf:icon file="tklabels/tk_a.png"/>
     888      </xsl:if>
     889      <xsl:if test="util:csvContains($labels-csv, 'tk.Clan')">
     890        <gsf:icon file="tklabels/tk_cl.png"/>
     891      </xsl:if>
     892      <xsl:if test="util:csvContains($labels-csv, 'tk.Family')">
     893        <gsf:icon file="tklabels/tk_f.png"/>
     894      </xsl:if>
     895      <xsl:if test="util:csvContains($labels-csv, 'tk.MultipleCommunities')">
     896        <gsf:icon file="tklabels/tk_mc.png"/>
     897      </xsl:if>
     898      <xsl:if test="util:csvContains($labels-csv, 'tk.CommunityVoice')">
     899        <gsf:icon file="tklabels/tk_cv.png"/>
     900      </xsl:if>
     901      <xsl:if test="util:csvContains($labels-csv, 'tk.Creative')">
     902        <gsf:icon file="tklabels/tk_cr.png"/>
     903      </xsl:if>
     904      <xsl:if test="util:csvContains($labels-csv, 'tk.Verified')">
     905        <gsf:icon file="tklabels/tk_v.png"/>
     906      </xsl:if>
     907      <xsl:if test="util:csvContains($labels-csv, 'tk.NonVerified')">
     908        <gsf:icon file="tklabels/tk_nv.png"/>
     909      </xsl:if>
     910      <xsl:if test="util:csvContains($labels-csv, 'tk.Seasonal')">
     911        <gsf:icon file="tklabels/tk_s.png"/>
     912      </xsl:if>
     913      <xsl:if test="util:csvContains($labels-csv, 'tk.WomenGeneral')">
     914        <gsf:icon file="tklabels/tk_wg.png"/>
     915      </xsl:if>
     916      <xsl:if test="util:csvContains($labels-csv, 'tk.MenGeneral')">
     917        <gsf:icon file="tklabels/tk_mg.png"/>
     918      </xsl:if>
     919      <xsl:if test="util:csvContains($labels-csv, 'tk.MenRestricted')">
     920        <gsf:icon file="tklabels/tk_mr.png"/>
     921      </xsl:if>
     922      <xsl:if test="util:csvContains($labels-csv, 'tk.WomenRestricted')">
     923        <gsf:icon file="tklabels/tk_wr.png"/>
     924      </xsl:if>
     925      <xsl:if test="util:csvContains($labels-csv, 'tk.CulturallySensitive')">
     926        <gsf:icon file="tklabels/tk_cs.png"/>
     927      </xsl:if>
     928      <xsl:if test="util:csvContains($labels-csv, 'tk.SecretSacred')">
     929        <gsf:icon file="tklabels/tk_ss.png"/>
     930      </xsl:if>
     931      <xsl:if test="util:csvContains($labels-csv, 'tk.OpenToCommercialization')">
     932        <gsf:icon file="tklabels/tk_oc.png"/>
     933      </xsl:if>
     934      <xsl:if test="util:csvContains($labels-csv, 'tk.nonCommercial')">
     935        <gsf:icon file="tklabels/tk_nc.png"/>
     936      </xsl:if>
     937      <xsl:if test="util:csvContains($labels-csv, 'tk.CommunityUseOnly')">
     938        <gsf:icon file="tklabels/tk_co.png"/>
     939      </xsl:if>
     940      <xsl:if test="util:csvContains($labels-csv, 'tk.Outreach')">
     941        <gsf:icon file="tklabels/tk_o.png"/>
     942      </xsl:if>
     943      <xsl:if test="util:csvContains($labels-csv, 'tk.OpenToCollaboration')">
     944        <gsf:icon file="tklabels/tk_cb.png"/>
     945      </xsl:if>
     946     
     947    </gsf:div>
     948  </xsl:template>
     949 
     950  <xsl:template name="choose-tklabels">
     951    <xsl:call-template name="js-for-loading-tk-metadata-set"/>
    876952    <gsf:div class="tklabels">
    877953        <gsf:switch>
Note: See TracChangeset for help on using the changeset viewer.