Display attach with missing title

- Rework preg_match_all call to remove 3 indentation levels
This commit is contained in:
Hypolite Petovan 2018-03-08 23:52:01 -05:00
parent 3ecc53b448
commit 9f693cc443

View file

@ -1281,13 +1281,8 @@ function prepare_body(&$item, $attach = false, $preview = false) {
$as = ''; $as = '';
$vhead = false; $vhead = false;
$arr = explode('[/attach],', $item['attach']); $matches = [];
if (count($arr)) { preg_match_all('|\[attach\]href=\"(.*?)\" length=\"(.*?)\" type=\"(.*?)\"(?: title=\"(.*?)\")?|', $item['attach'], $matches, PREG_SET_ORDER);
foreach ($arr as $r) {
$matches = false;
$icon = '';
$cnt = preg_match_all('|\[attach\]href=\"(.*?)\" length=\"(.*?)\" type=\"(.*?)\" title=\"(.*?)\"|',$r ,$matches, PREG_SET_ORDER);
if ($cnt) {
foreach ($matches as $mtch) { foreach ($matches as $mtch) {
$mime = $mtch[3]; $mime = $mtch[3];
@ -1328,15 +1323,13 @@ function prepare_body(&$item, $attach = false, $preview = false) {
$filesubtype = 'unkn'; $filesubtype = 'unkn';
} }
$title = ((strlen(trim($mtch[4]))) ? escape_tags(trim($mtch[4])) : escape_tags($mtch[1])); $title = escape_tags(trim(!empty($mtch[4]) ? $mtch[4] : $mtch[1]));
$title .= ' ' . $mtch[2] . ' ' . L10n::t('bytes'); $title .= ' ' . $mtch[2] . ' ' . L10n::t('bytes');
$icon = '<div class="attachtype icon s22 type-' . $filetype . ' subtype-' . $filesubtype . '"></div>'; $icon = '<div class="attachtype icon s22 type-' . $filetype . ' subtype-' . $filesubtype . '"></div>';
$as .= '<a href="' . strip_tags($the_url) . '" title="' . $title . '" class="attachlink" target="_blank" >' . $icon . '</a>'; $as .= '<a href="' . strip_tags($the_url) . '" title="' . $title . '" class="attachlink" target="_blank" >' . $icon . '</a>';
} }
}
}
}
if ($as != '') { if ($as != '') {
$s .= '<div class="body-attach">'.$as.'<div class="clear"></div></div>'; $s .= '<div class="body-attach">'.$as.'<div class="clear"></div></div>';
} }