ソースを参照

fix escaping errors on strings including '&' char

Yves Chedemois 14 年 前
コミット
97b98953f2
3 ファイル変更22 行追加16 行削除
  1. BIN
      catalogue_template.odt
  2. 0 1
      fgcf.module
  3. 22 15
      fgcf.odt.inc

BIN
catalogue_template.odt


+ 0 - 1
fgcf.module

@@ -297,7 +297,6 @@ function fgcf_page_thematique($thematique = 0) {
 function fgcf_page_odt() {
   module_load_include('inc', 'fgcf', 'fgcf.odt');
 
-  // @todo : à paramétrer
   $template = dirname(__FILE__) ."/catalogue_template.odt";
   $odf = fgcf_odt_export_formations($template);
 

+ 22 - 15
fgcf.odt.inc

@@ -85,7 +85,7 @@ function fgcf_odt_replace_term_1st_level($segment, $term) {
   $replace = array();
 
   $replace['thematique_1_nom'] = strip_tags(filter_xss_admin($term->description));
-  $replace['thematique_1_code'] = $term->name;
+  $replace['thematique_1_code'] = check_plain($term->name);
 
   _fgcf_odt_replace_segment($segment, $replace);
 
@@ -93,7 +93,7 @@ function fgcf_odt_replace_term_1st_level($segment, $term) {
   $term_nodes = nat_get_nids(array($term->tid), TRUE);
   if ($term_node = current($term_nodes)) {
     $file = $term_node->field_fgcf_thematique_logo[0]['filepath'];
-    $segment->setImage('thematique_1_image', $file);
+//    $segment->setImage('thematique_1_image', $file);
   }
 }
 
@@ -119,15 +119,17 @@ function fgcf_odt_replace_node_formation($segment, $node) {
   // Initialise replacements with 'unspecified' text.
   $replace = array_fill_keys($keys, '-');
 
+  // Note : check_plain() is needed to escape characters like &...
+
   // formation_drupal_id
   $replace['formation_drupal_id'] = $node->nid;
 
   // formation_titre
-  $replace['formation_titre'] = $node->title;
+  $replace['formation_titre'] = check_plain($node->title);
 
   // formation_reference
   if (!empty($node->field_fgcf_fiche_reference[0]['value'])) {
-    $replace['formation_reference'] = $node->field_fgcf_fiche_reference[0]['value'];
+    $replace['formation_reference'] = check_plain($node->field_fgcf_fiche_reference[0]['value']);
   }
 
   // formation_objectif
@@ -138,16 +140,21 @@ function fgcf_odt_replace_node_formation($segment, $node) {
   // formation_contenu
   // @todo bug sur certains nodes 220
   if (!empty($node->field_fgcf_fiche_contenu[0]['value'])) {
-    // Do not translate markdown syntax - only replace bullet points
+    // @todo Do not translate markdown syntax - only replace bullet points
     $replace['formation_contenu'] = $node->field_fgcf_fiche_contenu[0]['value'];
     //$replace['formation_contenu'] = check_markup($node->field_fgcf_fiche_contenu[0]['value'], $node->field_fgcf_fiche_contenu[0]['format']);
   }
 
   // formation_organisme
-  // @todo : organisme peut être multiple
-  // @todo bug sur nodes 220 221 : Staff & Line Management
-  $node_organisme = node_load($node->field_fgcf_fiche_organisme[0]['nid']);
-  $replace['formation_organisme'] = $node_organisme->title;
+  $values = array();
+  foreach ((array) $node->field_fgcf_fiche_organisme as $item) {
+    if ($node_organisme = node_load($item['nid'])) {
+      $values[] = check_plain($node_organisme->title);
+    }
+  }
+  if ($values) {
+    $replace['formation_organisme'] = implode(', ', $values);
+  }
 
   // formation_modalites
   $field = content_fields('field_fgcf_fiche_modalite', 'fgcf_fiche');
@@ -155,7 +162,7 @@ function fgcf_odt_replace_node_formation($segment, $node) {
   $values = array();
   foreach ((array) $node->field_fgcf_fiche_modalite as $item) {
     if (isset($map[$item['value']])) {
-      $values[] = $map[$item['value']];
+      $values[] = check_plain($map[$item['value']]);
     }
   }
   if ($values) {
@@ -168,7 +175,7 @@ function fgcf_odt_replace_node_formation($segment, $node) {
     $field = content_fields('field_fgcf_fiche_dif', 'fgcf_fiche');
     $map = content_allowed_values($field);
     if (isset($map[$item])) {
-      $replace['formation_dif'] = $map[$item];
+      $replace['formation_dif'] = check_plain($map[$item]);
     }
   }
 
@@ -189,7 +196,7 @@ function fgcf_odt_replace_node_formation($segment, $node) {
   foreach ((array) $node->field_fgcf_fiche_format as $item) {
     $tid = $item['value'];
     if ($term = taxonomy_get_term($tid)) {
-      $values[] = $term->name;
+      $values[] = check_plain($term->name);
     }
   }
   if ($values) {
@@ -202,7 +209,7 @@ function fgcf_odt_replace_node_formation($segment, $node) {
   foreach ((array) $node->field_fgcf_fiche_supports as $item) {
     $tid = $item['value'];
     if ($term = taxonomy_get_term($tid)) {
-      $values[] = $term->name;
+      $values[] = check_plain($term->name);
     }
   }
   if ($values) {
@@ -215,7 +222,7 @@ function fgcf_odt_replace_node_formation($segment, $node) {
   foreach ((array) $node->field_fgcf_fiche_sanction as $item) {
     $tid = $item['value'];
     if ($term = taxonomy_get_term($tid)) {
-      $values[] = $term->name;
+      $values[] = check_plain($term->name);
     }
   }
   if ($values) {
@@ -228,7 +235,7 @@ function fgcf_odt_replace_node_formation($segment, $node) {
   foreach ((array) $node->field_fgcf_fiche_public as $item) {
     $tid = $item['value'];
     if ($term = taxonomy_get_term($tid)) {
-      $values[] = $term->name;
+      $values[] = check_plain($term->name);
     }
   }
   if ($values) {