<?php

/**
 * Utility functions for violet application
 *
 */
class violetUtil {

  public static function getSpacePath($absolute = true) {
    if ($absolute) {
      return sfConfig::get('sf_upload_dir') . '/space/';
    } else {
      return sfConfig::get('sf_upload_dir_name') . '/space/';
    }
  }

  public static function getTempPath($subDir = '', $create = false) {
    $tempPath = sfConfig::get('sf_upload_dir') . '/copying/' . $subDir;
    if ($create && !file_exists($tempPath)) mkdir($tempPath, 0777, true);
    return $tempPath;
  }

  public static function getContentType($fileType) {
    switch (strtolower($fileType)) {
      case 'xml':
      case 'xvl': return 'text/xml';

      case 'jpe':
      case 'jpg':
      case 'jpeg': return 'image/jpeg';
      case 'gif': return 'image/gif';
      case 'png': return 'image/png';

      case 'flv': return 'video/x-flv';
      case 'mp4': return 'video/mp4';
      case 'mp3': return 'audio/mpeg';
      case 'swf': return 'application/x-shockwave-flash';
    }
  }
}
