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); }
/** * 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; }
protected function output() { $res = array(); $unread_only = false; if ($this->get('list_path', '') == 'unread') { $unread_only = true; } $cutoff = $this->get('wp_list_since', ''); if ($cutoff) { $cutoff = strtotime($cutoff); } else { $cutoff = 0; } foreach ($this->get('wp_notice_data', array()) as $vals) { if (array_key_exists('id', $vals)) { $id = 'wordpress_0_' . $vals['id']; $url = '?page=message&list_path=wp_notifications&uid=' . $this->html_safe($id); if ($this->get('list_parent', '')) { $url .= '&list_parent=' . $this->html_safe($this->get('list_parent', '')); } $style = 'email'; $style = $this->get('news_list_style') ? 'news' : 'email'; if ($this->get('is_mobile')) { $style = 'news'; } $subject = html_entity_decode($vals['subject']['text']); $from = ucfirst(str_replace('_', ' ', $vals['type'])); $ts = $vals['timestamp']; if ($ts < $cutoff) { continue; } $flags = array(); if ((int) $vals['unread'] > 0) { $flags[] = 'unseen'; } if ($unread_only && !in_array('unseen', $flags, true)) { continue; } $date = date('r', $ts); 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', 'WordPress'), array('safe_output_callback', 'from', $from), array('date_callback', human_readable_interval($date), $ts)), $id, $style, $this); } else { $res[$id] = message_list_row(array(array('checkbox_callback', $id), array('safe_output_callback', 'source', 'WordPress'), array('safe_output_callback', 'from', $from), array('subject_callback', $subject, $url, $flags), array('date_callback', human_readable_interval($date), $ts), array('icon_callback', $flags)), $id, $style, $this); } } } $this->out('formatted_message_list', $res); }
protected function output() { $res = array(); $login_time = false; $unread_only = false; if ($this->get('login_time')) { $login_time = $this->get('login_time'); } if ($this->get('list_path', '') == 'unread' || $this->get('github_unread', false)) { $unread_only = true; } $repo_id = $this->get('github_data_source_id'); $repo = $this->get('github_data_source', 'Github'); $cutoff = $this->get('github_list_since', ''); if ($cutoff) { $cutoff = strtotime($cutoff); } else { $cutoff = 0; } foreach ($this->get('github_data', array()) as $event) { $id = 'github_' . $repo_id . '_' . $event['id']; $subject = build_github_subject($event, $this); $url = '?page=message&uid=' . $this->html_safe($id) . '&list_path=github_' . $this->html_safe($repo); if ($this->get('list_parent', '')) { $url .= '&list_parent=' . $this->html_safe($this->get('list_parent')); } $from = $event['actor']['login']; $ts = strtotime($event['created_at']); if ($ts < $cutoff) { continue; } if (Hm_Github_Uid_Cache::is_read($event['id'])) { $flags = array(); } elseif (Hm_Github_Uid_Cache::is_unread($event['id'])) { $flags = array('unseen'); } elseif ($ts && $login_time && $ts <= $login_time) { $flags = array(); } else { $flags = array('unseen'); } if ($unread_only && !in_array('unseen', $flags)) { continue; } $date = date('r', $ts); $style = $this->get('news_list_style') ? 'news' : 'email'; if ($this->get('is_mobile')) { $style = 'news'; } 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', $repo), array('safe_output_callback', 'from', $from), array('date_callback', human_readable_interval($date), $ts)), $id, $style, $this); } else { $res[$id] = message_list_row(array(array('checkbox_callback', $id), array('safe_output_callback', 'source', $repo), array('safe_output_callback', 'from', $from), array('subject_callback', $subject, $url, $flags), array('date_callback', human_readable_interval($date), $ts), array('icon_callback', $flags)), $id, $style, $this); } } $this->out('formatted_message_list', $res); $this->out('github_server_id', $repo_id); }
/** * 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; }