class EmptyFieldText in Empty fields 7.2
Defines EmptyFieldText.
Hierarchy
- class \EmptyFieldHandler
- class \EmptyFieldText
Expanded class hierarchy of EmptyFieldText
3 string references to 'EmptyFieldText'
- EmptyFieldsViewModesWebTestCase::testEmptyFieldsOutput in tests/
empty_fields.test - Tests that the module actually works.
- EmptyFieldsViewModesWebTestCase::testEmptyFieldsWithMultipleViewModes in tests/
empty_fields.test - Test multiple view modes work.
- empty_fields_i18n_string_list_field_alter in ./
empty_fields.module - Implements hook_i18n_string_list_TEXTGROUP_alter().
File
- plugins/
empty_fields_handler_text.inc, line 10 - Contains the EmptyFieldText plugin for EmptyFieldHandler.
View source
class EmptyFieldText extends EmptyFieldHandler {
/**
* Implementation of EmptyFieldText::defaults().
*
* @return array
* An array of default_values for the form below. Key names must match.
*/
public function defaults() {
return array(
'empty_text' => '',
);
}
/**
* Implementation of EmptyFieldText::form().
*
* @return array
* A FAPI array to be used in configuration of this empty text plugin.
*/
public function form($context) {
$form['empty_text'] = array(
'#type' => 'textarea',
'#title' => t('Display Custom Text'),
'#default_value' => isset($this->options['empty_text']) ? $this->options['empty_text'] : '',
'#description' => t('Display text if the field is empty.'),
);
return $form;
}
/**
* Implementation of EmptyFieldText::react().
*
* @return string
* A rendered string of html for display.
*/
public function react($context) {
global $user;
$args = array(
$context['entity_type'] => $context['entity'],
'user' => $user,
);
$text = $this->options['empty_text'];
if (module_exists('i18n_field')) {
$text = i18n_string('field:' . $context['field_name'] . ':' . $context['instance']['bundle'] . ':' . 'empty_fields:' . $context['view_mode'] . ':text:empty_text', $text, array(
'langcode' => $context['language'],
));
}
$text = token_replace($text, $args, array(
'clear' => TRUE,
));
return filter_xss_admin($text);
}
/**
* Implementation of EmptyFieldText:summaryText().
*
* @return string
* Text for the field formatter settings summary.
*/
public function summaryText() {
return t('Empty Text: @empty_text', array(
'@empty_text' => $this->options['empty_text'],
));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EmptyFieldHandler:: |
public | property | ||
EmptyFieldHandler:: |
public | function | Provide a method to alter the output of the plugin. | |
EmptyFieldHandler:: |
public | function | Create a new EmptyFieldHandler. | |
EmptyFieldText:: |
public | function |
Implementation of EmptyFieldText::defaults(). Overrides EmptyFieldHandler:: |
|
EmptyFieldText:: |
public | function |
Implementation of EmptyFieldText::form(). Overrides EmptyFieldHandler:: |
|
EmptyFieldText:: |
public | function |
Implementation of EmptyFieldText::react(). Overrides EmptyFieldHandler:: |
|
EmptyFieldText:: |
public | function |
Implementation of EmptyFieldText:summaryText(). Overrides EmptyFieldHandler:: |