Graphics migration manual for versions 1.1.x, 1.2.x and 1.3.x to 2.0.0


This chapter covers graphics migration (content rendering, services) specific toODF.
Depending on the version of CMS you're migrating, you'll first need to follow the general instructions at CMS on the following pages:
- Graphics migration 3.2.x to 3.3.x
- Graphics migration 3.3.x to 3.4.x
- Graphics migration 3.4.x to 3.5.x

  1. Data format XML Inputs for content
    1. Displaying a single field
    2. Display a rich field
  2. Modifying the data model
    1. New fields
    2. Deleted fields
    3. universalAdjustment" metadata
    4. Multiple attachments
    5. Training location(s)
  3. Links to objects ODF
    1. Link to a training course (e.g. "List of training courses" service)
    2. Link to a route
    3. Links to an ELP

Data format XML Inputs for content

In 1.1.x, 1.2.x, 1.3.x a synchronizable field was saxed as a triplet: the non-synchronized value (metadataName), the synchronized value (metadataName_remote) and the value indicating whether the field is synchronized or not, i.e. which value to display (metadataName_sync) :

XML input in 1.1.x, 1.2.x and 1.3.x

<metadata>
     <title>Licence de mathématiques</title>
 	 <title_remote>LICENCE MATHS</title>
	 <title_sync>false</title_sync>
 	 <duration_remote>3 ans</duration>
	 <duration_sync>true</duration_sync>
</metadata>

In 2.0.x, only the value to be displayed (depending on whether the field is synchronized or not) is available as input, which will simplify XSL rendering.

XML entry in 2.0.x

<metadata>
     <title>Licence de mathématiques</title>
 	 <duration>3 ans</duration>
</metadata>

Displaying a single field

The template get-metadata-value is no longer necessary and has been removed. Now use directly <xsl:value-of select="metadata/metadataName">.

For example:

Simple field display in 1.1.x, 1.2.x and 1.3.x

<xsl:if test="metadata/duration or metadata/duration_remote">
	<p class="duration">
    	<span class="element-name">
        	<i18n:text i18n:catalogue="plugin.odf" i18n:key="CONTENT_PROGRAM_DURATION"/>
        </span>
        <xsl:text> </xsl:text>
        <span class="element-value">                    
        	<xsl:call-template name="get-metadata-value">
				<xsl:with-param name="metadataName" select="'duration'"/>
			</xsl:call-template>
        </span>
	</p>            
</xsl:if>

becomes

Displaying a single field in 2.0.x

<xsl:if test="normalize-space(metadata/duration) != ''">
	<p class="duration">
    	<span class="element-name">
        	<i18n:text i18n:catalogue="plugin.odf" i18n:key="CONTENT_PROGRAM_DURATION"/>
        </span>
        <xsl:text> </xsl:text>
        <span class="element-value"><xsl:value-of select="metadata/duration"/></span>                 
    </p>            
</xsl:if>

Astuce
Si vous devez remplacer un certain nombre de fois le template get-metadata-value, il est possible d'utiliser la fonctionnalité Trouver/Remplacer tout de votre IDE pour peu que celui-ci autorise les regexp.
Voici comment faire sous Eclipse :
- Champ trouver mettre <xsl:call-template name="get-metadata-value">\s*<xsl:with-param[^/]*select="'([^"]*)'"[^/]*/>\s*</xsl:call-template>
- Champ remplacer mettre <xsl:value-of select="metadata/$1" />
- N'oubliez pas de cocher la case Expressions regulières dans le bloc Options
L'utilisation de la fonctionnalité Remplacer tout avec cette configuration modifiera tous les appels de la forme :
En leur équivalent version 2.0.x :

Display a rich field

The template get-richText-value has been replaced by the template common-content-richtext-field

For example

Displaying a rich field 1.1.x, 1.2.x and 1.3.x

<xsl:if test="cms:isNotRichTextEmpty(metadata/presentation) or metadata/presentation_remote">
     <xsl:call-template name="get-richText-value">
     	<xsl:with-param name="metadataName" select="'presentation'"/>
        <xsl:with-param name="level" select="$truelevel + 1"/>
        <xsl:with-param name="title" select="'plugin.odf:CONTENT_PROGRAM_PRESENTATION'"/>
     </xsl:call-template>            
</xsl:if>

becomes

Displaying a rich field 2.0.x

<xsl:call-template name="common-content-richtext-field">
     <xsl:with-param name="value" select="metadata/presentation"/>
     <xsl:with-param name="level" select="$truelevel + 1"/>
     <xsl:with-param name="title" select="'plugin.odf:CONTENT_PROGRAM_PRESENTATION'"/>
</xsl:call-template>      

Modifying the data model

The data model has been slightly modified. A technical migration at data level is also necessary. See Technical migration manual for versions 1.1.x, 1.2.x and 1.3.x to 2.x, paragraph

New fields

New fields have been added and can be displayed in XSL :

  • Disciplinary sector DGESIP (multiple): metadata/dgesipCode
  • FAP code (multiple): metadata/fapCode

Deleted fields

The following fields have been deleted and should be removed from XSL (unless you wish to keep them):

  • Sectors of activity : metadata/sector_activity
  • Field / Discipline : metadata/domain_discipline
  • Department : metadata/ministryDomain

universalAdjustment" metadata

The "universalAdjustement" metadata corresponding to the "Aménagements particuliers" field has been renamed "universalAdjustment".

In your XSL renderings, replace the reference to metadata/universalAdjustement by metadata/universalAdjustment

Multiple attachments

As of version 2.0.x, the "File to download" field for a course is a multiple field.

Link to an attachment in 1.1.x, 1.2.x and 1.3.x

<xsl:template name="download">
        <xsl:param name="truelevel"/>
    
        <xsl:if test="metadata/attachment">
            <div class="bloc download">
                <xsl:element name="h{$truelevel}"><i18n:text i18n:catalogue="plugin.odf" i18n:key="CONTENT_PROGRAM_ATTACHMENT"/></xsl:element>
                <p><a href="{resolver:resolve(metadata/attachment/@type, metadata/attachment/@path, 'true')}"><xsl:value-of select="metadata/attachment/@filename"/></a></p>
            </div>
        </xsl:if>    
</xsl:template>

becomes

Links to attachments in 2.0.x

<xsl:template name="download">
        <xsl:param name="truelevel"/>
    
        <xsl:if test="metadata/attachments/entry/attachment">
            <div class="bloc download">
                <xsl:element name="h{$truelevel}"><i18n:text i18n:catalogue="plugin.odf" i18n:key="CONTENT_PROGRAM_ATTACHMENT"/></xsl:element>
                
                <xsl:for-each select="metadata/attachments/entry">
                    <p>
                    <span class="file">
                        <a href="{resolver:resolve(attachment/@type, attachment/@path, 'true')}" title="{attachment/@filename} ({attachment/@size})">
                            <img class="icon" alt=""><xsl:attribute name="src"><xsl:value-of select="$uri-prefix"/><xsl:text>/plugins/explorer/icon/</xsl:text><xsl:value-of select="filenameutils:getExtension(attachment/@filename)"/><xsl:text>.png</xsl:text></xsl:attribute></img>
                            <xsl:choose>
                                <xsl:when test="normalize-space(attachment-text) != ''"> <xsl:value-of select="attachment-text"/></xsl:when>
                                <xsl:otherwise><xsl:value-of select="attachment/@filename"/></xsl:otherwise>
                            </xsl:choose>
                        </a>
                        <span class="size"> (<xsl:call-template name="format-size"><xsl:with-param name="size" select="attachment/@size"/></xsl:call-template>)</span>            
                    </span> 
                    </p>   
                </xsl:for-each>
            </div>
        </xsl:if>    
    </xsl:template>

The template XSL download in 2.0.x also displays an icon according to file type and size.

If you decide to include file size information, add the following template to handle different size formats (this template is used in the code above):

Attachment size format

<xsl:template name="format-size">
    <xsl:param name="size"/>
        
    <xsl:choose>
		<xsl:when test="$size &lt; 1024">
			<i18n:translate>
				<i18n:text i18n:key="CONTENT_PROGRAM_ATTACHMENTS_FILE_SIZE_BYTES"/>
				<i18n:param><xsl:value-of select="$size"/></i18n:param>
			</i18n:translate>
		</xsl:when>
		<xsl:when test="$size &lt; (1024 * 1024)">
			<i18n:translate>
				<i18n:text i18n:key="CONTENT_PROGRAM_ATTACHMENTS_FILE_SIZE_KB"/>
				<i18n:param><xsl:value-of select="round($size div 1024)"/></i18n:param>
			</i18n:translate>
		</xsl:when>
		<xsl:otherwise>
			<i18n:translate>
				<i18n:text i18n:key="CONTENT_PROGRAM_ATTACHMENTS_FILE_SIZE_MB"/>
				<i18n:param><xsl:value-of select="round($size div (1024 * 1024))"/></i18n:param>
			</i18n:translate>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>

 

Training location(s)

The place of training is now multiple

Display of training location in 1.1.x, 1.2.x and 1.3.x

<xsl:if test="metadata/place or metadata/place_remote">
    <xsl:element name="h{$truelevel + 1}"><i18n:text i18n:catalogue="plugin.odf" i18n:key="CONTENT_PROGRAM_PLACE"/></xsl:element>
	<p><xsl:call-template name="get-metadata-value"><xsl:with-param name="metadataName" select="'place'"/></xsl:call-template></p>
</xsl:if>

becomes

Displaying the location(s) of a 2.0.x training course

<xsl:if test="normalize-space(metadata/place) != ''">
	<xsl:element name="h{$truelevel + 1}"><i18n:text i18n:catalogue="plugin.odf" i18n:key="CONTENT_PROGRAM_PLACE"/></xsl:element>
    <ul>
    	<xsl:for-each select="metadata/place">
        	<li><xsl:value-of select="."/></li>
        </xsl:for-each>
    </ul>
</xsl:if>

Links to objects ODF

The helper xsl org.ametys.plugins.odfweb.repository.OdfPagePathHelper has been removed. To display a link to a ODF object (training, course, ELP), you must now use the general helper org.ametys.cms.transformation.xslt.ResolveURIComponent and its method resolve.

Signature :
String resolve(String type, String uri)

with

  • type: "odf"
  • uri content identifier (training, course, elp)

In the case of an ELP, theuri can be composed of the content identifier and the identifier of its parent, separated by ";".

Link to a training course (e.g. "List of training courses" service)

Link to training in 1.1.x, 1.2.x and 1.3.x

<li class="program">
    <a href="{$odf-site-uri-prefix}/{$lang}/{/xml/programs/@root-page-path}/{degree/@code}/{@domain}/{@name}.html">
         <xsl:value-of select="@title"/>
    </a>
</li>

becomes

Link to a 2.0.x training course

<li class="program">
     <a href="{resolver:resolve('odf', @id)}">
     	<xsl:value-of select="@title"/>
     </a>
</li>

Link to a route

Link to a route in 1.1.x, 1.2.x and 1.3.x

<xsl:template match="subprogram">
	<li>
       <a href="{odf:getSubProgramPath($siteName, /view/content/@language, @path, @id)}"><xsl:value-of select="@title"/></a>
    </li>
</xsl:template>

becomes

Link to a 2.0.x course

<xsl:template match="subprogram">
    <li>
    	<a href="{resolver:resolve('odf', @id)}"><xsl:value-of select="@title"/></a>
	</li>
</xsl:template>

Links to an ELP

Link to an ELP in 1.1.x, 1.2.x and 1.3.x

<xsl:template match="course">
	<li>
    	<a href="{odf:getCoursePath($siteName, /view/content/@language, @path, @id, $programId)}"><xsl:value-of select="@title"/></a>
    </li>
</xsl:template>

becomes

Link to ELP 2.0.x

<xsl:template match="course">
	<li>
    	<a href="{resolver:resolve('odf', concat(@id, ';', /view/content/@id))}">
        	<xsl:value-of select="@title"/>
		</a>
	</li>
</xsl:template>

 

 

Back to top