forked from cdracars/mission_respondable
/
template.php
214 lines (194 loc) · 8.07 KB
/
template.php
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
<?php
/**
* @file
* Contains the theme's functions to manipulate Drupal's default markup.
*
* Complete documentation for this file is available online.
* @see https://drupal.org/node/1728096
*/
/**
* Override or insert variables into the maintenance page template.
*
* @param $variables
* An array of variables to pass to the theme template.
* @param $hook
* The name of the template being rendered ("maintenance_page" in this case.)
*/
/* -- Delete this line if you want to use this function
function mission_respondable_preprocess_maintenance_page(&$variables, $hook) {
// When a variable is manipulated or added in preprocess_html or
// preprocess_page, that same work is probably needed for the maintenance page
// as well, so we can just re-use those functions to do that work here.
mission_respondable_preprocess_html($variables, $hook);
mission_respondable_preprocess_page($variables, $hook);
}
// */
/**
* Override or insert variables into the html templates.
*
* @param $variables
* An array of variables to pass to the theme template.
* @param $hook
* The name of the template being rendered ("html" in this case.)
*/
function mission_respondable_preprocess_html(&$variables, $hook) {
drupal_add_js('http://use.typekit.com/cgw5wnf.js');
drupal_add_js('try{Typekit.load();}catch(e){}', array('type' => 'inline'));
drupal_add_js('/*<![CDATA[*/
(function() {
var sz = document.createElement("script"); sz.type = "text/javascript"; sz.async = true;
sz.src = "//us1.siteimprove.com/js/siteanalyze_6013742.js";
var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(sz, s);
})();
/*]]>*/', array('type' => 'inline'));
drupal_add_js(drupal_get_path('theme', 'mission_respondable') . '/js/quicktab-select.js');
drupal_add_js(drupal_get_path('theme', 'mission_respondable') . '/js/qtabborder.js');
$pageID = arg(0);
$otherPageID = arg(1);
if ($pageID == 'future-students' || $otherPageID == '38621' || $otherPageID =='39241') {
drupal_add_js(drupal_get_path('theme', 'mission_respondable') . '/js/fscodes.js');
}
if ($otherPageID == 'athletic-staff') {
drupal_add_js(drupal_get_path('theme', 'mission_respondable') . '/js/athleticsDirectoryRewrite.js');
}
drupal_add_library('system', 'ui.accordion');
drupal_add_library('system', 'ui.accordion');
drupal_add_js(drupal_get_path('theme', 'mission_respondable') . '/js/alignmentShift.js');
drupal_add_css(libraries_get_path('slick-master') . '/slick/slick.css');
drupal_add_js(libraries_get_path('slick-master') . '/slick/slick.js');
drupal_add_js(drupal_get_path('theme', 'mission_respondable') . '/js/slick-slider.js');
drupal_add_js(drupal_get_path('theme', 'mission_respondable') . '/js/slider-nav.js');
if (isset($_GET['q'])) {
$path = drupal_get_path_alias($_GET['q']);
if (preg_match('#gallery#', $path) ||
preg_match('#gallery\/about#', $path) ||
preg_match('#gallery\/directions#', $path)) {
drupal_add_js(drupal_get_path('theme', 'mission_respondable') . '/js/buttonCollapse.js');
}
}
// The body tag's classes are controlled by the $classes_array variable. To
// remove a class from $classes_array, use array_diff().
//$variables['classes_array'] = array_diff($variables['classes_array'], array('class-to-remove'));
}
// */
/**
* Override or insert variables into the page templates.
*
* @param $variables
* An array of variables to pass to the theme template.
* @param $hook
* The name of the template being rendered ("page" in this case.)
*/
function mission_respondable_preprocess_page(&$variables, $hook) {
// if this is a panel page, add template suggestions
if($panel_page = page_manager_get_current_page()) {
// add a generic suggestion for all panel pages
$variables['theme_hook_suggestions'][] = 'page__panel';
// add the panel page machine name to the template suggestions
$variables['theme_hook_suggestions'][] = 'page__' . $panel_page['name'];
//add a body class for good measure
$body_classes[] = 'page-panel';
}
}
/**
* Override or insert variables into the node templates.
*
* @param $variables
* An array of variables to pass to the theme template.
* @param $hook
* The name of the template being rendered ("node" in this case.)
*/
/* -- Delete this line if you want to use this function
function mission_respondable_preprocess_node(&$variables, $hook) {
$variables['sample_variable'] = t('Lorem ipsum.');
// Optionally, run node-type-specific preprocess functions, like
// mission_respondable_preprocess_node_page() or STARTERKIT_preprocess_node_story().
$function = __FUNCTION__ . '_' . $variables['node']->type;
if (function_exists($function)) {
$function($variables, $hook);
}
}
// */
/**
* Override or insert variables into the comment templates.
*
* @param $variables
* An array of variables to pass to the theme template.
* @param $hook
* The name of the template being rendered ("comment" in this case.)
*/
/* -- Delete this line if you want to use this function
function mission_respondable_preprocess_comment(&$variables, $hook) {
$variables['sample_variable'] = t('Lorem ipsum.');
}
// */
/**
* Override or insert variables into the region templates.
*
* @param $variables
* An array of variables to pass to the theme template.
* @param $hook
* The name of the template being rendered ("region" in this case.)
*/
/* -- Delete this line if you want to use this function
function mission_respondable_preprocess_region(&$variables, $hook) {
// Don't use Zen's region--sidebar.tpl.php template for sidebars.
//if (strpos($variables['region'], 'sidebar_') === 0) {
// $variables['theme_hook_suggestions'] = array_diff($variables['theme_hook_suggestions'], array('region__sidebar'));
//}
}
// */
/**
* Override or insert variables into the block templates.
*
* @param $variables
* An array of variables to pass to the theme template.
* @param $hook
* The name of the template being rendered ("block" in this case.)
*/
/*global $user;
$roles = $user->roles;
if (!in_array('administrator', $roles)){
print_r($block_id);
}*/
function mission_respondable_preprocess_block(&$variables, $hook) {
$block_id = $variables['block']->module . '-' . $variables['block']->delta;
$classes = &$variables['classes_array'];
/* Add classes based on the block delta. */
switch ($block_id) {
case 'views--exp-search-search':
$classes[] = 'search-block';
break;
}
// Add a count to all the blocks in the region.
// $variables['classes_array'][] = 'count-' . $variables['block_id'];
// By default, Zen will use the block--no-wrapper.tpl.php for the main
// content. This optional bit of code undoes that:
//if ($variables['block_html_id'] == 'block-system-main') {
// $variables['theme_hook_suggestions'] = array_diff($variables['theme_hook_suggestions'], array('block__no_wrapper'));
//}
}
// */
function mission_respondable_form_alter(&$form, &$form_state, $form_id) {
global $base_url;
$site_path = $base_url . base_path();
//drupal_set_message('<pre>'. print_r($form, TRUE) .'</pre>');
//if ($form_id == 'views_exposed_form' && $form['#id'] == 'views-exposed-form-search-search') {
if ($form_id == 'views_exposed_form' && $form['form_id']['#id'] == 'edit-views-exposed-form') {
$form['search_api_views_fulltext']['#size'] = 15; // define size of the textfield
$form['submit'] = array('#type' => 'image_button', '#src' => $site_path . path_to_theme() . '/images/searchICON.png');
// Alternative (HTML5) placeholder attribute instead of using the javascript
$form['search_api_views_fulltext']['#attributes']['placeholder'] = t('Search USAO');
}
switch ($form_id) {
case 'webform_client_form_38713':
$form['webform_client_form_38713']['#after_build'] = array('load_my_javascript');
break;
}
}
function load_my_javascript($element){
drupal_add_js(drupal_get_path('theme', 'mission_respondable') . '/js/printshop.js');
}
function mission_respondable_menu_tree__menu_future_students_resources($variables) {
return '<ul class="menu menu__vertical">' . $variables['tree'] . '</ul>';
}