1: <?php
2: /*
3: You may not change or alter any portion of this comment or credits
4: of supporting developers from this source code or any supporting source code
5: which is considered copyrighted (c) material of the original comment or credit authors.
6:
7: This program is distributed in the hope that it will be useful,
8: but WITHOUT ANY WARRANTY; without even the implied warranty of
9: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: */
11:
12: namespace Xoops\Core;
13:
14: use Dflydev\ApacheMimeTypes\PhpRepository;
15:
16: /**
17: * MimeTypes
18: *
19: * YProvide translation from file extension to mimetype and back.
20: *
21: * At present, this class expects the symfony/yaml package.
22: *
23: * @category Xoops\Core\MimeTypes
24: * @package MimeTypes
25: * @author Richard Griffith <richard@geekwright.com>
26: * @copyright 2014 XOOPS Project (http://xoops.org)
27: * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
28: * @version Release: 1.0
29: * @link http://xoops.org
30: * @see https://github.com/dflydev/dflydev-apache-mime-types
31: * @since 1.0
32: */
33: class MimeTypes
34: {
35: /**
36: * findExtensions - given a mimetype, get array of possible file extensions
37: *
38: * @param string $type mimetype
39: *
40: * @return array of applicable extensions, empty if no match
41: */
42: public static function findExtensions($type)
43: {
44: $mt = new PhpRepository();
45: return $mt->findExtensions($type);
46: }
47:
48: /**
49: * findType - given a file extensions, return applicable mimetype
50: *
51: * @param string $extension file extension
52: *
53: * @return string|null applicable mimetype (string) or null if no match
54: */
55: public static function findType($extension)
56: {
57: $mt = new PhpRepository();
58: return $mt->findType(strtolower($extension));
59: }
60: }
61: