protected function output() { $res = array(); $login_time = false; if ($this->get('login_time')) { $login_time = $this->get('login_time'); } foreach ($this->get('feed_list_data', array()) as $item) { $row_style = 'feeds'; if (isset($item['id']) && !isset($item['guid'])) { $item['guid'] = $item['id']; unset($item['id']); } elseif (isset($item['title']) && !isset($item['guid'])) { $item['guid'] = md5($item['title']); } if (isset($item['guid'])) { $id = sprintf("feeds_%s_%s", $item['server_id'], md5($item['guid'])); if (isset($item['dc:date'])) { $date = display_value('dc:date', $item, 'date'); $timestamp = display_value('dc:date', $item, 'time'); } elseif (isset($item['pubdate'])) { $date = display_value('pubdate', $item, 'date'); $timestamp = display_value('pubdate', $item, 'time'); } else { $date = ''; $timestamp = 0; } if ($date) { $date = translate_time_str($date, $this); } $url = '?page=message&uid=' . urlencode(md5($item['guid'])) . '&list_path=feeds_' . $item['server_id']; if ($this->in('feed_list_parent', array('combined_inbox', 'unread', 'feeds', 'search'))) { $url .= '&list_parent=' . $this->html_safe($this->get('feed_list_parent', '')); } else { $url .= '&list_parent=feeds_' . $item['server_id']; } if ($this->get('news_list_style')) { $style = 'news'; } else { $style = 'email'; } if ($this->get('is_mobile')) { $style = 'news'; } if (Hm_Feed_Uid_Cache::is_read(md5($item['guid']))) { $flags = array(); } elseif (Hm_Feed_Uid_Cache::is_unread(md5($item['guid']))) { $flags = array('unseen'); $row_style .= ' unseen'; } elseif ($timestamp && $login_time && $timestamp <= $login_time) { $flags = array(); } else { $flags = array('unseen'); } if (isset($item['author'])) { $from = display_value('author', $item, 'from'); } elseif (isset($item['name'])) { $from = display_value('name', $item, 'from'); } elseif (isset($item['dc:creator'])) { $from = display_value('dc:creator', $item, 'from'); } elseif ($style == 'email') { $from = $this->trans('[No From]'); } else { $from = ''; } $row_style .= ' ' . str_replace(' ', '_', $item['server_name']); if ($style == 'news') { $res[$id] = message_list_row(array(array('checkbox_callback', $id), array('icon_callback', $flags), array('subject_callback', strip_tags($item['title']), $url, $flags), array('safe_output_callback', 'source', $item['server_name']), array('safe_output_callback', 'from', $from), array('date_callback', $date, $timestamp)), $id, $style, $this, $row_style); } else { $res[$id] = message_list_row(array(array('checkbox_callback', $id), array('safe_output_callback', 'source', $item['server_name']), array('safe_output_callback', 'from', $from), array('subject_callback', strip_tags($item['title']), $url, $flags), array('date_callback', $date, $timestamp), array('icon_callback', $flags)), $id, $style, $this, $row_style); } } } $this->out('formatted_message_list', $res); }
/** * @subpackage github/functions */ function github_parse_headers($data, $output_mod) { $res = '<table class="msg_headers"><colgroup><col class="header_name_col"><col class="header_val_col"></colgroup>'; if (array_key_exists('type', $data)) { $type = build_github_subject($data, $output_mod); } else { $type = '[Unknown Type]'; } if (array_key_exists('created_at', $data)) { $date = sprintf("%s (%s)", date('r', strtotime($data['created_at'])), translate_time_str(human_readable_interval($data['created_at']), $output_mod)); } else { $date = '[No date]'; } $repo_link = ''; $from_link = ''; if (array_key_exists('actor', $data) && array_key_exists('login', $data['actor'])) { $from = $data['actor']['login']; $from_link = sprintf(' - <a target="_blank" href="https://github.com/%s">https://github.com/%s</a>', $output_mod->html_safe($from), $output_mod->html_safe($from)); } else { $from = '[No From]'; } if (array_key_exists('repo', $data) && array_key_exists('name', $data['repo'])) { $name = $data['repo']['name']; $repo_link = sprintf(' - <a target="_blank" href="https://github.com/%s">https://github.com/%s</a>', $output_mod->html_safe($name), $output_mod->html_safe($name)); } else { $name = '[No Repo]'; } $res .= '<tr class="header_subject"><th colspan="2">' . $output_mod->html_safe($type) . '</th></tr>'; $res .= '<tr><th>' . $output_mod->trans('Date') . '</th><td>' . $output_mod->html_safe($date) . '</td></tr>'; $res .= '<tr><th>' . $output_mod->trans('Author') . '</th><td>' . $output_mod->html_safe($from) . $from_link . '</td></tr>'; $res .= '<tr><th>' . $output_mod->trans('Repository') . '</th><td>' . $output_mod->html_safe($name) . $repo_link . '</td></tr>'; $res .= '<tr><td></td><td></td></tr></table>'; return $res; }
/** * Format a list of POP3 messages * @subpackage pop3/functions * @param array $msg_list list of message data * @param object $mod Hm_Output_Module * @param string $style list style * @param string $login_time timestamp of last login * @param string $list_parent list type * @return array */ function format_pop3_message_list($msg_list, $output_module, $style, $login_time, $list_parent) { $res = array(); foreach ($msg_list as $msg_id => $msg) { $row_class = 'email'; if ($msg['server_name'] == 'Default-Auth-Server') { $msg['server_name'] = 'Default'; } $id = sprintf("pop3_%s_%s", $msg['server_id'], $msg_id); $subject = display_value('subject', $msg); $from = display_value('from', $msg); if ($style == 'email' && !$from) { $from = '[No From]'; } $date = display_value('date', $msg); if ($date) { $date = translate_time_str($date, $output_module); } $timestamp = display_value('date', $msg, 'time'); $url = '?page=message&uid=' . $msg_id . '&list_path=' . sprintf('pop3_%d', $msg['server_id']) . '&list_parent=' . $list_parent; if (Hm_POP3_Uid_Cache::is_read($id)) { $flags = array(); } elseif (Hm_POP3_Uid_Cache::is_unread($id)) { $flags = array('unseen'); $row_class .= ' unseen'; } elseif (isset($msg['date']) && $login_time && strtotime($msg['date']) <= $login_time) { $flags = array(); } else { $flags = array('unseen'); } $row_class .= str_replace(' ', '_', $msg['server_name']); if ($style == 'news') { $res[$id] = message_list_row(array(array('checkbox_callback', $id), array('icon_callback', $flags), array('subject_callback', $subject, $url, $flags), array('safe_output_callback', 'source', $msg['server_name']), array('safe_output_callback', 'from', $from), array('date_callback', $date, $timestamp)), $id, $style, $output_module, $row_class); } else { $res[$id] = message_list_row(array(array('checkbox_callback', $id), array('safe_output_callback', 'source', $msg['server_name']), array('safe_output_callback', 'from', $from), array('subject_callback', $subject, $url, $flags), array('date_callback', $date, $timestamp), array('icon_callback', $flags)), $id, $style, $output_module, $row_class); } } return $res; }
/** * Format a list of message headers * @subpackage imap/functions * @param array $msg_list list of message headers * @param object $mod Hm_Output_Module * @param mixed $parent_list parent list id * @param string $style list style (email or news) * @return array */ function format_imap_message_list($msg_list, $output_module, $parent_list = false, $style = 'email') { $res = array(); if ($msg_list === array(false)) { return $msg_list; } foreach ($msg_list as $msg) { if (!$parent_list) { $parent_value = sprintf('imap_%d_%s', $msg['server_id'], $msg['folder']); } else { $parent_value = $parent_list; } if ($msg['server_name'] == 'Default-Auth-Server') { $msg['server_name'] = 'Default'; } $id = sprintf("imap_%s_%s_%s", $msg['server_id'], $msg['uid'], $msg['folder']); if (!trim($msg['subject'])) { $msg['subject'] = '[No Subject]'; } $subject = $msg['subject']; $from = preg_replace("/(\\<.+\\>)/U", '', $msg['from']); $from = str_replace('"', '', $from); if (!trim($from) && $style == 'email') { $from = '[No From]'; } $timestamp = strtotime($msg['internal_date']); $date = translate_time_str(human_readable_interval($msg['internal_date']), $output_module); $flags = array(); if (!stristr($msg['flags'], 'seen')) { $flags[] = 'unseen'; } if (stristr($msg['flags'], 'deleted')) { $flags[] = 'deleted'; } if (stristr($msg['flags'], 'flagged')) { $flags[] = 'flagged'; } $source = $msg['server_name']; if ($msg['folder'] && $msg['folder'] != 'INBOX') { $source .= '-' . preg_replace("/^INBOX.{1}/", '', $msg['folder']); } $url = '?page=message&uid=' . $msg['uid'] . '&list_path=' . sprintf('imap_%d_%s', $msg['server_id'], $msg['folder']) . '&list_parent=' . $parent_value; if ($style == 'news') { $res[$id] = message_list_row(array(array('checkbox_callback', $id), array('icon_callback', $flags), array('subject_callback', $subject, $url, $flags), array('safe_output_callback', 'source', $source), array('safe_output_callback', 'from', $from), array('date_callback', $date, $timestamp)), $id, $style, $output_module); } else { $res[$id] = message_list_row(array(array('checkbox_callback', $id), array('safe_output_callback', 'source', $source), array('safe_output_callback', 'from', $from), array('subject_callback', $subject, $url, $flags), array('date_callback', $date, $timestamp), array('icon_callback', $flags)), $id, $style, $output_module); } } return $res; }