You are here

function custom_formatters_token_values in Custom Formatters 6

Implements hook_token_values().

File

includes/token.inc, line 30
Provides Custom Formatters integration with the Token module.

Code

function custom_formatters_token_values($type, $object = array()) {
  $values = array();
  switch ($type) {
    case 'global':
      $values['path-to-theme'] = path_to_theme();
      foreach (list_themes() as $theme) {
        $values['path-to-theme-' . $theme->name] = drupal_get_path('theme', $theme->name);
      }
      foreach (module_list() as $module) {
        $values['path-to-module-' . $module] = drupal_get_path('module', $module);
      }
      $values['path-to-files'] = file_directory_path();
      break;
    case 'field':
      if (module_exists('filefield')) {
        $file = $object[0];
        $values['filefield-alt'] = isset($file['data']) && isset($file['data']['alt']) ? $file['data']['alt'] : '';
        $values['filefield-title'] = isset($file['data']) && isset($file['data']['title']) ? $file['data']['title'] : '';
        if (module_exists('imagecache')) {
          foreach (imagecache_presets() as $preset) {
            $values['filefield-imagecache-' . $preset['presetname']] = file_directory_path() . '/imagecache/' . $preset['presetname'] . str_replace(file_directory_path(), '', $file['filepath']);
          }
        }
      }
      break;
  }
  return $values;
}