PageRenderTime 41ms CodeModel.GetById 35ms RepoModel.GetById 0ms app.codeStats 0ms

/framework/vendor/zend/Zend/Mail/Message.php

http://zoop.googlecode.com/
PHP | 112 lines | 37 code | 10 blank | 65 comment | 5 complexity | 63c730a1a3707d501ee5332cf7528953 MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.1
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Mail
  17. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  18. * @license http://framework.zend.com/license/new-bsd New BSD License
  19. * @version $Id: Message.php 20096 2010-01-06 02:05:09Z bkarwin $
  20. */
  21. /**
  22. * Zend_Mail_Part
  23. */
  24. require_once 'Zend/Mail/Part.php';
  25. /**
  26. * Zend_Mail_Message_Interface
  27. */
  28. require_once 'Zend/Mail/Message/Interface.php';
  29. /**
  30. * @category Zend
  31. * @package Zend_Mail
  32. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  33. * @license http://framework.zend.com/license/new-bsd New BSD License
  34. */
  35. class Zend_Mail_Message extends Zend_Mail_Part implements Zend_Mail_Message_Interface
  36. {
  37. /**
  38. * flags for this message
  39. * @var array
  40. */
  41. protected $_flags = array();
  42. /**
  43. * Public constructor
  44. *
  45. * In addition to the parameters of Zend_Mail_Part::__construct() this constructor supports:
  46. * - file filename or file handle of a file with raw message content
  47. * - flags array with flags for message, keys are ignored, use constants defined in Zend_Mail_Storage
  48. *
  49. * @param string $rawMessage full message with or without headers
  50. * @throws Zend_Mail_Exception
  51. */
  52. public function __construct(array $params)
  53. {
  54. if (isset($params['file'])) {
  55. if (!is_resource($params['file'])) {
  56. $params['raw'] = @file_get_contents($params['file']);
  57. if ($params['raw'] === false) {
  58. /**
  59. * @see Zend_Mail_Exception
  60. */
  61. require_once 'Zend/Mail/Exception.php';
  62. throw new Zend_Mail_Exception('could not open file');
  63. }
  64. } else {
  65. $params['raw'] = stream_get_contents($params['file']);
  66. }
  67. }
  68. if (!empty($params['flags'])) {
  69. // set key and value to the same value for easy lookup
  70. $this->_flags = array_combine($params['flags'], $params['flags']);
  71. }
  72. parent::__construct($params);
  73. }
  74. /**
  75. * return toplines as found after headers
  76. *
  77. * @return string toplines
  78. */
  79. public function getTopLines()
  80. {
  81. return $this->_topLines;
  82. }
  83. /**
  84. * check if flag is set
  85. *
  86. * @param mixed $flag a flag name, use constants defined in Zend_Mail_Storage
  87. * @return bool true if set, otherwise false
  88. */
  89. public function hasFlag($flag)
  90. {
  91. return isset($this->_flags[$flag]);
  92. }
  93. /**
  94. * get all set flags
  95. *
  96. * @return array array with flags, key and value are the same for easy lookup
  97. */
  98. public function getFlags()
  99. {
  100. return $this->_flags;
  101. }
  102. }