You are here

function swftools_flowplayer3_autocomplete_player in SWF Tools 6.3

Autocompleter to suggest filename.

Parameters

string $string: The partial name of the file.

Return value

array An array of possible matches.

1 string reference to 'swftools_flowplayer3_autocomplete_player'
swftools_flowplayer3_menu in flowplayer3/swftools_flowplayer3.module
Implementation of hook_menu().

File

flowplayer3/swftools_flowplayer3.admin.inc, line 1128
Configuration settings for Flowplayer 3.

Code

function swftools_flowplayer3_autocomplete_player($string = '') {

  // Only do something if there is a string to be matched
  if ($string) {

    // Scan the flowplayer3 directory for possible matches
    $files = file_scan_directory(swftools_get_library('flowplayer3'), '.*');

    // Build an array skin names
    $possible_values = array();
    foreach ($files as $file) {
      $possible_values[] = $file->basename;
    }

    // Find matches
    $matches = array();
    foreach ($possible_values as $value) {
      if (preg_match("/{$string}/i", $value)) {
        $matches[$value] = $value;
      }
    }
    print drupal_json($matches);
  }
}