' . l((format_plural($thread['is_new'], '(1 new)', '(@count new)')), privatemsg_get_dynamic_url_prefix() . '/view/' . $thread['thread_id'], $options); } $field['class'] = 'privatemsg-list-count'; return $field; } /** * Theme the last updated column. */ function phptemplate_privatemsg_list_field__last_updated($thread) { $field = array(); $field['data'] = format_date($thread['last_updated'], 'small'); $field['class'] = 'privatemsg-list-date'; return $field; } /** * Theme the thread started column. */ function phptemplate_privatemsg_list_field__thread_started($thread) { $field = array(); $field['data'] = format_date($thread['thread_started'], 'small'); $field['class'] = 'privatemsg-list-date-started'; return $field; } /** * Theme to display the privatemsg list. * * This theme builds a table with paging based on the data which has been built * by the header and field theme patterns. */ function theme_privatemsg_list($form) { $has_posts = !empty($form['#data']); drupal_add_css(drupal_get_path('module', 'privatemsg') .'/styles/privatemsg-list.css'); // Get the headers. $headers = privatemsg_get_headers(TRUE); $themed_rows = array(); // Check if there is atleast a single thread. if ($has_posts) { foreach ($form['#data'] as $thread_id => $data) { // Theme the row. $row = _privatemsg_list_thread($data); $data = array(); // Render the checkbox. $data[] = array('data' => drupal_render($form['threads'][$thread_id]), 'class' => 'privatemsg-list-select'); // Store the #rows data in the same order as the header is, // the key property of the header refers to the field that belongs to it. foreach ($headers as $key => $header) { $data[] = isset($row['data'][$key]) ? $row['data'][$key] : ''; } // Replace the data $row['data'] = $data; $themed_rows[] = $row; } // Add select all checkox to header array. array_unshift($headers, theme('table_select_header_cell')); } else { // Display a message if now messages are available. $themed_rows[] = array(array('data' => t('No messages available.'), 'colspan' => count($headers))); } // Remove any data in header that we don't need anymore. foreach ($headers as $id => $header) { unset($headers[$id]['key']); unset($headers[$id]['#weight']); } // Theme the table, pass all generated information to the table theme function. $form['list'] = array('#value' => theme('table', $headers, $themed_rows, array('class' => 'privatemsg-list')), '#weight' => 5); return drupal_render($form); } /** * Theme a block which displays the number of new messages a user has. */ function theme_privatemsg_new_block($count) { if ($count == 0) { $text = t('Click here to go to your messages.'); } else { $text = format_plural($count, 'You have a new message! Click here to read it.', 'You have @count new messages! Click here to read them.', array('@count' => $count)); } return l($text, privatemsg_get_dynamic_url_prefix(), array('attributes' => array('id' => 'privatemsg-new-link'))); } /** * Used to theme and display user recipients. * * Wrapper for theme_username() with a few additional options. */ function theme_privatemsg_username($recipient, $options) { if (!isset($recipient->uid)) { $recipient->uid = $recipient->recipient; } if (!empty($options['plain'])) { $name = $recipient->name; if (!empty($options['unique'])) { $name .= ' [user]'; } return $name; } else { return theme('username', $recipient); } } /** * Output the admin settings display fields and weight settings as a * drag and drop sortable table. */ function theme_privatemsg_admin_settings_display_fields($element = array()) { $header = array( array('data' => t('Field'), 'class' => 'field'), array('data' => t('Enable'), 'class' => 'enable'), array('data' => t('Weight'), 'class' => 'weight'), ); $rows = array(); foreach (element_children($element['privatemsg_display_fields']) as $child) { $row = array(); // Title. $row[] = array('data' => $element['privatemsg_display_fields'][$child]['#title'], 'class' => 'field'); unset($element['privatemsg_display_fields'][$child]['#title']); // Enable checkbox. $row[] = array('data' => drupal_render($element['privatemsg_display_fields'][$child]), 'class' => 'enable'); // Weight selector. unset($element['privatemsg_display_fields_weights'][$child]['#title']); $element['privatemsg_display_fields_weights'][$child]['#attributes']['class'] = 'privatemsg-display-fields-weight'; $row[] = array( 'data' => drupal_render($element['privatemsg_display_fields_weights'][$child]), 'class' => 'weight', ); $rows[] = array('data' => $row, 'class' => 'draggable'); } if (!empty($rows)) { drupal_add_tabledrag('privatemsg-list-display-fields', 'order', 'sibling', 'privatemsg-display-fields-weight'); return theme('table', $header, $rows, array('id' => 'privatemsg-list-display-fields')) . drupal_render($element); } else { return drupal_render($element); } } /** * @} */