-
Notifications
You must be signed in to change notification settings - Fork 0
/
pubfile.inc
96 lines (82 loc) · 2.18 KB
/
pubfile.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
/**
* @file
* Implementation of migration to import CommonSpot uploaded files into Drupal Files.
*/
class NistPubFileMigration extends NistMigration {
public function __construct($arguments) {
parent::__construct($arguments);
$this->description = t('Import of NIKE Pub files into Drupal files.');
$list_url = '';
$item_url = '';
$fields = array(
'pub_id' => 'Name of the file',
'fileurl' => 'File url',
);
$this->source = new MigrateSourceList(
new MigrateListJSON($list_url),
new MigrateItemJSON($item_url, array()),
$fields
);
$this->destination = new MigrateDestinationFile();
$this->map = new MigrateSQLMap(
$this->machineName,
array(
'pub_id' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'Page ID',
)
),
MigrateDestinationNode::getKeySchema()
);
// Mapped fields
$this->addFieldMapping('value', 'Url');
$this->addFieldMapping('destination_dir', 'dir');
$this->addFieldMapping('preserve_files')
->defaultValue(true);
$this->addFieldMapping('file_replace')
->defaultValue(MigrateFile::FILE_EXISTS_REUSE);
$this->addFieldMapping('uid', 'uid')
->sourceMigration('NistUser');
$this->addFieldMapping('timestamp', 'changed');
$this->addUnmigratedDestinations(array(
'destination_file',
'fid',
'source_dir',
'path',
'urlencode'
));
$this->addUnmigratedSources(array(
/*
'id',
'unixpath',
'imageurl',
'creatorid',
'imagedescription',
'doctype',
'filename',
'ispublic',
'subsitedir',
'subsiteid',
'origheight',
'origwidth',
'filesize',
'category',
'taxonomy_ids'
*/
));
}
/**
* Implementation of Migration::prepareRow($row).
*/
public function prepareRow($row) {
if (parent::prepareRow($row) === FALSE) :
return FALSE;
endif;
//$row->title = str_replace('_', ' ', $row->title);
$row->dir = rtrim($row->dir, '/');
$row->dir = "public://documents{$row->dir}";
}
}