1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15:
16: class IMP_Mime_Viewer_Vcard extends Horde_Core_Mime_Viewer_Vcard
17: {
18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29:
30: protected function _render()
31: {
32: if (is_null(Horde_Util::getFormData('p'))) {
33: $this->_imageUrl = $this->getConfigParam('imp_contents')->urlView($this->_mimepart, 'download_render');
34: return parent::_render();
35: }
36:
37:
38: $data = $this->_mimepart->getContents();
39: $ical = new Horde_Icalendar();
40: if (!$ical->parsevCalendar($data, 'VCALENDAR', $this->_mimepart->getCharset())) {
41:
42: return array();
43: }
44: $components = $ical->getComponents();
45: $c = Horde_Util::getFormData('c');
46: $p = Horde_Util::getFormData('p');
47: if (!isset($components[$c])) {
48:
49: return array();
50: }
51: $name = $components[$c]->getAttributeDefault('FN', false);
52: if ($name === false) {
53: $name = $components[$c]->printableName();
54: }
55: if (empty($name)) {
56: $name = preg_replace('/\..*?$/', '', $this->_mimepart->getName());
57: }
58:
59: $photos = $components[$c]->getAllAttributes('PHOTO');
60: if (!isset($photos[$p])) {
61:
62: return array();
63: }
64: return array(
65: $this->_mimepart->getMimeId() => array(
66: 'data' => base64_decode($photos[$p]['value']),
67: 'name' => $name . '.' . Horde_Mime_Magic::mimeToExt($photos[$p]['params']['TYPE']),
68: 'type' => $photos[$p]['params']['TYPE'],
69: )
70: );
71: }
72:
73: }
74: