ContentType.class.php 1.7 KB

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