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