This repository was archived by the owner on Jan 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.php
More file actions
449 lines (396 loc) · 13.7 KB
/
template.php
File metadata and controls
449 lines (396 loc) · 13.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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
<?php
/**
* Implements hook_preprocess_maintainance_page().
* Override or insert variables into the maintenance page template.
*/
function adminx_preprocess_maintenance_page(&$variables) {
// While markup for normal pages is split into page.tpl.php and html.tpl.php,
// the markup for the maintenance page is all in the single
// maintenance-page.tpl.php template. So, to have what's done in
// adminx_preprocess_html() also happen on the maintenance page, it has to be
// called here.
adminx_preprocess_html($variables);
}
/**
* Implements hook_preprocess_html().
*
* @param array $variables
*/
function adminx_preprocess_html(&$variables) {
// Fix the viewport and zooming in mobile devices.
$viewport = array(
'#tag' => 'meta',
'#attributes' => array(
'name' => 'viewport',
'content' => 'width=device-width, maximum-scale=1, minimum-scale=1, user-scalable=no, initial-scale=1',
),
);
drupal_add_html_head($viewport, 'viewport');
// Force IE to use most up-to-date render engine.
$xua = array(
'#tag' => 'meta',
'#attributes' => array(
'http-equiv' => 'X-UA-Compatible',
'content' => 'IE=edge',
),
);
drupal_add_html_head($xua, 'x-ua-compatible');
$variables['minie'] = 'ie9';
//////////////////////////////
// HTML5 Base Theme Forwardport
//
// Backports the following changes made to Drupal 8:
// - #1077566: Convert html.tpl.php to HTML5.
//////////////////////////////
// Initializes attributes which are specific to the html and body elements.
$variables['html_attributes_array'] = array();
$variables['rdf_attributes_array'] = array();
$variables['body_attributes_array'] = array();
// HTML element attributes.
$variables['html_attributes_array']['lang'] = $GLOBALS['language']->language;
$variables['html_attributes_array']['dir'] = $GLOBALS['language']->direction ? 'rtl' : 'ltr';
// Update RDF Namespacing
if (module_exists('rdf')) {
// Adds RDF namespace prefix bindings in the form of an RDFa 1.1 prefix
// attribute inside the html element.
$prefixes = array();
foreach (rdf_get_namespaces() as $prefix => $uri) {
$variables['rdf_attributes_array']['prefix'][] = $prefix . ': ' . $uri . "\n";
}
}
//////////////////////////////
// LiveReload Integration
//////////////////////////////
$livereload = TRUE;
$livereload_port = 35729;
if ($livereload) {
drupal_add_js("document.write('<script src=\"http://' + ('localhost').split(':')[0] + ':$livereload_port/livereload.js?snipver=1\"></' + 'script>')", array('type' => 'inline', 'scope' => 'footer', 'weight' => 9999));
}
//////////////////////////////
// Add in Google font Code.
//////////////////////////////
$webfont_families = 'Open+Sans:300italic,400italic,600italic,400,300,600:latin,latin-ext';
$script = "WebFontConfig = {google: { families: [ '" . $webfont_families . " ' ] }};";
$script .= <<< script
(function() {
var wf = document.createElement('script');
wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
'://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
wf.type = 'text/javascript';
wf.async = 'true';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(wf, s);
})();
script;
drupal_add_js($script, array('type' => 'inline', 'force header' => true));
}
/**
* Implements hook_process_html().
*/
function adminx_process_html(&$variables) {
//////////////////////////////
// HTML5 Base Theme Forwardport
//
// Backports the following changes made to Drupal 8:
// - #1077566: Convert html.tpl.php to HTML5.
//////////////////////////////
// Flatten out html_attributes and body_attributes.
$variables['html_attributes'] = drupal_attributes($variables['html_attributes_array']);
$variables['rdf_attributes'] = drupal_attributes($variables['rdf_attributes_array']);
$variables['body_attributes'] = drupal_attributes($variables['body_attributes_array']);
}
/**
* Implements hook_preprocess_page().
* Override or insert variables into the page template.
*/
function adminx_preprocess_page(&$variables) {
$variables['primary_local_tasks'] = $variables['tabs'];
unset($variables['primary_local_tasks']['#secondary']);
$variables['secondary_local_tasks'] = array(
'#theme' => 'menu_local_tasks',
'#secondary' => $variables['tabs']['#secondary'],
);
}
/**
* Display the list of available node types for node creation.
*/
function adminx_node_add_list($variables) {
$content = $variables['content'];
$output = '';
if ($content) {
$output = '<ul class="admin-list">';
foreach ($content as $item) {
$output .= '<li class="clearfix">';
$output .= '<span class="label">' . l($item['title'], $item['href'], $item['localized_options']) . '</span>';
$output .= '<div class="description">' . filter_xss_admin($item['description']) . '</div>';
$output .= '</li>';
}
$output .= '</ul>';
}
else {
$output = '<p>' . t('You have not created any content types yet. Go to the <a href="@create-content">content type creation page</a> to add a new content type.', array('@create-content' => url('admin/structure/types/add'))) . '</p>';
}
return $output;
}
/**
* Implements theme_adminx_block_content().
*
* Use unordered list markup in both compact and extended mode.
*/
function adminx_adminx_block_content($variables) {
$content = $variables['content'];
$output = '';
if (!empty($content)) {
$output = system_adminx_compact_mode() ? '<ul class="admin-list compact">' : '<ul class="admin-list">';
foreach ($content as $item) {
$output .= '<li class="leaf">';
$output .= l($item['title'], $item['href'], $item['localized_options']);
if (isset($item['description']) && !system_adminx_compact_mode()) {
$output .= '<div class="description">' . filter_xss_admin($item['description']) . '</div>';
}
$output .= '</li>';
}
$output .= '</ul>';
}
return $output;
}
/**
* Implements theme_tablesort_indicator().
*
* Use our own image versions, so they show up as black and not gray on gray.
*/
function adminx_tablesort_indicator($variables) {
$style = $variables['style'];
$theme_path = drupal_get_path('theme', 'adminx');
if ($style == 'asc') {
return '<i class="icon icon-sort-alpha-asc"></i>';
}
else {
return '<i class="icon icon-sort-alpha-desc"></i>';
}
}
/**
* Implements hook_css_alter().
*/
function adminx_css_alter(&$css) {
// Remove Drupal default stylesheets
$exclude = array(
'modules/system/system.base.css' => FALSE,
'modules/system/system.theme.css' => FALSE,
'modules/system/system.menus.css' => FALSE,
'modules/system/system.messages.css' => FALSE,
'modules/comment/comment.css' => FALSE,
'modules/node/node.css' => FALSE,
'modules/shortcut/shortcut.css' => FALSE,
'sites/all/modules/contrib/panopoly_magic/css/panopoly-modal.css' => FALSE,
'sites/all/modules/contrib/panopoly_magic/css/panopoly-magic.css' => FALSE,
// jQuery UI
//'misc/ui/jquery.ui.core.css' => FALSE,
//'misc/ui/jquery.ui.tabs.css' => FALSE,
);
$css = array_diff_key($css, $exclude);
// Use our vertical tabs style instead of the default one.
if (isset($css['misc/vertical-tabs.css'])) {
$css['misc/vertical-tabs.css']['data'] = drupal_get_path('theme', 'adminx') . '/css/vertical-tabs.css';
}
if (isset($css['misc/vertical-tabs-rtl.css'])) {
$css['misc/vertical-tabs-rtl.css']['data'] = drupal_get_path('theme', 'adminx') . '/css/vertical-tabs-rtl.css';
}
// Use our jQuery UI theme style instead of the default one.
if (isset($css['misc/ui/jquery.ui.theme.css'])) {
$css['misc/ui/jquery.ui.theme.css']['data'] = drupal_get_path('theme', 'adminx') . '/css/jquery.ui.theme.css';
}
}
/**
* Implements theme_admin_block().
* Adding classes to the administration blocks see issue #1869690.
*/
function adminx_admin_block($variables) {
$block = $variables['block'];
$output = '';
// Don't display the block if it has no content to display.
if (empty($block['show'])) {
return $output;
}
if (!empty($block['path'])) {
$output .= '<div class="admin-panel ' . check_plain(str_replace("/", " ", $block['path'])) . ' ">';
}
elseif (!empty($block['title'])) {
$output .= '<div class="admin-panel ' . check_plain(strtolower($block['title'])) . '">';
}
else {
$output .= '<div class="admin-panel">';
}
if (!empty($block['title'])) {
$output .= '<h3 class="title">' . $block['title'] . '</h3>';
}
if (!empty($block['content'])) {
$output .= '<div class="body">' . $block['content'] . '</div>';
}
else {
$output .= '<div class="description">' . $block['description'] . '</div>';
}
$output .= '</div>';
return $output;
}
/**
* Implements theme_admin_block_content().
* Adding classes to the administration blocks see issue #1869690.
*/
function adminx_admin_block_content($variables) {
$content = $variables['content'];
$output = '';
if (!empty($content)) {
$class = 'admin-list';
if ($compact = system_admin_compact_mode()) {
$class .= ' compact';
}
$output .= '<dl class="' . $class . '">';
foreach ($content as $item) {
if (!isset($item['path'])) {
$item['path']='';
}
$output .= '<div class="admin-block-item ' . check_plain(str_replace("/", "-", $item['path'])) . '"><dt>' . l($item['title'], $item['href'], $item['localized_options']) . '</dt>';
if (!$compact && isset($item['description'])) {
$output .= '<dd class="description">' . filter_xss_admin($item['description']) . '</dd>';
}
$output .= '</div>';
}
$output .= '</dl>';
}
return $output;
}
/**
* Implements theme_table().
*/
function adminx_table($variables) {
$header = $variables['header'];
$rows = $variables['rows'];
$attributes = $variables['attributes'];
$caption = $variables['caption'];
$colgroups = $variables['colgroups'];
$sticky = $variables['sticky'];
$empty = $variables['empty'];
// Add sticky headers, if applicable.
if (count($header) && $sticky) {
drupal_add_js('misc/tableheader.js');
// Add 'sticky-enabled' class to the table to identify it for JS.
// This is needed to target tables constructed by this function.
$attributes['class'][] = 'sticky-enabled';
}
$output = '<div class="overflow-fix">';
$output .= '<table' . drupal_attributes($attributes) . ">\n";
if (isset($caption)) {
$output .= '<caption>' . $caption . "</caption>\n";
}
// Format the table columns:
if (count($colgroups)) {
foreach ($colgroups as $number => $colgroup) {
$attributes = array();
// Check if we're dealing with a simple or complex column
if (isset($colgroup['data'])) {
foreach ($colgroup as $key => $value) {
if ($key == 'data') {
$cols = $value;
}
else {
$attributes[$key] = $value;
}
}
}
else {
$cols = $colgroup;
}
// Build colgroup
if (is_array($cols) && count($cols)) {
$output .= ' <colgroup' . drupal_attributes($attributes) . '>';
$i = 0;
foreach ($cols as $col) {
$output .= ' <col' . drupal_attributes($col) . ' />';
}
$output .= " </colgroup>\n";
}
else {
$output .= ' <colgroup' . drupal_attributes($attributes) . " />\n";
}
}
}
// Add the 'empty' row message if available.
if (!count($rows) && $empty) {
$header_count = 0;
foreach ($header as $header_cell) {
if (is_array($header_cell)) {
$header_count += isset($header_cell['colspan']) ? $header_cell['colspan'] : 1;
}
else {
++$header_count;
}
}
$rows[] = array(array(
'data' => $empty,
'colspan' => $header_count,
'class' => array('empty', 'message'),
));
}
// Format the table header:
if (count($header)) {
$ts = tablesort_init($header);
// HTML requires that the thead tag has tr tags in it followed by tbody
// tags. Using ternary operator to check and see if we have any rows.
$output .= (count($rows) ? ' <thead><tr>' : ' <tr>');
foreach ($header as $cell) {
$cell = tablesort_header($cell, $header, $ts);
$output .= _theme_table_cell($cell, TRUE);
}
// Using ternary operator to close the tags based on whether or not there are rows
$output .= (count($rows) ? " </tr></thead>\n" : "</tr>\n");
}
else {
$ts = array();
}
// Format the table rows:
if (count($rows)) {
$output .= "<tbody>\n";
$flip = array(
'even' => 'odd',
'odd' => 'even',
);
$class = 'even';
foreach ($rows as $number => $row) {
// Check if we're dealing with a simple or complex row
if (isset($row['data'])) {
$cells = $row['data'];
$no_striping = isset($row['no_striping']) ? $row['no_striping'] : FALSE;
// Set the attributes array and exclude 'data' and 'no_striping'.
$attributes = $row;
unset($attributes['data']);
unset($attributes['no_striping']);
}
else {
$cells = $row;
$attributes = array();
$no_striping = FALSE;
}
if (count($cells)) {
// Add odd/even class
if (!$no_striping) {
$class = $flip[$class];
$attributes['class'][] = $class;
}
// Build row
$output .= ' <tr' . drupal_attributes($attributes) . '>';
$i = 0;
foreach ($cells as $cell) {
$cell = tablesort_cell($cell, $header, $ts, $i++);
$output .= _theme_table_cell($cell);
}
$output .= " </tr>\n";
}
}
$output .= "</tbody>\n";
}
$output .= "</table>\n";
$output .= "</div>\n";
return $output;
}
include_once('includes/theme_overrides.inc');