You are here

public function openlayers_views_plugin_style_source_vector::minify_data in Openlayers 7.3

Helper function to minify the output data.

Borrowed from the Minify module. @link https://www.drupal.org/project/minify

Parameters

string $buffer: The string to minify.

Return value

string The minified string.

File

modules/openlayers_views/views/openlayers_views_plugin_style_source_vector.inc, line 358
Style handler that provides vector features.

Class

openlayers_views_plugin_style_source_vector
Class openlayers_views_plugin_style_source_vector.

Code

public function minify_data($buffer) {
  if (module_exists('minify')) {
    return _minify_html($buffer);
  }
  $search = array(
    '/\\>[^\\S ]+/s',
    // strip whitespaces after tags, except space
    '/[^\\S ]+\\</s',
    // strip whitespaces before tags, except space
    '/(\\s)+/s',
    // shorten multiple whitespace sequences
    '/^\\s+|\\s+$/m',
  );
  $replace = array(
    '>',
    '<',
    '\\1',
    '',
  );
  $buffer = preg_replace($search, $replace, $buffer);
  $buffer = preg_replace_callback('/<!--([\\s\\S]*?)-->/', array(
    $this,
    'minify_remove_html_comment',
  ), $buffer);
  return $buffer;
}