You are here

function swftools_jw5_autocomplete_skin in SWF Tools 6.3

Autocompleter to suggest possible skin names.

Parameters

string $string: The partial name of the skin.

Return value

array An array of possible matches.

1 string reference to 'swftools_jw5_autocomplete_skin'
swftools_jw5_menu in jw5/swftools_jw5.module
Implementation of hook_menu().

File

jw5/swftools_jw5.admin.inc, line 72
Configuration settings for LongTail JW Player 4.

Code

function swftools_jw5_autocomplete_skin($string = '') {

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

    // Scan the mediaplayer4/skins directory for swf files
    $skins = file_scan_directory(swftools_get_library('mediaplayer4') . '/skins', '\\.swf$');

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

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