-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnotices.theme.inc
More file actions
130 lines (116 loc) · 3.95 KB
/
notices.theme.inc
File metadata and controls
130 lines (116 loc) · 3.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
74
75
76
77
78
79
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
<?php
/**
* @file
* Provides theme functions.
*/
/**
* Processes variables for notices-view.tpl.php.
*
* @param array $vars
* An associative array containing the following key:
* - notice.
*
* @see notices-view.tpl.php
*/
function template_preprocess_notices_view(&$vars) {
$notice = $vars['notice'];
$links[] = array(
'title' => t('Delete'),
'href' => 'notices/delete/' . $notice->noticeid,
'attributes' => array(
'rel' => $notice->noticeid,
'id' => 'noticeremove-' . $notice->noticeid,
'class' => 'notice-remove',
),
);
$vars['time'] = format_date($notice->timestamp, 'medium');
$vars['content'] = check_markup($notice->message, $notice->format, FALSE);
$variables = array(
'links' => $links,
'attributes' => array('class' => 'notice-links'),
);
$vars['links'] = theme('links', $variables);
$vars['timeago'] = t('@time ago', array('@time' => format_interval(REQUEST_TIME - $notice->timestamp)));
$file = drupal_get_path('module', $notice->provider) . '/' . $notice->provider . '.png';
if (!file_exists($file)) {
$file = drupal_get_path('module', 'notices') . '/default.png';
}
$vars['picture'] = $file;
$status_output = '';
$status = notices_getSendStatus($notice);
foreach ($status as $name => $value) {
$status_output .= '<li class="' . $name . '" style="background: url(/' . $value['icon'] . ') no-repeat center left; padding-left: 22px;"><span class="status">' . $value['status'] . '</span></li>';
}
if (!empty($status_output)) {
$vars['status'] = '<ul class="notices_status">' . $status_output . '</ul>';
}
}
/**
* Processes variables for notices-view.tpl.php.
*
* @param array $vars
* An associative array containing the following key:
* - notice.
*
* @see notices-view-teaser.tpl.php
*/
function template_preprocess_notices_view_teaser(&$vars) {
$notice = $vars['notice'];
$res = explode("\n", $notice->message);
$lines_show = variable_get('notices_lines_show_in_teaser', 5);
if (count($res) > 5) {
$notice->message = '';
$count_items = (count($res) < $lines_show ? count($res) : $lines_show) - 1;
for ($i = 0; $i <= $count_items; ++$i) {
$notice->message .= $res[$i] . "\n";
}
}
$vars['content'] = check_markup($notice->message, $notice->format, FALSE);
$links[] = array(
'title' => t('Read more'),
'href' => 'notices/view/' . $notice->noticeid,
'attributes' => array(
'class' => 'notice-read-more',
),
);
if ($notice->new) {
$links[] = array(
'title' => t('Mark as read'),
'href' => 'notices/read/' . $notice->noticeid,
'attributes' => array(
'rel' => $notice->noticeid,
'id' => 'noticeread-' . $notice->noticeid,
'class' => 'notice-mark-read',
),
);
}
$links[] = array(
'title' => t('Delete'),
'href' => 'notices/delete/' . $notice->noticeid,
'attributes' => array(
'rel' => $notice->noticeid,
'id' => 'noticeremove-' . $notice->noticeid,
'class' => 'notice-remove',
),
);
$vars['time'] = format_date($notice->timestamp, 'medium');
$variables = array(
'links' => $links,
'attributes' => array('class' => 'notice-links'),
);
$vars['links'] = theme('links', $variables);
$vars['timeago'] = t('@time ago', array('@time' => format_interval(REQUEST_TIME - $notice->timestamp)));
$file = drupal_get_path('module', $notice->provider) . '/' . $notice->provider . '.png';
if (!file_exists($file)) {
$file = drupal_get_path('module', 'notices') . '/default.png';
}
$vars['picture'] = $file;
$status_output = '';
$status = notices_getSendStatus($notice);
foreach ($status as $name => $value) {
$status_output .= '<li class="' . $name . '" style="background: url(/' . $value['icon'] . ') no-repeat center left; padding-left: 22px;"> <span class="status">' . $value['status'] . '</span></li>';
}
if (!empty($status_output)) {
$vars['status'] = '<ul class="notices_status">' . $status_output . '</ul>';
}
}