You are here

function globallink_format_file_name in GlobalLink Connect for Drupal 7.5

Same name and namespace in other branches
  1. 7.7 globallink.inc \globallink_format_file_name()
  2. 7.6 globallink.inc \globallink_format_file_name()

Formats file name.

Parameters

string $string: The file name to be formatted.

Return value

string The formatted file name.

2 calls to globallink_format_file_name()
globallink_entity_get_xml in globallink_entity/globallink_entity.inc
Gets XML data from specific entity.
globallink_get_xml in ./globallink_node.inc
Retrieves translation XML data.

File

./globallink.inc, line 601
Miscellaneous GlobalLink functions for node translations (non-entity).

Code

function globallink_format_file_name($string) {
  $bad = array_merge(array_map('chr', range(0, 31)), array(
    '<',
    '>',
    ':',
    '"',
    '/',
    '\\',
    '|',
    '?',
    '*',
    ';',
    '&',
    ' ',
    '.',
  ));
  $name = str_replace($bad, '_', utf8_decode(preg_replace('/[^(\\x20-\\x7F)]*/', '', $string)));
  if (strlen($name) > 50) {
    $name = substr($name, 0, 50);
  }
  return $name;
}