-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathluggage_events.module
82 lines (74 loc) · 2.87 KB
/
luggage_events.module
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
<?php
/**
* @file
* Code for the luggage_events feature.
*/
include_once 'luggage_events.features.inc';
/**
* Implements hook_update_projects_alter().
*/
function luggage_events_update_projects_alter(&$projects) {
// Hide a site-specific module from the list.
unset($projects['luggage_events']);
}
/*
* Implements hook_views_pre_build()
*/
function luggage_events_views_pre_build(&$view) {
if ($view->name == 'events') {
drupal_add_css(drupal_get_path('module','luggage_events').'/css/luggage_events.css');
}
}
/*
* Implements hook_node_view()
*/
function luggage_events_node_view($node, $view_mode, $langcode) {
if ($node->type == 'event' && $view_mode == 'full') {
drupal_add_css(drupal_get_path('module','luggage_events').'/css/luggage_events.css');
}
}
/**
* Implements hook_theme_registry_alter().
*/
function luggage_events_theme_registry_alter(&$theme_registry) {
// Defined path to the current module.
$module_path = drupal_get_path('module', 'luggage_events');
// Find all .tpl.php files in this module's folder recursively.
$template_file_objects = drupal_find_theme_templates($theme_registry, '.tpl.php', $module_path . '/templates');
// Iterate through all found template file objects.
foreach ($template_file_objects as $key => $template_file_object) {
// If the template has not already been overridden by a theme.
if (!isset($theme_registry[$key]['theme path']) || !preg_match('#/themes/#', $theme_registry[$key]['theme path'])) {
// Alter the theme path and template elements.
$theme_registry[$key]['theme path'] = $module_path;
$theme_registry[$key] = array_merge($theme_registry[$key], $template_file_object);
$theme_registry[$key]['type'] = 'module';
}
}
}
/**
* Implements hook_preprocess_HOOK().
*/
function luggage_events_preprocess_calendar_mini(&$vars) {
$vars['month_id'] = $vars['id'];
}
/*
* The link module helpfully tells you the maximum length limit of the title.
* This is rather pointless and distracting. We zap this out.
*
* The Link module builds its two-part form element (title and location)
* in a process function so we cannot change the description text using
* a simple form_alter(). Instead, we must modify the info for this element
* to point it to our own process function, which we run after the link
* field's process function to overwrite descriptions with our own.
*/
function luggage_events_element_info_alter(&$type) {
$type['link_field']['#process'][] = 'luggage_events_field_process';
}
function luggage_events_field_process($element, $form_state, $complete_form) {
if (isset($complete_form['#bundle']) && $complete_form['#bundle'] == 'event' && $element['#field_name'] == 'field_event_location') {
$element['title']['#description'] = t('Where is this event happening?');
$element['url']['#description'] = t('Optional link to event location.');
}
return $element;
}