-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.php
More file actions
286 lines (264 loc) · 12.7 KB
/
template.php
File metadata and controls
286 lines (264 loc) · 12.7 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
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
<?php
/**
* os2dagsorden_theme
*
* PHP version 5
*
* @category Themes
* @package Themes_os2dagsorden_theme
* @author Stanislav Kutasevits <stan@bellcom.dk>
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
* @file
* This file is empty by default because the base theme chain (Alpha & Omega) provides
* all the basic functionality. However, in case you wish to customize the output that Drupal
* generates through Alpha & Omega this file is a good place to do so.
*
* Alpha comes with a neat solution for keeping this file as clean as possible while the code
* for your subtheme grows. Please read the README.txt in the /preprocess and /process subfolders
* for more information on this topic.
*/
/**
* Implementation of hook_preprocess_page.
* Adds needed JS behaviour, loads the notes/speaker paper indicators, makes the security log entries.
*
* @param mixed &$variables variables
* @return none
*/
function os2dagsorden_theme_preprocess_page(&$variables)
{
drupal_add_js(drupal_get_path('theme', 'os2dagsorden_theme') . '/js/os2dagsorden_theme.js');
drupal_add_js('add_show_hide_menu_behaviour(' . variable_get('os2dagsorden_collapse_menu', true) . ');', 'inline');
drupal_add_js('add_tablet_orientation_listener();', 'inline');
drupal_add_js('add_indicator_help_text();', 'inline');
drupal_add_js('hide_print_buttons();', 'inline');
drupal_add_js('resize_listener();', 'inline');
if (variable_get('os2dagsorden_show_search_block_title', 'true')==='false')
drupal_add_js('hide_search_block_title()', 'inline');
$view = views_get_page_view();
if (!empty($view)) {
global $base_path;
if ($view->name == 'meeting_details') {
//adding expand/collapse behaviour to meeting details view
$os2dagsorden_expand_all_bullets= variable_get('os2dagsorden_expand_all_bullets', false)?true:'false';
drupal_add_js('bullet_point_add_expand_behaviour("'. $base_path .'?q=", ' . variable_get('os2dagsorden_expand_attachment', true) . ', ' . $os2dagsorden_expand_all_bullets . ' , ' . variable_get('os2dagsorden_expand_attachment_onload', 'false') . ')', 'inline');
drupal_add_js('open_all_bilag_case_bullet_points(' . variable_get('os2dagsorden_expand_bilags', "true") . ','. variable_get('os2dagsorden_expand_cases', "false") .')', 'inline');
$variables['views'] = '';
//adding pagescroll
drupal_add_css(drupal_get_path('theme', 'os2dagsorden_theme') . '/css/pagescroller.skins.css');
drupal_add_js(drupal_get_path('theme', 'os2dagsorden_theme') . '/js/jquery.pagescroller.js');
drupal_add_js('addPagescroller();', 'inline');
}
if ($view->name == 'meeting_details' || $view->name == 'speaking_paper') {
//adding has notes indicator to attachment
$annotations = os2dagsorden_annotator_get_notes_by_meeting_id(arg(1));
$attachment_ids = array();
foreach ($annotations as $note) {
$attachment_ids[] = $note->bilag_id;
}
$attachment_ids = array_unique($attachment_ids);
$attachment_ids = implode(",", $attachment_ids);
drupal_add_js('ids = [' . $attachment_ids . ']; bullet_point_attachment_add_notes_indicator(ids)', 'inline');
//reforcing the help text to be added
drupal_add_js('add_indicator_help_text();', 'inline');
//adding annotation
drupal_add_js(drupal_get_path('module', 'os2dagsorden_annotator') . '/lib/annotator-full.min.js');
//drupal_add_js(drupal_get_path('module', 'os2dagsorden_annotator') . '/lib/touch-plugin/annotator.touch-no-add.min.js');
//drupal_add_js(drupal_get_path('module', 'os2dagsorden_annotator') . '/lib/touch-plugin/annotator.touch.min.js');
drupal_add_js(drupal_get_path('module', 'os2dagsorden_annotator') . '/lib/touch-plugin/annotator.touch-syddjurs.min.js');
drupal_add_js(drupal_get_path('module', 'os2dagsorden_annotator') . '/lib/json2.js');
drupal_add_js(drupal_get_path('module', 'os2dagsorden_annotator') . '/lib/XPath.js');
drupal_add_css(drupal_get_path('module', 'os2dagsorden_annotator') . '/lib/annotator-full.min.css');
drupal_add_css(drupal_get_path('module', 'os2dagsorden_annotator') . '/lib/touch-plugin/annotator.touch.css');
drupal_add_js(drupal_get_path('module', 'os2dagsorden_annotator') . '/js/os2dagsorden_annotator_secure.js');
}
if ($view->name == 'speaking_paper') {
//adding expand/collapse behaviour bullet point details view
drupal_add_js('bullet_point_details_init("'. $base_path .'?q=", ' . variable_get('os2dagsorden_expand_attachment', true) . ', ' . variable_get('os2dagsorden_expand_attachment_onload', 'false') . ')', 'inline');
drupal_add_js('open_all_bilag_case_bullet_points(' . variable_get('os2dagsorden_expand_bilags', "true") . ','. variable_get('os2dagsorden_expand_cases', "false") .')', 'inline');
}
if (variable_get('os2dagsorden_show_massive_expand_collapse_button', 'true')==='false' && ($view->name == 'speaking_paper' || $view->name == 'meeting_details'))
drupal_add_js('hide_massive_expand_collapse_button();', 'inline');
} else if ($variables['page']['content']['content']['content']['system_main']['content']['#attributes']['class'][1] == 'node-os2web_meetings_spaper-form'){
//in "creating speaker paper"
//hide extra fields
drupal_add_js("jQuery(document).ready(function(){jQuery('.form-item-field-os2web-meetings-sp-bullet-und-0-target-id').hide();});","inline");
//setting breadcrumb
$destination = $_GET['destination'];
$destination = explode('/', $destination);
$breadcrumb[] = l('Hjem', $base_url);
$breadcrumb[] .= l('Mødedetaljer', 'meeting/' . $destination[1]);
if (isset($destination[3]))//bullet point
$breadcrumb[] .= l('Dagsordenspunkt', 'meeting/' . $destination[1] . '/bullet-point/' . $destination[3]);
$breadcrumb[] .= '<span class="breadcrumb-active">Opret talepapir</span>';
drupal_set_breadcrumb($breadcrumb);
}
}
/**
* Implementation of theming the calendar title.
* Change the format of navigation title in calendar day view to be [weekday], [day]. [month] [year]
*
* @param mixed $params params
*
* @return reformatted title
*/
function os2dagsorden_theme_date_nav_title($params)
{
$granularity = $params['granularity'];
$view = $params['view'];
$date_info = $view->date_info;
$link = !empty($params['link']) ? $params['link'] : FALSE;
$format = !empty($params['format']) ? $params['format'] : NULL;
switch ($granularity) {
case 'year':
$title = $date_info->year;
$date_arg = $date_info->year;
break;
case 'month':
$format = !empty($format) ? $format : (empty($date_info->mini) ? 'F Y' : 'F');
$title = date_format_date($date_info->min_date, 'custom', $format);
$date_arg = $date_info->year . '-' . date_pad($date_info->month);
break;
case 'day':
$format = !empty($format) ? $format : (empty($date_info->mini) ? 'l, j. F Y' : 'l, F j');
$title = date_format_date($date_info->min_date, 'custom', $format);
$date_arg = $date_info->year . '-' . date_pad($date_info->month) . '-' . date_pad($date_info->day);
break;
case 'week':
$format = !empty($format) ? $format : (empty($date_info->mini) ? 'F j, Y' : 'F j');
$title = t('Week of @date', array('@date' => date_format_date($date_info->min_date, 'custom', $format)));
$date_arg = $date_info->year . '-W' . date_pad($date_info->week);
break;
}
if (!empty($date_info->mini) || $link) {
// Month navigation titles are used as links in the mini view.
$attributes = array('title' => t('View full page month'));
$url = date_pager_url($view, $granularity, $date_arg, TRUE);
return l($title, $url, array('attributes' => $attributes));
}
else {
return $title;
}
}
/**
* Format the time row headings in the week and day view.
* Change the time format to be [hour].[minutes]
*
* @param mixed $vars vars
*
* @return reformatted title
*/
function os2dagsorden_theme_calendar_time_row_heading($vars)
{
$start_time = $vars['start_time'];
$next_start_time = $vars['next_start_time'];
$curday_date = $vars['curday_date'];
static $format_hour, $format_ampm;
if (empty($format_hour)) {
$format = variable_get('date_format_short', 'm/d/Y - H:i');
$limit = array('hour', 'minute');
$format_hour = str_replace(array('a', 'A'), '', date_limit_format($format, $limit));
$format_ampm = strstr($format, 'a') ? 'a' : (strstr($format, 'A') ? 'A' : '');
}
if ($start_time == '00:00:00' && $next_start_time == '23:59:59') {
$hour = t('All times');
}
elseif ($start_time == '00:00:00') {
$date = date_create($curday_date . ' ' . $next_start_time);
$hour = t('Before @time', array('@time' => date_format($date, $format_hour)));
}
else {
$date = date_create($curday_date . ' ' . $start_time);
$hour = date_format($date, $format_hour);
}
if (!empty($date)) {
$ampm = date_format($date, $format_ampm);
}
else {
$ampm = '';
}
return array('hour' => $hour, 'ampm' => $ampm);
}
/**
* Changes the format of the exposed form - meetings search.
* Also removes the unneeded links on log in page.
*
* @param mixed &$form form
* @param mixed &$form_state form state
*
* @return none
*/
function os2dagsorden_theme_form_alter(&$form, &$form_state) {
if ($form['#id'] == 'views-exposed-form-meetings-search-page') {
$form['from_date']['value']['#date_format'] = 'd-m-Y';
$form['to_date']['value']['#date_format'] = 'd-m-Y';
if (!is_array($_SESSION['views']['meetings_search']['page']['from_date']['value'])){
if (!empty($_SESSION['views']['meetings_search']['page']['from_date']['value'])){
$old_value = $_SESSION['views']['meetings_search']['page']['from_date']['value'];
$_SESSION['views']['meetings_search']['page']['from_date']['value'] = array();
$old_value = date_create_from_format("Y-m-d", $old_value);
$old_value = $old_value->format('d-m-Y');
$_SESSION['views']['meetings_search']['page']['from_date']['value']['date'] = $old_value;
}
}
if (!is_array($_SESSION['views']['meetings_search']['page']['to_date']['value'])){
if (!empty($_SESSION['views']['meetings_search']['page']['to_date']['value'])){
$old_value = $_SESSION['views']['meetings_search']['page']['to_date']['value'];
$_SESSION['views']['meetings_search']['page']['to_date']['value'] = array();
$old_value = date_create_from_format("Y-m-d", $old_value);
$old_value = $old_value->format('d-m-Y');
$_SESSION['views']['meetings_search']['page']['to_date']['value']['date'] = $old_value;
}
}
} else if ($form['#id'] == 'user-login-form') {
$form['name']['#description'] = "";
$form['pass']['#description'] = "";
$form['links']['#markup'] = "";
}
}
/**
* Preprocess HTML hook.
* Fixes the IE compatibility problem.
*
* @param mixed &$form form
* @param mixed &$form_state form state
*
* @return none
*/
function os2dagsorden_theme_preprocess_html(&$vars) {
// Setup IE meta tag to force IE rendering mode
$meta_ie_render_engine = array(
'#type' => 'html_tag',
'#tag' => 'meta',
'#attributes' => array(
'http-equiv' => 'X-UA-Compatible',
'content' => 'IE=8,IE=Edge,chrome=1',
),
'#weight' => '-99999',
);
$format_detection = array(
'#type' => 'html_tag',
'#tag' => 'meta',
'#attributes' => array(
'name' => 'format-detection',
'content' => 'telephone=no',
),
'#weight' => '-99999',
);
//<meta name="format-detection" content="telephone=no">
// Add header meta tag for IE to head
drupal_add_html_head($meta_ie_render_engine, 'meta_ie_render_engine');
drupal_add_html_head($format_detection, 'format-detection');
}
function os2dagsorden_theme_menu_local_task($variables) {
$link = $variables['element']['#link'];
$href = explode('/', $link['href']);
$node = node_load($href[1]);
if ($link['path'] === 'node/%/edit' && $node->type !== 'page')//disabling edit tab, if only node type is not page
return '';
else if ($link['path'] === 'node/%/view')//disabling view tab
return '';
else if ($link['path'] === 'user/%/edit' || $link['path'] === 'user/%/view' || $link['path'] === 'user/%/simple_edit')
return '';
else
return theme_menu_local_task($variables);
}