-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtemplate.php
592 lines (551 loc) · 22.7 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
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
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
<?php
/**
* @file
* The primary PHP file for this theme.
*/
// for devel
// function barnard_bootstrap_block_view_alter(&$data, $block) {
// kpr($block);
// }
// function barnard_bootstrap_form_alter(&$form, &$form_state, $form_id) {
// kpr($form);
// }
// function barnard_bootstrap_menu_link(array $variables) {
// kpr($variables);
// }
/**
* Implements hook_preprocess_page().
*/
function barnard_bootstrap_preprocess_page(&$vars) {
// Create new theme hook suggestion specific to nodes. This is used by Solr content type.
if (isset($vars['node'])) {
$node = $vars['node'];
$vars['theme_hook_suggestions'][] = 'page__node__' . $node->type;
}
// Navigation Simple Search
$simple_search_form = drupal_render(drupal_get_form('islandora_solr_simple_search_form'));
$vars['simple_search_box'] = $simple_search_form;
// If we have bc_islandora and this is the front page, invoke
// _bc_islandora_featured() and set $vars['page']['footer']['front_caption'].
if (module_exists('bc_islandora') && $vars['is_front']) {
module_load_include('inc', 'bc_islandora', 'includes/theme');
$vars['page']['footer']['front_caption'] = [
'#markup' => _barnard_islandora_featured(),
'#prefix' => '<div id="block-views-featured-block">',
'#suffix' => '</div>',
];
}
// If we have bc_islandora, this is NOT the front page, and this is not a
// search result page, call bc_islandora's custom breadcrumb theming method
// and set $vars['bc_breadcrumb'].
/*
// As of 2019-SEP we have DISABLED breadcrumbs.
if (isset($node) && $node->type == 'islandora_solr_content_type') {
$vars['bc_breadcrumb'] = theme('bc_islandora_breadcrumb', ['breadcrumb' => menu_get_active_breadcrumb()]);
}
else {
if (module_exists('bc_islandora') && !$vars['is_front'] && arg(1) != 'search') {
$vars['bc_breadcrumb'] = theme('bc_islandora_breadcrumb', ['breadcrumb' => []]);
}
}
*/
// If we have service_links, set $vars['socialmedia'].
// if (module_exists('service_links') && _service_links_match_path()) {
// $vars['socialmedia'] = implode('', service_links_render(NULL));
// }
// If this is an islandora object, add permalink js.
if (arg(0) == 'islandora' && arg(1) == 'object') {
drupal_add_js(['permalink_path' => $_GET['q']], 'setting');
drupal_add_js(drupal_get_path('theme', 'barnard_bootstrap') . '/js/permalink.js');
}
}
/**
* Implements hook_form_FORM_ID_alter().
*/
function barnard_bootstrap_form_islandora_solr_advanced_search_form_alter(&$form, &$form_state, $form_id) {
$sort_order = array(0,1,2,4,3,5,6); // Genius or lazy
$form['terms'][0]['search']['#attributes']['placeholder'] = "Search in this collection";
// if ($form['terms'][0]['search']['#default_value'] === ' ' || $form['terms'][0]['search']['#default_value'] === "*") {
//// NULL the term. Doing this breaks everything. WHYYYYYY?
// }
foreach ($form['terms'] as $key => &$value) {
if (!is_array($value)) { continue; }
unset($value['search']['#title'], $value['field']['#title']);
array_multisort($sort_order, $value);
}
$form['controls']['submit']['#value'] = "Apply";
}
/**
* Implements hook_form_FORM_ID_alter().
*/
function barnard_bootstrap_form_islandora_solr_date_filter_form_alter(&$form, &$form_state, $form_id) {
// Auto-epxand the date form.
$form['date_range_expand']['#markup'] = '<span class="toggle-date-range-filter date-range-expanded"></span>';
// Set the size.
$size = 4;
$form['date_filter']['date_filter_from']['#size'] = $size;
$form['date_filter']['date_filter_to']['#size'] = $size;
// Modify the suffix text.
$form['date_filter']['date_filter_from']['#suffix'] = '<span id="between-dates"> to </span>';
}
/**
* Implements hook_form_FORM_ID_alter().
*/
function barnard_bootstrap_form_islandora_solr_range_slider_form_alter(&$form, &$form_state, $form_id) {
// Disable access to the slider and all related items.
$disable_slider = TRUE;
if ($disable_slider) {
$form['markup']['#access'] = !$disable_slider;
$form['range_slider_submit']['#access'] = !$disable_slider;
drupal_add_js(drupal_get_path('theme', 'barnard_bootstrap') . '/js/date_slider.js',
array(
'type' => 'file',
'weight' => 5,
));
}
}
/**
* Implements hook_form_FORM_ID_alter().
*/
function barnard_bootstrap_form_islandora_solr_simple_search_form_alter(&$form, &$form_state) {
// Control form size attrib with CSS width.
unset($form['simple']['islandora_simple_search_query']['#size']);
// Add placeholder text.
$form['simple']['islandora_simple_search_query']['#attributes']['placeholder'] = "Search everything by name, keyword, etc.";
$form['simple']['islandora_simple_search_query']['#suffix'] = '<div class="element-invisible"><label for="edit-islandora-simple-search-query">Search</label></div>';
}
/**
* Implements hook_block_view_MODULE_DELTA_alter().
*/
function barnard_bootstrap_block_view_islandora_solr_display_switch_alter(&$data, $block) {
$findArray = array('display-bcislandora-list', 'display-grid',
'A simple output.', 'List', 'Grid', 'active');
$replaceArray = array('btn glyphicon glyphicon-th-list display-bcislandora-list', 'btn glyphicon glyphicon-th-large display-grid',
'Display search results as a list view', '', '', 'active disabled');
$data = str_replace($findArray, $replaceArray, $data);
}
/**
* Returns HTML for an islandora_solr_facet_wrapper.
*
* @param array $variables
* An associative array containing:
* - title: A string to use as the header/title.
* - content: A string containing the content being wrapped.
*
* @ingroup themeable
* @return string => HTML markup.
*/
function barnard_bootstrap_islandora_solr_facet_wrapper($variables) {
$output = '<div class="islandora-solr-facet-wrapper">';
if ($variables['pid'] === "mods_originInfo_dateCreated_sort") {
$output .= '<h3 class="facet-heading"><a class="facet-toggle" data-toggle="collapse" href="#' . $variables['pid'] . '" aria-expanded="true">' . $variables['title'] . '</a></h3>';
$output .= '<div class="collapse in" id="' . $variables['pid'] . '" aria-expanded="true">' . $variables['content'] . '</div>';
} else {
$output .= '<h3 class="facet-heading"><a class="facet-toggle collapsed" data-toggle="collapse" href="#'. $variables['pid'] . '" aria-expanded="false">' . $variables['title'] . '</a></h3>';
$output .= '<div class="collapse" id="' . $variables['pid'] . '" aria-expanded="false">' . $variables['content'] . '</div>';
}
$output .= '</div>';
return $output;
}
// ->>> Old Below:
/** @noinspection DuplicatedCode */
/**
* Exception.
*
* @param string $pid
* something to compare.
*
* @return string mode
* IAB mode.
*
*/
function _barnard_bootstrap_breadcrumb_view_exceptions($pid) {
$thumbs = explode(', ', variable_get('bc_islandora_bookreader_initial_thumbs'));
$one_ups = explode(', ', variable_get('bc_islandora_bookreader_initial_1up'));
$ns = islandora_get_namespace($pid);
if (in_array($pid, $thumbs) || in_array($ns, $thumbs)) {
return 'thumb';
}
elseif (strpos($ns, 'BC15-02') !== FALSE || in_array($pid, $one_ups) || in_array($ns, $one_ups)) {
return '1up';
}
return '2up';
}
/** **/
/**
* Implements hook_preprocess_islandora_basic_collection_wrapper().
*
* @noinspection DuplicatedCode PhpUnused
*/
function barnard_bootstrap_preprocess_islandora_basic_collection_wrapper(&$vars) {
$object = $vars['islandora_object'];
if (isset($object['MODS']) && $mods = simplexml_load_string($object['MODS']->getContent(NULL))) {
$mods_local_identifier = (string) $mods->identifier;
$is_student_pub = $object->id == variable_get('bc_islandora_student_pubs_pid', 'islandora:1022');
if (empty($mods_local_identifier) && !$is_student_pub) {
return;
}
$is_record_group12 = preg_match("/BC(12)-(\d{2})/", $mods_local_identifier);
// If this is a BC12 object, $vars['student_pubs'] is TRUE.
if ($is_record_group12 || $is_student_pub) {
$vars['student_pubs'] = TRUE;
}
}
}
/**
* Implements hook_preprocess_islandora_book_book().
*
* @noinspection DuplicatedCode PhpUnused
*/
function barnard_bootstrap_preprocess_islandora_book_book(&$vars) {
// Barnard Core Module.
if (!module_exists('bc_islandora')) {
return;
}
module_load_include('inc', 'bc_islandora', 'includes/theme');
$object = $vars['object'];
// Provide a link to this object's PDF datastream via $vars['dl_links'].
$vars['dl_links'] = _barnard_islandora_dl_links($object, ['PDF']);
drupal_add_js(libraries_get_path('openseadragon') . '/openseadragon.js');
$vars['viewer'] = theme('bc_islandora_newspaper_issue_navigator', ['object' => $object]);
}
/**
* Implements hook_preprocess_islandora_book_page().
*
* @noinspection DuplicatedCode PhpUnused
*/
function barnard_bootstrap_preprocess_islandora_book_page(&$vars) {
// Barnard Core Module.
if (!module_exists('bc_islandora')) {
return;
}
$object = $vars['object'];
module_load_include('inc', 'bc_islandora', 'includes/theme');
// Provide a link to this object's JPG datastream via $vars['dl_links'].
$vars['dl_links'] = _barnard_islandora_dl_links($object, ['JPG']);
}
/**
* Implements hook_preprocess_islandora_large_image().
*
* @noinspection DuplicatedCode PhpUnused
*/
function barnard_bootstrap_preprocess_islandora_large_image(&$vars) {
// Barnard Core Module.
if (!module_exists('bc_islandora')) {
return;
}
module_load_include('inc', 'bc_islandora', 'includes/theme');
// Provide a link to this object's JPG datastream via $vars['dl_links'].
$vars['dl_links'] = _barnard_islandora_dl_links($vars['islandora_object'], ['JPG']);
}
/**
* Implements hook_preprocess_islandora_book_book().
*
* @noinspection DuplicatedCode PhpUnused
*/
function barnard_bootstrap_preprocess_islandora_oralhistories(&$vars) {
// Barnard Core Module.
if (!module_exists('bc_islandora')) {
return;
}
module_load_include('inc', 'bc_islandora', 'includes/theme');
$object = $vars['object'];
$ds_required = isset($object['TRANSCRIPT']) ? ['TRANSCRIPT'] : ['UNCORRECTED_TRANSCRIPT'];
// $ds_required = ['TRANSCRIPT', 'UNCORRECTED_TRANSCRIPT']; // FOR REVIEW
$ds_required[] = ('OBJ');
// Provide a link to this object's transcript datastream via $vars['dl_links'].
$vars['dl_links'] = _barnard_islandora_dl_links($object, $ds_required);
}
/**
* Implements hook_preprocess_islandora_manuscript_manuscript().
*
* @noinspection DuplicatedCode PhpUnused
*/
function barnard_bootstrap_preprocess_islandora_manuscript_manuscript(&$vars) {
module_load_include('inc', 'islandora_paged_content', 'includes/utilities');
module_load_include('inc', 'islandora', 'includes/metadata');
drupal_add_js('misc/form.js');
drupal_add_js('misc/collapse.js');
drupal_add_js(drupal_get_path('theme', 'barnard_bootstrap') . '/js/manuscript.js');
$object = $vars['object'];
$vars['metadata'] = islandora_retrieve_metadata_markup($object);
$vars['description'] = islandora_retrieve_description_markup($object);
$pages_ocr = [];
$pages_hocr = [];
if ($pages = islandora_paged_content_get_pages($object)) {
$i = 1;
foreach ($pages as $pid => $page) {
if ($page_obj = islandora_object_load($pid)) {
if (isset($page_obj['OCR'])) {
$page_ocr = $page_obj['OCR']->getContent(NULL);
$page_grafs = explode("\n\n", $page_ocr);
$new_grafs = [];
foreach ($page_grafs as $i => $graf) {
$new_grafs[$i] = preg_replace("/\n/", ' ', $graf);
}
$pages_ocr[] = implode("\n\n", $new_grafs);
}
}
}
}
if (!empty($pages_ocr)) {
$vars['ms_transcript'] = $pages_ocr;
}
// Barnard Core Module.
if (!module_exists('bc_islandora')) {
return;
}
module_load_include('inc', 'bc_islandora', 'includes/theme');
$vars['dl_links'] = _barnard_islandora_dl_links($object, ['PDF', 'TRANSCRIPT']);
if (count(islandora_paged_content_get_pages($object)) > 1) {
$vars['ms_pager'] = _barnard_islandora_np_page_pager($object);
}
}
/**
* Implements hook_preprocess_islandora_manuscript_page().
*
* @noinspection DuplicatedCode PhpUnused
*/
function barnard_bootstrap_preprocess_islandora_manuscript_page(&$vars) {
module_load_include('inc', 'islandora_paged_content', 'includes/utilities');
$object = $vars['object'];
if (isset($object['OCR'])) {
$vars['ms_transcript'] = $object['OCR']->getContent(NULL);
drupal_add_js(drupal_get_path('theme', 'barnard_bootstrap') . '/js/manuscript.js');
}
// Barnard Core Module.
if (!module_exists('bc_islandora')) {
return;
}
module_load_include('inc', 'bc_islandora', 'includes/theme');
$vars['dl_links'] = _barnard_islandora_dl_links($object, ['TRANSCRIPT']);
$vars['ms_pager'] = _barnard_islandora_np_page_pager($object);
}
/**
* Implements hook_CMODEL_PID_islandora_solr_object_result_alter().
*
* Replaces the url for the search result to be the book's url, not the page.
* The page is added as a fragment at the end of the book url.
*
* @noinspection DuplicatedCode PhpUnused
*/
function barnard_bootstrap_islandora_compoundcmodel_islandora_solr_object_result_alter(&$search_results, $query_processor) {
$parent_book_field_name = variable_get('islandora_book_parent_book_solr_field', 'RELS_EXT_isMemberOf_uri_ms');
$book_pid = preg_replace('/info\:fedora\//', '', $search_results['solr_doc'][$parent_book_field_name][0], 1);
$field_match = [
'catch_all_fields_mt',
'OCR_t',
'text_nodes_HOCR_hlt',
];
$field_term = '';
$fields = preg_split('/OR|AND|NOT/', $query_processor->solrQuery);
foreach ($fields as $field) {
if (preg_match('/^(.*):\((.*)\)/', $field, $matches)) {
if (isset($matches[1]) && in_array($matches[1], $field_match)) {
$field_term = ((isset($matches[2]) && $matches[2]) ? $matches[2] : '');
break;
}
}
}
if ($field_term) {
$search_term = trim($field_term);
}
elseif ($query_processor->solrDefType == 'dismax' || $query_processor->solrDefType == 'edismax') {
$search_term = trim($query_processor->solrQuery);
}
$search_results['object_url_fragment'] = "page/1/mode/1up";
if (!empty($search_term)) {
$search_results['object_url_fragment'] .= "/search/" . rawurlencode($search_term);
}
}
/**
* Implements hook_CMODEL_PID_islandora_solr_object_result_alter().
*
* @noinspection DuplicatedCode PhpUnused
*/
function barnard_bootstrap_islandora_manuscriptpagecmodel_islandora_solr_object_result_alter(&$search_results, $query_processor) {
$search_results['object_url_params']['solr'] = [
'query' => $query_processor->solrQuery,
'params' => $query_processor->solrParams,
];
}
/**
* Implements hook_CMODEL_PID_islandora_solr_object_result_alter().
*
* @noinspection DuplicatedCode PhpUnused
*/
function barnard_bootstrap_islandora_newspaperpagecmodel_islandora_solr_object_result_alter(&$search_results, $query_processor) {
$field_match = [
'catch_all_fields_mt',
'OCR_t',
'text_nodes_HOCR_hlt',
];
$field_term = '';
$fields = preg_split('/OR|AND|NOT/', $query_processor->solrQuery);
foreach ($fields as $field) {
if (preg_match('/^(.*):\((.*)\)/', $field, $matches)) {
if (isset($matches[1]) && in_array($matches[1], $field_match)) {
$field_term = ((isset($matches[2]) && $matches[2]) ? $matches[2] : '');
break;
}
}
}
if ($field_term) {
$search_term = trim($field_term);
$search_results['object_url_params']['solr'] = [
'query' => $search_term,
'params' => ['defType' => 'dismax'],
];
}
}
/**
* Implements hook_CMODEL_PID_islandora_solr_object_result_alter().
*
* Add page viewing fragment and search term to show all search results within
* book on page load.
*
* @noinspection DuplicatedCode PhpUnused
*/
function barnard_bootstrap_islandora_bookcmodel_islandora_solr_object_result_alter(&$search_results, $query_processor) {
$parent_book_field_name = variable_get('islandora_book_parent_book_solr_field', 'RELS_EXT_isMemberOf_uri_ms');
$book_pid = preg_replace('/info\:fedora\//', '', $search_results['solr_doc'][$parent_book_field_name][0], 1);
$field_match = [
'catch_all_fields_mt',
'OCR_t',
'text_nodes_HOCR_hlt',
];
$field_term = '';
$fields = preg_split('/OR|AND|NOT/', $query_processor->solrQuery);
foreach ($fields as $field) {
if (preg_match('/^(.*):\((.*)\)/', $field, $matches)) {
if (isset($matches[1]) && in_array($matches[1], $field_match)) {
$field_term = ((isset($matches[2]) && $matches[2]) ? $matches[2] : '');
break;
}
}
}
if ($field_term) {
$search_term = trim($field_term);
}
elseif ($query_processor->solrDefType == 'dismax' || $query_processor->solrDefType == 'edismax') {
$search_term = trim($query_processor->solrQuery);
}
$mode = _barnard_bootstrap_breadcrumb_view_exceptions($book_pid);
$search_results['object_url_fragment'] = "page/1/mode/$mode";
if (!empty($search_term)) {
$search_results['object_url_fragment'] .= "/search/" . rawurlencode($search_term);
}
}
/**
* Implements hook_CMODEL_PID_islandora_solr_object_result_alter().
*
* Replaces the url for the search result to be the book's url, not the page.
* The page is added as a fragment at the end of the book url.
*
* @noinspection DuplicatedCode PhpUnused
*/
function barnard_bootstrap_islandora_pagecmodel_islandora_solr_object_result_alter(&$search_results, $query_processor) {
$parent_book_field_name = variable_get('islandora_book_parent_book_solr_field', 'RELS_EXT_isMemberOf_uri_ms');
$page_number_field_name = variable_get('islandora_paged_content_page_number_solr_field', 'RELS_EXT_isSequenceNumber_literal_ms');
// @TODO: what is wrong here, as well? dev is acting odd using the literal. What.
if (!isset($search_results['solr_doc'][$page_number_field_name])) {
// Fall back to ms if you cannot get the page number from literal.
$page_number_field_name = 'RELS_EXT_isSequenceNumber_uri_ms';
}
if (empty($search_results['object_url']) || empty($search_results['solr_doc'])) {
drupal_set_message('Received an invalid or broken solr_search_results.', 'warning', FALSE);
return;
}
// If:
// the solr doc contains the parent book AND
// the solr doc contains the page number...
if (isset($search_results['solr_doc'][$parent_book_field_name]) &&
count($search_results['solr_doc'][$parent_book_field_name]) &&
isset($search_results['solr_doc'][$page_number_field_name]) &&
count($search_results['solr_doc'][$page_number_field_name])) {
// Replace the result url with that of the parent book and add the page
// number as a fragment.
$book_pid = preg_replace('/info\:fedora\//', '', $search_results['solr_doc'][$parent_book_field_name][0], 1);
// Waste of time (depending on where the page number comes from).
$page_number = preg_replace('/info\:fedora\//', '', $search_results['solr_doc'][$page_number_field_name][0], 1);
if (islandora_object_access(ISLANDORA_VIEW_OBJECTS, islandora_object_load($book_pid))) {
$search_results['object_url'] = "islandora/object/$book_pid";
$mode = _barnard_bootstrap_breadcrumb_view_exceptions($book_pid);
$search_results['object_url_fragment'] = "page/$page_number/mode/$mode";
$field_match = [
'catch_all_fields_mt',
'OCR_t',
'text_nodes_HOCR_hlt',
];
$field_term = '';
$fields = preg_split('/OR|AND|NOT/', $query_processor->solrQuery);
foreach ($fields as $field) {
if (preg_match('/^(.*):\((.*)\)/', $field, $matches)) {
if (isset($matches[1]) && in_array($matches[1], $field_match)) {
$field_term = ((isset($matches[2]) && $matches[2]) ? $matches[2] : '');
break;
}
}
}
if ($field_term) {
$search_term = trim($field_term);
}
elseif ($query_processor->solrDefType == 'dismax' || $query_processor->solrDefType == 'edismax') {
$search_term = trim($query_processor->solrQuery);
}
if (!empty($search_term)) {
$search_results['object_url_fragment'] .= "/search/" . rawurlencode($search_term);
}
}
}
}
/**
* Implements hook_CMODEL_PID_islandora_solr_object_result_alter().
*
* @noinspection DuplicatedCode PhpUnused
*/
function barnard_bootstrap_islandora_sp_large_image_cmodel_islandora_solr_object_result_alter(&$search_results, $query_processor) {
$search_results['object_url_params']['solr'] = [
'query' => $query_processor->solrQuery,
'params' => $query_processor->solrParams,
];
}
/**
* Implements hook_CMODEL_PID_islandora_solr_object_result_alter().
*
* Replaces the url for the search result to be the book's url, not the page.
* The page is added as a fragment at the end of the book url.
*/
// function barnard_bootstrap_islandora_pagecmodel_islandora_solr_object_result_alter(&$search_results, $query_processor) {
// // Grab the names of the appropriate solr fields from the db.
// $parent_book_field_name = variable_get('islandora_book_parent_book_solr_field', 'RELS_EXT_isMemberOf_uri_ms');
// $page_number_field_name = variable_get('islandora_paged_content_page_number_solr_field', 'RELS_EXT_isSequenceNumber_literal_ms');
// // @TODO: what is wrong here, as well? dev is acting odd using the literal. What.
// if (!isset($search_results['solr_doc'][$page_number_field_name])) {
// // Fall back to ms if you cannot get the page number from literal.
// $page_number_field_name = 'RELS_EXT_isSequenceNumber_uri_ms';
// }
// if (isset($search_results['solr_doc'][$parent_book_field_name]) &&
// count($search_results['solr_doc'][$parent_book_field_name]) &&
// isset($search_results['solr_doc'][$page_number_field_name]) &&
// count($search_results['solr_doc'][$page_number_field_name])) {
// // Replace the result url with that of the parent book and add the page
// // number as a fragment.
// $book_pid = preg_replace('/info\:fedora\//', '', $search_results['solr_doc'][$parent_book_field_name][0], 1);
// // Waste of time (depending on where the page number comes from).
// $page_number = preg_replace('/info\:fedora\//', '', $search_results['solr_doc'][$page_number_field_name][0], 1);
// $search_term = trim($query_processor->solrQuery);
// // @TODO COME BACK HERE!
// if (islandora_object_access(ISLANDORA_VIEW_OBJECTS, islandora_object_load($book_pid))) {
// $extra_life = strpos($book_pid, 'BC15') !== FALSE;
// $mode = $extra_life ? '1up' : '2up';
// $search_results['object_url'] = "islandora/object/$book_pid";
// $search_results['object_url_fragment'] = "page/$page_number/mode/$mode";
// // XXX: Won't handle fielded searches nicely... then again, if our
// // highlighting field is not the one being search on, this makes sense?
// if ($query_processor->solrDefType == 'dismax' || $query_processor->solrDefType == 'edismax') {
// $search_results['object_url_fragment'] .= "/search/" . rawurlencode($query_processor->solrQuery);
// }
// }
// }
// }