IMP_Contents::urlView PHP Method

urlView() public method

Return the URL to the download/view page.
public urlView ( Horde_Mime_Part $mime_part = null, integer $actionID = 'view_attach', array $options = [] ) : Horde_Url
$mime_part Horde_Mime_Part The MIME part to view.
$actionID integer The actionID to perform.
$options array Additional options: - params: (array) A list of any additional parameters that need to be passed to the download/view page (key => name).
return Horde_Url The URL to the download/view page.
    public function urlView($mime_part = null, $actionID = 'view_attach', array $options = array())
    {
        $params = $this->_urlViewParams($mime_part, $actionID, isset($options['params']) ? $options['params'] : array());
        return strpos($actionID, 'download_') === 0 ? IMP_Contents_View::downloadUrl($mime_part->getName(true), $params) : Horde::url('view.php', true)->add($params);
    }

Usage Example

Example #1
0
 /**
  * Create the object used to display the message.
  *
  * @return array  Array with the following keys:
  *   - atc: (object) Attachment information.
  *     - download: (string) The URL for the download all action.
  *     - label: (string) The attachment label.
  *     - list: (array) Attachment information.
  *   - md: (array) Metadata.
  *   - msgtext: (string) The text of the message.
  *   - onepart: (boolean) True if message only contains one part.
  *
  * @throws IMP_Exception
  */
 public function showMessage()
 {
     global $prefs, $registry, $session;
     $result = array();
     // Create message text and attachment list.
     $result['msgtext'] = '';
     $show_parts = $prefs->getValue('parts_display');
     /* Do MDN processing now. */
     switch ($registry->getView()) {
         case $registry::VIEW_DYNAMIC:
             if ($this->_indices->mdnCheck($this->_loadHeaders())) {
                 $status = new IMP_Mime_Status(null, array(_("The sender of this message is requesting notification from you when you have read this message."), Horde::link('#', '', '', '', '', '', '', array('id' => 'send_mdn_link')) . _("Click to send the notification message.") . '</a>'));
                 $status->domid('sendMdnMessage');
                 $result['msgtext'] .= strval($status);
             }
     }
     /* Build body text. This needs to be done before we build the
      * attachment list. */
     $session->close();
     $inlineout = $this->getInlineOutput();
     $session->start();
     $result['md'] = $inlineout['metadata'];
     $result['msgtext'] .= $inlineout['msgtext'];
     if ($inlineout['one_part']) {
         $result['onepart'] = true;
     }
     if (count($inlineout['atc_parts']) || $show_parts == 'all' && count($inlineout['display_ids']) > 2) {
         $result['atc']['label'] = $show_parts == 'all' ? _("Parts") : sprintf(ngettext("%d Attachment", "%d Attachments", count($inlineout['atc_parts'])), count($inlineout['atc_parts']));
         if (count($inlineout['atc_parts']) > 1) {
             $result['atc']['download'] = strval($this->contents->urlView($this->contents->getMIMEMessage(), 'download_all')->setRaw(true));
         }
     }
     /* Show attachment information in headers? */
     if (!empty($inlineout['atc_parts'])) {
         $partlist = array();
         $contents_mask = IMP_Contents::SUMMARY_DESCRIP | IMP_Contents::SUMMARY_DESCRIP_LINK | IMP_Contents::SUMMARY_DOWNLOAD | IMP_Contents::SUMMARY_ICON | IMP_Contents::SUMMARY_SIZE;
         $part_info = array('icon', 'description', 'size', 'download', 'description_raw', 'download_url');
         if ($show_parts == 'all') {
             array_unshift($part_info, 'id');
         }
         foreach ($inlineout['atc_parts'] as $id) {
             $summary = $this->contents->getSummary($id, $contents_mask);
             $tmp = array();
             foreach ($part_info as $val) {
                 if (isset($summary[$val])) {
                     $tmp[$val] = $summary[$val] instanceof Horde_Url ? strval($summary[$val]->setRaw(true)) : $summary[$val];
                 }
             }
             $partlist[] = array_filter($tmp);
         }
         $result['atc']['list'] = $partlist;
     }
     return $result;
 }
All Usage Examples Of IMP_Contents::urlView