[ Index ]
 

Code source de IMP H3 (4.1.5)

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/lib/MIME/Viewer/ -> related.php (source)

   1  <?php
   2  /**
   3   * The IMP_MIME_Viewer_related class handles multipart/related messages
   4   * as defined by RFC 2387.
   5   *
   6   * $Horde: imp/lib/MIME/Viewer/related.php,v 1.21.10.12 2007/01/02 13:55:00 jan Exp $
   7   *
   8   * Copyright 2002-2007 Michael Slusarz <slusarz@bigworm.colorado.edu>
   9   *
  10   * See the enclosed file COPYING for license information (GPL). If you
  11   * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
  12   *
  13   * @author  Michael Slusarz <slusarz@bigworm.colorado.edu>
  14   * @since   IMP 4.0
  15   * @package Horde_MIME_Viewer
  16   */
  17  class IMP_MIME_Viewer_related extends MIME_Viewer {
  18  
  19      /**
  20       * The character set of the rendered HTML part.
  21       *
  22       * @var string
  23       */
  24      var $_charset = null;
  25  
  26      /**
  27       * The mime type of the message part that has been chosen to be displayed.
  28       *
  29       * @var string
  30       */
  31      var $_viewerType = 'text/html';
  32  
  33      /**
  34       * Render out the currently set contents.
  35       *
  36       * @param array $params  An array with a reference to a MIME_Contents
  37       *                       object.
  38       *
  39       * @return string  The rendered text in HTML.
  40       */
  41      function render($params)
  42      {
  43          $contents = &$params[0];
  44  
  45          /* Look at the 'start' parameter to determine which part to start
  46             with. If no 'start' parameter, use the first part.
  47             RFC 2387 [3.1] */
  48          if ($this->mime_part->getContentTypeParameter('start') &&
  49              ($key = array_search($this->mime_part->getContentTypeParameter('start'), $this->mime_part->getCIDList()))) {
  50              if (($pos = strrpos($key, '.'))) {
  51                  $id = substr($key, $pos + 1);
  52              } else {
  53                  $id = $key;
  54              }
  55          } else {
  56              $id = 1;
  57          }
  58          $start = $this->mime_part->getPart($this->mime_part->getRelativeMimeID($id));
  59  
  60          /* Only display if the start part (normally text/html) can be displayed
  61             inline -OR- we are viewing this part as an attachment. */
  62          if ($contents->canDisplayInline($start) ||
  63              $contents->viewAsAttachment()) {
  64              $text = $contents->renderMIMEPart($start);
  65              $this->_viewerType = $contents->getMIMEViewerType($start);
  66              $this->_charset = $start->getCharset();
  67              $contents->removeIndex($start->getMIMEId());
  68          } else {
  69              $text = '';
  70          }
  71  
  72          return $text;
  73       }
  74  
  75      /**
  76       * Render out attachment information.
  77       *
  78       * @param array $params  An array with a reference to a MIME_Contents
  79       *                       object.
  80       *
  81       * @return string  The rendered text in HTML.
  82       */
  83      function renderAttachmentInfo($params)
  84      {
  85          $contents = &$params[0];
  86  
  87          $msg = sprintf(_("Click %s to view this multipart/related part in a separate window."), $contents->linkViewJS($this->mime_part, 'view_attach', _("HERE"), _("View content in a separate window")));
  88          return $contents->formatStatusMsg($msg, Horde::img('mime/html.png', _("HTML")), false);
  89      }
  90  
  91      /**
  92       * Return the content-type.
  93       *
  94       * @return string  The content-type of the message.
  95       */
  96      function getType()
  97      {
  98          return $this->_viewerType . '; charset=' . $this->getCharset();
  99      }
 100  
 101      /**
 102       * Returns the character set used for the Viewer.
 103       *
 104       * @return string  The character set used by this Viewer.
 105       */
 106      function getCharset()
 107      {
 108          return (is_null($this->_charset)) ? NLS::getCharset() : $this->_charset;
 109      }
 110  
 111  }


Généré le : Thu Nov 29 12:30:07 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics