You are here

public function FeedsCSVParser::configEncodingForm in Feeds 7.2

Builds configuration field for setting file encoding.

If the mbstring extension is not available a markup render array will be returned instead.

Return value

array A renderable array.

2 calls to FeedsCSVParser::configEncodingForm()
FeedsCSVParser::configForm in plugins/FeedsCSVParser.inc
Build configuration form.
FeedsCSVParser::sourceForm in plugins/FeedsCSVParser.inc
Source form.

File

plugins/FeedsCSVParser.inc, line 263
Contains the FeedsCSVParser class.

Class

FeedsCSVParser
Parses a given file as a CSV file.

Code

public function configEncodingForm() {
  if (extension_loaded('mbstring') && variable_get('feeds_use_mbstring', TRUE)) {

    // Get the system's list of available encodings.
    $options = mb_list_encodings();

    // Make the key/values the same in the array.
    $options = array_combine($options, $options);

    // Sort alphabetically not-case sensitive.
    natcasesort($options);
    return array(
      '#type' => 'select',
      '#title' => t('File encoding'),
      '#description' => t('Performs character encoding conversion from selected option to UTF-8.'),
      '#options' => $options,
      '#default_value' => $this->config['encoding'],
    );
  }
  else {
    return array(
      '#markup' => '<em>' . t('PHP mbstring extension must be available for character encoding conversion.') . '</em>',
    );
  }
}