1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
15: class IMP_Minimal_Messagepart extends IMP_Minimal_Base
16: {
17: 18: 19: 20: 21: 22:
23: protected function _init()
24: {
25: global $injector;
26:
27:
28: try {
29: $imp_contents = $injector->getInstance('IMP_Factory_Contents')->create($this->indices);
30: } catch (IMP_Exception $e) {
31: IMP_Minimal_Mailbox::url(array('mailbox' => $this->indices->mailbox))->add('a', 'm')->redirect();
32: }
33:
34: if (isset($this->vars->atc)) {
35: $summary = $imp_contents->getSummary($this->vars->atc, IMP_Contents::SUMMARY_SIZE | IMP_Contents::SUMMARY_DESCRIP | IMP_Contents::SUMMARY_DOWNLOAD);
36:
37: $this->title = _("Download Attachment");
38:
39: $this->view->descrip = $summary['description_raw'];
40: $this->view->download = $summary['download_url'];
41: $this->view->size = $summary['size'];
42: $this->view->type = $summary['type'];
43: } else {
44: $this->title = _("View Attachment");
45:
46: $data = $imp_contents->renderMIMEPart($this->vars->id, $imp_contents->canDisplay($this->vars->id, IMP_Contents::RENDER_INLINE));
47: $this->view->data = isset($data[$this->vars->id])
48: ? $data[$this->vars->id]['data']
49: : _("This part is empty.");
50: }
51:
52: $this->view->self_link = IMP_Minimal_Message::url(array(
53: 'buid' => $this->vars->buid,
54: 'mailbox' => $this->indices->mailbox
55: ));
56: $this->view->title = $this->title;
57:
58: $this->_pages[] = 'messagepart';
59: }
60:
61: 62: 63: 64: 65:
66: public static function url(array $opts = array())
67: {
68: return IMP_Mailbox::get($opts['mailbox'])->url('minimal', $opts['buid'])->add('page', 'messagepart');
69: }
70:
71: }
72: