PageRenderTime 44ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/app/protected/extensions/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/QpHeaderEncoder.php

https://bitbucket.org/ddonthula/zurmoldap31
PHP | 68 lines | 31 code | 7 blank | 30 comment | 0 complexity | 743520c8c3d9c4905ed5e1f5849b04a6 MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-3.0, LGPL-2.1, BSD-2-Clause, GPL-2.0, GPL-3.0
  1. <?php
  2. /*
  3. * This file is part of SwiftMailer.
  4. * (c) 2004-2009 Chris Corbyn
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. require_once dirname(__FILE__) . '/../HeaderEncoder.php';
  10. require_once dirname(__FILE__) . '/../../Encoder/QpEncoder.php';
  11. require_once dirname(__FILE__) . '/../../CharacterStream.php';
  12. /**
  13. * Handles Quoted Printable (Q) Header Encoding in Swift Mailer.
  14. * @package Swift
  15. * @subpackage Mime
  16. * @author Chris Corbyn
  17. */
  18. class Swift_Mime_HeaderEncoder_QpHeaderEncoder extends Swift_Encoder_QpEncoder
  19. implements Swift_Mime_HeaderEncoder
  20. {
  21. /**
  22. * Creates a new QpHeaderEncoder for the given CharacterStream.
  23. * @param Swift_CharacterStream $charStream to use for reading characters
  24. */
  25. public function __construct(Swift_CharacterStream $charStream)
  26. {
  27. parent::__construct($charStream);
  28. // Reset the safeMap
  29. $this->_safeMap=array();
  30. foreach (array_merge(
  31. range(0x61, 0x7A), range(0x41, 0x5A),
  32. range(0x30, 0x39), array(0x20, 0x21, 0x2A, 0x2B, 0x2D, 0x2F)
  33. ) as $byte)
  34. {
  35. $this->_safeMap[$byte] = chr($byte);
  36. }
  37. }
  38. /**
  39. * Get the name of this encoding scheme.
  40. * Returns the string 'Q'.
  41. * @return string
  42. */
  43. public function getName()
  44. {
  45. return 'Q';
  46. }
  47. /**
  48. * Takes an unencoded string and produces a Q encoded string from it.
  49. * @param string $string to encode
  50. * @param int $firstLineOffset, optional
  51. * @param int $maxLineLength, optional, 0 indicates the default of 76 chars
  52. * @return string
  53. */
  54. public function encodeString($string, $firstLineOffset = 0,
  55. $maxLineLength = 0)
  56. {
  57. return str_replace(array(' ', '=20', "=\r\n"), array('_', '_', "\r\n"),
  58. parent::encodeString($string, $firstLineOffset, $maxLineLength)
  59. );
  60. }
  61. }