Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function settingsSummary()
 {
     $settings = $this->getSettings();
     $summary = array();
     $field_name = explode('.', $this->fieldDefinition->id());
     $field_name = end($field_name);
     $machine_name = isset($settings['format']) ? $settings['format'] : 'default';
     $name_format = entity_load('name_format', $machine_name);
     if ($name_format) {
         $summary[] = t('Format: %format (@machine_name)', array('%format' => $name_format->label(), '@machine_name' => $name_format->id()));
     } else {
         $summary[] = t('Format: <strong>Missing format.</strong><br/>This field will be displayed using the Default format.');
         $machine_name = 'default';
     }
     // Provide an example of the selected format.
     module_load_include('admin.inc', 'name');
     $used_components = $this->getFieldSetting('components');
     $excluded_components = array_diff_key($used_components, _name_translations());
     $examples = name_example_names($excluded_components, $field_name);
     if ($examples && ($example = array_shift($examples))) {
         $format = name_get_format_by_machine_name($machine_name);
         $formatted = SafeMarkup::checkPlain(NameFormatParser::parse($example, $format));
         if (empty($formatted)) {
             $formatted = '<em>&lt;&lt;empty&gt;&gt;</em>';
         }
         $summary[] = t('Example: !example', array('!example' => $formatted));
     }
     $summary[] = t('Markup: @yesno', array('@yesno' => empty($settings['markup']) ? t('no') : t('yes')));
     $output_options = _name_formatter_output_options();
     $output = empty($settings['output']) ? 'default' : $settings['output'];
     $summary[] = t('Output: @format', array('@format' => $output_options[$output]));
     return $summary;
 }
 /**
  * Example names.
  *
  * @return null
  */
 public function nameExamples()
 {
     module_load_include('inc', 'name', 'name.admin');
     return name_example_names();
 }