Uploaded image for project: 'Multimedia gallery'
  1. Multimedia gallery
  2. GALL-38

[Audio gallery] Impossible to click on track link when the track description is multiline.

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 1.2
    • None
    • None

      It is impossible to click on track link to change track when the track description is multiline.

      I have made a change in a project in order to make this work :

      Instead of

      <a href="#" onclick="playAudio (this, '{$playListId}', '{$audioUrl}', '{$info-id}', '{file-description}'); return false;">
      

      I put

      <xsl:variable name="description">
          <xsl:call-template name="replace-string">
      	<xsl:with-param name="str" select="file-description"/>
      	<xsl:with-param name="strToReplace" select="'&#10;'"/>
      	<xsl:with-param name="newStr" select="' '"/>
          </xsl:call-template>
      </xsl:variable>
      <a href="#" onclick="playAudio (this, '{$playListId}', '{$audioUrl}', '{$info-id}', '{$description}'); return false;">
      

      With this template to replace strings :

      <xsl:template name="replace-string">
      	<xsl:param name="str" />
      	<xsl:param name="strToReplace" />
      	<xsl:param name="newStr" />
      
      	<xsl:if test="string-length(substring-before($str,$strToReplace)) =0">
      		<xsl:value-of select="$str" />
      	</xsl:if>
      	<xsl:if test="string-length(substring-before($str,$strToReplace)) > 0">
      		<xsl:value-of select="substring-before($str,$strToReplace)" />
      		<xsl:value-of select="$newStr" />
      	</xsl:if>
      
      	<xsl:if test="string-length(substring-after($str,$strToReplace)) > 0">
      		<xsl:call-template name="replace-string">
      			<xsl:with-param name="str" select="substring-after($str,$strToReplace)" />
      			<xsl:with-param name="strToReplace" select="$strToReplace" />
      			<xsl:with-param name="newStr" select="$newStr" />
      		</xsl:call-template>
      	</xsl:if>
      </xsl:template>
      

          [GALL-38] [Audio gallery] Impossible to click on track link when the track description is multiline.

          Laurence Aumeunier added a comment - - edited

          It is because of the ' in filename /Will%20I%20Am%20-%20%20It's%20a%20New%20Day.mp3.
          https://issues.ametys.org/browse/GALL-41

          Laurence Aumeunier added a comment - - edited It is because of the ' in filename /Will%20I%20Am%20-%20%20It's%20a%20New%20Day.mp3 . https://issues.ametys.org/browse/GALL-41

          Does not work in version 1.2 with cms 3.2

          "missing ) after argument list
          -> playAudio (this, 'clips-N10003', '/cms...', 'Sur pl<br/>usieurs<br/><br/>lignes"

          In the js :
          onclick="playAudio (this, 'clips-N10003', '/cms/preview/www/_contents/ametys%253Asites/www/ametys-internal%253Acontents/audio-galerie-audio/_metadata/files/1/file/Will%20I%20Am%20-%20%20It's%20a%20New%20Day.mp3?', 'info-N10003', 'Sur pl<br/>usieurs<br/><br/>lignes'); return false;"

          Jonathan Wendlinger added a comment - Does not work in version 1.2 with cms 3.2 "missing ) after argument list -> playAudio (this, 'clips-N10003', '/cms...', 'Sur pl<br/>usieurs<br/><br/>lignes" In the js : onclick="playAudio (this, 'clips-N10003', '/cms/preview/www/_contents/ametys%253Asites/www/ametys-internal%253Acontents/audio-galerie-audio/_metadata/files/1/file/Will%20I%20Am%20-%20%20It's%20a%20New%20Day.mp3?', 'info-N10003', 'Sur pl<br/>usieurs<br/><br/>lignes'); return false;"

          Laurence Aumeunier added a comment - - edited

          How to use :

          • in JS argument :
            <xsl:variable name="description">
            	<xsl:call-template name="replaceBrForJS">
            	      <xsl:with-param name="str" select="file-description"/>
            	</xsl:call-template>
            </xsl:variable>
            							
            <a href="#" onclick="playAudio (this, '{$playListId}', '{$audioUrl}', '{$info-id}', '{$description}'); return false">Link</a>
            
          • In HTML :
            <div id="{$info-id}" class="audio_info">
            	<xsl:call-template name="replaceBr">
            		<xsl:with-param name="str" select="metadata/files/entry[1]/file-description"/>
            	</xsl:call-template>
            </div>
            

          Laurence Aumeunier added a comment - - edited How to use : in JS argument : < xsl:variable name= "description" > < xsl:call-template name= "replaceBrForJS" > < xsl:with-param name= "str" select= "file-description" /> </ xsl:call-template > </ xsl:variable > <a href= "#" onclick= "playAudio (this, '{$playListId}' , '{$audioUrl}' , '{$info-id}' , '{$description}' ); return false" > Link </a> In HTML : <div id= "{$info-id}" class= "audio_info" > < xsl:call-template name= "replaceBr" > < xsl:with-param name= "str" select= "metadata/files/entry[1]/file-description" /> </ xsl:call-template > </div>

          Laurence Aumeunier added a comment - - edited

          Be careful ! Your patch does not work with a sequence of two breaklines.

          To replace by <br/> instead of space " ", you can use :

          • to be call in JS function argument
            <xsl:template name="replaceBrForJS">
            		<xsl:param name="str" />
            	
            		<xsl:if test="string-length(substring-before($str, '&#10;')) = 0 and not(starts-with($str, '&#10;'))">
            			<xsl:value-of select="$str" />
            		</xsl:if>
            		
                            <xsl:choose>
            			<xsl:when test="starts-with($str, '&#10;')"> 
            			        <xsl:text>&lt;br/&gt;</xsl:text>
            			</xsl:when>
            			<xsl:when test="string-length(substring-before($str, '&#10;')) > 0">
            				<xsl:value-of select="substring-before($str, '&#10;')" />
            				<xsl:text>&lt;br/&gt;</xsl:text>
            			</xsl:when>
            		</xsl:choose>
            	
            		<xsl:if test="string-length(substring-after($str, '&#10;')) > 0">
            			<xsl:call-template name="replaceBrForJS">
            				<xsl:with-param name="str" select="substring-after($str, '&#10;')" />
            			</xsl:call-template>
            		</xsl:if>
            	</xsl:template>
            
          • to be display directly in HTML :
          <xsl:template name="replaceBr">
          		<xsl:param name="str" />
          	
          		<xsl:if test="string-length(substring-before($str, '&#10;')) = 0 and not(starts-with($str, '&#10;'))">
          			<xsl:value-of select="$str" />
          		</xsl:if>
          		
          		<xsl:choose>
          			<xsl:when test="starts-with($str, '&#10;')"> 
          				<br/>
          			</xsl:when>
          			<xsl:when test="string-length(substring-before($str, '&#10;')) > 0">
          				<xsl:value-of select="substring-before($str, '&#10;')" />
          				<br/>
          			</xsl:when>
          		</xsl:choose>
          	
          		<xsl:if test="string-length(substring-after($str, '&#10;')) > 0">
          			<xsl:call-template name="replaceBr">
          				<xsl:with-param name="str" select="substring-after($str, '&#10;')" />
          			</xsl:call-template>
          		</xsl:if>
          	</xsl:template>
          

          Laurence Aumeunier added a comment - - edited Be careful ! Your patch does not work with a sequence of two breaklines. To replace by <br/> instead of space " ", you can use : to be call in JS function argument < xsl:template name= "replaceBrForJS" > < xsl:param name= "str" /> < xsl:if test= "string-length(substring-before($str, '&#10;' )) = 0 and not(starts-with($str, '&#10;' ))" > < xsl:value-of select= "$str" /> </ xsl:if > < xsl:choose > < xsl:when test= "starts-with($str, '&#10;' )" > < xsl:text > &lt;br/&gt; </ xsl:text > </ xsl:when > < xsl:when test= "string-length(substring-before($str, '&#10;' )) > 0" > < xsl:value-of select= "substring-before($str, '&#10;' )" /> < xsl:text > &lt;br/&gt; </ xsl:text > </ xsl:when > </ xsl:choose > < xsl:if test= "string-length(substring-after($str, '&#10;' )) > 0" > < xsl:call-template name= "replaceBrForJS" > < xsl:with-param name= "str" select= "substring-after($str, '&#10;' )" /> </ xsl:call-template > </ xsl:if > </ xsl:template > to be display directly in HTML : < xsl:template name= "replaceBr" > < xsl:param name= "str" /> < xsl:if test= "string-length(substring-before($str, '&#10;' )) = 0 and not(starts-with($str, '&#10;' ))" > < xsl:value-of select= "$str" /> </ xsl:if > < xsl:choose > < xsl:when test= "starts-with($str, '&#10;' )" > <br/> </ xsl:when > < xsl:when test= "string-length(substring-before($str, '&#10;' )) > 0" > < xsl:value-of select= "substring-before($str, '&#10;' )" /> <br/> </ xsl:when > </ xsl:choose > < xsl:if test= "string-length(substring-after($str, '&#10;' )) > 0" > < xsl:call-template name= "replaceBr" > < xsl:with-param name= "str" select= "substring-after($str, '&#10;' )" /> </ xsl:call-template > </ xsl:if > </ xsl:template >

            Unassigned Unassigned
            jonathan Jonathan Wendlinger
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: