|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @file |
|
5
|
|
|
* Process theme data. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Implements hook_theme(). |
|
10
|
|
|
*/ |
|
11
|
|
|
function commons_origins_theme($existing, $type, $theme, $path) { |
|
|
|
|
|
|
12
|
|
|
return array( |
|
13
|
|
|
// Register the newly added theme_form_content() hook so we can utilize |
|
14
|
|
|
// theme hook suggestions. |
|
15
|
|
|
// @see commons_origins_form_alter(). |
|
16
|
|
|
'form_content' => array( |
|
17
|
|
|
'render element' => 'form', |
|
18
|
|
|
'path' => drupal_get_path('theme', 'commons_origins') . '/templates/form', |
|
19
|
|
|
'template' => 'form-content', |
|
20
|
|
|
'pattern' => 'form_content__', |
|
21
|
|
|
), |
|
22
|
|
|
); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Implements hook_commons_utility_links_alter(). |
|
27
|
|
|
*/ |
|
28
|
|
|
function commons_origins_commons_utility_links_alter(&$element) { |
|
29
|
|
|
// Add wrappers to title elements in notification links so that they can be |
|
30
|
|
|
// replaced with an icon. |
|
31
|
|
|
$iconify = array( |
|
32
|
|
|
'unread-invitations', |
|
33
|
|
|
'unread-messages', |
|
34
|
|
|
); |
|
35
|
|
|
foreach ($iconify as $name) { |
|
36
|
|
|
if (isset($element[$name])) { |
|
37
|
|
|
$words = explode(' ', $element[$name]['title']); |
|
38
|
|
|
foreach($words as &$word) { |
|
39
|
|
|
if(is_numeric($word)) { |
|
40
|
|
|
$word = '<span class="notification-count">' . $word . '</span>'; |
|
41
|
|
|
} |
|
42
|
|
|
else { |
|
43
|
|
|
$word = '<span class="notification-label element-invisible">' . $word . '</span>'; |
|
44
|
|
|
} |
|
45
|
|
|
} |
|
46
|
|
|
$element[$name]['title'] = implode(' ', $words); |
|
47
|
|
|
$element[$name]['html'] = TRUE; |
|
48
|
|
|
} |
|
49
|
|
|
} |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Implements hook_preprocess_media_oembed(). |
|
54
|
|
|
*/ |
|
55
|
|
|
function commons_origins_preprocess_media_oembed(&$variables) { |
|
56
|
|
|
$content = $variables['content']; |
|
57
|
|
|
$type = $variables['type']; |
|
58
|
|
|
|
|
59
|
|
|
// Video and rich type must have HTML content. |
|
60
|
|
|
// Wrap the HTML content in a <div> to allow it to be made responsive. |
|
61
|
|
|
if (in_array($type, array('video', 'rich'))) { |
|
62
|
|
|
$variables['content'] = '<div class="oembed">' . $content . '</div>'; |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Implements hook_preprocess_search_result(). |
|
68
|
|
|
*/ |
|
69
|
|
|
function commons_origins_preprocess_search_result(&$variables, $hook) { |
|
|
|
|
|
|
70
|
|
|
$variables['title_attributes_array']['class'][] = 'title'; |
|
71
|
|
|
$variables['title_attributes_array']['class'][] = 'search-result-title'; |
|
72
|
|
|
$variables['content_attributes_array']['class'][] = 'search-result-content'; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* Implements hook_preprocess_search_results(). |
|
77
|
|
|
* |
|
78
|
|
|
* Assemble attributes for styling that core does not do so we can keep the |
|
79
|
|
|
* tpl files simpler and make maintaining it a bit less worrisome since there |
|
80
|
|
|
* are 2 forms of search supported. |
|
81
|
|
|
*/ |
|
82
|
|
|
function commons_origins_preprocess_search_results(&$variables, $hook) { |
|
|
|
|
|
|
83
|
|
|
$variables['classes_array'][] = 'search-results-wrapper'; |
|
84
|
|
|
$variables['title_attributes_array']['class'][] = 'search-results-title'; |
|
85
|
|
|
$variables['content_attributes_array']['class'][] = 'search-results-content'; |
|
86
|
|
|
$variables['content_attributes_array']['class'][] = 'commons-pod'; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* Implements hook_process_search_results(). |
|
91
|
|
|
*/ |
|
92
|
|
|
function commons_origins_process_search_results(&$variables, $hook) { |
|
|
|
|
|
|
93
|
|
|
// Set the title in preprocess so that it can be overridden by modules |
|
94
|
|
|
// further upstream. |
|
95
|
|
|
if (empty($variables['title'])) { |
|
96
|
|
|
$variables['title'] = t('Search results'); |
|
97
|
|
|
} |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* Shows a groups of blocks for starting a search from a filter. |
|
102
|
|
|
*/ |
|
103
|
|
|
function commons_origins_apachesolr_search_browse_blocks($vars) { |
|
104
|
|
|
$result = ''; |
|
105
|
|
|
if ($vars['content']['#children']) { |
|
106
|
|
|
$result .= '<div class="apachesolr-browse-blocks">' . "\n"; |
|
107
|
|
|
$result .= ' <h2 class="search-results-title">' . t('Browse available categories') . '</h2>' . "\n"; |
|
108
|
|
|
$result .= ' <div class="commons-pod">' . "\n"; |
|
109
|
|
|
$result .= ' <p>' . t('Pick a category to launch a search.') . '</p>' . "\n"; |
|
110
|
|
|
$result .= $vars['content']['#children'] . "\n"; |
|
111
|
|
|
$result .= ' </div>' . "\n"; |
|
112
|
|
|
$result .= '</div>'; |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
return $result; |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
/** |
|
119
|
|
|
* Preprocess variables for the html template. |
|
120
|
|
|
*/ |
|
121
|
|
|
function commons_origins_preprocess_html(&$variables, $hook) { |
|
|
|
|
|
|
122
|
|
|
global $theme_key; |
|
123
|
|
|
|
|
124
|
|
|
$site_name = variable_get('site_name', 'Commons'); |
|
|
|
|
|
|
125
|
|
|
|
|
126
|
|
|
// Add a class to the body so we can adjust styles for the new menu item. |
|
127
|
|
|
if (module_exists('commons_search_solr_user')) { |
|
128
|
|
|
$variables['classes_array'][] = 'people-search-active'; |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
$palette = variable_get('commons_origins_palette', 'default'); |
|
132
|
|
|
if ($palette != 'default') { |
|
133
|
|
|
$variables['classes_array'][] = 'palette-active'; |
|
134
|
|
|
$variables['classes_array'][] = drupal_html_class($palette); |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
// Browser/platform sniff - adds body classes such as ipad, webkit, chrome |
|
138
|
|
|
// etc. |
|
139
|
|
|
$variables['classes_array'][] = css_browser_selector(); |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
/** |
|
143
|
|
|
* Implements hook_privatemsg_view_alter(). |
|
144
|
|
|
*/ |
|
145
|
|
|
function commons_origins_privatemsg_view_alter(&$elements) { |
|
146
|
|
|
// Wrap the message view and reply form in a commons pod. |
|
147
|
|
|
$elements['#theme_wrappers'][] = 'container'; |
|
148
|
|
|
$elements['#attributes']['class'][] = 'privatemsg-conversation'; |
|
149
|
|
|
$elements['#attributes']['class'][] = 'commons-pod'; |
|
150
|
|
|
|
|
151
|
|
|
// Knock the reply form title down an h-level. |
|
152
|
|
|
if (isset($elements['reply']['reply']['#markup'])) { |
|
153
|
|
|
$elements['reply']['reply']['#markup'] = str_replace('h2', 'h3', $elements['reply']['reply']['#markup']); |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
// Apply classes to the form actions and make sure the submit comes first. |
|
157
|
|
View Code Duplication |
if (isset($elements['reply']['actions']['submit'])) { |
|
|
|
|
|
|
158
|
|
|
$elements['reply']['actions']['submit']['#attributes']['class'][] = 'action-item-primary'; |
|
159
|
|
|
$elements['reply']['actions']['submit']['#weight'] = 0; |
|
160
|
|
|
} |
|
161
|
|
View Code Duplication |
if (isset($elements['reply']['actions']['cancel'])) { |
|
|
|
|
|
|
162
|
|
|
$elements['reply']['actions']['cancel']['#attributes']['class'][] = 'action-item'; |
|
163
|
|
|
$elements['reply']['actions']['cancel']['#weight'] = 1; |
|
164
|
|
|
} |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
/** |
|
168
|
|
|
* Implements hook_privatemsg_message_view_alter(). |
|
169
|
|
|
*/ |
|
170
|
|
|
function commons_origins_privatemsg_message_view_alter(&$elements) { |
|
171
|
|
|
if (isset($elements['message_actions'])) { |
|
172
|
|
|
// Move the message links into a different variable and make it a renderable |
|
173
|
|
|
// array. Privatemsg has the links hardcoded, so this is the only way to |
|
174
|
|
|
// gain control and prevent extra processing. |
|
175
|
|
|
$elements['message_links'] = array( |
|
176
|
|
|
'#theme' => 'links__privatemsg_message', |
|
177
|
|
|
'#links' => $elements['message_actions'], |
|
178
|
|
|
'#attributes' => array( |
|
179
|
|
|
'class' => array('privatemsg-message-links', 'links'), |
|
180
|
|
|
), |
|
181
|
|
|
); |
|
182
|
|
|
unset($elements['message_actions']); |
|
183
|
|
|
} |
|
184
|
|
|
} |
|
185
|
|
|
|
|
186
|
|
|
/** |
|
187
|
|
|
* Implements hook_preprocess_privatemsg_view(). |
|
188
|
|
|
*/ |
|
189
|
|
|
function commons_origins_preprocess_privatemsg_view(&$variables, $hook) { |
|
|
|
|
|
|
190
|
|
|
// Make the template conform with Drupal standard attributes. |
|
191
|
|
|
if (isset($variables['message_classes'])) { |
|
192
|
|
|
$variables['classes_array'] = array_merge($variables['classes_array'], $variables['message_classes']); |
|
193
|
|
|
} |
|
194
|
|
|
$variables['classes_array'][] = 'clearfix'; |
|
195
|
|
|
$variables['attributes_array']['id'] = 'privatemsg-mid-' . $variables['mid']; |
|
196
|
|
|
$variables['content_attributes_array']['class'][] = 'privatemsg-message-content'; |
|
197
|
|
|
|
|
198
|
|
|
// Add a distinct class to the "Delete" action. |
|
199
|
|
|
if (isset($variables['message_links']['#links'])) { |
|
200
|
|
|
foreach ($variables['message_links']['#links'] as &$link) { |
|
201
|
|
|
// Due to the lack of a proper key-baed identifier, a string search is the |
|
202
|
|
|
// only flexible way to sniff out the link. |
|
203
|
|
|
if (strpos($link['href'], 'delete')) { |
|
204
|
|
|
$link['attributes']['class'][] = 'message-delete'; |
|
205
|
|
|
} |
|
206
|
|
|
} |
|
207
|
|
|
} |
|
208
|
|
|
} |
|
209
|
|
|
|
|
210
|
|
|
/** |
|
211
|
|
|
* Implements theme_menu_link(). |
|
212
|
|
|
*/ |
|
213
|
|
|
function commons_origins_menu_link($variables) { |
|
214
|
|
|
$output = ''; |
|
|
|
|
|
|
215
|
|
|
$path_to_at_core = drupal_get_path('theme', 'adaptivetheme'); |
|
216
|
|
|
|
|
217
|
|
|
include_once($path_to_at_core . '/inc/get.inc'); |
|
218
|
|
|
|
|
219
|
|
|
global $theme_key; |
|
220
|
|
|
$theme_name = $theme_key; |
|
221
|
|
|
|
|
222
|
|
|
$element = $variables['element']; |
|
223
|
|
|
commons_origins_menu_link_class($element); |
|
224
|
|
|
$sub_menu = ''; |
|
225
|
|
|
|
|
226
|
|
|
if ($element['#below']) { |
|
227
|
|
|
$sub_menu = drupal_render($element['#below']); |
|
228
|
|
|
} |
|
229
|
|
|
|
|
230
|
|
|
if (at_get_setting('extra_menu_classes', $theme_name) == 1 && !empty($element['#original_link'])) { |
|
231
|
|
View Code Duplication |
if (!empty($element['#original_link']['depth'])) { |
|
|
|
|
|
|
232
|
|
|
$element['#attributes']['class'][] = 'menu-depth-' . $element['#original_link']['depth']; |
|
233
|
|
|
} |
|
234
|
|
View Code Duplication |
if (!empty($element['#original_link']['mlid'])) { |
|
|
|
|
|
|
235
|
|
|
$element['#attributes']['class'][] = 'menu-item-' . $element['#original_link']['mlid']; |
|
236
|
|
|
} |
|
237
|
|
|
} |
|
238
|
|
|
|
|
239
|
|
|
if (at_get_setting('menu_item_span_elements', $theme_name) == 1 && !empty($element['#title'])) { |
|
240
|
|
|
$element['#title'] = '<span>' . $element['#title'] . '</span>'; |
|
241
|
|
|
$element['#localized_options']['html'] = TRUE; |
|
242
|
|
|
} |
|
243
|
|
|
|
|
244
|
|
|
if (at_get_setting('unset_menu_titles', $theme_name) == 1 && !empty($element['#localized_options']['attributes']['title'])) { |
|
245
|
|
|
unset($element['#localized_options']['attributes']['title']); |
|
246
|
|
|
} |
|
247
|
|
|
|
|
248
|
|
|
$output = l($element['#title'], $element['#href'], $element['#localized_options']); |
|
249
|
|
|
return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>"; |
|
250
|
|
|
} |
|
251
|
|
|
|
|
252
|
|
|
/** |
|
253
|
|
|
* Helper function to examine menu links and return the appropriate class. |
|
254
|
|
|
*/ |
|
255
|
|
|
function commons_origins_menu_link_class(&$element) { |
|
256
|
|
|
if ($element['#original_link']['menu_name'] == 'main-menu') { |
|
257
|
|
|
$element['#attributes']['class'][] = drupal_html_class($element['#original_link']['menu_name'] . '-' . $element['#original_link']['router_path']); |
|
258
|
|
|
} |
|
259
|
|
|
} |
|
260
|
|
|
|
|
261
|
|
|
/** |
|
262
|
|
|
* Override or insert variables for the page templates. |
|
263
|
|
|
*/ |
|
264
|
|
|
function commons_origins_preprocess_page(&$variables, $hook) { |
|
|
|
|
|
|
265
|
|
|
if (module_exists('page_manager')) { |
|
266
|
|
|
$p = page_manager_get_current_page(); |
|
267
|
|
|
if (isset($p['name']) && $p['name'] == 'node_view') { |
|
268
|
|
|
$node = $p['contexts']['argument_entity_id:node_1']->data; |
|
269
|
|
|
if (module_exists('og') && !og_is_group('node', $node)) { |
|
270
|
|
|
$variables['hide_panelized_title'] = 1; |
|
271
|
|
|
} |
|
272
|
|
|
} |
|
273
|
|
|
} |
|
274
|
|
|
|
|
275
|
|
|
$variables['header_attributes_array']['class'][] = 'container'; |
|
276
|
|
|
|
|
277
|
|
|
$cf_pos = in_array('clearfix', $variables['branding_attributes_array']['class']); |
|
278
|
|
|
unset($variables['branding_attributes_array']['class'][$cf_pos]); |
|
279
|
|
|
|
|
280
|
|
|
// Only load the media styles if Commons Media is enabled. |
|
281
|
|
|
if (module_exists('commons_media')) { |
|
282
|
|
|
drupal_add_css(drupal_get_path('theme', 'commons_origins') . '/css/commons-media.css', array('media' => 'screen', 'group' => CSS_THEME)); |
|
283
|
|
|
} |
|
284
|
|
|
} |
|
285
|
|
|
|
|
286
|
|
|
/** |
|
287
|
|
|
* Override or insert variables into the node templates. |
|
288
|
|
|
*/ |
|
289
|
|
|
function commons_origins_preprocess_node(&$variables, $hook) { |
|
|
|
|
|
|
290
|
|
|
$node = $variables['node']; |
|
291
|
|
|
|
|
292
|
|
|
// Some content does not get a user image on the full node. |
|
293
|
|
|
$no_avatar = array( |
|
294
|
|
|
'event', |
|
295
|
|
|
'group', |
|
296
|
|
|
'page', |
|
297
|
|
|
'wiki', |
|
298
|
|
|
); |
|
299
|
|
|
if (!$variables['teaser'] && in_array($node->type, $no_avatar)) { |
|
300
|
|
|
$variables['user_picture'] = ''; |
|
301
|
|
|
} |
|
302
|
|
|
|
|
303
|
|
|
// If there does happen to be a user image, add a class for styling purposes. |
|
304
|
|
|
if (!empty($variables['user_picture'])) { |
|
305
|
|
|
$variables['classes_array'][] = 'user-picture-available'; |
|
306
|
|
|
} |
|
307
|
|
|
|
|
308
|
|
|
// Style node links like buttons. |
|
309
|
|
|
if (isset($variables['content']['links'])) { |
|
310
|
|
|
foreach ($variables['content']['links'] as $type => &$linkgroup) { |
|
311
|
|
|
// Button styling for the "rate" and "flag" types will be handled |
|
312
|
|
|
// separately. |
|
313
|
|
|
if ($type != 'rate' && $type != 'flag' && substr($type, 0, 1) != '#') { |
|
314
|
|
|
foreach ($linkgroup['#links'] as $name => &$link) { |
|
315
|
|
|
// Prevent errors when no classes have been defined. |
|
316
|
|
|
if (!isset($link['attributes']['class'])) { |
|
317
|
|
|
$link['attributes']['class'] = array(); |
|
318
|
|
|
} |
|
319
|
|
|
|
|
320
|
|
|
// Apply button classes to everything but comment_forbidden. |
|
321
|
|
|
if ($name != 'comment_forbidden' && $name != 'answer-add' && !is_string($link['attributes']['class'])) { |
|
322
|
|
|
$link['attributes']['class'][] = 'action-item-small'; |
|
323
|
|
|
$link['attributes']['class'][] = 'action-item-inline'; |
|
324
|
|
|
} |
|
325
|
|
|
elseif ($name != 'comment_forbidden' && $name != 'answer-add') { |
|
326
|
|
|
$link['attributes']['class'] .= ' action-item-small action-item-inline'; |
|
327
|
|
|
} |
|
328
|
|
|
} |
|
329
|
|
|
// Clean the reference so it does not confuse things further down. |
|
330
|
|
|
unset($link); |
|
331
|
|
|
} |
|
332
|
|
|
} |
|
333
|
|
|
} |
|
334
|
|
|
|
|
335
|
|
|
// Add classes to render the comment-comments link as a button with a number |
|
336
|
|
|
// attached. |
|
337
|
|
|
if (!empty($variables['content']['links']['comment']['#links']['comment-comments'])) { |
|
338
|
|
|
$comments_link = &$variables['content']['links']['comment']['#links']['comment-comments']; |
|
339
|
|
|
$comments_link['attributes']['class'][] = 'link-with-counter'; |
|
340
|
|
|
$chunks = explode(' ', $comments_link['title']); |
|
341
|
|
|
|
|
342
|
|
|
// Add appropriate classes to words in the title. |
|
343
|
|
|
foreach ($chunks as &$chunk) { |
|
344
|
|
|
if ($chunk == $variables['comment_count']) { |
|
345
|
|
|
$chunk = '<span class="action-item-small-append">' . $variables['comment_count'] . '</span>'; |
|
346
|
|
|
} |
|
347
|
|
|
else { |
|
348
|
|
|
$chunk = '<span class="element-invisible">' . $chunk . '</span>'; |
|
349
|
|
|
} |
|
350
|
|
|
} |
|
351
|
|
|
$comments_link['title'] = implode(' ', $chunks); |
|
352
|
|
|
} |
|
353
|
|
|
|
|
354
|
|
|
// Push the reporting link to the end. |
|
355
|
|
|
if (!empty($variables['content']['links']['flag']['#links']['flag-inappropriate_node'])) { |
|
356
|
|
|
$variables['content']['report_link'] = array('#markup' => $variables['content']['links']['flag']['#links']['flag-inappropriate_node']['title']); |
|
357
|
|
|
} |
|
358
|
|
|
|
|
359
|
|
|
if (!empty($variables['content']['links'])) { |
|
360
|
|
|
// Hide some of the node links. |
|
361
|
|
|
$hidden_links = array( |
|
362
|
|
|
'node' => array( |
|
363
|
|
|
'node-readmore', |
|
364
|
|
|
), |
|
365
|
|
|
'comment' => array( |
|
366
|
|
|
'comment-add', |
|
367
|
|
|
'comment-new-comments' |
|
368
|
|
|
), |
|
369
|
|
|
'flag' => array( |
|
370
|
|
|
'flag-inappropriate_node', |
|
371
|
|
|
), |
|
372
|
|
|
); |
|
373
|
|
|
foreach ($hidden_links as $element => $links) { |
|
374
|
|
|
foreach ($links as $link) { |
|
375
|
|
|
if (!empty($variables['content']['links'][$element]['#links'][$link])) { |
|
376
|
|
|
$variables['content']['links'][$element]['#links'][$link]['#access'] = FALSE; |
|
377
|
|
|
} |
|
378
|
|
|
} |
|
379
|
|
|
} |
|
380
|
|
|
} |
|
381
|
|
|
|
|
382
|
|
|
// Add a class to the node when there is a logo image. |
|
383
|
|
|
if (!empty($variables['field_logo'])) { |
|
384
|
|
|
$variables['classes_array'][] = 'logo-available'; |
|
385
|
|
|
} |
|
386
|
|
|
|
|
387
|
|
|
// Move the answer link on question nodes to the top of the content. |
|
388
|
|
|
if ($variables['node']->type == 'question' && !empty($variables['content']['links']['answer'])) { |
|
389
|
|
|
$variables['content']['answer'] = $variables['content']['links']['answer']; |
|
390
|
|
|
$variables['content']['answer']['#attributes']['class'][] = 'node-actions'; |
|
391
|
|
|
$variables['content']['answer']['#links']['answer-add']['attributes']['class'][] = 'action-item-primary'; |
|
392
|
|
|
$variables['content']['answer']['#weight'] = -100; |
|
393
|
|
|
$variables['content']['links']['answer']['#access'] = FALSE; |
|
394
|
|
|
} |
|
395
|
|
|
|
|
396
|
|
|
// Groups the related fields into their own container. |
|
397
|
|
|
$related_information = array( |
|
398
|
|
|
'og_group_ref', |
|
399
|
|
|
'field_related_question', |
|
400
|
|
|
'field_topics', |
|
401
|
|
|
); |
|
402
|
|
|
foreach($related_information as $field) { |
|
403
|
|
|
if (!empty($variables['content'][$field])) { |
|
404
|
|
|
$variables['content']['related_information'][$field] = $variables['content'][$field]; |
|
405
|
|
|
hide($variables['content'][$field]); |
|
406
|
|
|
} |
|
407
|
|
|
} |
|
408
|
|
|
if (!empty($variables['content']['related_information'])) { |
|
409
|
|
|
$variables['content']['related_information'] += array( |
|
410
|
|
|
'#theme_wrappers' => array('container'), |
|
411
|
|
|
'#attributes' => array( |
|
412
|
|
|
'class' => array('related-information', 'clearfix'), |
|
413
|
|
|
), |
|
414
|
|
|
'#weight' => 1000, |
|
415
|
|
|
); |
|
416
|
|
|
} |
|
417
|
|
|
|
|
418
|
|
|
// Add classes when there is a voting widget present. |
|
419
|
|
|
if (!empty($variables['content']['rate_commons_answer'])) { |
|
420
|
|
|
$variables['content_attributes_array']['class'][] = 'has-rate-widget'; |
|
421
|
|
|
$variables['content']['rate_commons_answer']['#weight'] = 999; |
|
422
|
|
|
} |
|
423
|
|
|
|
|
424
|
|
|
// Add a general class to the node links. |
|
425
|
|
|
if (!empty($variables['content']['links'])) { |
|
426
|
|
|
$variables['content']['links']['#attributes']['class'][] = 'node-action-links'; |
|
427
|
|
|
|
|
428
|
|
|
// For some reason, the node links processing is not always added and |
|
429
|
|
|
// multiple ul elements are output instead of a single. |
|
430
|
|
|
if (!isset($variables['content']['links']['#pre_render']) || !in_array('drupal_pre_render_links', $variables['content']['links']['#pre_render'])) { |
|
431
|
|
|
$variables['content']['links']['#pre_render'][] = 'drupal_pre_render_links'; |
|
432
|
|
|
} |
|
433
|
|
|
} |
|
434
|
|
|
} |
|
435
|
|
|
|
|
436
|
|
|
/** |
|
437
|
|
|
* Implements hook_preprocess_comment_wrapper(). |
|
438
|
|
|
*/ |
|
439
|
|
|
function commons_origins_preprocess_comment_wrapper(&$variables, $hook) { |
|
|
|
|
|
|
440
|
|
|
// Change things around to use the attribute arrays for the titles. |
|
441
|
|
|
$variables['title_attributes_array']['class'][] = 'comments-title'; |
|
442
|
|
|
$variables['form_title_attributes_array'] = array( |
|
443
|
|
|
'class' => array('comment-title', 'title', 'comment-form', 'comment-form-title') |
|
444
|
|
|
); |
|
445
|
|
|
} |
|
446
|
|
|
|
|
447
|
|
|
/** |
|
448
|
|
|
* Implements hook_process_comment_wrapper(). |
|
449
|
|
|
*/ |
|
450
|
|
|
function commons_origins_process_comment_wrapper(&$variables, $hook) { |
|
|
|
|
|
|
451
|
|
|
// Make sure the form_title_attributes_array is rendered into a single string. |
|
452
|
|
|
$variables['form_title_attributes'] = drupal_attributes($variables['form_title_attributes_array']); |
|
453
|
|
|
} |
|
454
|
|
|
|
|
455
|
|
|
/** |
|
456
|
|
|
* Implements hook_preprocess_comment(). |
|
457
|
|
|
*/ |
|
458
|
|
|
function commons_origins_preprocess_comment(&$variables, $hook) { |
|
|
|
|
|
|
459
|
|
|
$variables['content']['links']['#attributes']['class'][] = 'comment-links'; |
|
460
|
|
|
|
|
461
|
|
|
// Push the reporting link to the end. |
|
462
|
|
|
if (!empty($variables['content']['links']['flag']['#links']['flag-inappropriate_comment'])) { |
|
463
|
|
|
$variables['content']['report_link'] = array('#markup' => $variables['content']['links']['flag']['#links']['flag-inappropriate_comment']['title']); |
|
464
|
|
|
$variables['content']['links']['flag']['#links']['flag-inappropriate_comment']['#access'] = FALSE; |
|
465
|
|
|
} |
|
466
|
|
|
} |
|
467
|
|
|
|
|
468
|
|
|
/** |
|
469
|
|
|
* Implements hook_preprocess_flag(). |
|
470
|
|
|
*/ |
|
471
|
|
|
function commons_origins_preprocess_flag(&$variables, $hook) { |
|
|
|
|
|
|
472
|
|
|
if (strpos($variables['flag_name_css'], 'inappropriate-') !== 0) { |
|
473
|
|
|
// Style the flag links like buttons. |
|
474
|
|
|
if ($variables['last_action'] == 'flagged') { |
|
475
|
|
|
$variables['flag_classes_array'][] = 'action-item-small-active'; |
|
476
|
|
|
} |
|
477
|
|
|
else { |
|
478
|
|
|
$variables['flag_classes_array'][] = 'action-item-small'; |
|
479
|
|
|
} |
|
480
|
|
|
$variables['flag_classes'] = implode(' ', $variables['flag_classes_array']); |
|
481
|
|
|
} |
|
482
|
|
|
} |
|
483
|
|
|
|
|
484
|
|
|
/** |
|
485
|
|
|
* Implements hook_preprocess_two_33_66(). |
|
486
|
|
|
*/ |
|
487
|
|
|
function commons_origins_preprocess_two_33_66(&$variables, $hook) { |
|
|
|
|
|
|
488
|
|
|
$menu = menu_get_item(); |
|
489
|
|
|
|
|
490
|
|
|
// Suggest a variant for the search page so the facets will be wrapped in pod |
|
491
|
|
|
// styling. |
|
492
|
|
|
if (strpos($menu['path'], 'search') === 0) { |
|
493
|
|
|
$variables['theme_hook_suggestions'][] = 'two_33_66__search'; |
|
494
|
|
|
} |
|
495
|
|
|
} |
|
496
|
|
|
|
|
497
|
|
|
function commons_origins_preprocess_three_25_50_25(&$variables, $hook) { |
|
|
|
|
|
|
498
|
|
|
$menu = menu_get_item(); |
|
499
|
|
|
|
|
500
|
|
|
// Suggest a variant for the search page so the facets will be wrapped in pod |
|
501
|
|
|
// styling. |
|
502
|
|
|
if (isset($menu['page_arguments']) && $menu['page_arguments'][0] == 'solr_events') { |
|
503
|
|
|
$variables['theme_hook_suggestions'][] = 'three_25_50_25__events'; |
|
504
|
|
|
} |
|
505
|
|
|
} |
|
506
|
|
|
|
|
507
|
|
|
/** |
|
508
|
|
|
* Implements hook_preprocess_panelizer_view_mode(). |
|
509
|
|
|
*/ |
|
510
|
|
|
function commons_origins_preprocess_panelizer_view_mode(&$variables, $hook) { |
|
511
|
|
|
// Add classed to identity the entity type being overridden. |
|
512
|
|
|
$variables['classes_array'][] = drupal_html_class('panelizer-' . $variables['element']['#entity_type']); |
|
513
|
|
|
$variables['title_attributes_array']['class'][] = drupal_html_class($variables['element']['#entity_type'] . '-title'); |
|
514
|
|
|
$variables['title_attributes_array']['class'][] = drupal_html_class('panelizer-' . $variables['element']['#entity_type'] . '-title'); |
|
515
|
|
|
|
|
516
|
|
|
// Add some extra theme hooks for the subthemers. |
|
517
|
|
|
$variables['hook_theme_suggestions'][] = $hook . '__' . $variables['element']['#entity_type']; |
|
518
|
|
|
$variables['hook_theme_suggestions'][] = $hook . '__' . $variables['element']['#entity_type'] . '__' . $variables['element']['#bundle']; |
|
519
|
|
|
} |
|
520
|
|
|
|
|
521
|
|
|
/** |
|
522
|
|
|
* Implements hook_preprocess_panels_pane(). |
|
523
|
|
|
*/ |
|
524
|
|
|
function commons_origins_preprocess_panels_pane(&$variables, $hook) { |
|
|
|
|
|
|
525
|
|
|
$pane = $variables['pane']; |
|
526
|
|
|
|
|
527
|
|
|
// Add pod styling to some of the panels panes. |
|
528
|
|
|
$not_pods = array( |
|
529
|
|
|
'commons_events-commons_events_create_event_link', |
|
530
|
|
|
); |
|
531
|
|
|
$content_pods = array( |
|
532
|
|
|
'commons_question_answers-panel_pane_1', |
|
533
|
|
|
); |
|
534
|
|
|
if (($pane->panel == 'two_66_33_second' && !in_array($pane->subtype, $not_pods)) || in_array($pane->subtype, $content_pods)) { |
|
535
|
|
|
$variables['attributes_array']['class'][] = 'commons-pod'; |
|
536
|
|
|
} |
|
537
|
|
|
|
|
538
|
|
|
// Mimic the class for the facetapi blocks on the panel variant. |
|
539
|
|
|
if (strpos($pane->subtype, 'facetapi-') === 0) { |
|
540
|
|
|
$variables['attributes_array']['class'][] = 'block-facetapi'; |
|
541
|
|
|
} |
|
542
|
|
|
|
|
543
|
|
|
// Hide the pane title for the group contributor count. |
|
544
|
|
|
if ($pane->subtype == 'node:commons-groups-group-contributors-count-topics') { |
|
545
|
|
|
$variables['title_attributes_array']['class'][] = 'element-invisible'; |
|
546
|
|
|
} |
|
547
|
|
|
|
|
548
|
|
|
// Apply common classes to the recent items related to a group. |
|
549
|
|
|
static $recent_count = 0; |
|
550
|
|
|
if ($pane->subtype == 'commons_groups_recent_content' || $pane->subtype == 'commons_contributors_group-panel_pane_1') { |
|
551
|
|
|
$variables['attributes_array']['class'][] = 'group-recent-data'; |
|
552
|
|
|
$variables['attributes_array']['class'][] = $recent_count % 2 == 0 ? 'group-recent-data-even' : 'group-recent-data-odd'; |
|
553
|
|
|
$recent_count++; |
|
554
|
|
|
} |
|
555
|
|
|
|
|
556
|
|
|
// Hide the groups view title since it is redundant. |
|
557
|
|
|
if ($pane->subtype == 'commons_groups_directory-panel_pane_1') { |
|
558
|
|
|
$variables['title_attributes_array']['class'][] = 'element-invisible'; |
|
559
|
|
|
} |
|
560
|
|
|
} |
|
561
|
|
|
|
|
562
|
|
|
/** |
|
563
|
|
|
* Overrides theme_panels_default_style_render_region(); |
|
564
|
|
|
*/ |
|
565
|
|
|
function commons_origins_panels_default_style_render_region($variables) { |
|
566
|
|
|
$output = ''; |
|
567
|
|
|
// Remove the empty panels-separator div. |
|
568
|
|
|
$output .= implode("\n", $variables['panes']); |
|
569
|
|
|
return $output; |
|
570
|
|
|
} |
|
571
|
|
|
|
|
572
|
|
|
/** |
|
573
|
|
|
* Implements hook_preprocess_views_view(). |
|
574
|
|
|
*/ |
|
575
|
|
|
function commons_origins_preprocess_views_view(&$variables, $hook) { |
|
|
|
|
|
|
576
|
|
|
$view = $variables['view']; |
|
577
|
|
|
|
|
578
|
|
|
// Wrap page views in pod styling. |
|
579
|
|
|
if ($view->display_handler->plugin_name == 'page') { |
|
580
|
|
|
$variables['classes_array'][] = 'commons-pod'; |
|
581
|
|
|
$variables['classes_array'][] = 'clearfix'; |
|
582
|
|
|
} |
|
583
|
|
|
|
|
584
|
|
|
// Style some views without bottom borders and padding. |
|
585
|
|
|
$plain = array( |
|
586
|
|
|
'commons_groups_directory' => array('panel_pane_1'), |
|
587
|
|
|
'commons_groups_recent_content' => array('block'), |
|
588
|
|
|
'commons_groups_user_groups' => array('panel_pane_1'), |
|
589
|
|
|
'commons_radioactivity_groups_active_in_group' => array('panel_pane_1'), |
|
590
|
|
|
); |
|
591
|
|
|
if (isset($plain[$variables['name']]) && in_array($variables['display_id'], $plain[$variables['name']])) { |
|
592
|
|
|
$variables['classes_array'][] = 'view-plain'; |
|
593
|
|
|
} |
|
594
|
|
|
} |
|
595
|
|
|
|
|
596
|
|
|
/** |
|
597
|
|
|
* Implements hook_preprocess_views_view_unformatted(). |
|
598
|
|
|
*/ |
|
599
|
|
|
function commons_origins_preprocess_views_view_unformatted(&$variables, $hook) { |
|
|
|
|
|
|
600
|
|
|
$view = $variables['view']; |
|
601
|
|
|
|
|
602
|
|
|
// Prevent the avatars in the activity stream blocks from bleeding into the |
|
603
|
|
|
// rows below them. |
|
604
|
|
|
if ($view->name == 'commons_activity_streams_activity') { |
|
605
|
|
|
foreach ($variables['classes_array'] as &$classes) { |
|
606
|
|
|
$classes .= ' clearfix'; |
|
607
|
|
|
} |
|
608
|
|
|
} |
|
609
|
|
|
|
|
610
|
|
|
// Add a class to rows designating the node type for the rows that give us the |
|
611
|
|
|
// node type information. |
|
612
|
|
|
foreach ($view->result as $id => $result) { |
|
613
|
|
|
if (isset($result->node_type)) { |
|
614
|
|
|
$variables['classes_array'][$id] .= ' ' . drupal_html_class('row-type-' . $result->node_type); |
|
615
|
|
|
} |
|
616
|
|
|
else if (($view->name == 'commons_events_upcoming' && $view->override_path != 'events') || $view->name == 'commons_events_user_upcoming_events') { |
|
617
|
|
|
$variables['classes_array'][$id] .= ' ' . drupal_html_class('row-type-event'); |
|
618
|
|
|
} |
|
619
|
|
|
} |
|
620
|
|
|
} |
|
621
|
|
|
|
|
622
|
|
|
/** |
|
623
|
|
|
* Implements hook_preprocess_pager(). |
|
624
|
|
|
*/ |
|
625
|
|
|
function commons_origins_preprocess_pager_link (&$variables, $hook) { |
|
|
|
|
|
|
626
|
|
|
// Style pager links like buttons. |
|
627
|
|
|
$variables['attributes']['class'][] = 'action-item'; |
|
628
|
|
|
$variables['attributes']['class'][] = 'action-item-inline'; |
|
629
|
|
|
} |
|
630
|
|
|
|
|
631
|
|
|
/** |
|
632
|
|
|
* Implements hook_preprocess_form(). |
|
633
|
|
|
* |
|
634
|
|
|
* Since Commons Origins overrides the default theme_form() function, we will |
|
635
|
|
|
* need to perform some processing on attributes to make it work in a template. |
|
636
|
|
|
*/ |
|
637
|
|
|
function commons_origins_preprocess_form(&$variables, $hook) { |
|
638
|
|
|
// Bootstrap the with some of Drupal's default variables. |
|
639
|
|
|
template_preprocess($variables, $hook); |
|
640
|
|
|
|
|
641
|
|
|
$element = &$variables['element']; |
|
642
|
|
|
if (isset($element['#action'])) { |
|
643
|
|
|
$element['#attributes']['action'] = drupal_strip_dangerous_protocols($element['#action']); |
|
644
|
|
|
} |
|
645
|
|
|
element_set_attributes($element, array('method', 'id')); |
|
646
|
|
|
if (empty($element['#attributes']['accept-charset'])) { |
|
647
|
|
|
$element['#attributes']['accept-charset'] = "UTF-8"; |
|
648
|
|
|
} |
|
649
|
|
|
$variables['attributes_array'] = $element['#attributes']; |
|
650
|
|
|
|
|
651
|
|
|
// Roll the classes into the attributes. |
|
652
|
|
|
if (empty($variables['attributes_array']['class'])) { |
|
653
|
|
|
$variables['attributes_array']['class'] = $variables['classes_array']; |
|
654
|
|
|
} |
|
655
|
|
|
else { |
|
656
|
|
|
$variables['attributes_array']['class'] = array_merge($variables['attributes_array']['class'], $variables['classes_array']); |
|
657
|
|
|
} |
|
658
|
|
|
|
|
659
|
|
|
// Give the search form on the search page pod styling. |
|
660
|
|
|
if (isset($element['#search_page']) || (isset($element['module']) && ($element['module']['#value'] == 'search_facetapi' || $element['module']['#value'] == 'user'))) { |
|
661
|
|
|
$variables['attributes_array']['class'][] = 'search-form-page'; |
|
662
|
|
|
$variables['attributes_array']['class'][] = 'commons-pod'; |
|
663
|
|
|
$variables['attributes_array']['class'][] = 'clearfix'; |
|
664
|
|
|
} |
|
665
|
|
|
|
|
666
|
|
|
// Wrap some forms in the commons pod styling. |
|
667
|
|
|
$pods = array( |
|
668
|
|
|
'user-login', |
|
669
|
|
|
'user-pass', |
|
670
|
|
|
'user-register-form', |
|
671
|
|
|
); |
|
672
|
|
|
if (in_array($element['#id'], $pods)) { |
|
673
|
|
|
$variables['attributes_array']['class'][] = 'commons-pod'; |
|
674
|
|
|
} |
|
675
|
|
|
|
|
676
|
|
|
// Give the dynamic filters a special class to target. |
|
677
|
|
|
if (strpos($element['#id'], 'views-exposed-form-commons-homepage-content') === 0 || strpos($element['#id'], 'views-exposed-form-commons-events-upcoming') === 0 || strpos($element['#id'], 'views-exposed-form-commons-bw') === 0) { |
|
678
|
|
|
$variables['attributes_array']['class'][] = 'dynamic-filter-lists'; |
|
679
|
|
|
} |
|
680
|
|
|
|
|
681
|
|
|
// Give the keyword filter a pod wrapper. |
|
682
|
|
|
if (strpos($element['#id'], 'views-exposed-form-commons-groups') === 0) { |
|
683
|
|
|
$variables['attributes_array']['class'][] = 'keyword-filter'; |
|
684
|
|
|
$variables['attributes_array']['class'][] = 'commons-pod'; |
|
685
|
|
|
} |
|
686
|
|
|
|
|
687
|
|
|
// Set an identifying class to the event attendance form. |
|
688
|
|
|
if(strpos($element['#id'], 'commons-events-attend-event-form') === 0) { |
|
689
|
|
|
$variables['attributes_array']['class'][] = 'node-actions'; |
|
690
|
|
|
} |
|
691
|
|
|
|
|
692
|
|
|
// Make sure the bottom of the partial node form clears all content. |
|
693
|
|
|
if (strpos($element['#form_id'], 'commons_bw_partial_node_form_') === 0) { |
|
694
|
|
|
$variables['attributes_array']['class'][] = 'user-picture-available'; |
|
695
|
|
|
$variables['attributes_array']['class'][] = 'clearfix'; |
|
696
|
|
|
} |
|
697
|
|
|
|
|
698
|
|
|
// Place the user avatar to the left of the private message form content. |
|
699
|
|
|
if ($variables['element']['#form_id'] == 'commons_trusted_contacts_messages_popup') { |
|
700
|
|
|
$variables['content_attributes_array']['class'][] = 'user-picture-available'; |
|
701
|
|
|
} |
|
702
|
|
|
} |
|
703
|
|
|
|
|
704
|
|
|
/** |
|
705
|
|
|
* Implements hook_process_form(). |
|
706
|
|
|
* |
|
707
|
|
|
* Since Commons Origins overrides the default theme_form() function, we will |
|
708
|
|
|
* need to perform some processing on attributes to make it work in a template. |
|
709
|
|
|
*/ |
|
710
|
|
|
function commons_origins_process_form(&$variables, $hook) { |
|
711
|
|
|
// Crunch down attribute arrays. |
|
712
|
|
|
template_process($variables, $hook); |
|
713
|
|
|
} |
|
714
|
|
|
|
|
715
|
|
|
/** |
|
716
|
|
|
* Implements hook_preprocess_form_content(). |
|
717
|
|
|
*/ |
|
718
|
|
|
function commons_origins_preprocess_form_content(&$variables, $hook) { |
|
719
|
|
|
// Bootstrap the with some of Drupal's default variables. |
|
720
|
|
|
template_preprocess($variables, $hook); |
|
721
|
|
|
|
|
722
|
|
|
if (isset($variables['form']['supplementary'])) { |
|
723
|
|
|
foreach ($variables['form']['supplementary'] as &$field) { |
|
724
|
|
|
if (is_array($field) && isset($field['#theme_wrappers'])) { |
|
725
|
|
|
$field['#theme_wrappers'][] = 'container'; |
|
726
|
|
|
$field['#attributes']['class'][] = 'commons-pod'; |
|
727
|
|
|
} |
|
728
|
|
|
} |
|
729
|
|
|
} |
|
730
|
|
|
|
|
731
|
|
|
// The buttons for toggling event attendance should be large and noticeable. |
|
732
|
|
|
// These forms have a varying form id, so check for if the id contains a |
|
733
|
|
|
// string instead of the whole thing. |
|
734
|
|
|
if (strpos($variables['form']['#form_id'], 'commons_events_attend_event_form') === 0) { |
|
735
|
|
|
$variables['form']['submit']['#attributes']['class'][] = 'action-item-primary'; |
|
736
|
|
|
} |
|
737
|
|
|
if (strpos($variables['form']['#form_id'], 'commons_events_cancel_event_form') === 0) { |
|
738
|
|
|
$variables['form']['submit']['#attributes']['class'][] = 'action-item-active'; |
|
739
|
|
|
} |
|
740
|
|
|
|
|
741
|
|
|
// Make the "Save" button more noticeable. |
|
742
|
|
View Code Duplication |
if (isset($variables['form']['#node_edit_form']) && $variables['form']['#node_edit_form']) { |
|
|
|
|
|
|
743
|
|
|
$variables['form']['actions']['submit']['#attributes']['class'][] = 'action-item-primary'; |
|
744
|
|
|
} |
|
745
|
|
|
|
|
746
|
|
|
// Make the comment form "Save" button more noticeable. |
|
747
|
|
View Code Duplication |
if ($variables['form']['#id'] == 'comment-form') { |
|
|
|
|
|
|
748
|
|
|
$variables['form']['actions']['submit']['#attributes']['class'][] = 'action-item-primary'; |
|
749
|
|
|
} |
|
750
|
|
|
|
|
751
|
|
|
// Hide the label and make the search button primary. |
|
752
|
|
|
if (isset($variables['form']['#search_page']) || (isset($variables['form']['module']) && ($variables['form']['module']['#value'] == 'search_facetapi' || $variables['form']['module']['#value'] == 'user'))) { |
|
753
|
|
|
$variables['form']['basic']['keys']['#title_display'] = 'invisible'; |
|
754
|
|
|
$variables['form']['basic']['submit']['#attributes']['class'][] = 'action-item-search'; |
|
755
|
|
|
} |
|
756
|
|
|
|
|
757
|
|
|
// Make the partial post form submit button a primary action and give some |
|
758
|
|
|
// theme hook suggestions for easy overriding. |
|
759
|
|
|
if (strpos($variables['form']['#form_id'], 'commons_bw_partial_node_form_') === 0) { |
|
760
|
|
|
$variables['form']['actions']['submit']['#attributes']['class'][] = 'action-item-primary'; |
|
761
|
|
|
|
|
762
|
|
|
if (isset($variables['form']['title'])) { |
|
763
|
|
|
$variables['form']['title']['#markup'] = '<h3 class="partial-node-form-title">' . $variables['form']['title']['#markup'] . '</h3>'; |
|
764
|
|
|
} |
|
765
|
|
|
} |
|
766
|
|
|
|
|
767
|
|
|
// Make the links and buttons on the private message forms have the |
|
768
|
|
|
// appropriate styles. |
|
769
|
|
|
if ($variables['form']['#form_id'] == 'commons_trusted_contacts_messages_popup' || $variables['form']['#form_id'] == 'privatemsg_new') { |
|
770
|
|
View Code Duplication |
if (isset($variables['form']['actions']['submit'])) { |
|
|
|
|
|
|
771
|
|
|
$variables['form']['actions']['submit']['#attributes']['class'][] = 'action-item-primary'; |
|
772
|
|
|
} |
|
773
|
|
View Code Duplication |
if (isset($variables['form']['actions']['full_form'])) { |
|
|
|
|
|
|
774
|
|
|
$variables['form']['actions']['full_form']['#attributes']['class'][] = 'action-item'; |
|
775
|
|
|
} |
|
776
|
|
|
if (isset($variables['form']['actions']['cancel'])) { |
|
777
|
|
|
$variables['form']['actions']['cancel']['#attributes']['class'][] = 'action-item'; |
|
778
|
|
|
$variables['form']['actions']['cancel']['#weight'] = $variables['form']['actions']['submit']['#weight'] + 1; |
|
779
|
|
|
} |
|
780
|
|
|
} |
|
781
|
|
|
} |
|
782
|
|
|
|
|
783
|
|
|
/** |
|
784
|
|
|
* Implements hook_process_form_content(). |
|
785
|
|
|
*/ |
|
786
|
|
|
function commons_origins_process_form_content(&$variables, $hook) { |
|
787
|
|
|
// Crunch down attribute arrays. |
|
788
|
|
|
template_process($variables, $hook); |
|
789
|
|
|
} |
|
790
|
|
|
|
|
791
|
|
|
/** |
|
792
|
|
|
* Implements hook_preprocess_rate_template_commons_like(). |
|
793
|
|
|
*/ |
|
794
|
|
|
function commons_origins_preprocess_rate_template_commons_like(&$variables, $hook) { |
|
|
|
|
|
|
795
|
|
|
// Roll the content into a renderable array to make the template simpler. |
|
796
|
|
|
$variables['content'] = array( |
|
797
|
|
|
'link' => array( |
|
798
|
|
|
'#theme' => 'rate_button__commons_like', |
|
799
|
|
|
'#text' => $variables['links'][0]['text'], |
|
800
|
|
|
'#href' => $variables['links'][0]['href'], |
|
801
|
|
|
'#class' => 'rate-commons-like-btn action-item-small action-item-merge', |
|
802
|
|
|
), |
|
803
|
|
|
'count' => array( |
|
804
|
|
|
'#theme' => 'html_tag', |
|
805
|
|
|
'#tag' => 'span', |
|
806
|
|
|
'#value' => $variables['results']['count'], |
|
807
|
|
|
'#attributes' => array( |
|
808
|
|
|
'class' => array( |
|
809
|
|
|
'rate-commons-like-count', |
|
810
|
|
|
'action-item-small-append', |
|
811
|
|
|
'action-item-merge', |
|
812
|
|
|
), |
|
813
|
|
|
), |
|
814
|
|
|
), |
|
815
|
|
|
); |
|
816
|
|
|
} |
|
817
|
|
|
|
|
818
|
|
|
/** |
|
819
|
|
|
* Overrides hook_rate_button() for commons_like. |
|
820
|
|
|
*/ |
|
821
|
|
|
function commons_origins_rate_button__commons_like($variables) { |
|
822
|
|
|
$text = $variables['text']; |
|
823
|
|
|
$href = $variables['href']; |
|
824
|
|
|
$class = $variables['class']; |
|
825
|
|
|
static $id = 0; |
|
826
|
|
|
$id++; |
|
827
|
|
|
|
|
828
|
|
|
$classes = 'rate-button'; |
|
829
|
|
|
if ($class) { |
|
830
|
|
|
$classes .= ' ' . $class; |
|
831
|
|
|
} |
|
832
|
|
|
if (empty($href)) { |
|
833
|
|
|
// Widget is disabled or closed. |
|
834
|
|
|
return '<span class="' . $classes . '" id="rate-button-' . $id . '">' . |
|
835
|
|
|
'<span class="element-invisible">' . check_plain($text) . '</span>' . |
|
836
|
|
|
'</span>'; |
|
837
|
|
|
} |
|
838
|
|
|
else { |
|
839
|
|
|
return '<a class="' . $classes . '" id="rate-button-' . $id . '" rel="nofollow" href="' . htmlentities($href) . '" title="' . check_plain($text) . '">' . |
|
840
|
|
|
'<span class="element-invisible">' . check_plain($text) . '</span>' . |
|
841
|
|
|
'</a>'; |
|
842
|
|
|
} |
|
843
|
|
|
} |
|
844
|
|
|
|
|
845
|
|
|
/** |
|
846
|
|
|
* Implements hook_form_alter(). |
|
847
|
|
|
*/ |
|
848
|
|
|
function commons_origins_form_alter(&$form, &$form_state, $form_id) { |
|
|
|
|
|
|
849
|
|
|
// Give forms a common theme function so we do not have to declare every |
|
850
|
|
|
// single form we want to override in hook_theme(). |
|
851
|
|
|
if (is_array($form['#theme'])) { |
|
852
|
|
|
$hooks = array('form_content'); |
|
853
|
|
|
$form['#theme'] = array_merge($form['#theme'], $hooks); |
|
854
|
|
|
} |
|
855
|
|
|
else { |
|
856
|
|
|
$form['#theme'] = array( |
|
857
|
|
|
$form['#theme'], |
|
858
|
|
|
'form_content', |
|
859
|
|
|
); |
|
860
|
|
|
} |
|
861
|
|
|
|
|
862
|
|
|
// Description text on these fields is redundant. |
|
863
|
|
|
if ($form_id == 'user_login') { |
|
864
|
|
|
$form['name']['#description'] = ''; |
|
865
|
|
|
$form['pass']['#description'] = ''; |
|
866
|
|
|
} |
|
867
|
|
|
|
|
868
|
|
|
if ($form_id == 'user_register_form') { |
|
869
|
|
|
$form['account']['mail']['#description'] = t('Password reset and notification emails will be sent to this address.'); |
|
870
|
|
|
} |
|
871
|
|
|
|
|
872
|
|
|
if (isset($form['#node_edit_form']) && $form['#node_edit_form']) { |
|
873
|
|
|
// Vertical tabs muck things up, so things need to be shuffled to get rid |
|
874
|
|
|
// of them. |
|
875
|
|
|
$general_settings = array(); |
|
876
|
|
|
foreach ($form as $id => $field) { |
|
877
|
|
|
if (is_array($field) && isset($field['#group']) && $field['#group'] == 'additional_settings' && (!isset($field['#access']) || $field['#access'] !== FALSE)) { |
|
878
|
|
|
$general_settings[$id] = $field; |
|
879
|
|
|
$general_settings[$id]['#collapsible'] = TRUE; |
|
880
|
|
|
$general_settings[$id]['#collapsed'] = TRUE; |
|
881
|
|
|
unset($general_settings[$id]['#group']); |
|
882
|
|
|
} |
|
883
|
|
|
} |
|
884
|
|
|
if (!empty($general_settings)) { |
|
885
|
|
|
$form['general_settings'] = array( |
|
886
|
|
|
'#theme_wrappers' => array('container'), |
|
887
|
|
|
'#attributes' => array( |
|
888
|
|
|
'class' => array('general-settings'), |
|
889
|
|
|
), |
|
890
|
|
|
'#weight' => 100, |
|
891
|
|
|
'general_settings' => $general_settings, |
|
892
|
|
|
); |
|
893
|
|
|
$form['additional_settings']['#access'] = FALSE; |
|
894
|
|
|
} |
|
895
|
|
|
|
|
896
|
|
|
// Declare the fields to go into each column. |
|
897
|
|
|
$supplementary = array( |
|
898
|
|
|
'event_topics', |
|
899
|
|
|
'field_topics', |
|
900
|
|
|
'general_settings', |
|
901
|
|
|
); |
|
902
|
|
|
|
|
903
|
|
|
foreach ($supplementary as $field) { |
|
904
|
|
|
if (isset($form[$field])) { |
|
905
|
|
|
// Translate the field to the appropriate container. |
|
906
|
|
|
$form['supplementary'][$field] = $form[$field]; |
|
907
|
|
|
|
|
908
|
|
|
// Remove access to the old placement instead of unset() to maintain |
|
909
|
|
|
// the legacy information. |
|
910
|
|
|
$form[$field]['#access'] = FALSE; |
|
911
|
|
|
} |
|
912
|
|
|
} |
|
913
|
|
|
} |
|
914
|
|
|
} |
|
915
|
|
|
|
|
916
|
|
|
/** |
|
917
|
|
|
* Implements hook_views_bulk_operations_form_Alter(). |
|
918
|
|
|
*/ |
|
919
|
|
|
function commons_origins_views_bulk_operations_form_alter(&$form, $form_state, $vbo) { |
|
|
|
|
|
|
920
|
|
|
// change the buttons' fieldset wrapper to a div and push it to the bottom of |
|
921
|
|
|
// the form. |
|
922
|
|
|
$form['select']['#type'] = 'container'; |
|
923
|
|
|
$form['select']['#weight'] = 9999; |
|
924
|
|
|
} |
|
925
|
|
|
|
|
926
|
|
|
/** |
|
927
|
|
|
* Implements hook_css_alter(). |
|
928
|
|
|
*/ |
|
929
|
|
|
function commons_origins_css_alter(&$css) { |
|
930
|
|
|
// Remove preset styles that interfere with theming. |
|
931
|
|
|
$unset = array( |
|
932
|
|
|
drupal_get_path('module', 'search') . '/search.css', |
|
933
|
|
|
drupal_get_path('module', 'rich_snippets') . '/rich_snippets.css', |
|
934
|
|
|
drupal_get_path('module', 'commons_like') . '/commons-like.css', |
|
935
|
|
|
drupal_get_path('module', 'panels') . '/css/panels.css', |
|
936
|
|
|
); |
|
937
|
|
|
foreach ($unset as $path) { |
|
938
|
|
|
if (isset($css[$path])) { |
|
939
|
|
|
unset($css[$path]); |
|
940
|
|
|
} |
|
941
|
|
|
} |
|
942
|
|
|
} |
|
943
|
|
|
|
|
944
|
|
|
/** |
|
945
|
|
|
* Overrides theme_links() for nodes. |
|
946
|
|
|
* |
|
947
|
|
|
* This allows for the theme to set a link's #access argument to FALSE so it |
|
948
|
|
|
* will not render. |
|
949
|
|
|
*/ |
|
950
|
|
|
function commons_origins_links($variables) { |
|
951
|
|
|
$links = $variables['links']; |
|
952
|
|
|
$attributes = $variables['attributes']; |
|
953
|
|
|
$heading = $variables['heading']; |
|
954
|
|
|
global $language_url; |
|
955
|
|
|
$output = ''; |
|
956
|
|
|
|
|
957
|
|
|
if (count($links) > 0) { |
|
958
|
|
|
$output = ''; |
|
959
|
|
|
|
|
960
|
|
|
// Treat the heading first if it is present to prepend it to the |
|
961
|
|
|
// list of links. |
|
962
|
|
|
if (!empty($heading)) { |
|
963
|
|
|
if (is_string($heading)) { |
|
964
|
|
|
// Prepare the array that will be used when the passed heading |
|
965
|
|
|
// is a string. |
|
966
|
|
|
$heading = array( |
|
967
|
|
|
'text' => $heading, |
|
968
|
|
|
// Set the default level of the heading. |
|
969
|
|
|
'level' => 'h2', |
|
970
|
|
|
); |
|
971
|
|
|
} |
|
972
|
|
|
$output .= '<' . $heading['level']; |
|
973
|
|
|
if (!empty($heading['class'])) { |
|
974
|
|
|
$output .= drupal_attributes(array('class' => $heading['class'])); |
|
975
|
|
|
} |
|
976
|
|
|
$output .= '>' . check_plain($heading['text']) . '</' . $heading['level'] . '>'; |
|
977
|
|
|
} |
|
978
|
|
|
|
|
979
|
|
|
$output .= '<ul' . drupal_attributes($attributes) . '>'; |
|
980
|
|
|
|
|
981
|
|
|
$num_links = count($links); |
|
982
|
|
|
$i = 1; |
|
983
|
|
|
|
|
984
|
|
|
foreach ($links as $key => $link) { |
|
985
|
|
|
if (!isset($link['#access']) || $link['#access'] !== FALSE) { |
|
986
|
|
|
$class = array($key); |
|
987
|
|
|
|
|
988
|
|
|
// Add first, last and active classes to the list of links to help out themers. |
|
989
|
|
|
if ($i == 1) { |
|
990
|
|
|
$class[] = 'first'; |
|
991
|
|
|
} |
|
992
|
|
|
if ($i == $num_links) { |
|
993
|
|
|
$class[] = 'last'; |
|
994
|
|
|
} |
|
995
|
|
|
if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page())) && (empty($link['language']) || $link['language']->language == $language_url->language)) { |
|
996
|
|
|
$class[] = 'active'; |
|
997
|
|
|
} |
|
998
|
|
|
$output .= '<li' . drupal_attributes(array('class' => $class)) . '>'; |
|
999
|
|
|
|
|
1000
|
|
|
if (isset($link['href'])) { |
|
1001
|
|
|
// Pass in $link as $options, they share the same keys. |
|
1002
|
|
|
$output .= l($link['title'], $link['href'], $link); |
|
1003
|
|
|
} |
|
1004
|
|
|
elseif (!empty($link['title'])) { |
|
1005
|
|
|
// Some links are actually not links, but we wrap these in <span> for adding title and class attributes. |
|
1006
|
|
|
if (empty($link['html'])) { |
|
1007
|
|
|
$link['title'] = check_plain($link['title']); |
|
1008
|
|
|
} |
|
1009
|
|
|
$span_attributes = ''; |
|
1010
|
|
|
if (isset($link['attributes'])) { |
|
1011
|
|
|
$span_attributes = drupal_attributes($link['attributes']); |
|
1012
|
|
|
} |
|
1013
|
|
|
$output .= '<span' . $span_attributes . '>' . $link['title'] . '</span>'; |
|
1014
|
|
|
} |
|
1015
|
|
|
|
|
1016
|
|
|
$i++; |
|
1017
|
|
|
$output .= "</li>\n"; |
|
1018
|
|
|
} |
|
1019
|
|
|
} |
|
1020
|
|
|
|
|
1021
|
|
|
$output .= '</ul>'; |
|
1022
|
|
|
} |
|
1023
|
|
|
|
|
1024
|
|
|
return $output; |
|
1025
|
|
|
} |
|
1026
|
|
|
|
|
1027
|
|
|
/** |
|
1028
|
|
|
* Overrides theme_fieldset(). |
|
1029
|
|
|
* |
|
1030
|
|
|
* Add another div wrapper around fieldsets for styling purposes. |
|
1031
|
|
|
*/ |
|
1032
|
|
|
function commons_origins_fieldset($variables) { |
|
1033
|
|
|
$element = $variables['element']; |
|
1034
|
|
|
element_set_attributes($element, array('id')); |
|
1035
|
|
|
_form_set_class($element, array('form-wrapper')); |
|
1036
|
|
|
|
|
1037
|
|
|
$output = '<fieldset' . drupal_attributes($element['#attributes']) . '>'; |
|
1038
|
|
|
if (!empty($element['#title'])) { |
|
1039
|
|
|
// Always wrap fieldset legends in a SPAN for CSS positioning. |
|
1040
|
|
|
$output .= '<legend><span class="fieldset-legend">' . $element['#title'] . '</span></legend>'; |
|
1041
|
|
|
} |
|
1042
|
|
|
$output .= '<div class="fieldset-wrapper">'; |
|
1043
|
|
|
if (!empty($element['#description'])) { |
|
1044
|
|
|
$output .= '<div class="fieldset-description">' . $element['#description'] . '</div>'; |
|
1045
|
|
|
} |
|
1046
|
|
|
$output .= $element['#children']; |
|
1047
|
|
|
if (isset($element['#value'])) { |
|
1048
|
|
|
$output .= $element['#value']; |
|
1049
|
|
|
} |
|
1050
|
|
|
$output .= '</div>'; |
|
1051
|
|
|
$output .= "</fieldset>\n"; |
|
1052
|
|
|
return '<div class="fieldset-outer-wrapper">' . $output . '</div>'; |
|
1053
|
|
|
} |
|
1054
|
|
|
|
|
1055
|
|
|
/** |
|
1056
|
|
|
* Process an address to add microformat structure and remove |
|
1057
|
|
|
* characters. |
|
1058
|
|
|
*/ |
|
1059
|
|
|
function _commons_origins_format_address(&$address) { |
|
1060
|
|
|
$address['#theme_wrappers'][] = 'container'; |
|
1061
|
|
|
$address['#attributes']['class'][] = 'adr'; |
|
1062
|
|
|
if (!empty($address['street_block']['thoroughfare'])) { |
|
1063
|
|
|
$address['street_block']['thoroughfare']['#attributes']['class'][] = 'street-address'; |
|
1064
|
|
|
} |
|
1065
|
|
|
if (!empty($address['street_block']['premise'])) { |
|
1066
|
|
|
$address['street_block']['premise']['#attributes']['class'][] = 'extended-address'; |
|
1067
|
|
|
} |
|
1068
|
|
|
if (!empty($address['locality_block']['locality'])) { |
|
1069
|
|
|
$address['locality_block']['locality']['#suffix'] = ','; |
|
1070
|
|
|
} |
|
1071
|
|
|
if (!empty($address['locality_block']['administrative_area'])) { |
|
1072
|
|
|
$address['locality_block']['administrative_area']['#attributes']['class'][] = 'region'; |
|
1073
|
|
|
// Remove the hardcoded " " as it causes issues with |
|
1074
|
|
|
// formatting. |
|
1075
|
|
|
$address['locality_block']['administrative_area']['#prefix'] = ' '; |
|
1076
|
|
|
} |
|
1077
|
|
|
if (!empty($address['locality_block']['postal_code'])) { |
|
1078
|
|
|
// Remove the hardcoded " " as it causes issues with |
|
1079
|
|
|
// formatting. |
|
1080
|
|
|
$address['locality_block']['postal_code']['#prefix'] = ' '; |
|
1081
|
|
|
} |
|
1082
|
|
|
if (!empty($address['country'])) { |
|
1083
|
|
|
$address['country']['#attributes']['class'][] = 'country-name'; |
|
1084
|
|
|
} |
|
1085
|
|
|
} |
|
1086
|
|
|
|
|
1087
|
|
|
/** |
|
1088
|
|
|
* Implements hook_preprocess_field(). |
|
1089
|
|
|
*/ |
|
1090
|
|
|
function commons_origins_preprocess_field(&$variables, $hook) { |
|
|
|
|
|
|
1091
|
|
|
// Style the trusted contact link like a button. |
|
1092
|
|
|
if (isset($variables['element']['#formatter']) && $variables['element']['#formatter'] == 'trusted_contact') { |
|
1093
|
|
|
foreach ($variables['items'] as &$container) { |
|
1094
|
|
|
foreach (element_children($container) as $index) { |
|
1095
|
|
|
$item = &$container[$index]; |
|
1096
|
|
|
if (isset($item['#options'])) { |
|
1097
|
|
|
$item['#options']['attributes']['class'][] = 'action-item-small'; |
|
1098
|
|
|
} |
|
1099
|
|
View Code Duplication |
if (isset($item['#href']) && strpos($item['#href'], 'messages')) { |
|
|
|
|
|
|
1100
|
|
|
$item['#options']['attributes']['class'][] = 'message-contact'; |
|
1101
|
|
|
} |
|
1102
|
|
|
elseif (isset($item['#href'])) { |
|
1103
|
|
|
$item['#options']['attributes']['class'][] = 'trusted-status-request'; |
|
1104
|
|
|
} |
|
1105
|
|
|
} |
|
1106
|
|
|
} |
|
1107
|
|
|
} |
|
1108
|
|
|
} |
|
1109
|
|
|
|
|
1110
|
|
|
/** |
|
1111
|
|
|
* Override theme_html_tag__request_pending(). |
|
1112
|
|
|
*/ |
|
1113
|
|
|
function commons_origins_html_tag__request_pending($variables) { |
|
1114
|
|
|
$element = $variables['element']; |
|
1115
|
|
|
$element['#attributes']['class'][] = 'action-item-small-active'; |
|
1116
|
|
|
$element['#attributes']['class'][] = 'trusted-status-pending'; |
|
1117
|
|
|
$attributes = drupal_attributes($element['#attributes']); |
|
1118
|
|
|
|
|
1119
|
|
|
if (!isset($element['#value'])) { |
|
1120
|
|
|
return '<' . $element['#tag'] . $attributes . " />\n"; |
|
1121
|
|
|
} |
|
1122
|
|
|
else { |
|
1123
|
|
|
$output = '<' . $element['#tag'] . $attributes . '>'; |
|
1124
|
|
|
if (isset($element['#value_prefix'])) { |
|
1125
|
|
|
$output .= $element['#value_prefix']; |
|
1126
|
|
|
} |
|
1127
|
|
|
$output .= $element['#value']; |
|
1128
|
|
|
if (isset($element['#value_suffix'])) { |
|
1129
|
|
|
$output .= $element['#value_suffix']; |
|
1130
|
|
|
} |
|
1131
|
|
|
$output .= '</' . $element['#tag'] . ">\n"; |
|
1132
|
|
|
return $output; |
|
1133
|
|
|
} |
|
1134
|
|
|
} |
|
1135
|
|
|
|
|
1136
|
|
|
/** |
|
1137
|
|
|
* Overrides theme_field() for group fields. |
|
1138
|
|
|
* |
|
1139
|
|
|
* This will apply button styling to the links for leaving and joining a group. |
|
1140
|
|
|
*/ |
|
1141
|
|
|
function commons_origins_field__group_group__group($variables) { |
|
1142
|
|
|
$output = ''; |
|
1143
|
|
|
|
|
1144
|
|
|
// Render the label, if it's not hidden. |
|
1145
|
|
View Code Duplication |
if (!$variables['label_hidden']) { |
|
|
|
|
|
|
1146
|
|
|
$output .= '<div class="field-label"' . $variables['title_attributes'] . '>' . $variables['label'] . ': </div>'; |
|
1147
|
|
|
} |
|
1148
|
|
|
|
|
1149
|
|
|
// Render the items. |
|
1150
|
|
|
$output .= '<div class="field-items"' . $variables['content_attributes'] . '>'; |
|
1151
|
|
|
foreach ($variables['items'] as $delta => $item) { |
|
1152
|
|
View Code Duplication |
if (isset($item['#type']) && $item['#type'] == 'link') { |
|
|
|
|
|
|
1153
|
|
|
if (strpos($item['#href'], '/subscribe')) { |
|
1154
|
|
|
$item['#options']['attributes']['class'][] = 'action-item-primary'; |
|
1155
|
|
|
} |
|
1156
|
|
|
else { |
|
1157
|
|
|
$item['#options']['attributes']['class'][] = 'action-item'; |
|
1158
|
|
|
} |
|
1159
|
|
|
} |
|
1160
|
|
|
|
|
1161
|
|
|
$classes = 'field-item ' . ($delta % 2 ? 'odd' : 'even'); |
|
1162
|
|
|
$output .= '<div class="' . $classes . '"' . $variables['item_attributes'][$delta] . '>' . drupal_render($item) . '</div>'; |
|
1163
|
|
|
} |
|
1164
|
|
|
$output .= '</div>'; |
|
1165
|
|
|
|
|
1166
|
|
|
// Render the top-level DIV. |
|
1167
|
|
|
$output = '<div class="' . $variables['classes'] . '"' . $variables['attributes'] . '>' . $output . '</div>'; |
|
1168
|
|
|
|
|
1169
|
|
|
return $output; |
|
1170
|
|
|
} |
|
1171
|
|
|
|
|
1172
|
|
|
/** |
|
1173
|
|
|
* Overrides theme_field__addressfield(). |
|
1174
|
|
|
*/ |
|
1175
|
|
|
function commons_origins_field__addressfield($variables) { |
|
1176
|
|
|
$output = ''; |
|
1177
|
|
|
|
|
1178
|
|
|
// Add Microformat classes to each address. |
|
1179
|
|
|
foreach($variables['items'] as &$address) { |
|
1180
|
|
|
// Only display an address if it has been populated. We determine this by |
|
1181
|
|
|
// validating that the administrative area has been populated. |
|
1182
|
|
|
if (!empty($address['#address']['administrative_area'])) { |
|
1183
|
|
|
_commons_origins_format_address($address); |
|
1184
|
|
|
} |
|
1185
|
|
|
else { |
|
1186
|
|
|
// Deny access to incomplete addresses. |
|
1187
|
|
|
$address['#access'] = FALSE; |
|
1188
|
|
|
} |
|
1189
|
|
|
} |
|
1190
|
|
|
|
|
1191
|
|
|
// Render the label, if it's not hidden. |
|
1192
|
|
View Code Duplication |
if (!$variables['label_hidden']) { |
|
|
|
|
|
|
1193
|
|
|
$output .= '<div class="field-label"' . $variables['title_attributes'] . '>' . $variables['label'] . ':</div> '; |
|
1194
|
|
|
} |
|
1195
|
|
|
|
|
1196
|
|
|
// Render the items. |
|
1197
|
|
|
$output .= '<div class="field-items"' . $variables['content_attributes'] . '>'; |
|
1198
|
|
|
foreach ($variables['items'] as $delta => $item) { |
|
1199
|
|
|
$classes = 'field-item ' . ($delta % 2 ? 'odd' : 'even'); |
|
1200
|
|
|
$output .= '<div class="' . $classes . '"' . $variables['item_attributes'][$delta] . '>' . drupal_render($item) . '</div>'; |
|
1201
|
|
|
} |
|
1202
|
|
|
$output .= '</div>'; |
|
1203
|
|
|
|
|
1204
|
|
|
// Render the top-level DIV. |
|
1205
|
|
|
$output = '<div class="' . $variables['classes'] . '"' . $variables['attributes'] . '>' . $output . '</div>'; |
|
1206
|
|
|
|
|
1207
|
|
|
return $output; |
|
1208
|
|
|
} |
|
1209
|
|
|
|
|
1210
|
|
|
/** |
|
1211
|
|
|
* Implements hook_preprocess_views_view_field(). |
|
1212
|
|
|
*/ |
|
1213
|
|
|
function commons_origins_preprocess_views_view_field(&$variables, $hook) { |
|
|
|
|
|
|
1214
|
|
|
// Make sure empty addresses are not displayed. |
|
1215
|
|
|
// Views does not use theme_field__addressfield(), so we need to process |
|
1216
|
|
|
// these implementations separately. |
|
1217
|
|
|
if (isset($variables['theme_hook_suggestion']) && $variables['theme_hook_suggestion'] == 'views_view_field__field_address') { |
|
1218
|
|
|
foreach ($variables['row']->field_field_address as $key => &$address) { |
|
1219
|
|
|
if (!$address['raw']['administrative_area']) { |
|
1220
|
|
|
// If an address is incomplete, remove it and tell the system a |
|
1221
|
|
|
// rebuild is needed. |
|
1222
|
|
|
unset($variables['row']->field_field_address[$key]); |
|
1223
|
|
|
} |
|
1224
|
|
|
else { |
|
1225
|
|
|
_commons_origins_format_address($address['rendered']); |
|
1226
|
|
|
} |
|
1227
|
|
|
} |
|
1228
|
|
|
|
|
1229
|
|
|
// The output will need rebuilt to get the changes applied. |
|
1230
|
|
|
$variables['output'] = $variables['field']->advanced_render($variables['row']); |
|
1231
|
|
|
} |
|
1232
|
|
|
} |
|
1233
|
|
|
|
|
1234
|
|
|
/** |
|
1235
|
|
|
* Implements hook_preprocess_user_profile(). |
|
1236
|
|
|
*/ |
|
1237
|
|
|
function commons_origins_preprocess_user_profile(&$variables, $hook) { |
|
|
|
|
|
|
1238
|
|
|
if (in_array('user_profile__search_results', $variables['theme_hook_suggestions'])) { |
|
1239
|
|
|
// Give the profile a distinctive class to target and wrap the display in |
|
1240
|
|
|
// pod styling. |
|
1241
|
|
|
$variables['classes_array'][] = 'profile-search-result'; |
|
1242
|
|
|
$variables['classes_array'][] = 'commons-pod'; |
|
1243
|
|
|
|
|
1244
|
|
|
// Wrap the group list and related title in a div. |
|
1245
|
|
|
if (isset($variables['user_profile']['group_membership'])) { |
|
1246
|
|
|
$variables['user_profile']['group_membership']['#theme_wrappers'][] = 'container'; |
|
1247
|
|
|
$variables['user_profile']['group_membership']['#attributes']['class'][] = 'profile-groups'; |
|
1248
|
|
|
} |
|
1249
|
|
|
|
|
1250
|
|
|
// Group actionable items together in a container. |
|
1251
|
|
|
$variables['user_profile']['user_actions'] = array(); |
|
1252
|
|
|
$user_actions = array( |
|
1253
|
|
|
'flags', |
|
1254
|
|
|
'privatemsg_send_new_message', |
|
1255
|
|
|
'group_group', |
|
1256
|
|
|
); |
|
1257
|
|
|
foreach ($user_actions as $action) { |
|
1258
|
|
|
if (isset($variables['user_profile'][$action])) { |
|
1259
|
|
|
$variables['user_profile']['user_actions'][$action] = $variables['user_profile'][$action]; |
|
1260
|
|
|
$variables['user_profile'][$action]['#access'] = FALSE; |
|
1261
|
|
|
} |
|
1262
|
|
|
} |
|
1263
|
|
|
if (!module_exists('commons_trusted_contacts') && isset( $variables['user_profile']['user_actions']['group_group'])) { |
|
1264
|
|
|
$variables['user_profile']['user_actions']['group_group']['#access'] = FALSE; |
|
1265
|
|
|
} |
|
1266
|
|
|
if (!empty($variables['user_profile']['user_actions'])) { |
|
1267
|
|
|
$variables['user_profile']['user_actions'] += array( |
|
1268
|
|
|
'#theme_wrappers' => array('container'), |
|
1269
|
|
|
'#attributes' => array( |
|
1270
|
|
|
'class' => array('profile-actions'), |
|
1271
|
|
|
), |
|
1272
|
|
|
); |
|
1273
|
|
|
} |
|
1274
|
|
|
} |
|
1275
|
|
|
} |
|
1276
|
|
|
|
|
1277
|
|
|
/** |
|
1278
|
|
|
* Implements hook_preprocess_commons_search_solr_user_results(). |
|
1279
|
|
|
*/ |
|
1280
|
|
|
function commons_origins_preprocess_commons_search_solr_user_results(&$variables, $hook) { |
|
|
|
|
|
|
1281
|
|
|
// Hide the results title. |
|
1282
|
|
|
$variables['title_attributes_array']['class'][] = 'element-invisible'; |
|
1283
|
|
|
} |
|
1284
|
|
|
|
|
1285
|
|
|
/** |
|
1286
|
|
|
* Implements hook_process_node(). |
|
1287
|
|
|
*/ |
|
1288
|
|
|
function commons_origins_process_node(&$variables, $hook) { |
|
|
|
|
|
|
1289
|
|
|
$node = $variables['node']; |
|
1290
|
|
|
$wrapper = entity_metadata_wrapper('node', $node); |
|
1291
|
|
|
|
|
1292
|
|
|
// Use timeago module for formatting node submission date |
|
1293
|
|
|
// if it is enabled and also configured to be used on nodes. |
|
1294
|
|
|
if (module_exists('timeago') && variable_get('timeago_node', 1)) { |
|
1295
|
|
|
$variables['date'] = timeago_format_date($node->created, $variables['date']); |
|
1296
|
|
|
$use_timeago_date_format = TRUE; |
|
1297
|
|
|
} |
|
1298
|
|
|
else { |
|
1299
|
|
|
$use_timeago_date_format = FALSE; |
|
1300
|
|
|
} |
|
1301
|
|
|
|
|
1302
|
|
|
// Replace the submitted text on nodes with something a bit more pertinent to |
|
1303
|
|
|
// the content type. |
|
1304
|
|
|
if (variable_get('node_submitted_' . $node->type, TRUE)) { |
|
1305
|
|
|
$node_type_info = node_type_get_type($variables['node']); |
|
1306
|
|
|
$type_attributes = array('class' => array( |
|
1307
|
|
|
'node-content-type', |
|
1308
|
|
|
drupal_html_class('node-content-type-' . $node->type), |
|
1309
|
|
|
)); |
|
1310
|
|
|
$placeholders = array( |
|
1311
|
|
|
'!type' => '<span' . drupal_attributes($type_attributes) . '>' . check_plain($node_type_info->name) . '</span>', |
|
1312
|
|
|
'!user' => $variables['name'], |
|
1313
|
|
|
'!date' => $variables['date'], |
|
1314
|
|
|
'@interval' => format_interval(REQUEST_TIME - $node->created), |
|
1315
|
|
|
); |
|
1316
|
|
|
// Show what group the content belongs to if applicable. |
|
1317
|
|
|
if (!empty($node->{OG_AUDIENCE_FIELD}) && $wrapper->{OG_AUDIENCE_FIELD}->count() == 1) { |
|
1318
|
|
|
$placeholders['!group'] = l($wrapper->{OG_AUDIENCE_FIELD}->get(0)->label(), 'node/' . $wrapper->{OG_AUDIENCE_FIELD}->get(0)->getIdentifier()); |
|
1319
|
|
View Code Duplication |
if ($use_timeago_date_format == TRUE) { |
|
|
|
|
|
|
1320
|
|
|
$variables['submitted'] = t('!type created !date in the !group group by !user', $placeholders); |
|
1321
|
|
|
} |
|
1322
|
|
|
else { |
|
1323
|
|
|
$variables['submitted'] = t('!type created @interval ago in the !group group by !user', $placeholders); |
|
1324
|
|
|
} |
|
1325
|
|
|
} |
|
1326
|
|
View Code Duplication |
else { |
|
|
|
|
|
|
1327
|
|
|
if ($use_timeago_date_format == TRUE) { |
|
|
|
|
|
|
1328
|
|
|
$variables['submitted'] = t('!type created !date by !user', $placeholders); |
|
1329
|
|
|
} |
|
1330
|
|
|
else { |
|
1331
|
|
|
$variables['submitted'] = t('!type created @interval ago by !user', $placeholders); |
|
1332
|
|
|
} |
|
1333
|
|
|
} |
|
1334
|
|
|
} |
|
1335
|
|
|
|
|
1336
|
|
|
// Append a feature label to featured node teasers. |
|
1337
|
|
|
if ($variables['teaser'] && $variables['promote']) { |
|
1338
|
|
|
$variables['submitted'] .= ' <span class="featured-node-tooltip">' . t('Featured') . ' ' . $variables['type'] . '</span>'; |
|
1339
|
|
|
} |
|
1340
|
|
|
} |
|
1341
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.