1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16:
17: class Horde_Mime_Viewer_Plain extends Horde_Mime_Viewer_Base
18: {
19: 20: 21: 22: 23:
24: protected $_capability = array(
25: 'full' => true,
26: 'info' => false,
27: 'inline' => true,
28: 'raw' => false
29: );
30:
31: 32: 33: 34: 35:
36: protected function _render()
37: {
38: $text = $this->_mimepart->getContents();
39: $charset = $this->_mimepart->getCharset();
40:
41:
42: if ($this->_mimepart->getContentTypeParameter('format') == 'flowed') {
43: $text = $this->_formatFlowed($text, $this->_mimepart->getContentTypeParameter('delsp'));
44: }
45:
46: $text = '<html><body><tt>' . $this->_textFilter($text, 'Text2html', array(
47: 'charset' => $charset,
48: 'parselevel' => Horde_Text_Filter_Text2html::MICRO_LINKURL
49: )) . '</tt></body></html>';
50:
51: return $this->_renderReturn(
52: $text,
53: 'text/html; charset=' . $charset
54: );
55: }
56:
57: 58: 59: 60: 61:
62: protected function _renderInline()
63: {
64: $text = Horde_String::convertCharset($this->_mimepart->getContents(), $this->_mimepart->getCharset(), 'UTF-8');
65:
66:
67: $data = ($this->_mimepart->getContentTypeParameter('format') == 'flowed')
68: ? $this->_formatFlowed($text, $this->_mimepart->getContentTypeParameter('delsp'))
69: : $text;
70:
71: return $this->_renderReturn(
72: $data,
73: 'text/html; charset=UTF-8'
74: );
75: }
76:
77: 78: 79: 80: 81: 82: 83: 84:
85: protected function _formatFlowed($text, $delsp = null)
86: {
87: $flowed = new Horde_Text_Flowed($text, $this->_mimepart->getCharset());
88: $flowed->setMaxLength(0);
89: if (!is_null($delsp)) {
90: $flowed->setDelSp($delsp);
91: }
92:
93: return $flowed->toFixed();
94: }
95:
96: }
97: