Newer
Older
<?php
// $Id$
/**
* @file
* Theme functions for privatemsg.
*/
function theme_privatemsg_list_field($thread) {
}
litwol
committed
function phptemplate_privatemsg_list_field__participants($thread) {
if (empty($thread['participants'])) {
litwol
committed
$participants = _privatemsg_generate_user_array($thread['participants']);
litwol
committed
$field['data'] = _privatemsg_format_participants($participants, 3, TRUE);
$field['class'] = 'privatemsg-list-participants';
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
return $field;
}
function phptemplate_privatemsg_list_field__subject($thread) {
$field = array();
$field['data'] =l($thread['subject'], 'messages/view/'. $thread['thread_id']);
$field['class'] = 'privatemsg-list-subject';
return $field;
}
function phptemplate_privatemsg_list_field__count($thread) {
$field = array();
$field['data'] =$thread['count'] -1;
$field['class'] = 'privatemsg-list-count';
return $field;
}
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;
}
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;
}
function theme_privatemsg_list_header() {
}
function phptemplate_privatemsg_list_header__subject() {
return array(
'data' => t('Subject'),
'field' => 'subject',
'key' => 'subject',
'class' => 'privatemsg-header-subject',
'#weight' => -40,
);
}
function phptemplate_privatemsg_list_header__count() {
return array(
'data' => t('Answers'),
'key' => 'count',
'class' => 'privatemsg-header-count',
'#weight' => -25,
);
}
litwol
committed
function phptemplate_privatemsg_list_header__participants() {
litwol
committed
'data' => t('Participants'),
'key' => 'participants',
'class' => 'privatemsg-header-participants',
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
);
}
function phptemplate_privatemsg_list_header__last_updated() {
return array(
'data' => t('Last Updated'),
'field' => 'last_updated',
'key' => 'last_updated',
'sort' => 'desc',
'class' => 'privatemsg-header-lastupdated',
'#weight' => -20,
);
}
function phptemplate_privatemsg_list_header__thread_started() {
return array(
'data' => t('Started'),
'field' => 'thread_started',
'key' => 'thread_started',
'class' => 'privatemsg-header-threadstarted',
'#weight' => -15,
);
}
/**
* Theme to display the privatemsg list
*/
function theme_privatemsg_list($form) {
$has_posts = !empty($form['#rows']);
drupal_add_css(drupal_get_path('module', 'privatemsg') .'/styles/privatemsg-list.css');
// sort the headers array based on the #weight property.
$headers = $form['#headers'];
usort($headers, 'element_sort');
$themed_rows = array();
// Check if there is atleast a single thread.
if ($has_posts) {
foreach ($form['#rows'] as $thread_id => $row) {
$data = array();
// Render the checkbox.
$data[] = drupal_render($form['threads'][$thread_id]);
// 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 $header) {
if (!empty($header['key'])) {
if (isset($row['data'][$header['key']])) {
$data[] = $row['data'][$header['key']];
}
else {
// Store a empty value so that the order is still correct.
$data[] = '';
}
}
}
// Replace the data
$row['data'] = $data;
$themed_rows[] = $row;
}
}
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);
}
function theme_privatemsg_new_block($count) {
$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, 'messages', array('attributes' => array('id' => 'privatemsg-new-link')));
}