|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @file |
|
5
|
|
|
* Migrations for WEM News Nodes Translations. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
class DFSWEMNewsNodesTranslations extends DemoFrameworkBaseNodesTranslations { |
|
9
|
|
|
|
|
10
|
|
|
public function __construct($arguments) { |
|
11
|
|
|
parent::__construct($arguments); |
|
12
|
|
|
$this->description = t('Import node translations.'); |
|
13
|
|
|
$import_path = drupal_get_path('module', 'dfs_wem') . '/import/'; |
|
14
|
|
|
// Create a MigrateSource object. |
|
15
|
|
|
$this->source = new MigrateSourceCSV($import_path . 'dfs_wem.nodes.wem_news.translations.csv', $this->csvcolumns(), array('header_rows' => 1)); |
|
16
|
|
|
$this->destination = new MigrateDestinationNode('wem_news'); |
|
17
|
|
|
// Image |
|
18
|
|
|
$this->addFieldMapping('field_wem_image', 'image'); |
|
19
|
|
|
$this->addFieldMapping('field_wem_image:file_replace')->defaultValue(FILE_EXISTS_REPLACE); |
|
20
|
|
|
$this->addFieldMapping('field_wem_image:source_dir')->defaultValue($import_path . 'images'); |
|
21
|
|
|
$this->addFieldMapping('field_wem_image:destination_file', 'filename'); |
|
22
|
|
|
// Video |
|
23
|
|
|
$this->addFieldMapping('field_wem_video', 'video')->sourceMigration('DFSWEMNewsVideo'); |
|
24
|
|
|
$this->addFieldMapping('field_wem_video:file_class')->defaultValue('MigrateFileFid'); |
|
25
|
|
|
// Taxonomy |
|
26
|
|
|
$this->addFieldMapping('field_wem_interests', 'interests'); |
|
27
|
|
|
// Workbench |
|
28
|
|
|
$this->addFieldMapping('workbench_moderation_state_new', 'workbench_moderation_state_new')->defaultValue('published'); |
|
29
|
|
|
// Translations |
|
30
|
|
|
$this->addFieldMapping('title', 'translated_title'); |
|
31
|
|
|
$this->addFieldMapping('tnid', 'title')->sourceMigration('DFSWEMNewsNodes'); |
|
32
|
|
|
// UUID |
|
33
|
|
|
$this->addFieldMapping('uuid', 'uuid'); |
|
34
|
|
|
// Created |
|
35
|
|
|
$this->addFieldMapping('created', 'created')->defaultValue(strtotime("now")); |
|
36
|
|
|
// Persona |
|
37
|
|
|
$this->addFieldMapping('field_persona', 'persona'); |
|
38
|
|
|
// Site Section |
|
39
|
|
|
$this->addFieldMapping('field_site_section', 'site_section')->defaultValue("Content"); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
function csvcolumns() { |
|
|
|
|
|
|
43
|
|
|
$columns[0] = array('title', 'Source Title'); |
|
|
|
|
|
|
44
|
|
|
$columns[1] = array('language', 'Language'); |
|
45
|
|
|
$columns[2] = array('translated_title', 'Title'); |
|
46
|
|
|
$columns[3] = array('body', 'Body'); |
|
47
|
|
|
$columns[4] = array('image', 'Image'); |
|
48
|
|
|
$columns[5] = array('video', 'Video'); |
|
49
|
|
|
$columns[6] = array('interests', 'Interests'); |
|
50
|
|
|
$columns[7] = array('uuid', 'UUID'); |
|
51
|
|
|
$columns[8] = array('created', 'Created'); |
|
52
|
|
|
$columns[9] = array('persona', 'Persona'); |
|
53
|
|
|
return $columns; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
function prepareRow($row) { |
|
|
|
|
|
|
57
|
|
|
$row->interests = explode(", ", $row->interests); |
|
58
|
|
|
return TRUE; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
function prepare(&$node, $row) { |
|
|
|
|
|
|
62
|
|
|
if (isset($node->tnid) && ($source = node_load($node->tnid))) { |
|
63
|
|
|
$node->translation_source = $source; |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.