|
@@ -1083,48 +1083,52 @@ function showMessagesForMailbox($imapConnection, &$aMailbox,$aProps, &$iError) {
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
-* FIXME: Undocumented function
|
|
|
|
|
|
+* Truncates a string and take care of html encoded characters
|
|
|
|
+*
|
|
|
|
+* @param string $s string to truncate
|
|
|
|
+* @param int $iTrimAt Trim at nn characters
|
|
|
|
+* @return string Trimmed string
|
|
*/
|
|
*/
|
|
-function truncateWithEntities($subject, $trim_at)
|
|
|
|
-{
|
|
|
|
- $ent_strlen = strlen($subject);
|
|
|
|
- if (($trim_at <= 0) || ($ent_strlen <= $trim_at))
|
|
|
|
- return $subject;
|
|
|
|
-
|
|
|
|
|
|
+function truncateWithEntities($s, $iTrimAt) {
|
|
global $languages, $squirrelmail_language;
|
|
global $languages, $squirrelmail_language;
|
|
|
|
|
|
- /*
|
|
|
|
- * see if this is entities-encoded string
|
|
|
|
- * If so, Iterate through the whole string, find out
|
|
|
|
- * the real number of characters, and if more
|
|
|
|
- * than $trim_at, substr with an updated trim value.
|
|
|
|
- */
|
|
|
|
- $trim_val = $trim_at;
|
|
|
|
- $ent_offset = 0;
|
|
|
|
- $ent_loc = 0;
|
|
|
|
- while ( $ent_loc < $trim_val && (($ent_loc = strpos($subject, '&', $ent_offset)) !== false) &&
|
|
|
|
- (($ent_loc_end = strpos($subject, ';', $ent_loc+3)) !== false) ) {
|
|
|
|
- $trim_val += ($ent_loc_end-$ent_loc);
|
|
|
|
- $ent_offset = $ent_loc_end+1;
|
|
|
|
- }
|
|
|
|
- if (($trim_val > $trim_at) && ($ent_strlen > $trim_val) && (strpos($subject,';',$trim_val) < ($trim_val + 6))) {
|
|
|
|
- $i = strpos($subject,';',$trim_val);
|
|
|
|
- if ($i) {
|
|
|
|
- $trim_val = strpos($subject,';',$trim_val);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- // only print '...' when we're actually dropping part of the subject
|
|
|
|
- if ($ent_strlen <= $trim_val)
|
|
|
|
- return $subject;
|
|
|
|
|
|
+ $ent_strlen = strlen($s);
|
|
|
|
+ if (($iTrimAt <= 0) || ($ent_strlen <= $iTrimAt))
|
|
|
|
+ return $s;
|
|
|
|
|
|
if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
|
|
if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
|
|
function_exists($languages[$squirrelmail_language]['XTRA_CODE'] . '_strimwidth')) {
|
|
function_exists($languages[$squirrelmail_language]['XTRA_CODE'] . '_strimwidth')) {
|
|
- return call_user_func($languages[$squirrelmail_language]['XTRA_CODE'] . '_strimwidth', $subject, $trim_val);
|
|
|
|
- }
|
|
|
|
|
|
+ return call_user_func($languages[$squirrelmail_language]['XTRA_CODE'] . '_strimwidth', $s, $iTrimAt);
|
|
|
|
+ } else {
|
|
|
|
+ /*
|
|
|
|
+ * see if this is entities-encoded string
|
|
|
|
+ * If so, Iterate through the whole string, find out
|
|
|
|
+ * the real number of characters, and if more
|
|
|
|
+ * than $iTrimAt, substr with an updated trim value.
|
|
|
|
+ */
|
|
|
|
+ $trim_val = $iTrimAt;
|
|
|
|
+ $ent_offset = 0;
|
|
|
|
+ $ent_loc = 0;
|
|
|
|
+ while ( $ent_loc < $trim_val && (($ent_loc = strpos($s, '&', $ent_offset)) !== false) &&
|
|
|
|
+ (($ent_loc_end = strpos($s, ';', $ent_loc+3)) !== false) ) {
|
|
|
|
+ $trim_val += ($ent_loc_end-$ent_loc);
|
|
|
|
+ $ent_offset = $ent_loc_end+1;
|
|
|
|
+ }
|
|
|
|
|
|
- return substr_replace($subject, '...', $trim_val);
|
|
|
|
|
|
+ if (($trim_val > $iTrimAt) && ($ent_strlen > $trim_val) && (strpos($s,';',$trim_val) < ($trim_val + 6))) {
|
|
|
|
+ $i = strpos($s,';',$trim_val);
|
|
|
|
+ if ($i !== false) {
|
|
|
|
+ $trim_val = strpos($s,';',$trim_val)+1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // only print '...' when we're actually dropping part of the subject
|
|
|
|
+ if ($ent_strlen <= $trim_val)
|
|
|
|
+ return $s;
|
|
|
|
+ }
|
|
|
|
+ return substr_replace($s, '...', $trim_val);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* This should go in imap_mailbox.php
|
|
* This should go in imap_mailbox.php
|
|
* @param string $mailbox
|
|
* @param string $mailbox
|