1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Definition of views_handler_field_custom.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* A handler to provide a field that is completely custom by the administrator.
|
10 |
|
|
*
|
11 |
|
|
* @ingroup views_field_handlers
|
12 |
|
|
*/
|
13 |
|
|
class views_handler_field_custom extends views_handler_field {
|
14 |
|
|
function query() {
|
15 |
|
|
// do nothing -- to override the parent query.
|
16 |
|
|
}
|
17 |
|
|
|
18 |
|
|
function option_definition() {
|
19 |
|
|
$options = parent::option_definition();
|
20 |
|
|
|
21 |
|
|
// Override the alter text option to always alter the text.
|
22 |
|
|
$options['alter']['contains']['alter_text'] = array('default' => TRUE, 'bool' => TRUE);
|
23 |
|
|
$options['hide_alter_empty'] = array('default' => FALSE, 'bool' => TRUE);
|
24 |
|
|
return $options;
|
25 |
|
|
}
|
26 |
|
|
|
27 |
|
|
function options_form(&$form, &$form_state) {
|
28 |
|
|
parent::options_form($form, $form_state);
|
29 |
|
|
|
30 |
|
|
// Remove the checkbox
|
31 |
|
|
unset($form['alter']['alter_text']);
|
32 |
|
|
unset($form['alter']['text']['#dependency']);
|
33 |
|
|
unset($form['alter']['text']['#process']);
|
34 |
|
|
unset($form['alter']['help']['#dependency']);
|
35 |
|
|
unset($form['alter']['help']['#process']);
|
36 |
|
|
$form['#pre_render'][] = 'views_handler_field_custom_pre_render_move_text';
|
37 |
|
|
}
|
38 |
|
|
|
39 |
|
|
function render($values) {
|
40 |
|
|
// Return the text, so the code never thinks the value is empty.
|
41 |
|
|
return $this->options['alter']['text'];
|
42 |
|
|
}
|
43 |
|
|
}
|
44 |
|
|
|
45 |
|
|
/**
|
46 |
|
|
* Prerender function to move the textarea to the top.
|
47 |
|
|
*/
|
48 |
|
|
function views_handler_field_custom_pre_render_move_text($form) {
|
49 |
|
|
$form['text'] = $form['alter']['text'];
|
50 |
|
|
$form['help'] = $form['alter']['help'];
|
51 |
|
|
unset($form['alter']['text']);
|
52 |
|
|
unset($form['alter']['help']);
|
53 |
|
|
|
54 |
|
|
return $form;
|
55 |
|
|
} |