source: pro-violet-viettel/www/deploy/api/platform/lib/violetUtil.class.php @ 784

Last change on this file since 784 was 784, checked in by dungnv, 10 years ago
File size: 1.1 KB
Line 
1<?php
2
3/**
4 * Utility functions for violet application
5 *
6 */
7class violetUtil {
8
9  public static function getSpacePath($absolute = true) {
10    if ($absolute) {
11      return sfConfig::get('sf_upload_dir').'/'.sfConfig::get('app_space_dir').'/';
12    } else {
13      return sfConfig::get('sf_upload_dir_name').'/'.sfConfig::get('app_space_dir').'/';
14    }
15  }
16
17  public static function getTempPath($subDir = '', $create = false) {
18    $tempPath = sfConfig::get('sf_upload_dir') .'/'. sfConfig::get('app_temp_dir') .'/'. $subDir;
19    if ($create && !file_exists($tempPath)) mkdir($tempPath, 0777, true);
20    return $tempPath;
21  }
22
23  public static function getContentType($fileType) {
24    switch (strtolower($fileType)) {
25      case 'xml':
26      case 'xvl': return 'text/xml';
27
28      case 'jpe':
29      case 'jpg':
30      case 'jpeg': return 'image/jpeg';
31      case 'gif': return 'image/gif';
32      case 'png': return 'image/png';
33
34      case 'flv': return 'video/x-flv';
35      case 'mp4': return 'video/mp4';
36      case 'mp3': return 'audio/mpeg';
37      case 'swf': return 'application/x-shockwave-flash';
38    }
39  }
40}
Note: See TracBrowser for help on using the repository browser.