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
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
<?php
/**
* @file
* Misc theme functions.
*/
/**
* Theme callback.
*/
function theme_muamba_transactions($variables) {
$path = drupal_get_path('module', 'muamba');
drupal_add_js($path .'/muamba.js');
$rows = array();
$type = $variables['type'];
$transactions = $variables['transactions'];
$output = '<div class="muamba-transactions">';
if ($type == 'sent') {
$title = t('Items I requested from people');
}
else {
$title = t('My items that people requested');
}
$output .= '<h2>'. $title .'</h2>';
if (empty($transactions)) {
$output .= t('There are no transactions.');
$output .= '</div>';
return $output;
}
foreach($transactions as $transaction) {
$actions = array();
foreach (muamba_actions_available($type, $transaction) as $action) {
$callback = muamba_actions($action);
$actions[] = l(t($callback), 'muamba/'. $callback .'/'. $transaction['mid']);
}
$rows[] = array(
'asset' => $transaction['node']->title,
'user' => $transaction['user']->name,
'status' => t(muamba_statuses($transaction['status'])),
'actions' => implode($actions, ' | '),
//'thread' => theme('muamba_colorbox_link', array(
// 'path' => '/messages/view/'. $transaction['thread_id'],
// 'text' => t('view messages'),
//)),
'thread' => l(
t('view messages'),
'messages/view/'. $transaction['thread_id'],
array(
'attributes' => array(
//'class' => array('colorbox-ajax', 'colorbox-load')
)
)
)
);
}
// Make a table for them.
$header = array(t('Item'), t('User'), t('Status'), t('Actions'), t('Negotiation'));
$output .= theme('table', array('header' => $header, 'rows' => $rows));
$output .= '</div>';
return $output;
}
/**
* Theme callback.
*/
function theme_muamba_colorbox_link($variables) {
$path = $variables['path'];
$text = $variables['text'];
$output = '<a href="'. $path .'?width=500&height=500&iframe=true';
$output .= '" class="colorbox-ajax colorbox-load">';
$output .= $text .'</a>';
return $output;
}
/**
* Theme callback.
*/
function theme_muamba_request_message($transaction = NULL) {
$link = l(t('your requests page'), 'muamba');
return t('Hi, I would like to request this item of yours. Please visit @link to manage this request',
array('@link' => $link));
}
/**
* Theme callback.
*/
function theme_muamba_accept_message($transaction = NULL) {
return t('I accept your item request');
}
/**
* Theme callback.
*/
function theme_muamba_reject_message($transaction = NULL) {
return t('I reject your item request');
}
/**
* Theme callback.
*/
function theme_muamba_cancel_message($transaction = NULL) {
return t('I cancel my item request');
}
/**
* Theme callback.
*/
function theme_muamba_return_message($transaction = NULL) {
return t('I return your item');
}
/**
* Theme callback.
*/
function theme_muamba_recovered_message($transaction = NULL) {
return t('I recovered my item');
}
/**
* Theme callback.
*/
function theme_muamba_lost_message($transaction = NULL) {
return t('I declare that my item is lost');
}
/**
* Theme callback.
*/
function theme_muamba_widget_icon($variables) {
$status = $variables['status'];
$id = $variables['id'];
$size = $variables['size'];
$path = drupal_get_path('module', 'muamba');
$action = muamba_actions($status);
$image = $path .'/images/icons/'. $size .'/'. $action .'.png';
$title = ucfirst($action) .' item';
$icon = theme('image',
array(
'path' => $image,
'alt' => t($title),
'title' => t($title),
)
);
$output = l($icon, 'muamba/'. $action .'/'. $id, array('html' => TRUE));
return $output;
}
/**
* Theme callback.
*/
function theme_muamba_widget_owner($variables) {
$content = '';
$transaction = $variables['transaction'];
$size = $variables['size'];
$requester = user_load($transaction['uid']);
if ($size != 'small') {
$content .= t('Request from @name.', array('@name' => $requester->name));
$content .= '<br />';
}
foreach (muamba_actions_available('received', $transaction) as $action) {
$content .= theme('muamba_widget_icon', array(
'status' => $action,
'id' => $transaction['mid'],
'size' => $size,
));
}
return $content;
}
/**
* Theme callback.
*/
function theme_muamba_widget_requester($variables) {
$content = '';
$transaction = $variables['transaction'];
$size = $variables['size'];
foreach (muamba_actions_available('sent', $transaction) as $action) {
$content .= theme('muamba_widget_icon', array(
'status' => $action,
'id' => $transaction['mid'],
'size' => $size,
));
}
return $content;
}
|