1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15:
16: class IMP_Mime_Viewer_Partial extends Horde_Mime_Viewer_Base
17: {
18: 19: 20: 21: 22:
23: protected $_capability = array(
24: 'full' => false,
25: 'info' => true,
26: 'inline' => false,
27: 'raw' => false
28: );
29:
30: 31: 32: 33: 34:
35: protected $_metadata = array(
36: 'compressed' => false,
37: 'embedded' => true,
38: 'forceinline' => true
39: );
40:
41: 42: 43: 44: 45:
46: static protected $_statuscache = array();
47:
48: 49: 50: 51: 52:
53: protected function _renderInfo()
54: {
55: $id = $this->_mimepart->getMimeId();
56:
57: if (isset(self::$_statuscache[$id])) {
58: return array(
59: $id => array(
60: 'data' => null,
61: 'status' => self::$_statuscache[$id],
62: 'type' => 'text/plain; charset=' . $this->getConfigParam('charset')
63: )
64: );
65: } else {
66: return array($id => null);
67: }
68: }
69:
70: 71: 72: 73: 74: 75: 76:
77: protected function _getEmbeddedMimeParts()
78: {
79: $id = $this->_mimepart->getContentTypeParameter('id');
80: $number = $this->_mimepart->getContentTypeParameter('number');
81: $total = $this->_mimepart->getContentTypeParameter('total');
82:
83: if (is_null($id) || is_null($number) || is_null($total)) {
84: return null;
85: }
86:
87:
88: $query = new Horde_Imap_Client_Search_Query();
89: $query->headerText('Content-Type', $id);
90: $indices = $this->getConfigParam('imp_contents')->getMailbox()->runSearchQuery($query);
91:
92: 93:
94: $msg_count = count($indices);
95: if ($msg_count != $total) {
96: $status = new IMP_Mime_Status(sprintf(_("Cannot display message - found only %s of %s parts of this message in the current mailbox."), $msg_count, $total));
97: $status->action(IMP_Mime_Status::ERROR);
98: self::$_statuscache[$this->_mimepart->getMimeId()] = $status;
99: return null;
100: }
101:
102:
103: $parts = array();
104: foreach ($indices as $ob) {
105: foreach ($ob->uids as $val) {
106:
107: if ($val == $number) {
108: $parts[$number] = $this->_mimepart->getContents();
109: } else {
110: $ic = $GLOBALS['injector']->getInstance('IMP_Factory_Contents')->create($ob->mbox->getIndicesOb($val));
111: $parts[$ic->getMIMEMessage()->getContentTypeParameter('number')] = $ic->getBody();
112: }
113: }
114: }
115:
116:
117: ksort($parts, SORT_NUMERIC);
118:
119:
120: $mime_part = Horde_Mime_Part::parseMessage(implode('', $parts), array('forcemime' => true));
121:
122: return ($mime_part === false)
123: ? null
124: : $mime_part;
125: }
126:
127: }
128: