1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Render an importer name.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
*
|
10
|
*/
|
11
|
class feeds_views_handler_field_importer_name extends views_handler_field {
|
12
|
|
13
|
/**
|
14
|
* Overrides parent::option_definition().
|
15
|
*/
|
16
|
public function option_definition() {
|
17
|
$options = parent::option_definition();
|
18
|
$options['link'] = array('default' => 0);
|
19
|
return $options;
|
20
|
}
|
21
|
|
22
|
/**
|
23
|
* Overrides parent::options_form().
|
24
|
*/
|
25
|
public function options_form(&$form, &$form_state) {
|
26
|
parent::options_form($form, $form_state);
|
27
|
$options = array(
|
28
|
0 => t('Do not link'),
|
29
|
1 => t('Link to configuration form'),
|
30
|
2 => t('Link to standalone form'),
|
31
|
);
|
32
|
$form['link'] = array(
|
33
|
'#type' => 'radios',
|
34
|
'#title' => t('Link importer name'),
|
35
|
'#description' => t('If "Link to standalone form" is used, only importers that use a standalone form will be linked.'),
|
36
|
'#default_value' => isset($this->options['link']) ? $this->options['link'] : FALSE,
|
37
|
'#options' => $options,
|
38
|
);
|
39
|
}
|
40
|
|
41
|
/**
|
42
|
* Overrides parent::render().
|
43
|
*/
|
44
|
public function render($values) {
|
45
|
try {
|
46
|
$importer = feeds_importer($values->{$this->field_alias})->existing();
|
47
|
if ($this->options['link'] == 1) {
|
48
|
return l($importer->config['name'], 'admin/structure/feeds/' . $importer->id);
|
49
|
}
|
50
|
elseif ($this->options['link'] == 2 && empty($importer->config['content_type'])) {
|
51
|
return l($importer->config['name'], 'import/' . $importer->id);
|
52
|
}
|
53
|
return check_plain($importer->config['name']);
|
54
|
}
|
55
|
catch (Exception $e) {
|
56
|
return t('Missing importer');
|
57
|
}
|
58
|
}
|
59
|
|
60
|
/**
|
61
|
* Disallows advanced rendering.
|
62
|
*/
|
63
|
public function allow_advanced_render() {
|
64
|
return FALSE;
|
65
|
}
|
66
|
|
67
|
}
|