1: <?php
 2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 
16: class IMP_Mime_Viewer_Enriched extends Horde_Mime_Viewer_Enriched
17: {
18:     19: 20: 21: 22: 
23:     protected function _render()
24:     {
25:         $ret = parent::_render();
26:         if (!empty($ret)) {
27:             reset($ret);
28:             $ret[key($ret)]['data'] = $this->_IMPformat($ret[key($ret)]['data']);
29:         }
30:         return $ret;
31:     }
32: 
33:     34: 35: 36: 37: 
38:     protected function _renderInline()
39:     {
40:         $ret = parent::_renderInline();
41:         if (!empty($ret)) {
42:             reset($ret);
43:             $ret[key($ret)]['data'] = $this->_IMPformat($ret[key($ret)]['data']);
44:         }
45:         return $ret;
46:     }
47: 
48:     49: 50: 51: 52: 53: 54: 
55:     protected function _IMPformat($text)
56:     {
57:         
58:         if ($GLOBALS['prefs']->getValue('highlight_text')) {
59:             $text = implode("\n", preg_replace('|^(\s*>.+)$|', '<span class="quoted1">\1</span>', explode("\n", $text)));
60:             $indent = 1;
61:             while (preg_match('|>(\s?>){' . $indent . '}|', $text)) {
62:                 $text = implode("\n", preg_replace('|^<span class="quoted' . ((($indent - 1) % 5) + 1) . '">(\s*>(\s?>){' . $indent . '}.+)$|', '<span class="quoted' . (($indent % 5) + 1) . '">\1', explode("\n", $text)));
63:                 ++$indent;
64:             }
65:         }
66: 
67:         
68:         if ($GLOBALS['prefs']->getValue('dim_signature')) {
69:             $parts = preg_split('|(\n--\s*\n)|', $text, 2, PREG_SPLIT_DELIM_CAPTURE);
70:             $text = array_shift($parts);
71:             if (count($parts)) {
72:                 $text .= '<span class="signature">' . $parts[0] .
73:                     preg_replace('|class="[^"]+"|', 'class="signature-fixed"', $parts[1]) .
74:                     '</span>';
75:             }
76:         }
77: 
78:         
79:         return IMP::filterText($text);
80:     }
81: 
82: }
83: