You are here

function _filetree_icon in File Tree 6

Same name and namespace in other branches
  1. 6.2 filetree.module \_filetree_icon()
  2. 7.2 filetree.module \_filetree_icon()
  3. 7 filetree.module \_filetree_icon()

Determines which icon should be displayed, based on file extension.

1 call to _filetree_icon()
_filetree_list_files in ./filetree.module
Recursively lists folders and files in this directory.

File

./filetree.module, line 243

Code

function _filetree_icon($extension) {
  $extension = strtolower($extension);
  $icon = 'file';
  $map = array(
    'application' => array(
      'exe',
    ),
    // 'code' => array(''),
    'css' => array(
      'css',
    ),
    'db' => array(
      'sql',
    ),
    'doc' => array(
      'doc',
      'docx',
    ),
    'film' => array(
      'avi',
      'mov',
    ),
    'flash' => array(
      'flv',
      'swf',
    ),
    'html' => array(
      'htm',
      'html',
    ),
    // 'java' => array(''),
    // 'linux' => array(''),
    'music' => array(
      'mp3',
      'aac',
    ),
    'pdf' => array(
      'pdf',
    ),
    'php' => array(
      'php',
    ),
    'image' => array(
      'jpg',
      'jpeg',
      'gif',
      'png',
      'bmp',
    ),
    'ppt' => array(
      'ppt',
    ),
    'psd' => array(
      'psd',
    ),
    // 'ruby' => array(''),
    'script' => array(
      'asp',
    ),
    'txt' => array(
      'txt',
    ),
    'xls' => array(
      'xls',
      'xlsx',
    ),
    'zip' => array(
      'zip',
    ),
  );
  foreach ($map as $key => $values) {
    foreach ($values as $value) {
      if ($extension == $value) {
        $icon = $key;
      }
    }
  }
  return $icon;
}