-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathffunctions.module
More file actions
101 lines (91 loc) · 2.62 KB
/
ffunctions.module
File metadata and controls
101 lines (91 loc) · 2.62 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
<?php
/**
* @file
* Module that contains helpful utility functions.
*/
require_once 'ffunctions.inc';
/**
* Log a message to a file.
*
* @param mixed $mesage
* The message or data to log.
*/
function ffunctions_drupal_log_message($message) {
if (!$log = variable_get('ffunctions_log', FALSE)) {
$log = getcwd() . '/logs/test.log';
}
ffunctions_log_message($log, $message);
}
/**
* Determine if an event is all day or not.
*
* @param array $date
* The loaded field date field data. This must include
* value, value2, timezone, timezone_db.
* @param string $granularity
* (optional) The granularity of the date. Defaults to 'second'.
*
* @return boolean
* Whether or not this is an all day date.
*/
function ffunctions_date_is_all_day($date, $granularity = 'second') {
if (!module_exists('date_all_day')) {
return FALSE;
}
$format = 'Y-m-d H:i:s';
$from = ffunctions_get_formatted_date($date['value'], $format, $date['timezone'], $date['timezone_db']);
$to = $date['value'] == $date['value2'] ? $from : ffunctions_get_formatted_date($date['value2'], $format, $date['timezone'], $date['timezone_db']);
return date_is_all_day($from, $to, $granularity);
}
/**
* Implements hook_filter_info().
*/
function ffunctions_filter_info() {
$filters = array();
$filters['ffunctions_hodor'] = array(
'title' => t('HODOR'),
'process callback' => 'ffunctions_hodor_drupal_filter_process',
'tips callback' => '_ffunctions_hodor_filter_tips',
'settings callback' => '_ffunctions_hodor_filter_settings',
'default settings' => array(
'hodor' => 'hodor',
),
'weight' => -20,
);
return $filters;
}
/**
* Implements callback_filter_process().
*
* Provides filtering of input into accepted HODOR.
*/
function ffunctions_hodor_drupal_filter_process($string, $filter) {
return ffunctions_hodor_filter_process($string, $filter->settings['hodor']);
}
/**
* Implements callback_filter_tips().
*
* Provides help for the HODOR filter.
*
* @see ffunctions_filter_info()
*/
function _ffunctions_hodor_filter_tips($filter, $format, $long = FALSE) {
return ucfirst($filter->settings['hodor']);
}
/**
* Implements callback_filter_settings().
*
* Filter settings callback for the HODOR content filter.
*/
function _ffunctions_hodor_filter_settings($form, &$form_state, $filter, $format, $defaults) {
$settings = array();
$filter->settings += $defaults;
$settings['hodor'] = array(
'#type' => 'textfield',
'#title' => t('Hodor'),
'#default_value' => $filter->settings['hodor'],
'#maxlength' => 30,
'#description' => t('Hodor hodor. Hodor.'),
);
return $settings;
}