- $javascript = '';
- foreach ($a_show_cols as $col)
- {
- // get column name
- switch ($col)
- {
- case 'flag':
- $col_name = sprintf($image_tag, $skin_path, $attrib['unflaggedicon'], '');
- break;
- case 'attachment':
- $col_name = sprintf($image_tag, $skin_path, $attrib['attachmenticon'], '');
- break;
- default:
- $col_name = Q(rcube_label($col));
- }
-
- // make sort links
- $sort = '';
- if (in_array($col, $a_sort_cols))
- {
- // have buttons configured
- if (!empty($attrib['sortdescbutton']) || !empty($attrib['sortascbutton']))
- {
- $sort = ' ';
-
- // asc link
- if (!empty($attrib['sortascbutton']))
- {
- $sort .= $OUTPUT->button(array(
- 'command' => 'sort',
- 'prop' => $col.'_ASC',
- 'image' => $attrib['sortascbutton'],
- 'align' => 'absmiddle',
- 'title' => 'sortasc'));
- }
-
- // desc link
- if (!empty($attrib['sortdescbutton']))
- {
- $sort .= $OUTPUT->button(array(
- 'command' => 'sort',
- 'prop' => $col.'_DESC',
- 'image' => $attrib['sortdescbutton'],
- 'align' => 'absmiddle',
- 'title' => 'sortdesc'));
- }
- }
- // just add a link tag to the header
- else
- {
- $col_name = sprintf(
- '<a href="./#sort" onclick="return %s.command(\'sort\',\'%s\',this)" title="%s">%s</a>',
- JS_OBJECT_NAME,
- $col,
- rcube_label('sortby'),
- $col_name);
- }
- }
-
- $sort_class = $col==$sort_col ? " sorted$sort_order" : '';
-
- // put it all together
- if ($col!='attachment')
- $out .= '<td class="'.$col.$sort_class.'" id="rcm'.$col.'">' . "$col_name$sort</td>\n";
- else
- $out .= '<td class="icon" id="rcm'.$col.'">' . "$col_name$sort</td>\n";
- }
-
- $out .= "</tr></thead>\n<tbody>\n";
-
- // no messages in this mailbox
- if (!sizeof($a_headers))
- $OUTPUT->show_message('nomessagesfound', 'notice');
-
- $a_js_message_arr = array();
-
- // create row for each message
- foreach ($a_headers as $i => $header) //while (list($i, $header) = each($a_headers))
- {
- $message_icon = $attach_icon = $flagged_icon = '';
- $js_row_arr = array();
- $zebra_class = $i%2 ? ' even' : ' odd';
-
- // set messag attributes to javascript array
- if ($header->deleted)
- $js_row_arr['deleted'] = true;
- if (!$header->seen)
- $js_row_arr['unread'] = true;
- if ($header->answered)
- $js_row_arr['replied'] = true;
- if ($header->forwarded)
- $js_row_arr['forwarded'] = true;
- if ($header->flagged)
- $js_row_arr['flagged'] = true;
-
- // set message icon
- if ($attrib['deletedicon'] && $header->deleted)
- $message_icon = $attrib['deletedicon'];
- else if ($attrib['repliedicon'] && $header->answered)
- {
- if ($attrib['forwardedrepliedicon'] && $header->forwarded)
- $message_icon = $attrib['forwardedrepliedicon'];
- else
- $message_icon = $attrib['repliedicon'];
- }
- else if ($attrib['forwardedicon'] && $header->forwarded)
- $message_icon = $attrib['forwardedicon'];
- else if ($attrib['unreadicon'] && !$header->seen)
- $message_icon = $attrib['unreadicon'];
- else if ($attrib['messageicon'])
- $message_icon = $attrib['messageicon'];
-
- if ($attrib['flaggedicon'] && $header->flagged)
- $flagged_icon = $attrib['flaggedicon'];
- else if ($attrib['unflaggedicon'] && !$header->flagged)
- $flagged_icon = $attrib['unflaggedicon'];
-
- // set attachment icon
- if ($attrib['attachmenticon'] && preg_match("/multipart\/m/i", $header->ctype))
- $attach_icon = $attrib['attachmenticon'];
-
- $out .= sprintf('<tr id="rcmrow%d" class="message%s%s%s%s">'."\n",
- $header->uid,
- $header->seen ? '' : ' unread',
- $header->deleted ? ' deleted' : '',
- $header->flagged ? ' flagged' : '',
- $zebra_class);
-
- $out .= sprintf("<td class=\"icon\">%s</td>\n", $message_icon ? sprintf($image_tag, $skin_path, $message_icon, '') : '');
-
- $IMAP->set_charset(!empty($header->charset) ? $header->charset : $CONFIG['default_charset']);
-
- // format each col
- foreach ($a_show_cols as $col)
- {
- if ($col=='from' || $col=='to')
- $cont = Q(rcmail_address_string($header->$col, 3, false, $attrib['addicon']), 'show');
- else if ($col=='subject')
- {
- $action = $mbox==$CONFIG['drafts_mbox'] ? 'compose' : 'show';
- $uid_param = $mbox==$CONFIG['drafts_mbox'] ? '_draft_uid' : '_uid';
- $cont = abbreviate_string(trim($IMAP->decode_header($header->$col)), 160);
- if (empty($cont)) $cont = rcube_label('nosubject');
- $cont = $OUTPUT->browser->ie ? Q($cont) : sprintf('<a href="%s" onclick="return rcube_event.cancel(event)">%s</a>', Q(rcmail_url($action, array($uid_param=>$header->uid, '_mbox'=>$mbox))), Q($cont));
- }
- else if ($col=='flag')
- $cont = $flagged_icon ? sprintf($image_tag, $skin_path, $flagged_icon, '') : '';
- else if ($col=='size')
- $cont = show_bytes($header->$col);
- else if ($col=='date')
- $cont = format_date($header->date);
- else
- $cont = Q($header->$col);
-
- if ($col!='attachment')
- $out .= '<td class="'.$col.'">' . $cont . "</td>\n";
- else
- $out .= sprintf("<td class=\"icon\">%s</td>\n", $attach_icon ? sprintf($image_tag, $skin_path, $attach_icon, '') : ' ');
- }
-
- $out .= "</tr>\n";
-
- if (sizeof($js_row_arr))
- $a_js_message_arr[$header->uid] = $js_row_arr;
- }
-
- // complete message table
- $out .= "</tbody></table>\n";
-
- $message_count = $IMAP->messagecount();
-