forked from mindinformatics/datalens
-
Notifications
You must be signed in to change notification settings - Fork 0
/
1_remove_contrast.php
46 lines (34 loc) · 1.09 KB
/
1_remove_contrast.php
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
<?php
/**
* Remove Contrast uploaded with Mouse 2.0 Analysis files by mistake
* using the values in an input file.
*
* Usage: drush scr 1_remove_contrast.php analysis_nids.txt
*/
$options = drush_get_arguments();
$filename = $options[2];
if ($fh = fopen($filename, "r")) {
//Read first/header line, but do nothing with it
//$header_row = fgets($fh);
while (!feof($fh)) {
$line_array = explode("\t", rtrim(fgets($fh)));
$nid = $line_array[0];
if ($nid) {
// Load the node by NID then wrap node with Entity API
$node = node_load($nid);
$node_wrapper = entity_metadata_wrapper('node', $node);
//$node_wrapper->field_contrast->set('');
//$node_wrapper->field_contrast->set(array(NULL)); does not work.
//$node_wrapper->field_contrast = null; errors but works
$node_wrapper->field_contrast = null;
var_dump("Contrast removed for:" . $nid);
//$node_wrapper->field_contrast->set(NULL);
$node_wrapper->save();
} else {
var_dump("Error! Not a valid nid. Probably empty last line of file.");
var_dump($nid);
}
}
fclose($fh);
}
?>