Skip to content

Commit

Permalink
Remove old, unused preview code
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed Nov 19, 2014
1 parent 7416946 commit 34830bd
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 108 deletions.
58 changes: 0 additions & 58 deletions imp/lib/Contents.php
Original file line number Diff line number Diff line change
Expand Up @@ -694,64 +694,6 @@ public function findBody($subtype = null)
return $this->_message->findBody($subtype);
}

/**
* Generate the preview text.
*
* @return array Array with the following keys:
* - cut: (boolean) Was the preview text cut?
* - text: (string) The preview text.
*/
public function generatePreview()
{
// For preview generation, don't go through overhead of scanning for
// embedded parts. Necessary evil, or else very large parts (e.g
// 5 MB+ text parts) will take ages to scan.
$oldbuild = $this->_build;
$this->_build = true;
$mimeid = $this->findBody();

if (is_null($mimeid)) {
$this->_build = $oldbuild;
return array('cut' => false, 'text' => '');
}

$maxlen = empty($GLOBALS['conf']['msgcache']['preview_size'])
? $GLOBALS['prefs']->getValue('preview_maxlen')
: $GLOBALS['conf']['msgcache']['preview_size'];

// Retrieve 3x the size of $maxlen of bodytext data. This should
// account for any content-encoding & HTML tags.
$pmime = $this->getMimePart($mimeid, array('length' => $maxlen * 3));

if ($pmime) {
$ptext = Horde_String::convertCharset(
$pmime->getContents(),
$pmime->getCharset(),
'UTF-8'
);

if ($pmime->getType() == 'text/html') {
$ptext = $GLOBALS['injector']->getInstance('Horde_Core_Factory_TextFilter')->filter($ptext, 'Html2text');
}
} else {
$ptext = '';
}

$this->_build = $oldbuild;

if (Horde_String::length($ptext) > $maxlen) {
return array(
'cut' => true,
'text' => Horde_String::truncate($ptext, $maxlen)
);
}

return array(
'cut' => false,
'text' => $ptext
);
}

/**
* Get summary info for a MIME ID.
*
Expand Down
50 changes: 0 additions & 50 deletions imp/lib/Mailbox/List.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,6 @@ public function __construct($mbox)
* - headers: (boolean) Return info on the non-envelope headers
* 'Importance', 'List-Post', and 'X-Priority'.
* DEFAULT: false (only envelope headers returned)
* - preview: (mixed) Include preview information? If empty, add no
* preview information. If 1, uses value from prefs.
* If 2, forces addition of preview info.
* DEFAULT: No preview information.
* - type: (boolean) Return info on the MIME Content-Type of the base
* message part ('Content-Type' header).
* DEFAULT: false
Expand All @@ -120,9 +116,6 @@ public function __construct($mbox)
* true.
* - idx: (integer) Array index of this message.
* - mailbox: (string) The mailbox containing the message.
* - preview: (string) If requested in $options['preview'], the preview
* text.
* - previewcut: (boolean) Has the preview text been cut?
* - size: (integer) The size of the message in bytes.
* - uid: (string) The unique ID of the message.
* - uids: (IMP_Indices) An indices object.
Expand Down Expand Up @@ -168,13 +161,6 @@ public function getMailboxArray($msgnum, $options = array())
));
}

if (empty($options['preview'])) {
$cache = null;
$options['preview'] = 0;
} else {
$cache = $this->_mailbox->imp_imap->getCache();
}

/* Retrieve information from each mailbox. */
foreach ($to_process as $mbox => $ids) {
try {
Expand All @@ -183,15 +169,6 @@ public function getMailboxArray($msgnum, $options = array())
'ids' => $imp_imap->getIdsOb($ids)
));

if ($options['preview']) {
$preview_info = $tostore = array();
if ($cache) {
try {
$preview_info = $cache->get($mbox, $ids, array('IMPpreview', 'IMPpreviewc'));
} catch (IMP_Imap_Exception $e) {}
}
}

$mbox_ids = array();

foreach ($ids as $k => $v) {
Expand All @@ -211,33 +188,6 @@ public function getMailboxArray($msgnum, $options = array())
'uid' => $uid
);

if (($options['preview'] === 2) ||
(($options['preview'] === 1) &&
(!$GLOBALS['prefs']->getValue('preview_show_unread') ||
!in_array(Horde_Imap_Client::FLAG_SEEN, $v['flags'])))) {
if (empty($preview_info[$uid])) {
try {
$imp_contents = $GLOBALS['injector']->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($mbox, $uid));
$prev = $imp_contents->generatePreview();
$preview_info[$uid] = array(
'IMPpreview' => $prev['text'],
'IMPpreviewc' => $prev['cut']
);
if (!is_null($cache)) {
$tostore[$uid] = $preview_info[$uid];
}
} catch (Exception $e) {
$preview_info[$uid] = array(
'IMPpreview' => '',
'IMPpreviewc' => false
);
}
}

$v['preview'] = $preview_info[$uid]['IMPpreview'];
$v['previewcut'] = $preview_info[$uid]['IMPpreviewc'];
}

$overview[] = $v;
$mbox_ids[] = $uid;
}
Expand Down

0 comments on commit 34830bd

Please sign in to comment.