You are here

function views_isotope_sanitize in Brainstorm profile 7

Strip all special chars to make value suitable for css class name.

Parameters

string $raw: The raw value to be sanitized.

Return value

string The sanitized value.

2 calls to views_isotope_sanitize()
theme_isotope_filter in modules/custom/views_isotope/views_isotope.module
Default theme implementation for the filter list.
theme_isotope_grid in modules/custom/views_isotope/views_isotope.module
Default theme implementation for the grid.

File

modules/custom/views_isotope/views_isotope.module, line 314
Load the isotope library and provide configuration and theme options.

Code

function views_isotope_sanitize($raw) {
  $safe = $raw;
  if (is_array($raw)) {
    $safe = [];
    foreach ($raw as $i) {
      $safe[] = views_isotope_sanitize($i);
    }
    return implode(' ', $safe);
  }

  // Transliterate other language chars to latin.
  if (function_exists('transliteration_get')) {
    $safe = transliteration_get($safe, '?', language_default('language'));
  }

  // Basic class-name rules.
  $safe = strtolower($safe);
  $safe = preg_replace('/[^a-z0-9]/s', '-', $safe);
  $safe = preg_replace('/-{2,}/', '-', $safe);

  // Allow other modules to modify it with hook_views_isotope_sanitize_alter().
  drupal_alter('views_isotope_sanitize', $safe, $raw);
  return $safe;
}