1287bb3a7b9183b09f12ad444010decab234c693
[squirrelmail.git] / class / mime / ContentType.class.php
1 <?php
2
3 /**
4 * ContentType.class.php
5 *
6 * This file contains functions needed to handle content type headers
7 * (rfc2045) in mime messages.
8 *
9 * @copyright 2003-2017 The SquirrelMail Project Team
10 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
11 * @version $Id$
12 * @package squirrelmail
13 * @subpackage mime
14 * @since 1.3.2
15 */
16
17 /**
18 * Class that handles content-type headers
19 * Class was named content_type in 1.3.0 and 1.3.1. It is used internally
20 * by rfc822header class.
21 * @package squirrelmail
22 * @subpackage mime
23 * @since 1.3.2
24 */
25 class ContentType {
26 /**
27 * Media type
28 * @var string
29 */
30 var $type0 = 'text';
31 /**
32 * Media subtype
33 * @var string
34 */
35 var $type1 = 'plain';
36 /**
37 * Auxiliary header information
38 * prepared with parseContentType() function in rfc822header class.
39 * @var array
40 */
41 var $properties = '';
42
43 /**
44 * Constructor (PHP5 style, required in some future version of PHP)
45 * Prepared type0 and type1 properties
46 * @param string $type content type string without auxiliary information
47 */
48 function __construct($type) {
49 $type = strtolower($type);
50 $pos = strpos($type, '/');
51 if ($pos > 0) {
52 $this->type0 = substr($type, 0, $pos);
53 $this->type1 = substr($type, $pos+1);
54 } else {
55 $this->type0 = $type;
56 }
57 $this->properties = array();
58 }
59
60 /**
61 * Constructor (PHP4 style, kept for compatibility reasons)
62 * Prepared type0 and type1 properties
63 * @param string $type content type string without auxiliary information
64 */
65 function ContentType($type) {
66 self::__construct($type);
67 }
68 }