You are here

function asset_bonus_asset_formatter in Asset 5.2

Same name and namespace in other branches
  1. 5 asset_bonus/asset_bonus.module \asset_bonus_asset_formatter()
  2. 6 asset_bonus/asset_bonus.module \asset_bonus_asset_formatter()
  3. 6 contrib/asset_bonus/asset_bonus.module \asset_bonus_asset_formatter()

File

contrib/asset_bonus/asset_bonus.module, line 164

Code

function asset_bonus_asset_formatter($op = 'list', $asset = NULL, $attr = array()) {
  switch ($op) {
    case 'info':
      $formats['mp3player'] = array(
        'name' => 'mp3 Player',
        'types' => array(
          'local' => array(
            'mp3',
          ),
        ),
        'description' => t('Embed the mp3 file using the !1pixelout audio player', array(
          '!1pixelout' => l('1pixelout', 'http://www.1pixelout.net/code/audio-player-wordpress-plugin/'),
        )),
        'module' => 'asset_bonus',
      );
      $formats['swfobject'] = array(
        'name' => 'swfobject',
        'types' => array(
          'local' => array(
            'swf',
            'flv',
          ),
        ),
        'description' => t('Embed the flash movie using the !swfobject javascript library', array(
          '!swfobject' => l('swfobject', 'http://blog.deconcept.com/swfobject/'),
        )),
        'module' => 'asset_bonus',
      );
      return $formats;
    case 'load':
      if ($asset->type == 'file' && $asset->file['filemime'] == 'audio/mpeg') {
        return array(
          'mp3player',
        );
      }
      elseif ($asset->type == 'file' && $asset->file['filemime'] == 'application/x-shockwave-flash') {
        return array(
          'swfobject',
        );
      }
    case 'img':
    case 'form':
      $function = 'asset_bonus_' . $attr['format'] . '_' . $op;
      if (function_exists($function)) {
        return call_user_func($function, $asset);
      }
      break;
    case 'render':
      $function = 'asset_bonus_' . $attr['format'];
      return theme($function, $asset, $attr);
  }
}