first global commit
This commit is contained in:
@@ -0,0 +1,182 @@
|
||||
<?php
|
||||
|
||||
abstract class PerfApiMigration extends XMLMigration {
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct(MigrateGroup::getInstance('PerfMigrate'));
|
||||
}
|
||||
|
||||
public function getTextsAuthors($xml, $attr, $l){
|
||||
$values = array();
|
||||
$authors = array();
|
||||
$language = array();
|
||||
foreach ($xml as $xml_value) {
|
||||
$values = array_merge( $values, array( $this->getAttribute($xml_value, $attr), $this->getAttribute($xml_value, 'TRADUCTION')) );
|
||||
$auteur_nom = $this->getAttribute($xml_value, 'NOM_AUTEUR');
|
||||
$auteur_prenom = $this->getAttribute($xml_value, 'PRENOM_AUTEUR');
|
||||
$auteur = $auteur_nom != '' || $auteur_prenom != '' ? trim($auteur_prenom .' '. $auteur_nom) : '';
|
||||
$authors = array_merge($authors, array($auteur,$auteur));
|
||||
$language = array_merge($language, $l);
|
||||
}
|
||||
|
||||
return array(
|
||||
'values'=>$values,
|
||||
'authors'=>$authors,
|
||||
'language'=>$language,
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
public function getAttribute($object, $attr){
|
||||
$attr_objects = $object->xpath('@'.$attr);
|
||||
return isset($attr_objects[0]) ? (string) $attr_objects[0] : '';
|
||||
}
|
||||
|
||||
public function getPersonne($object, $suffix = ''){
|
||||
$nom = $this->getAttribute($object, 'NOM'.$suffix);
|
||||
$prenom = $this->getAttribute($object, 'PRENOM'.$suffix);
|
||||
return $nom != '' || $prenom != '' ? trim($prenom .' '. $nom) : '';
|
||||
}
|
||||
|
||||
public function getDate($o, $moment){
|
||||
$date = $this->getAttribute($o, 'ANNEE_'.$moment)
|
||||
.'/'. $this->getAttribute($o, 'MOIS_'.$moment)
|
||||
.'/'. $this->getAttribute($o, 'JOUR_'.$moment)
|
||||
.'-'. $this->getAttribute($o, 'HEURE_'.$moment)
|
||||
.':'. $this->getAttribute($o, 'MINUTE_'.$moment);
|
||||
do {
|
||||
$date = preg_replace('/(\/+|:+|-+)$/', '', $date, 1, $count);
|
||||
} while ($count);
|
||||
|
||||
|
||||
return $date;
|
||||
}
|
||||
|
||||
|
||||
public function recordGroup(&$node, $field, $xml, $attr){
|
||||
|
||||
foreach ($xml->xpath('GROUPE_ARTISTES[@'.$attr.'="oui"]') as $xml_group){
|
||||
# group d'artiste
|
||||
$gname = trim($this->getAttribute($xml_group, 'NOM'));
|
||||
// drush_log(dt('recordGroup !name', array('!name'=>$gname)), 'status');
|
||||
$gts = taxonomy_get_term_by_name($gname);
|
||||
//
|
||||
// drush_log(dt('group_term : !gt', array('!gt'=>print_r($gt, true))));
|
||||
if(!count($gts)){
|
||||
$gt = new stdClass();
|
||||
$gt->name = $gname;
|
||||
$gt->vid = 7;
|
||||
taxonomy_term_save($gt);
|
||||
}else{
|
||||
// print_r($gts);
|
||||
foreach ($gts as $tid => $t) {
|
||||
$gt = $t;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// drush_log(dt('term group !name, tid : !tid', array('!name'=>$gt->name,'!tid'=>$gt->tid)), 'status');
|
||||
$node->{$field}['und'][] = array('tid'=>$gt->tid);
|
||||
|
||||
# personne dans le group d'artist
|
||||
//!\\ ici ça ne boucle pas
|
||||
foreach ($xml->xpath('GROUPE_ARTISTES[@NOM="'.$gname.'"]/PERSONNE[@'.$attr.'="oui"]') as $xml_p){
|
||||
$term_name = trim($this->getPersonne($xml_p));
|
||||
// drush_log(dt('recordGroup :: personne : !p', array('!p'=>$term_name)), 'status');
|
||||
$tbn = taxonomy_get_term_by_name($term_name);
|
||||
if(!count($tbn)){
|
||||
$t = new stdClass();
|
||||
$t->name = $term_name;
|
||||
$t->vid = 7;
|
||||
taxonomy_term_save($t);
|
||||
}else{
|
||||
foreach ($tbn as $tid => $tt) {
|
||||
$t = $tt;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$parents = taxonomy_get_parents($t->tid);
|
||||
$t->parent = array();
|
||||
foreach ($parents as $tid => $parent_term) {
|
||||
$t->parent[] = $tid;
|
||||
}
|
||||
if(!in_array($gt->tid, $t->parent)){
|
||||
$t->parent[] = $gt->tid;
|
||||
}
|
||||
$nom = trim($this->getAttribute($xml_p, 'NOM'));
|
||||
$prenom = trim($this->getAttribute($xml_p, 'PRENOM'));
|
||||
$t->field_nom = array(
|
||||
'und'=>array(
|
||||
array(
|
||||
'value' => $nom,
|
||||
'format' => null,
|
||||
'safe_value' => $nom,
|
||||
)
|
||||
)
|
||||
);
|
||||
$t->field_prenom = array(
|
||||
'und'=>array(
|
||||
array(
|
||||
'value' => $prenom,
|
||||
'format' => null,
|
||||
'safe_value' => $prenom,
|
||||
)
|
||||
)
|
||||
);
|
||||
taxonomy_term_save($t);
|
||||
// drush_log(dt('term personne !name, tid : !tid', array('!name'=>$t->name,'!tid'=>$t->tid)), 'status');
|
||||
$node->{$field}['und'][] = array('tid'=>$t->tid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function updatePersonneTerms($xml){
|
||||
foreach ($xml->xpath('PERSONNE') as $xml_concepteur){
|
||||
$nom = trim($this->getAttribute($xml_concepteur, 'NOM'));
|
||||
$prenom = trim($this->getAttribute($xml_concepteur, 'PRENOM'));
|
||||
|
||||
$term_name = $nom != '' || $prenom != '' ? trim($prenom .' '. $nom) : '';
|
||||
$tbn = taxonomy_get_term_by_name($term_name);
|
||||
// if(!count($tbn)){
|
||||
// $t = new stdClass();
|
||||
// $t->name = $term_name;
|
||||
// $t->vid = 7;
|
||||
// taxonomy_term_save($t);
|
||||
// }else{
|
||||
foreach ($tbn as $tid => $tt) {
|
||||
$term = $tt;
|
||||
break;
|
||||
}
|
||||
// }
|
||||
|
||||
$term->field_nom = array(
|
||||
'und'=>array(
|
||||
array(
|
||||
'value' => $nom,
|
||||
'format' => null,
|
||||
'safe_value' => $nom,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$term->field_prenom = array(
|
||||
'und'=>array(
|
||||
array(
|
||||
'value' => $prenom,
|
||||
'format' => null,
|
||||
'safe_value' => $prenom,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
taxonomy_term_save($term);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,375 @@
|
||||
<?php
|
||||
|
||||
abstract class PerfBasicMigration extends PerfApiMigration {
|
||||
|
||||
public function __construct(){
|
||||
|
||||
$this->description = t('Migrate Performance Basic Class');
|
||||
|
||||
parent::__construct();
|
||||
|
||||
// There isn't a consistent way to automatically identify appropriate "fields"
|
||||
// from an XML feed, so we pass an explicit list of source fields
|
||||
$fields = array(
|
||||
'treeline_id' => t('Treeline id'),
|
||||
'title' => t('title'),
|
||||
'sous_titre' => t('Sous-titre'),
|
||||
'language' => t('Language'),
|
||||
'description' => t('description'),
|
||||
'auteur_description' => t('Auteur description'),
|
||||
'language_description' => t('Language description'),
|
||||
'intention' => t('Intention'),
|
||||
'auteur_intention' => t('Auteur intention'),
|
||||
'language_intention' => t('Language intention'),
|
||||
'serie' => t('Série'),
|
||||
'typologie_performance' => t('Typologie performance'),
|
||||
'tags_libre' => t('Tags libres'),
|
||||
'concepteur' => t('Concepteur'),
|
||||
'executant' => t('Executant'),
|
||||
'organisateur' => t('Organisateur'),
|
||||
'contexte_theorique' => t('contexte_theorique'),
|
||||
'auteur_contexte_theorique' => t('auteur_contexte_theorique'),
|
||||
'language_contexte_theorique' => t('Language contexte'),
|
||||
// 'date_de_debut' => t('Date de debut'),
|
||||
// 'date_de_fin' => t('Date de fin'),
|
||||
// 'lieu' => t('Lieu'),
|
||||
// 'duree' => t('Durée'),
|
||||
// 'topologie' => t('Topologie'),
|
||||
'effectuations_id' => t('effectuations id'),
|
||||
'temoin' => t('Temoin'),
|
||||
'site_internet' => t('Site internet'),
|
||||
'images' => t('Images'),
|
||||
'images_alt' => t('Images Alt'),
|
||||
'images_title' => t('Images Title'),
|
||||
'recherche' => t('recherche'),
|
||||
'sources_bibliographiques' => t('Sources bibliographiques'), // BIBLIOGRAPHIE
|
||||
'docs_audiovisuels' => t('docs audio visuel'), // DOC_AUDIOVISUEL
|
||||
'docs_sonor' => t('docs sonor'),//DOC_SONORE
|
||||
'documents' => t('documents'), // DOC_IMPRIME
|
||||
'objects' => t('Objets'), // OBJET
|
||||
|
||||
// 'docs_press' => t('doc press'), // DOC_PRESSE
|
||||
// 'docs_manuscrit' => t('doc manuscrits'), // DOC_MANUSCRITS
|
||||
);
|
||||
|
||||
// The source ID here is the one retrieved from the XML listing file, and
|
||||
// used to identify the specific item's file
|
||||
$this->map = new MigrateSQLMap($this->machineName,
|
||||
array(
|
||||
'treeline_id' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
)
|
||||
),
|
||||
MigrateDestinationNode::getKeySchema()
|
||||
);
|
||||
|
||||
// This can also be an URL instead of a file path.
|
||||
$xml_folder = DRUPAL_ROOT . '/' . drupal_get_path('module', 'PerfMigrate') . '/xml/';
|
||||
$items_url = $xml_folder . 'baseperf-parsed.xml';
|
||||
|
||||
// We use the MigrateSourceMultiItems class for any source where we obtain the list
|
||||
// of IDs to process and the data for each item from the same file. Typically the data
|
||||
// for an item is not contained in a single line within the source file. Examples include
|
||||
// multiple items defined in a single xml file or a single json file where in both cases
|
||||
// the id is part of the item.
|
||||
|
||||
$item_ID_xpath = '@ID'; // relative to item_xpath and gets assembled
|
||||
// into full path /producers/producer/sourceid
|
||||
|
||||
|
||||
$items_class = new MigrateItemsXML($items_url, $this->item_xpath, $item_ID_xpath); //
|
||||
$this->source = new MigrateSourceMultiItems($items_class, $fields);
|
||||
|
||||
$this->destination = new MigrateDestinationNode('performance');
|
||||
|
||||
$this->addFieldMapping('language')->defaultValue('fr');
|
||||
$this->addFieldMapping('is_new')->defaultValue(TRUE);
|
||||
// $this->addFieldMapping('created', 'date_creation');
|
||||
// $this->addFieldMapping('changed', 'date_modif');
|
||||
$this->addFieldMapping('status')->defaultValue(1);
|
||||
$this->addFieldMapping('promote')->defaultValue(0);
|
||||
$this->addFieldMapping('sticky')->defaultValue(0);
|
||||
|
||||
# titre & sous titre
|
||||
// $this->addFieldMapping('title', 'title')
|
||||
// ->xpath('@TITRE');
|
||||
|
||||
$this->addFieldMapping('title_field', 'title');
|
||||
$this->addFieldMapping('title_field:language', 'language');
|
||||
|
||||
$this->addFieldMapping('field_sous_titre', 'sous_titre')
|
||||
->xpath('@SOUS_TITRE');
|
||||
|
||||
# description
|
||||
$this->addFieldMapping('field_description', 'description');
|
||||
$this->addFieldMapping('field_description:format')->defaultValue('filtred_html');
|
||||
$this->addFieldMapping('field_description:language', 'language_description');
|
||||
$this->addFieldMapping('field_description:author', 'auteur_description');
|
||||
|
||||
# intention (nexiste pas dans la base xml)
|
||||
$this->addFieldMapping('field_intention', 'intention');
|
||||
$this->addFieldMapping('field_intention:format')->defaultValue('filtred_html');
|
||||
$this->addFieldMapping('field_intention:language', 'language_intention');
|
||||
$this->addFieldMapping('field_intention:author', 'auteur_intention');
|
||||
|
||||
# contexte theorique
|
||||
$this->addFieldMapping('field_contexte_theorique', 'contexte_theorique');
|
||||
$this->addFieldMapping('field_contexte_theorique:format')->defaultValue('filtred_html');
|
||||
$this->addFieldMapping('field_contexte_theorique:language', 'language_contexte_theorique');
|
||||
$this->addFieldMapping('field_contexte_theorique:author', 'auteur_contexte_theorique');
|
||||
|
||||
# typologie perf
|
||||
$this->addFieldMapping('field_type_de_performance', 'typologie_performance')
|
||||
->xpath('TYPOLOGIE_PERFORMANCE/@TYPOLOGIE_PERFORMANCE');
|
||||
$this->addFieldMapping('field_type_de_performance:create_term')->defaultValue(TRUE);
|
||||
|
||||
# serie
|
||||
$this->addFieldMapping('field_serie', 'serie')
|
||||
->xpath('SERIE/@NOM_SERIE');
|
||||
$this->addFieldMapping('field_serie:create_term')->defaultValue(TRUE);
|
||||
|
||||
# tags libre perf
|
||||
$this->addFieldMapping('field_tags_libre', 'tags_libre');
|
||||
$this->addFieldMapping('field_tags_libre:create_term')->defaultValue(TRUE);
|
||||
|
||||
# personnes
|
||||
$this->addFieldMapping('field_concepteur', 'concepteur');
|
||||
$this->addFieldMapping('field_concepteur:create_term')->defaultValue(TRUE);
|
||||
$this->addFieldMapping('field_executant', 'executant');
|
||||
$this->addFieldMapping('field_executant:create_term')->defaultValue(TRUE);
|
||||
$this->addFieldMapping('field_organisateur', 'organisateur');
|
||||
$this->addFieldMapping('field_organisateur:create_term')->defaultValue(TRUE);
|
||||
$this->addFieldMapping('field_temoin', 'temoin');
|
||||
$this->addFieldMapping('field_temoin:create_term')->defaultValue(TRUE);
|
||||
|
||||
# lieu date contexte
|
||||
// $this->addFieldMapping('field_date_de_debut', 'date_de_debut');
|
||||
// $this->addFieldMapping('field_date_de_fin', 'date_de_fin');
|
||||
// $this->addFieldMapping('field_dure', 'duree');
|
||||
// $this->addFieldMapping('field_lieu', 'lieu')
|
||||
// ->xpath('LIEU_DATE_CONTEXTE/@NOM_LIEU');
|
||||
// $this->addFieldMapping('field_lieu:create_term')->defaultValue(TRUE);
|
||||
// $this->addFieldMapping('field_topologie', 'topologie')
|
||||
// ->xpath('LIEU_DATE_CONTEXTE/@TYPE');
|
||||
// $this->addFieldMapping('field_topologie:create_term')->defaultValue(TRUE);
|
||||
|
||||
$this->addFieldMapping('field_effectuations', 'effectuations_id')
|
||||
->sourceMigration('PerfLDCNode');
|
||||
|
||||
#site internet
|
||||
$this->addFieldMapping('field_site_internet', 'site_internet');
|
||||
|
||||
#images
|
||||
$this->addFieldMapping('field_images', 'images');
|
||||
$this->addFieldMapping('field_images:source_dir')->defaultValue('public://SRC_IMAGES');
|
||||
// $this->addFieldMapping('field_images:destination_file', 'images');
|
||||
// $this->addFieldMapping('field_images:alt', 'images_alt');
|
||||
$this->addFieldMapping('field_images:title', 'images_title');
|
||||
$this->addFieldMapping('field_images:alt', 'images_alt');
|
||||
|
||||
$this->addFieldMapping('field_recherche', 'recherche')
|
||||
->xpath('/RECHERCHE/@NOTES');
|
||||
|
||||
$this->addFieldMapping('field_sources_bibliographiques', 'sources_bibliographiques')
|
||||
->xpath('/BIBLIOGRAPHIE/@BIBLIOGRAPHIE');
|
||||
|
||||
$this->addFieldMapping('field_documents_videos', 'docs_audiovisuels')
|
||||
->sourceMigration('PerfDvidsNode');
|
||||
|
||||
$this->addFieldMapping('field_documents_sonor', 'docs_sonor')
|
||||
->sourceMigration('PerfDsonsNode');
|
||||
|
||||
$this->addFieldMapping('field_documents', 'documents')
|
||||
->sourceMigration(array('PerfDimpNode', 'PerfDpressNode', 'PerfDmanuNode')); // ?????
|
||||
|
||||
$this->addFieldMapping('field_objects', 'objects')
|
||||
->sourceMigration('PerfObjetNode');
|
||||
|
||||
|
||||
$this->addUnmigratedDestinations(array('revision_uid', 'created', 'changed', 'revision', 'log', 'tnid','comment', 'uid','path', 'pathauto',
|
||||
'title',
|
||||
'title_field:format',
|
||||
'field_sous_titre:format', 'field_sous_titre:language',
|
||||
'field_performances_associees',
|
||||
// 'body:summary',
|
||||
// 'field_auteur_description:source_type',
|
||||
// 'field_auteur_intention:source_type',
|
||||
// 'field_auteur_contexte:source_type',
|
||||
'field_serie:source_type', 'field_type_de_performance:source_type', 'field_tags_libre:source_type',
|
||||
'field_concepteur:source_type','field_executant:source_type','field_organisateur:source_type','field_temoin:source_type',
|
||||
// 'field_date_de_debut:format', 'field_date_de_debut:language', 'field_date_de_fin:format', 'field_date_de_fin:language',
|
||||
// 'field_dure:format', 'field_dure:language',
|
||||
// 'field_lieu:source_type', 'field_topologie:source_type'
|
||||
'field_images:file_class', 'field_images:language', 'field_images:destination_dir', 'field_images:destination_file', 'field_images:file_replace', 'field_images:preserve_files',
|
||||
'field_recherche:language', 'field_recherche:format',
|
||||
'field_sources_bibliographiques:language', 'field_sources_bibliographiques:format',
|
||||
//'field_images:alt', //'field_images:title',
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
public function prepareRow($row){
|
||||
// dsm($row , '--- $row ---');
|
||||
$xml = $row->xml;
|
||||
|
||||
$row->language = array('fr', 'en');
|
||||
|
||||
$titre = $this->getAttribute($xml, 'TITRE');
|
||||
$traduction_titre = $this->getAttribute($xml, 'TRADUCTION_TITRE');
|
||||
$traduction_titre = $traduction_titre != '' ? $traduction_titre : $titre;
|
||||
$row->title = array(
|
||||
$titre,
|
||||
$traduction_titre,
|
||||
);
|
||||
|
||||
# description
|
||||
$results = $this->getTextsAuthors($xml->xpath('DESCRIPTION'), 'DESCRIPTION', $row->language);
|
||||
$row->description = $results['values'];
|
||||
$row->auteur_description = $results['authors'];
|
||||
$row->language_description = $results['language'];
|
||||
|
||||
# intention
|
||||
$results = $this->getTextsAuthors($xml->xpath('INTENTION'), 'INTENTION', $row->language);
|
||||
$row->intention = $results['values'];
|
||||
$row->auteur_intention = $results['authors'];
|
||||
$row->language_intention = $results['language'];
|
||||
|
||||
# Contexte theorique
|
||||
$results = $this->getTextsAuthors($xml->xpath('CONTEXTE_THEORIQUE'), 'CONTEXTE_THEORIQUE', $row->language);
|
||||
$row->contexte_theorique = $results['values'];
|
||||
$row->auteur_contexte_theorique = $results['authors'];
|
||||
$row->language_contexte_theorique = $results['language'];
|
||||
|
||||
#tags libres
|
||||
$tags = array();
|
||||
foreach ($xml->xpath('MOTS_CLE') as $xml_mot_clef)
|
||||
$tags[] = $this->getAttribute($xml_mot_clef, 'MOT_CLE');
|
||||
$row->tags_libre = $tags;
|
||||
|
||||
# personnes
|
||||
$concepteurs = array();
|
||||
foreach ($xml->xpath('PERSONNE[@CONCEPTEUR="oui"]') as $xml_concepteur)
|
||||
$concepteurs[] = $this->getPersonne($xml_concepteur);
|
||||
$row->concepteur = $concepteurs;
|
||||
|
||||
$executants = array();
|
||||
foreach ($xml->xpath('PERSONNE[@EXECUTANT="oui"]') as $xml_executant)
|
||||
$executants[] = $this->getPersonne($xml_executant);
|
||||
$row->executant = $executants;
|
||||
|
||||
$organisateurs = array();
|
||||
foreach ($xml->xpath('PERSONNE[@ORGANISATEUR="oui"]') as $xml_organisateur)
|
||||
$organisateurs[] = $this->getPersonne($xml_organisateur);
|
||||
$row->organisateur = $organisateurs;
|
||||
|
||||
$temoins = array();
|
||||
foreach ($xml->xpath('TEMOIN') as $xml_temoin)
|
||||
$temoins[] = $this->getPersonne($xml_temoin, '_TEMOIN');
|
||||
$row->temoin = $temoins;
|
||||
|
||||
# lieu date contexte
|
||||
// $ldc = $xml->LIEU_DATE_CONTEXTE;
|
||||
// $row->date_de_debut = $this->getDate($ldc, 'DEBUT');
|
||||
// $row->date_de_fin = $this->getDate($ldc, 'FIN');
|
||||
// $row->duree = $this->getAttribute($ldc, 'DUREE') .' '. $this->getAttribute($ldc, 'UNITE_DUREE');
|
||||
// $row->lieu = $this->getAttribute($ldc, 'NOM_LIEU');
|
||||
$effectuations_id = array();
|
||||
foreach ($xml->xpath('LIEU_DATE_CONTEXTE') as $ldc)
|
||||
$effectuations_id[] = $this->getAttribute($ldc, 'ID');
|
||||
$row->effectuations_id = count($effectuations_id) ? $effectuations_id : NULL;
|
||||
|
||||
# doc audiovisuel
|
||||
$docs = array();
|
||||
foreach ($xml->xpath('DOC_AUDIOVISUEL') as $doc)
|
||||
$docs[] = $this->getAttribute($doc, 'ID');
|
||||
$row->docs_audiovisuels = count($docs) ? $docs : NULL;
|
||||
|
||||
# doc sonor
|
||||
$docs = array();
|
||||
foreach ($xml->xpath('DOC_SONORE') as $doc)
|
||||
$docs[] = $this->getAttribute($doc, 'ID');
|
||||
$row->docs_sonor = count($docs) ? $docs : NULL;
|
||||
|
||||
# doc imprime
|
||||
$docs = array();
|
||||
foreach ($xml->xpath('DOC_IMPRIME') as $doc)
|
||||
$docs[] = $this->getAttribute($doc, 'ID');
|
||||
|
||||
foreach ($xml->xpath('DOC_PRESSE') as $doc)
|
||||
$docs[] = $this->getAttribute($doc, 'ID');
|
||||
|
||||
foreach ($xml->xpath('DOC_MANUSCRITS') as $doc)
|
||||
$docs[] = $this->getAttribute($doc, 'ID');
|
||||
|
||||
$row->documents = count($docs) ? $docs : NULL;
|
||||
|
||||
# objet
|
||||
$docs = array();
|
||||
foreach ($xml->xpath('OBJET') as $doc)
|
||||
$docs[] = $this->getAttribute($doc, 'ID');
|
||||
$row->objects = count($docs) ? $docs : NULL;
|
||||
|
||||
|
||||
#site internet
|
||||
// $sites = array();
|
||||
// foreach ($xml->xpath('SITE_INTERNET') as $xml)
|
||||
// $sites[] = str_replace('http://', '', $this->getAttribute($xml, 'URL'));
|
||||
// $row->site_internet = $sites;
|
||||
// dsm($row->site_internet)
|
||||
|
||||
/*
|
||||
TODO site internet ne marche pas !!!
|
||||
*/
|
||||
// $row->site_internet = '';
|
||||
foreach ($xml->xpath('SITE_INTERNET') as $xml_site)
|
||||
//$row->site_internet = array('url'=>str_replace('http://', '', $this->getAttribute($xml_site, 'URL')));
|
||||
$row->site_internet = str_replace('http://', '', $this->getAttribute($xml_site, 'URL'));
|
||||
// dsm($row->site_internet, '$row->site_internet');
|
||||
// drush_log(dt('web : !url', array('!url'=>$row->site_internet)), 'status');
|
||||
|
||||
|
||||
#images
|
||||
$images = array();
|
||||
$titles = array();
|
||||
$alts = array();
|
||||
// $i = 0;
|
||||
$str_xml = print_r($xml, true);
|
||||
//drush_log(dt('xml : !xml', array('!xml'=>$str_xml)), 'status');
|
||||
//drush_log(dt('start images import : !images', array('!images'=>count($xml->IMAGE_CONSULTABLE))), 'status');
|
||||
foreach ($xml->IMAGE_CONSULTABLE as $xml_image) { //IMAGE_CONSULTABLE
|
||||
// drush_log(dt('image'), 'status');
|
||||
$images[] = $this->getAttribute($xml_image, 'SRC');
|
||||
$alts[] = $this->getAttribute($xml_image, 'ALT');
|
||||
$titles[] = $this->getAttribute($xml_image, 'TITLE');
|
||||
// $i++;
|
||||
}
|
||||
$row->images = $images;
|
||||
$row->images_title = $titles;
|
||||
$row->images_alt = $alts;
|
||||
// dsm($row->images, '$row->images');
|
||||
}
|
||||
|
||||
public function prepare($node, stdClass $row) {
|
||||
$node->name = 'migration';
|
||||
$node->workflow = 2;
|
||||
|
||||
}
|
||||
|
||||
public function complete($node, stdClass $row){
|
||||
$handler = entity_translation_get_handler('node', $node);
|
||||
|
||||
$translation = array(
|
||||
'translate' => 0,
|
||||
'status' => 1,
|
||||
'language' => 'en',
|
||||
'source' => $node->language,
|
||||
);
|
||||
|
||||
$handler->setTranslation($translation, $node);
|
||||
|
||||
node_save($node);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
|
||||
abstract class PerfBasicUpdateMigration extends PerfApiMigration {
|
||||
|
||||
public function __construct(){
|
||||
|
||||
$this->description = t('Migrate Update Performance Basic Class');
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->systemOfRecord = Migration::DESTINATION;
|
||||
|
||||
// There isn't a consistent way to automatically identify appropriate "fields"
|
||||
// from an XML feed, so we pass an explicit list of source fields
|
||||
$fields = array(
|
||||
'treeline_id' => t('Treeline id'),
|
||||
'language'=>t('language'),
|
||||
// 'title' => t('title'),
|
||||
'site_internet' => t('Site internet'),
|
||||
// 'images' => t('Images'),
|
||||
'images_alt' => t('Images Alt'),
|
||||
'images_title' => t('Images Title'),
|
||||
'sources_bibliographiques' => t('Sources bibliographiques'), // BIBLIOGRAPHIE
|
||||
);
|
||||
|
||||
// The source ID here is the one retrieved from the XML listing file, and
|
||||
// used to identify the specific item's file
|
||||
$this->map = new MigrateSQLMap($this->machineName,
|
||||
array(
|
||||
'treeline_id' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
)
|
||||
),
|
||||
MigrateDestinationNode::getKeySchema()
|
||||
);
|
||||
|
||||
// This can also be an URL instead of a file path.
|
||||
$xml_folder = DRUPAL_ROOT . '/' . drupal_get_path('module', 'PerfMigrate') . '/xml/';
|
||||
$items_url = $xml_folder . 'baseperf-parsed.xml';
|
||||
|
||||
// We use the MigrateSourceMultiItems class for any source where we obtain the list
|
||||
// of IDs to process and the data for each item from the same file. Typically the data
|
||||
// for an item is not contained in a single line within the source file. Examples include
|
||||
// multiple items defined in a single xml file or a single json file where in both cases
|
||||
// the id is part of the item.
|
||||
|
||||
$item_ID_xpath = '@ID'; // relative to item_xpath and gets assembled
|
||||
// into full path /producers/producer/sourceid
|
||||
|
||||
|
||||
$items_class = new MigrateItemsXML($items_url, $this->item_xpath, $item_ID_xpath); //
|
||||
$this->source = new MigrateSourceMultiItems($items_class, $fields);
|
||||
|
||||
$this->destination = new MigrateDestinationNode('performance');
|
||||
|
||||
#site internet
|
||||
$this->addFieldMapping('field_site_internet', 'site_internet');
|
||||
|
||||
#images
|
||||
$this->addFieldMapping('field_images', 'images');
|
||||
$this->addFieldMapping('field_images:source_dir')->defaultValue('public://SRC_IMAGES');
|
||||
$this->addFieldMapping('field_images:file_replace')->defaultValue(FILE_EXISTS_REPLACE);
|
||||
$this->addFieldMapping('field_images:title', 'images_title');
|
||||
$this->addFieldMapping('field_images:alt', 'images_alt');
|
||||
|
||||
$this->addFieldMapping('field_sources_bibliographiques', 'sources_bibliographiques')
|
||||
->xpath('BIBLIOGRAPHIE/@BIBLIOGRAPHIE');
|
||||
|
||||
$this->addUnmigratedDestinations(array());
|
||||
|
||||
}
|
||||
|
||||
public function prepareRow($row){
|
||||
// dsm($row , '--- $row ---');
|
||||
$xml = $row->xml;
|
||||
|
||||
#site internet
|
||||
$row->site_internet = array();
|
||||
foreach ($xml->xpath('SITE_INTERNET') as $xml_site){
|
||||
$row->site_internet[] = trim($this->getAttribute($xml_site, 'URL'));
|
||||
}
|
||||
|
||||
#images
|
||||
$images = array();
|
||||
$titles = array();
|
||||
$alts = array();
|
||||
//drush_log(dt('start images import : !images', array('!images'=>count($xml->IMAGE_CONSULTABLE))), 'status');
|
||||
foreach ($xml->IMAGE_CONSULTABLE as $xml_image) { //IMAGE_CONSULTABLE
|
||||
$images[] = $this->getAttribute($xml_image, 'SRC');
|
||||
$alts[] = $this->getAttribute($xml_image, 'ALT');
|
||||
$titles[] = $this->getAttribute($xml_image, 'TITLE');
|
||||
}
|
||||
$row->images = $images;
|
||||
$row->images_title = $titles;
|
||||
$row->images_alt = $alts;
|
||||
|
||||
}
|
||||
|
||||
// public function prepare($node, stdClass $row) {
|
||||
// // $xml = $row->xml;
|
||||
|
||||
// }
|
||||
|
||||
public function complete($node, stdClass $row){
|
||||
$xml = $row->xml;
|
||||
|
||||
# images
|
||||
# this script only update title and alt field of image files that already exists
|
||||
# but i sa that some files are missing after the first import …
|
||||
// $delta = 0;
|
||||
// foreach ($xml->IMAGE_CONSULTABLE as $xml_image) { //IMAGE_CONSULTABLE
|
||||
// if(isset($node->field_images['und'][$delta])){
|
||||
// $node->field_images['und'][$delta]['title'] = $this->getAttribute($xml_image, 'TITLE');
|
||||
// $node->field_images['und'][$delta]['alt'] = $this->getAttribute($xml_image, 'ALT');
|
||||
// }
|
||||
// $delta ++;
|
||||
// }
|
||||
|
||||
|
||||
# personnes
|
||||
$this->recordGroup($node, 'field_concepteur', $xml, 'CONCEPTEUR');
|
||||
|
||||
$this->recordGroup($node, 'field_executant',$xml, 'EXECUTANT');
|
||||
|
||||
$this->recordGroup($node, 'field_organisateur', $xml, 'ORGANISATEUR');
|
||||
|
||||
$this->recordGroup($node, 'field_temoin', $xml, 'TEMOIN');
|
||||
|
||||
node_save($node);
|
||||
|
||||
# personnes
|
||||
$this->updatePersonneTerms($xml);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
/**
|
||||
* PerfGroupeNodeMigration
|
||||
*
|
||||
*/
|
||||
abstract class PerfDNodeMigration extends PerfApiMigration {
|
||||
public function __construct() {
|
||||
|
||||
$this->description = t('Migrate Document Sonore Class');
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->fields += array(
|
||||
'ID' => t('id'),
|
||||
'title' => t('title'),
|
||||
'synopsis_description' => t('SYNOPSIS_DESCRIPTION'),
|
||||
'duree' => t('duree'),
|
||||
'proprietaire' => t('proprietaire'),
|
||||
'realisateur' => t('realisateur'),
|
||||
'date_realisation' => t('date_realisation'),
|
||||
'production' => t('production'),
|
||||
'notes' => t('notes'),
|
||||
);
|
||||
|
||||
// The source ID here is the one retrieved from the XML listing file, and
|
||||
// used to identify the specific item's file
|
||||
$this->map = new MigrateSQLMap($this->machineName,
|
||||
array(
|
||||
'ID' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
)
|
||||
),
|
||||
MigrateDestinationNode::getKeySchema()
|
||||
);
|
||||
|
||||
$item_ID_xpath = '@ID'; // relative to item_xpath and gets assembled
|
||||
// into full path /producers/producer/sourceid
|
||||
|
||||
|
||||
$items_class = new MigrateItemsXML($this->items_url, $this->item_xpath, $item_ID_xpath); //
|
||||
$this->source = new MigrateSourceMultiItems($items_class, $this->fields);
|
||||
|
||||
$this->addFieldMapping('language')->defaultValue('fr');
|
||||
$this->addFieldMapping('is_new')->defaultValue(TRUE);
|
||||
// $this->addFieldMapping('created', 'date_creation');
|
||||
// $this->addFieldMapping('changed', 'date_modif');
|
||||
$this->addFieldMapping('status')->defaultValue(1);
|
||||
$this->addFieldMapping('promote')->defaultValue(0);
|
||||
$this->addFieldMapping('sticky')->defaultValue(0);
|
||||
|
||||
$this->addFieldMapping('title', 'title');
|
||||
|
||||
$this->addFieldMapping('field_duree', 'duree');
|
||||
|
||||
$this->addFieldMapping('field_synopsis_description', 'synopsis_description')
|
||||
->xpath('@SYNOPSIS_DESCRIPTION');
|
||||
$this->addFieldMapping('field_synopsis_description:format')->defaultValue('filtred_html');
|
||||
|
||||
$this->addFieldMapping('field_proprietaire', 'proprietaire')
|
||||
->xpath('@ID_PROPRIETAIRE_OBJET');
|
||||
|
||||
$this->addFieldMapping('field_realisateur', 'realisateur')
|
||||
->xpath('@REALISATEUR');
|
||||
|
||||
$this->addFieldMapping('field_date_realisation', 'date_realisation')
|
||||
->xpath('@DATE_REALISATION');
|
||||
|
||||
$this->addFieldMapping('field_production', 'production')
|
||||
->xpath('@PRODUCTION');
|
||||
|
||||
$this->addFieldMapping('field_notes', 'notes')
|
||||
->xpath('@NOTES');
|
||||
|
||||
$this->addUnmigratedDestinations(array('revision_uid', 'created', 'changed', 'revision', 'log', 'tnid','comment', 'uid','path', 'pathauto',
|
||||
'field_duree:format', 'field_duree:language',
|
||||
'field_synopsis_description:language',
|
||||
'field_proprietaire:language', 'field_proprietaire:format',
|
||||
'field_realisateur:language', 'field_realisateur:format',
|
||||
'field_date_realisation:language', 'field_date_realisation:format',
|
||||
'field_production:language', 'field_production:format',
|
||||
'field_notes:language', 'field_notes:format',
|
||||
'field_performances'
|
||||
));
|
||||
}
|
||||
|
||||
public function prepareRow($row){
|
||||
// dsm($row , '--- $row ---');
|
||||
$xml = $row->xml;
|
||||
|
||||
$title = $this->getAttribute($xml, 'TITRE');
|
||||
if(strlen($title) > 255)
|
||||
$title = substr($title, 0, 250) . '...';
|
||||
$row->title = $title;
|
||||
|
||||
|
||||
$row->duree = $this->getAttribute($xml, 'DUREE') .' '. $this->getAttribute($xml, 'UNITE_DUREE');
|
||||
|
||||
}
|
||||
|
||||
public function prepare($node, stdClass $row) {
|
||||
$node->name = 'migration';
|
||||
$node->workflow = 2;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* PerfGroupeNodeMigration
|
||||
*
|
||||
*/
|
||||
class PerfDimpNodeMigration extends PerfDocsNodeMigration {
|
||||
public function __construct() {
|
||||
|
||||
$this->description = t('Migrate Document Imprimé Class');
|
||||
|
||||
$this->fields = array(
|
||||
'fichier_pdf' => t('fichier_pdf'),
|
||||
);
|
||||
|
||||
$this->itemsfile = 'baseperf-dimps.xml';
|
||||
|
||||
$this->item_xpath = '/ROOT/ITEMS/DOC_IMPRIME'; // relative to document
|
||||
|
||||
parent::__construct();
|
||||
|
||||
|
||||
$this->addFieldMapping('field_type')->defaultValue('imprime');
|
||||
|
||||
$this->addFieldMapping('field_fichier_pdf', 'fichier_pdf')
|
||||
->xpath('@FICHIER_PDF');
|
||||
|
||||
$this->addUnmigratedDestinations(array(
|
||||
'field_fichier_pdf:language', 'field_fichier_pdf:format',
|
||||
// 'field_resume_retranscription', 'field_resume_retranscription:format', 'field_resume_retranscription:language',
|
||||
));
|
||||
}
|
||||
|
||||
// public function prepareRow($row){
|
||||
// // $xml = $row->xml;
|
||||
// parent::prepareRow($row);
|
||||
//
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* PerfGroupeNodeMigration
|
||||
*
|
||||
*/
|
||||
class PerfDimpNodeUpdateMigration extends PerfDocsNodeUpdateMigration {
|
||||
public function __construct() {
|
||||
|
||||
$this->description = t('Migrate Document Imprimé Update Class');
|
||||
|
||||
$this->fields = array();
|
||||
|
||||
$this->itemsfile = 'baseperf-dimps.xml';
|
||||
|
||||
$this->item_xpath = '/ROOT/ITEMS/DOC_IMPRIME'; // relative to document
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->addFieldMapping('nid', 'ID')
|
||||
->sourceMigration('PerfDimpNode');
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* PerfGroupeNodeMigration
|
||||
*
|
||||
*/
|
||||
class PerfDmanuNodeMigration extends PerfDocsNodeMigration {
|
||||
public function __construct() {
|
||||
|
||||
$this->description = t('Migrate Document Manuel Class');
|
||||
|
||||
$this->fields = array();
|
||||
|
||||
$this->itemsfile = 'baseperf-dmanus.xml';
|
||||
|
||||
$this->item_xpath = '/ROOT/ITEMS/DOC_MANUSCRITS'; // relative to document
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->addFieldMapping('field_type')->defaultValue('manuscrit');
|
||||
// $this->addUnmigratedDestinations(array());
|
||||
}
|
||||
|
||||
// public function prepareRow($row){
|
||||
// // $xml = $row->xml;
|
||||
// parent::prepareRow($row);
|
||||
//
|
||||
//
|
||||
// }
|
||||
|
||||
public function prepare($node, stdClass $row) {
|
||||
parent::prepare($node, $row);
|
||||
// dsm($node);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* PerfGroupeNodeMigration
|
||||
*
|
||||
*/
|
||||
class PerfDmanuNodeUpdateMigration extends PerfDocsNodeUpdateMigration {
|
||||
public function __construct() {
|
||||
|
||||
$this->description = t('Update Document Manuel Class');
|
||||
|
||||
$this->fields = array();
|
||||
|
||||
$this->itemsfile = 'baseperf-dmanus.xml';
|
||||
|
||||
$this->item_xpath = '/ROOT/ITEMS/DOC_MANUSCRITS'; // relative to document
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->addFieldMapping('nid', 'ID')
|
||||
->sourceMigration('PerfDmanuNode');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
/**
|
||||
* PerfGroupeNodeMigration
|
||||
*
|
||||
*/
|
||||
abstract class PerfDocsNodeMigration extends PerfApiMigration {
|
||||
public function __construct() {
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->fields += array(
|
||||
'ID' => t('id'),
|
||||
'title' => t('title'),
|
||||
'technique_description' => t('technique_description'),
|
||||
'dimensions' => t('dimensions'),
|
||||
'proprietaire' => t('proprietaire'),
|
||||
'images' => t('images'),
|
||||
'images_title' => t('images title'),
|
||||
'images_alt' => t('images alt'),
|
||||
'serie' => t('serie'),
|
||||
'notes' => t('notes'),
|
||||
);
|
||||
|
||||
// The source ID here is the one retrieved from the XML listing file, and
|
||||
// used to identify the specific item's file
|
||||
$this->map = new MigrateSQLMap($this->machineName,
|
||||
array(
|
||||
'ID' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
)
|
||||
),
|
||||
MigrateDestinationNode::getKeySchema()
|
||||
);
|
||||
|
||||
// This can also be an URL instead of a file path.
|
||||
$xml_folder = DRUPAL_ROOT . '/' . drupal_get_path('module', 'PerfMigrate') . '/xml/';
|
||||
$items_url = $xml_folder . $this->itemsfile;
|
||||
|
||||
|
||||
$item_ID_xpath = '@ID'; // relative to item_xpath and gets assembled
|
||||
// into full path /producers/producer/sourceid
|
||||
|
||||
|
||||
$items_class = new MigrateItemsXML($items_url, $this->item_xpath, $item_ID_xpath); //
|
||||
$this->source = new MigrateSourceMultiItems($items_class, $this->fields);
|
||||
|
||||
$this->destination = new MigrateDestinationNode('document');
|
||||
|
||||
$this->addFieldMapping('language')->defaultValue('fr');
|
||||
$this->addFieldMapping('is_new')->defaultValue(TRUE);
|
||||
// $this->addFieldMapping('created', 'date_creation');
|
||||
// $this->addFieldMapping('changed', 'date_modif');
|
||||
$this->addFieldMapping('status')->defaultValue(1);
|
||||
$this->addFieldMapping('promote')->defaultValue(0);
|
||||
$this->addFieldMapping('sticky')->defaultValue(0);
|
||||
|
||||
$this->addFieldMapping('title', 'title');
|
||||
|
||||
$this->addFieldMapping('field_technique_description', 'technique_description')
|
||||
->xpath('@TECHNIQUE_DESCRIPTION_REFERENCE');
|
||||
|
||||
$this->addFieldMapping('field_dimensions', 'dimensions')
|
||||
->xpath('@DIMENSIONS_OBJET');
|
||||
|
||||
$this->addFieldMapping('field_proprietaire', 'proprietaire')
|
||||
->xpath('@ID_PROPRIETAIRE_OBJET');
|
||||
|
||||
#images
|
||||
$this->addFieldMapping('field_images', 'images');
|
||||
$this->addFieldMapping('field_images:source_dir')->defaultValue('public://SRC_IMAGES');
|
||||
$this->addFieldMapping('field_images:title', 'images_title');
|
||||
$this->addFieldMapping('field_images:alt', 'images_alt');
|
||||
|
||||
|
||||
# serie
|
||||
$this->addFieldMapping('field_serie', 'serie')
|
||||
->xpath('@SERIE');
|
||||
$this->addFieldMapping('field_serie:create_term')->defaultValue(TRUE);
|
||||
|
||||
|
||||
$this->addFieldMapping('field_notes', 'notes')
|
||||
->xpath('@NOTES');
|
||||
|
||||
$this->addUnmigratedDestinations(array('revision_uid', 'created', 'changed', 'revision', 'log', 'tnid','comment', 'uid','path', 'pathauto',
|
||||
'field_technique_description:language', 'field_technique_description:format',
|
||||
'field_dimensions:language', 'field_dimensions:format',
|
||||
'field_proprietaire:language', 'field_proprietaire:format',
|
||||
'field_images:file_class', 'field_images:language', 'field_images:destination_dir', 'field_images:destination_file', 'field_images:file_replace', 'field_images:preserve_files',
|
||||
// 'field_images:title', 'field_images:alt',
|
||||
'field_serie:source_type',
|
||||
'field_notes:language', 'field_notes:format',
|
||||
'field_performances',
|
||||
));
|
||||
}
|
||||
|
||||
public function prepareRow($row){
|
||||
// dsm($row , '--- $row ---');
|
||||
$xml = $row->xml;
|
||||
|
||||
$title = $this->getAttribute($xml, 'TITRE');
|
||||
if(strlen($title) > 255)
|
||||
$title = substr($title, 0, 250) . '...';
|
||||
$row->title = $title;
|
||||
|
||||
|
||||
#images
|
||||
$images = array();
|
||||
$titles = array();
|
||||
$alts = array();
|
||||
$i = 0;
|
||||
foreach ($xml->xpath('IMAGE_CONSULTABLE') as $xml_image) {
|
||||
$images[] = $this->getAttribute($xml_image, 'SRC');
|
||||
$alts[] = $this->getAttribute($xml_image, 'ALT');
|
||||
$titles[] = $this->getAttribute($xml_image, 'TITLE');
|
||||
$i++;
|
||||
}
|
||||
$row->images = $images;
|
||||
$row->images_title = $titles;
|
||||
$row->images_alt = $alts;
|
||||
// dsm($row->images, '$row->images');
|
||||
|
||||
}
|
||||
|
||||
public function prepare($node, stdClass $row) {
|
||||
$node->name = 'migration';
|
||||
$node->workflow = 2;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/**
|
||||
* PerfGroupeNodeMigration
|
||||
*
|
||||
*/
|
||||
abstract class PerfDocsNodeUpdateMigration extends PerfApiMigration {
|
||||
public function __construct() {
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->systemOfRecord = Migration::DESTINATION;
|
||||
|
||||
$this->fields += array(
|
||||
'ID' => t('id'),
|
||||
'images' => t('images'),
|
||||
'images_title' => t('images title'),
|
||||
'images_alt' => t('images alt'),
|
||||
);
|
||||
|
||||
// The source ID here is the one retrieved from the XML listing file, and
|
||||
// used to identify the specific item's file
|
||||
$this->map = new MigrateSQLMap($this->machineName,
|
||||
array(
|
||||
'ID' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
)
|
||||
),
|
||||
MigrateDestinationNode::getKeySchema()
|
||||
);
|
||||
|
||||
// This can also be an URL instead of a file path.
|
||||
$xml_folder = DRUPAL_ROOT . '/' . drupal_get_path('module', 'PerfMigrate') . '/xml/';
|
||||
$items_url = $xml_folder . $this->itemsfile;
|
||||
|
||||
|
||||
$item_ID_xpath = '@ID'; // relative to item_xpath and gets assembled
|
||||
// into full path /producers/producer/sourceid
|
||||
|
||||
|
||||
$items_class = new MigrateItemsXML($items_url, $this->item_xpath, $item_ID_xpath); //
|
||||
$this->source = new MigrateSourceMultiItems($items_class, $this->fields);
|
||||
|
||||
$this->destination = new MigrateDestinationNode('document');
|
||||
|
||||
#images
|
||||
$this->addFieldMapping('field_images', 'images');
|
||||
$this->addFieldMapping('field_images:source_dir')->defaultValue('public://SRC_IMAGES');
|
||||
$this->addFieldMapping('field_images:file_replace')->defaultValue(FILE_EXISTS_REPLACE);
|
||||
$this->addFieldMapping('field_images:title', 'images_title');
|
||||
$this->addFieldMapping('field_images:alt', 'images_alt');
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function prepareRow($row){
|
||||
// dsm($row , '--- $row ---');
|
||||
$xml = $row->xml;
|
||||
|
||||
#images
|
||||
$images = array();
|
||||
$titles = array();
|
||||
$alts = array();
|
||||
foreach ($xml->xpath('IMAGE_CONSULTABLE') as $xml_image) {
|
||||
$images[] = $this->getAttribute($xml_image, 'SRC');
|
||||
$alts[] = $this->getAttribute($xml_image, 'ALT');
|
||||
$titles[] = $this->getAttribute($xml_image, 'TITLE');
|
||||
}
|
||||
$row->images = $images;
|
||||
$row->images_title = $titles;
|
||||
$row->images_alt = $alts;
|
||||
|
||||
}
|
||||
|
||||
// public function prepare($node, stdClass $row) {
|
||||
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* PerfGroupeNodeMigration
|
||||
*
|
||||
*/
|
||||
class PerfDpressNodeMigration extends PerfDocsNodeMigration {
|
||||
public function __construct() {
|
||||
|
||||
$this->description = t('Migrate Document Presse Class');
|
||||
|
||||
$this->fields = array(
|
||||
'fichier_pdf' => t('fichier_pdf'),
|
||||
'resume_retranscription' => t('resume_retranscription'),
|
||||
);
|
||||
|
||||
$this->itemsfile = 'baseperf-dpress.xml';
|
||||
|
||||
$this->item_xpath = '/ROOT/ITEMS/DOC_PRESSE'; // relative to document
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->addFieldMapping('field_type')->defaultValue('presse');
|
||||
|
||||
$this->addFieldMapping('field_fichier_pdf', 'fichier_pdf')
|
||||
->xpath('@FICHIER_PDF');
|
||||
|
||||
$this->addFieldMapping('field_resume_retranscription', 'fichier_pdf')
|
||||
->xpath('@RESUME_RETRANSCRIPTION');
|
||||
$this->addFieldMapping('field_resume_retranscription:format')->defaultValue('filtred_html');
|
||||
|
||||
$this->addUnmigratedDestinations(array(
|
||||
'field_fichier_pdf:language', 'field_fichier_pdf:format',
|
||||
'field_resume_retranscription:language',
|
||||
));
|
||||
}
|
||||
|
||||
// public function prepareRow($row){
|
||||
// // $xml = $row->xml;
|
||||
// parent::prepareRow($row);
|
||||
//
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* PerfGroupeNodeMigration
|
||||
*
|
||||
*/
|
||||
class PerfDpressNodeUpdateMigration extends PerfDocsNodeUpdateMigration {
|
||||
public function __construct() {
|
||||
|
||||
$this->description = t('Migrate Document Presse Class');
|
||||
|
||||
$this->fields = array();
|
||||
|
||||
$this->itemsfile = 'baseperf-dpress.xml';
|
||||
|
||||
$this->item_xpath = '/ROOT/ITEMS/DOC_PRESSE'; // relative to document
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->addFieldMapping('nid', 'ID')
|
||||
->sourceMigration('PerfDpressNode');
|
||||
}
|
||||
|
||||
// public function prepareRow($row){
|
||||
// // $xml = $row->xml;
|
||||
// parent::prepareRow($row);
|
||||
//
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* PerfGroupeNodeMigration
|
||||
*
|
||||
*/
|
||||
class PerfDsonsNodeMigration extends PerfDNodeMigration {
|
||||
public function __construct() {
|
||||
|
||||
$this->description = t('Migrate Document Sonore Class');
|
||||
|
||||
$this->fields = array(
|
||||
'support' => t('support'),
|
||||
);
|
||||
|
||||
// This can also be an URL instead of a file path.
|
||||
$xml_folder = DRUPAL_ROOT . '/' . drupal_get_path('module', 'PerfMigrate') . '/xml/';
|
||||
$this->items_url = $xml_folder . 'baseperf-dsons.xml';
|
||||
|
||||
$this->item_xpath = '/ROOT/ITEMS/DOC_SONORE'; // relative to document
|
||||
|
||||
$this->destination = new MigrateDestinationNode('document_sonor');
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->addFieldMapping('field_support', 'support')
|
||||
->xpath('@SUPPORT');
|
||||
|
||||
$this->addUnmigratedDestinations(array('field_support:language', 'field_support:format'));
|
||||
|
||||
}
|
||||
|
||||
public function prepareRow($row){
|
||||
parent::prepareRow($row);
|
||||
}
|
||||
|
||||
public function prepare($node, stdClass $row) {
|
||||
parent::prepare($node, $row);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* PerfGroupeNodeMigration
|
||||
*
|
||||
*/
|
||||
class PerfDvidsNodeMigration extends PerfDNodeMigration {
|
||||
public function __construct() {
|
||||
|
||||
$this->description = t('Migrate Document Video Class');
|
||||
|
||||
$this->fields = array(
|
||||
'fichiers' => t('fichiers'),
|
||||
'etat_conservation' => t('etat_conservation'),
|
||||
);
|
||||
|
||||
// This can also be an URL instead of a file path.
|
||||
$xml_folder = DRUPAL_ROOT . '/' . drupal_get_path('module', 'PerfMigrate') . '/xml/';
|
||||
$this->items_url = $xml_folder . 'baseperf-dvids.xml';
|
||||
|
||||
$this->item_xpath = '/ROOT/ITEMS/DOC_AUDIOVISUEL'; // relative to document
|
||||
|
||||
$this->destination = new MigrateDestinationNode('document_video');
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->addFieldMapping('field_etat_de_conservation', 'etat_conservation')
|
||||
->xpath('@ETAT_CONSERVATION');
|
||||
|
||||
$this->addFieldMapping('field_fichiers', 'fichiers');
|
||||
|
||||
$this->addUnmigratedDestinations(array(
|
||||
'field_etat_de_conservation:language', 'field_etat_de_conservation:format',
|
||||
'field_fichiers:language', 'field_fichiers:format',
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
public function prepareRow($row){
|
||||
parent::prepareRow($row);
|
||||
|
||||
$xml = $row->xml;
|
||||
|
||||
$row->fichiers .= "\n".'Fichier MP4 : '.$this->getAttribute($xml, 'FICHIER_MP4');
|
||||
$row->fichiers .= "\n".'Fichier FLV : '.$this->getAttribute($xml, 'FICHIER_FLV');
|
||||
}
|
||||
|
||||
public function prepare($node, stdClass $row) {
|
||||
parent::prepare($node, $row);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* PerfGroupeNodeMigration
|
||||
*
|
||||
*/
|
||||
class PerfDvidsVimeoMigration extends PerfDNodeMigration {
|
||||
|
||||
public function __construct() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function prepareRow($row){
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function prepare($node, stdClass $row) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* PerfGroupeNodeMigration
|
||||
*
|
||||
*/
|
||||
class PerfGroupeNodeMigration extends PerfBasicMigration {
|
||||
public function __construct() {
|
||||
|
||||
$this->item_xpath = '/RACINE/ARBRE/INITIALE/GROUPE/PERFORMANCE'; // relative to document
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->description = t('XML feed of groupe of performances');
|
||||
// $this->dependencies = array('WineRegion', 'WineUser');
|
||||
|
||||
}
|
||||
|
||||
// public function prepareRow($row){
|
||||
// parent::prepareRow($row);
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* PerfGroupeNodeMigration
|
||||
*
|
||||
*/
|
||||
class PerfGroupeNodeUpdateMigration extends PerfBasicUpdateMigration {
|
||||
public function __construct() {
|
||||
|
||||
$this->item_xpath = '/RACINE/ARBRE/INITIALE/GROUPE/PERFORMANCE'; // relative to document
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->description = t('XML feed of groupe of performances');
|
||||
// $this->dependencies = array('WineRegion', 'WineUser');
|
||||
|
||||
$this->addFieldMapping('nid', 'treeline_id')
|
||||
->sourceMigration('PerfGroupeNode');
|
||||
|
||||
}
|
||||
|
||||
// public function prepareRow($row){
|
||||
// parent::prepareRow($row);
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
name = PerfMigrate
|
||||
description = "The description of this module"
|
||||
|
||||
; Core version (required)
|
||||
core = 7.x
|
||||
|
||||
; Package name (see http://drupal.org/node/542202 for a list of names)
|
||||
; package =
|
||||
|
||||
; PHP version requirement (optional)
|
||||
; php = 5.2
|
||||
|
||||
; Loadable code files
|
||||
files[] = PerfMigrate.module
|
||||
files[] = PerfMigrate.api.inc
|
||||
files[] = PerfMigrate.basic.inc
|
||||
files[] = PerfMigrate.performance.inc
|
||||
files[] = PerfMigrate.groupe.inc
|
||||
files[] = PerfMigrate.ldcs.inc
|
||||
files[] = PerfMigrate.d.inc
|
||||
files[] = PerfMigrate.dvids.inc
|
||||
files[] = PerfMigrate.dsons.inc
|
||||
files[] = PerfMigrate.docs.inc
|
||||
files[] = PerfMigrate.dimp.inc
|
||||
files[] = PerfMigrate.dpresse.inc
|
||||
files[] = PerfMigrate.dmanu.inc
|
||||
files[] = PerfMigrate.objet.inc
|
||||
; files[] = PerfMigrate.dvidsVimeo.inc
|
||||
|
||||
files[] = PerfMigrate.basic_update.inc
|
||||
files[] = PerfMigrate.performance_update.inc
|
||||
files[] = PerfMigrate.groupe_update.inc
|
||||
files[] = PerfMigrate.ldcs_update.inc
|
||||
;files[] = PerfMigrate.d.inc
|
||||
;files[] = PerfMigrate.dvids.inc
|
||||
;files[] = PerfMigrate.dsons.inc
|
||||
files[] = PerfMigrate.docs_update.inc
|
||||
files[] = PerfMigrate.dimp_update.inc
|
||||
files[] = PerfMigrate.dpresse_update.inc
|
||||
files[] = PerfMigrate.dmanu_update.inc
|
||||
files[] = PerfMigrate.objet_update.inc
|
||||
|
||||
; Module dependencies
|
||||
dependencies[] = migrate
|
||||
dependencies[] = migrate_extras
|
||||
; dependencies[] = anothermodule (>=2.4)
|
||||
; dependencies[] = views (3.x)
|
||||
|
||||
; Configuration page
|
||||
; configure = admin/config/PerfMigration
|
||||
|
||||
|
||||
; For further information about configuration options, see
|
||||
; - http://drupal.org/node/542202
|
||||
@@ -0,0 +1,233 @@
|
||||
<?php
|
||||
/**
|
||||
* PerfGroupeNodeMigration
|
||||
*
|
||||
*/
|
||||
class PerfLDCNodeMigration extends PerfApiMigration {
|
||||
public function __construct() {
|
||||
|
||||
$this->description = t('Migrate Lieu Date Contexte (effectuation) Class');
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$fields = array(
|
||||
'language' => t('Lanuguage'),
|
||||
'ID' => t('id'),
|
||||
'title' => t('title'),
|
||||
|
||||
'structure_organisatrice' => t('Structure organisatrice'), // STRUCTURE_ORGANISATRICE
|
||||
|
||||
'topologie' => t('Topologie'),
|
||||
|
||||
'date_de_debut' => t('date debut'),
|
||||
'date_de_fin' => t('date fin'),
|
||||
'duree' => t('duree'), //'UNITE_DUREE' => t('UNITE_DUREE'),
|
||||
|
||||
'contexte' => t('contexte'), // CONTEXTE- TRADUCTION_CONTEXTE
|
||||
|
||||
'lieu' => t('lieu'),
|
||||
'adresse' => t('adresse'),
|
||||
'precision'=> t('precision'),
|
||||
'ville' => t('ville'),
|
||||
'pays' => t('pays'),
|
||||
|
||||
'executant'=> t('executant'),
|
||||
'concepteur'=> t('concepteur'),
|
||||
'organisateur'=> t('organisateur'),
|
||||
|
||||
'notes' => t('notes'),
|
||||
|
||||
);
|
||||
|
||||
// The source ID here is the one retrieved from the XML listing file, and
|
||||
// used to identify the specific item's file
|
||||
$this->map = new MigrateSQLMap($this->machineName,
|
||||
array(
|
||||
'ID' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
)
|
||||
),
|
||||
MigrateDestinationNode::getKeySchema()
|
||||
);
|
||||
|
||||
// This can also be an URL instead of a file path.
|
||||
$xml_folder = DRUPAL_ROOT . '/' . drupal_get_path('module', 'PerfMigrate') . '/xml/';
|
||||
$items_url = $xml_folder . 'baseperf-ldcs.xml';
|
||||
|
||||
// We use the MigrateSourceMultiItems class for any source where we obtain the list
|
||||
// of IDs to process and the data for each item from the same file. Typically the data
|
||||
// for an item is not contained in a single line within the source file. Examples include
|
||||
// multiple items defined in a single xml file or a single json file where in both cases
|
||||
// the id is part of the item.
|
||||
$item_xpath = '/ROOT/ITEMS/LIEU_DATE_CONTEXTE'; // relative to document
|
||||
|
||||
$item_ID_xpath = '@ID'; // relative to item_xpath and gets assembled
|
||||
// into full path /producers/producer/sourceid
|
||||
|
||||
|
||||
$items_class = new MigrateItemsXML($items_url, $item_xpath, $item_ID_xpath); //
|
||||
$this->source = new MigrateSourceMultiItems($items_class, $fields);
|
||||
|
||||
$this->destination = new MigrateDestinationNode('effectuation');
|
||||
|
||||
$this->addFieldMapping('language')->defaultValue('fr');
|
||||
$this->addFieldMapping('is_new')->defaultValue(TRUE);
|
||||
// $this->addFieldMapping('created', 'date_creation');
|
||||
// $this->addFieldMapping('changed', 'date_modif');
|
||||
$this->addFieldMapping('status')->defaultValue(1);
|
||||
$this->addFieldMapping('promote')->defaultValue(0);
|
||||
$this->addFieldMapping('sticky')->defaultValue(0);
|
||||
|
||||
$this->addFieldMapping('title', 'title');
|
||||
|
||||
# temps
|
||||
$this->addFieldMapping('field_date_de_debut', 'date_de_debut');
|
||||
$this->addFieldMapping('field_date_de_fin', 'date_de_fin');
|
||||
$this->addFieldMapping('field_duree', 'duree');
|
||||
|
||||
# lieu
|
||||
$this->addFieldMapping('field_lieu', 'lieu')
|
||||
->xpath('@NOM_LIEU');
|
||||
$this->addFieldMapping('field_lieu:create_term')->defaultValue(TRUE);
|
||||
|
||||
# topologie
|
||||
$this->addFieldMapping('field_topologie', 'topologie')
|
||||
->xpath('@TYPE');
|
||||
$this->addFieldMapping('field_topologie:create_term')->defaultValue(TRUE);
|
||||
|
||||
# structure_organisatrice
|
||||
$this->addFieldMapping('field_structure', 'structure_organisatrice');
|
||||
$this->addFieldMapping('field_structure:create_term')->defaultValue(TRUE);
|
||||
|
||||
# contexte
|
||||
$this->addFieldMapping('field_contexte', 'contexte');
|
||||
$this->addFieldMapping('field_contexte:format')->defaultValue('filtred_html');
|
||||
$this->addFieldMapping('field_contexte:language', 'language');
|
||||
|
||||
# personnes
|
||||
$this->addFieldMapping('field_concepteur', 'concepteur');
|
||||
$this->addFieldMapping('field_concepteur:create_term')->defaultValue(TRUE);
|
||||
$this->addFieldMapping('field_executant', 'executant');
|
||||
$this->addFieldMapping('field_executant:create_term')->defaultValue(TRUE);
|
||||
$this->addFieldMapping('field_organisateur', 'organisateur');
|
||||
$this->addFieldMapping('field_organisateur:create_term')->defaultValue(TRUE);
|
||||
|
||||
# note
|
||||
$this->addFieldMapping('field_note', 'notes')
|
||||
->xpath('@NOTES');
|
||||
|
||||
# addresse
|
||||
// $this->addFieldMapping('field_precision', 'precision')
|
||||
// ->xpath('@PRECISION');
|
||||
// $this->addFieldMapping('field_precision:format')->defaultValue('filtred_html');
|
||||
// $this->addFieldMapping('field_precision:language')->defaultValue('fr');
|
||||
$arguments = array(
|
||||
'thoroughfare' => array('source_field' => 'adresse'),
|
||||
'premise' => array('source_field' => 'precision'),
|
||||
// 'sub_premise' => array('source_field' => 'sub_premise'),
|
||||
'locality' => array('source_field' => 'ville'),
|
||||
// 'postal_code' => array('source_field' => 'zip'),
|
||||
);
|
||||
$this->addFieldMapping('field_address', 'pays')
|
||||
->arguments($arguments);
|
||||
$this->addFieldMapping(NULL, 'adresse');
|
||||
$this->addFieldMapping(NULL, 'precision');
|
||||
$this->addFieldMapping(NULL, 'ville');
|
||||
|
||||
|
||||
$this->addUnmigratedDestinations(array('revision_uid', 'created', 'changed', 'revision', 'log', 'tnid','comment', 'uid','path', 'pathauto',
|
||||
'field_date_de_debut:format', 'field_date_de_debut:language', 'field_date_de_fin:format', 'field_date_de_fin:language',
|
||||
'field_dure:format', 'field_dure:language',
|
||||
'field_lieu:source_type', 'field_topologie:source_type', 'field_structure:source_type',
|
||||
'field_concepteur:source_type','field_executant:source_type','field_organisateur:source_type',
|
||||
'field_note:format', "field_note:language",
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
public function prepareRow($row){
|
||||
// dsm($row , '--- $row ---');
|
||||
$xml = $row->xml;
|
||||
|
||||
$row->language = array('fr', 'en');
|
||||
|
||||
$title = $this->getAttribute($xml, 'TITLE');
|
||||
if(strlen($title) > 255)
|
||||
$title = substr($title, 0, 250) . '...';
|
||||
$row->title = $title;
|
||||
|
||||
# temps
|
||||
$row->date_de_debut = $this->getDate($xml, 'DEBUT');
|
||||
$row->date_de_fin = $this->getDate($xml, 'FIN');
|
||||
$row->duree = $this->getAttribute($xml, 'DUREE') .' '. $this->getAttribute($xml, 'UNITE_DUREE');
|
||||
|
||||
# espace
|
||||
$row->lieu = $this->getAttribute($xml, 'NOM_LIEU');
|
||||
|
||||
# structure
|
||||
$structure = array();
|
||||
foreach ($xml->xpath('STRUCTURE_ORGANISATRICE') as $xml_strucrture)
|
||||
$structure[] = $this->getAttribute($xml_strucrture, 'NOM');
|
||||
$row->structure_organisatrice = $structure;
|
||||
|
||||
# contexte
|
||||
$row->contexte = array(
|
||||
$this->getAttribute($xml, "CONTEXTE"),
|
||||
$this->getAttribute($xml, "TRADUCTION_CONTEXTE"),
|
||||
);
|
||||
|
||||
# personnes
|
||||
$concepteurs = array();
|
||||
foreach ($xml->xpath('PERSONNE[@CONCEPTEUR="oui"]') as $xml_concepteur)
|
||||
$concepteurs[] = $this->getPersonne($xml_concepteur);
|
||||
$row->concepteur = $concepteurs;
|
||||
|
||||
$executants = array();
|
||||
foreach ($xml->xpath('PERSONNE[@EXECUTANT="oui"]') as $xml_executant)
|
||||
$executants[] = $this->getPersonne($xml_executant);
|
||||
$row->executant = $executants;
|
||||
|
||||
$organisateurs = array();
|
||||
foreach ($xml->xpath('PERSONNE[@ORGANISATEUR="oui"]') as $xml_organisateur)
|
||||
$organisateurs[] = $this->getPersonne($xml_organisateur);
|
||||
$row->organisateur = $organisateurs;
|
||||
|
||||
#address
|
||||
$row->adresse = $this->getAttribute($xml, 'ADRESSE');
|
||||
$row->precision = $this->getAttribute($xml, 'PRECISION');
|
||||
$row->ville = $this->getAttribute($xml, 'VILLE');
|
||||
$pays = $this->getAttribute($xml, 'PAYS');
|
||||
if($pays == 'France' || $pays == 'france' || $pays = ''){
|
||||
$pays = 'FR';
|
||||
}else if($pays == 'Allemagne' || $pays == 'RFA'){
|
||||
$pays = 'DE';
|
||||
}else if($pays == 'Monaco' || $pays == "Principauté de Monaco"){
|
||||
$pays = 'MC';
|
||||
}else if($pays == 'Canada'){
|
||||
$pays = 'CA';
|
||||
}else if($pays == 'Italie'){
|
||||
$pays = 'IT';
|
||||
}else if($pays == 'USA'){
|
||||
$pays = 'US';
|
||||
}else{
|
||||
// dsm($pays, '$pays');
|
||||
$pays = '';
|
||||
}
|
||||
|
||||
$row->pays = $pays;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function prepare($node, stdClass $row) {
|
||||
$node->name = 'migration';
|
||||
$node->workflow = 2;
|
||||
$node->language = 'fr';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/**
|
||||
* PerfGroupeNodeMigration
|
||||
*
|
||||
*/
|
||||
class PerfLDCNodeUpdateMigration extends PerfApiMigration {
|
||||
public function __construct() {
|
||||
|
||||
$this->description = t('Update Lieu Date Contexte (effectuation) Class');
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->systemOfRecord = Migration::DESTINATION;
|
||||
|
||||
$fields = array(
|
||||
'ID' => t('id'),
|
||||
);
|
||||
|
||||
// The source ID here is the one retrieved from the XML listing file, and
|
||||
// used to identify the specific item's file
|
||||
$this->map = new MigrateSQLMap($this->machineName,
|
||||
array(
|
||||
'ID' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
)
|
||||
),
|
||||
MigrateDestinationNode::getKeySchema()
|
||||
);
|
||||
|
||||
// This can also be an URL instead of a file path.
|
||||
$xml_folder = DRUPAL_ROOT . '/' . drupal_get_path('module', 'PerfMigrate') . '/xml/';
|
||||
$items_url = $xml_folder . 'baseperf-ldcs.xml';
|
||||
|
||||
// We use the MigrateSourceMultiItems class for any source where we obtain the list
|
||||
// of IDs to process and the data for each item from the same file. Typically the data
|
||||
// for an item is not contained in a single line within the source file. Examples include
|
||||
// multiple items defined in a single xml file or a single json file where in both cases
|
||||
// the id is part of the item.
|
||||
$item_xpath = '/ROOT/ITEMS/LIEU_DATE_CONTEXTE'; // relative to document
|
||||
|
||||
$item_ID_xpath = '@ID'; // relative to item_xpath and gets assembled
|
||||
// into full path /producers/producer/sourceid
|
||||
|
||||
|
||||
$items_class = new MigrateItemsXML($items_url, $item_xpath, $item_ID_xpath); //
|
||||
$this->source = new MigrateSourceMultiItems($items_class, $fields);
|
||||
|
||||
$this->destination = new MigrateDestinationNode('effectuation');
|
||||
|
||||
$this->addFieldMapping('nid', 'ID')
|
||||
->sourceMigration('PerfLDCNode');
|
||||
|
||||
}
|
||||
|
||||
public function prepareRow($row){
|
||||
|
||||
}
|
||||
|
||||
public function prepare($node, stdClass $row) {
|
||||
|
||||
}
|
||||
|
||||
public function complete($node, stdClass $row){
|
||||
$xml = $row->xml;
|
||||
|
||||
# personnes
|
||||
$this->recordGroup($node, 'field_concepteur', $xml, 'CONCEPTEUR');
|
||||
|
||||
$this->recordGroup($node, 'field_executant',$xml, 'EXECUTANT');
|
||||
|
||||
$this->recordGroup($node, 'field_organisateur', $xml, 'ORGANISATEUR');
|
||||
|
||||
$this->recordGroup($node, 'field_temoin', $xml, 'TEMOIN');
|
||||
|
||||
node_save($node);
|
||||
|
||||
# personnes
|
||||
$this->updatePersonneTerms($xml);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* This is the file description for PerfMigration module.
|
||||
*
|
||||
* In this more verbose, multi-line description, you can specify what this
|
||||
* file does exactly. Make sure to wrap your documentation in column 78 so
|
||||
* that the file can be displayed nicely in default-sized consoles.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_menu().
|
||||
*/
|
||||
// function PerfMigrate_menu() {
|
||||
// $items = array();
|
||||
//
|
||||
// // Type '$item ⇥' to create a new menu item.
|
||||
//
|
||||
// return $items;
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* You must implement hook_migrate_api(), setting the API level to 2, for
|
||||
* your migration classes to be recognized by the Migrate module (for the 7.x-2.x branch).
|
||||
*/
|
||||
function PerfMigrate_migrate_api() {
|
||||
$api = array(
|
||||
'api' => 2,
|
||||
'migrations' => array(
|
||||
'PerfPerformanceNode' => array('class_name' => 'PerfPerformanceNodeMigration'),
|
||||
'PerfGroupeNode' => array('class_name' => 'PerfGroupeNodeMigration'),
|
||||
'PerfLDCNode' => array('class_name' => 'PerfLDCNodeMigration'),
|
||||
'PerfDimpNode' => array('class_name' => 'PerfDimpNodeMigration'),
|
||||
'PerfDmanuNode' => array('class_name' => 'PerfDmanuNodeMigration'),
|
||||
'PerfDpressNode' => array('class_name' => 'PerfDpressNodeMigration'),
|
||||
'PerfDsonsNode' => array('class_name' => 'PerfDsonsNodeMigration'),
|
||||
'PerfDvidsNode' => array('class_name' => 'PerfDvidsNodeMigration'),
|
||||
'PerfObjetNode' => array('class_name' => 'PerfObjetNodeMigration'),
|
||||
// updates
|
||||
'PerfPerformanceUpdateNode' => array('class_name' => 'PerfPerformanceUpdateNodeMigration'),
|
||||
'PerfGroupeNodeUpdate' => array('class_name' => 'PerfGroupeNodeUpdateMigration'),
|
||||
'PerfLDCNodeUpdate' => array('class_name' => 'PerfLDCNodeUpdateMigration'),
|
||||
'PerfDimpNodeUpdate' => array('class_name' => 'PerfDimpNodeUpdateMigration'),
|
||||
'PerfDmanuNodeUpdate' => array('class_name' => 'PerfDmanuNodeUpdateMigration'),
|
||||
'PerfDpressNodeUpdate' => array('class_name' => 'PerfDpressNodeUpdateMigration'),
|
||||
'PerfObjetNodeUpdate' => array('class_name' => 'PerfObjetNodeUpdateMigration'),
|
||||
)
|
||||
);
|
||||
return $api;
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
/**
|
||||
* PerfGroupeNodeMigration
|
||||
*
|
||||
*/
|
||||
class PerfObjetNodeMigration extends PerfApiMigration {
|
||||
public function __construct() {
|
||||
|
||||
$this->description = t('Migrate Objects Class');
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$fields = array(
|
||||
'ID' => t('id'),
|
||||
'title' => t('title'),
|
||||
'technique_description' => t('technique_description'),
|
||||
'dimensions' => t('dimensions'),
|
||||
'proprietaire' => t('proprietaire'),
|
||||
'images' => t('images'),
|
||||
'images_title' => t('images title'),
|
||||
'images_alt' => t('images alt'),
|
||||
'serie' => t('serie'),
|
||||
'notes' => t('notes'),
|
||||
);
|
||||
|
||||
// The source ID here is the one retrieved from the XML listing file, and
|
||||
// used to identify the specific item's file
|
||||
$this->map = new MigrateSQLMap($this->machineName,
|
||||
array(
|
||||
'ID' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
)
|
||||
),
|
||||
MigrateDestinationNode::getKeySchema()
|
||||
);
|
||||
|
||||
// This can also be an URL instead of a file path.
|
||||
$xml_folder = DRUPAL_ROOT . '/' . drupal_get_path('module', 'PerfMigrate') . '/xml/';
|
||||
$items_url = $xml_folder . 'baseperf-objets.xml';
|
||||
|
||||
// We use the MigrateSourceMultiItems class for any source where we obtain the list
|
||||
// of IDs to process and the data for each item from the same file. Typically the data
|
||||
// for an item is not contained in a single line within the source file. Examples include
|
||||
// multiple items defined in a single xml file or a single json file where in both cases
|
||||
// the id is part of the item.
|
||||
$item_xpath = '/ROOT/ITEMS/OBJET'; // relative to document
|
||||
|
||||
$item_ID_xpath = '@ID'; // relative to item_xpath and gets assembled
|
||||
// into full path /producers/producer/sourceid
|
||||
|
||||
|
||||
$items_class = new MigrateItemsXML($items_url, $item_xpath, $item_ID_xpath); //
|
||||
$this->source = new MigrateSourceMultiItems($items_class, $fields);
|
||||
|
||||
$this->destination = new MigrateDestinationNode('object');
|
||||
|
||||
$this->addFieldMapping('language')->defaultValue('fr');
|
||||
$this->addFieldMapping('is_new')->defaultValue(TRUE);
|
||||
// $this->addFieldMapping('created', 'date_creation');
|
||||
// $this->addFieldMapping('changed', 'date_modif');
|
||||
$this->addFieldMapping('status')->defaultValue(1);
|
||||
$this->addFieldMapping('promote')->defaultValue(0);
|
||||
$this->addFieldMapping('sticky')->defaultValue(0);
|
||||
|
||||
$this->addFieldMapping('title', 'title');
|
||||
|
||||
$this->addFieldMapping('field_technique_description', 'technique_description')
|
||||
->xpath('@TECHNIQUE_DESCRIPTION_REFERENCE');
|
||||
|
||||
$this->addFieldMapping('field_dimensions', 'dimensions')
|
||||
->xpath('@DIMENSIONS_OBJET');
|
||||
|
||||
$this->addFieldMapping('field_proprietaire', 'proprietaire')
|
||||
->xpath('@ID_PROPRIETAIRE_OBJET');
|
||||
|
||||
#images
|
||||
$this->addFieldMapping('field_images', 'images');
|
||||
$this->addFieldMapping('field_images:source_dir')->defaultValue('public://SRC_IMAGES');
|
||||
$this->addFieldMapping('field_images:title', 'images_title');
|
||||
$this->addFieldMapping('field_images:alt', 'images_alt');
|
||||
|
||||
|
||||
# serie
|
||||
$this->addFieldMapping('field_serie', 'serie')
|
||||
->xpath('@SERIE');
|
||||
$this->addFieldMapping('field_serie:create_term')->defaultValue(TRUE);
|
||||
|
||||
|
||||
$this->addFieldMapping('field_notes', 'notes')
|
||||
->xpath('@NOTES');
|
||||
|
||||
$this->addUnmigratedDestinations(array('revision_uid', 'created', 'changed', 'revision', 'log', 'tnid','comment', 'uid','path', 'pathauto',
|
||||
'field_technique_description:language', 'field_technique_description:format',
|
||||
'field_dimensions:language', 'field_dimensions:format',
|
||||
'field_proprietaire:language', 'field_proprietaire:format',
|
||||
'field_images:file_class', 'field_images:language', 'field_images:destination_dir', 'field_images:destination_file', 'field_images:file_replace', 'field_images:preserve_files',
|
||||
// 'field_images:title', 'field_images:alt',
|
||||
'field_serie:source_type',
|
||||
'field_notes:language', 'field_notes:format',
|
||||
'field_performances'
|
||||
));
|
||||
}
|
||||
|
||||
public function prepareRow($row){
|
||||
// dsm($row , '--- $row ---');
|
||||
$xml = $row->xml;
|
||||
|
||||
$title = $this->getAttribute($xml, 'TITRE');
|
||||
if(strlen($title) > 255)
|
||||
$title = substr($title, 0, 250) . '...';
|
||||
$row->title = $title;
|
||||
|
||||
|
||||
|
||||
#images
|
||||
$images = array();
|
||||
$titles = array();
|
||||
$alts = array();
|
||||
$i = 0;
|
||||
foreach ($xml->xpath('IMAGE_CONSULTABLE') as $xml_image) {
|
||||
$images[] = $this->getAttribute($xml_image, 'SRC');
|
||||
$alts[] = $this->getAttribute($xml_image, 'ALT');
|
||||
$titles[] = $this->getAttribute($xml_image, 'TITLE');
|
||||
$i++;
|
||||
}
|
||||
$row->images = $images;
|
||||
// $row->images_title = $alt;
|
||||
// $row->images_alt = $titles;
|
||||
// dsm($row->images, '$row->images');
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function prepare($node, stdClass $row) {
|
||||
$node->name = 'migration';
|
||||
$node->workflow = 2;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
/**
|
||||
* PerfGroupeNodeMigration
|
||||
*
|
||||
*/
|
||||
class PerfObjetNodeUpdateMigration extends PerfApiMigration {
|
||||
public function __construct() {
|
||||
|
||||
$this->description = t('Update Objects Class');
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->systemOfRecord = Migration::DESTINATION;
|
||||
|
||||
$fields = array(
|
||||
'ID' => t('id'),
|
||||
'images' => t('images'),
|
||||
'images_title' => t('images title'),
|
||||
'images_alt' => t('images alt'),
|
||||
);
|
||||
|
||||
// The source ID here is the one retrieved from the XML listing file, and
|
||||
// used to identify the specific item's file
|
||||
$this->map = new MigrateSQLMap($this->machineName,
|
||||
array(
|
||||
'ID' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
)
|
||||
),
|
||||
MigrateDestinationNode::getKeySchema()
|
||||
);
|
||||
|
||||
// This can also be an URL instead of a file path.
|
||||
$xml_folder = DRUPAL_ROOT . '/' . drupal_get_path('module', 'PerfMigrate') . '/xml/';
|
||||
$items_url = $xml_folder . 'baseperf-objets.xml';
|
||||
|
||||
// We use the MigrateSourceMultiItems class for any source where we obtain the list
|
||||
// of IDs to process and the data for each item from the same file. Typically the data
|
||||
// for an item is not contained in a single line within the source file. Examples include
|
||||
// multiple items defined in a single xml file or a single json file where in both cases
|
||||
// the id is part of the item.
|
||||
$item_xpath = '/ROOT/ITEMS/OBJET'; // relative to document
|
||||
|
||||
$item_ID_xpath = '@ID'; // relative to item_xpath and gets assembled
|
||||
// into full path /producers/producer/sourceid
|
||||
|
||||
|
||||
$items_class = new MigrateItemsXML($items_url, $item_xpath, $item_ID_xpath); //
|
||||
$this->source = new MigrateSourceMultiItems($items_class, $fields);
|
||||
|
||||
$this->destination = new MigrateDestinationNode('object');
|
||||
|
||||
$this->addFieldMapping('nid', 'ID')
|
||||
->sourceMigration('PerfObjetNode');
|
||||
|
||||
|
||||
#images
|
||||
$this->addFieldMapping('field_images', 'images');
|
||||
$this->addFieldMapping('field_images:source_dir')->defaultValue('public://SRC_IMAGES');
|
||||
$this->addFieldMapping('field_images:file_replace')->defaultValue(FILE_EXISTS_REPLACE);
|
||||
$this->addFieldMapping('field_images:title', 'images_title');
|
||||
$this->addFieldMapping('field_images:alt', 'images_alt');
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function prepareRow($row){
|
||||
// dsm($row , '--- $row ---');
|
||||
$xml = $row->xml;
|
||||
|
||||
|
||||
#images
|
||||
$images = array();
|
||||
$titles = array();
|
||||
$alts = array();
|
||||
foreach ($xml->xpath('IMAGE_CONSULTABLE') as $xml_image) {
|
||||
$images[] = $this->getAttribute($xml_image, 'SRC');
|
||||
$alts[] = $this->getAttribute($xml_image, 'ALT');
|
||||
$titles[] = $this->getAttribute($xml_image, 'TITLE');
|
||||
}
|
||||
$row->images = $images;
|
||||
$row->images_title = $titles;
|
||||
$row->images_alt = $alts;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function prepare($node, stdClass $row) {
|
||||
$node->name = 'migration';
|
||||
$node->workflow = 2;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/**
|
||||
* MaterioMateriauNodeMigration
|
||||
*
|
||||
*/
|
||||
class PerfPerformanceNodeMigration extends PerfBasicMigration {
|
||||
public function __construct() {
|
||||
|
||||
$this->item_xpath = '/RACINE/ARBRE/INITIALE/PERFORMANCE'; // relative to document
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->description = t('XML feed of performances');
|
||||
// $this->dependencies = array('WineRegion', 'WineUser');
|
||||
|
||||
}
|
||||
|
||||
// public function prepareRow($row){
|
||||
// parent::prepareRow($row);
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* MaterioMateriauNodeMigration
|
||||
*
|
||||
*/
|
||||
class PerfPerformanceUpdateNodeMigration extends PerfBasicUpdateMigration {
|
||||
public function __construct() {
|
||||
|
||||
$this->item_xpath = '/RACINE/ARBRE/INITIALE/PERFORMANCE'; // relative to document
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->description = t('XML feed of performances');
|
||||
// $this->dependencies = array('WineRegion', 'WineUser');
|
||||
|
||||
$this->addFieldMapping('nid', 'treeline_id')
|
||||
->sourceMigration('PerfPerformanceNode');
|
||||
|
||||
}
|
||||
|
||||
// public function prepareRow($row){
|
||||
// parent::prepareRow($row);
|
||||
// }
|
||||
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user