-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdg7.module
executable file
·2633 lines (2286 loc) · 114 KB
/
dg7.module
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
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
// $Id$ dg7.module
/**
* Custom code module for functions written specifically for Digital.Grinnell.edu.
* @see https://digital.grinnell.edu
*
* Authors: Mark A. McFate
*
* On 08-Feb-2016 the session_cache module was implemented here and all $_SESSION
* variable put and fetch operations were modified to use the session_cache_set($bin, $data)
* and session_cache_get($bin) functions.
*
*/
define('ISLANDORA_ISMEMBEROFCOLLECTION_PREDICATE', 'RELS_EXT_isMemberOfCollection_uri_ms');
function p($item) {
drupal_set_message('<pre>' . print_r($item, true) . '</pre>');
}
/**
* Important!
*
* In order to function correctly, ALL of the search options defined below
* in both dg7_default_search_options() and dg7_special_islandora_solr_collection_search_alter()
* MUST also be contained in the configuration settings for the Advanced Search Block found
* at admin/islandora/search/islandora_solr/settings. This admin overlay also
* is where default search term labels are set and where search permissions are
* determined.
*/
/**
* Implements hook_views_default_views().
*
* This hook implementation technique lifted from https://www.drupal.org/docs/7/modules/views/views-howtos/overriding-default-views-in-code on 10-August-2017.
*
* The view defined here is "Collection" exported from Digital on 16-August-2017.
*
* Important!!! You must put the site into MAINTENANCE MODE then delete the existing dg7_collection
* view from /admin/structure/views in order to trigger re-generation of a new dg7_collection view! Then
* you MUST follow-up by editing and saving the new view to secure it in the database.
*
*/
function dg7_views_default_views( ) {
$view = views_get_view('dg7_collection');
$update = (!$view && variable_get('maintenance_mode', 0));
if (!$update) { // call is not from within maintenance mode...do nothing here!
watchdog('dg7','dg7_views_default_views has been called but not in MAINTENANCE MODE, or dg7_collection already exists, so the view will NOT be updated.', NULL,WATCHDOG_NOTICE);
return;
} else {
$msg = 'dg7_views_default_views has been called in MAINTENANCE MODE and dg7_collection does not exist so it will be created.';
watchdog('dg7',$msg, NULL,WATCHDOG_NOTICE);
drupal_set_message($msg);
drupal_set_message("Note that you MUST alter the new dg7_Collection view in order to secure the new definitions in the database! It's easy, just edit the view and update all display titles to be empty. Do NOT delete the existing dg7_Collection view again unless you want to force an update from this code in MAINTENACE MODE!", 'warning');
}
// On DGAdmin ONLY, append "/manage" to all tile links.
if ($_SERVER['SERVER_NAME'] === 'dgadmin.grinnell.edu') {
$manage = "/manage";
} else {
$manage = "";
}
// The following collections have their own landing pages (they do not use the default). Defining a
// banner element for each causes their pages to render a grid of thumbnails rather than the default list view.
$collections = array( );
$collections = dg7_collections_list( );
watchdog("dg7_views_default_views", '<pre>' . print_r( $collections, true) . '</pre>');
$collections['islandora:root']['banner'] = 'Welcome to Digital Grinnell';
$collections['grinnell:special-collections']['banner'] = 'Special Collections and Archives';
$collections['grinnell:scholarship']['banner'] = "Scholarship at Grinnell";
$collections['grinnell:campus-collections']['banner'] = "Grinnell College Campus Collection";
$collections['grinnell:phpp']['banner'] = "Poweshiek History Preservation Project";
// if (user_access('administer')) { drupal_set_message("Attention: dg7_views_default_views_alter is now overriding the 'dg7_Collection' view.", 'info'); }
// The definition from the exported view goes here.
$view = new view();
$view->name = 'dg7_collection';
$view->description = 'This is a set of views pages that make up most of DG\'s display. This view IS OVERRIDEN in dg7.module code!';
$view->tag = 'default';
$view->base_table = 'islandora_solr';
$view->human_name = 'dg7_Collection';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit to true to make a default view disabled initially */
// Display: Master
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = '<none>';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '20';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['pager']['options']['id'] = '0';
$handler->display->display_options['pager']['options']['quantity'] = '9';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
// No results behavior: Global: Text area
$handler->display->display_options['empty']['area']['id'] = 'area';
$handler->display->display_options['empty']['area']['table'] = 'views';
$handler->display->display_options['empty']['area']['field'] = 'area';
$handler->display->display_options['empty']['area']['empty'] = TRUE;
$handler->display->display_options['empty']['area']['content'] = 'This collection contains no visible items at this time. Our collection visibility sometimes changes with time so please check back here at a later date. If you feel that this message is incorrect please use the "Report a Problem" link at the bottom of the page to let us know. Thank you.';
// Field: Islandora Solr: mods_extension_creators_ss
$handler->display->display_options['fields']['mods_extension_creators_ss']['id'] = 'mods_extension_creators_ss';
$handler->display->display_options['fields']['mods_extension_creators_ss']['table'] = 'islandora_solr';
$handler->display->display_options['fields']['mods_extension_creators_ss']['field'] = 'mods_extension_creators_ss';
$handler->display->display_options['fields']['mods_extension_creators_ss']['label'] = '';
$handler->display->display_options['fields']['mods_extension_creators_ss']['exclude'] = TRUE;
$handler->display->display_options['fields']['mods_extension_creators_ss']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['mods_extension_creators_ss']['link_to_object'] = 0;
// Field: Islandora Solr: fgs_label_s
$handler->display->display_options['fields']['fgs_label_s']['id'] = 'fgs_label_s';
$handler->display->display_options['fields']['fgs_label_s']['table'] = 'islandora_solr';
$handler->display->display_options['fields']['fgs_label_s']['field'] = 'fgs_label_s';
$handler->display->display_options['fields']['fgs_label_s']['label'] = '';
$handler->display->display_options['fields']['fgs_label_s']['exclude'] = TRUE;
$handler->display->display_options['fields']['fgs_label_s']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['fgs_label_s']['link_to_object'] = 0;
// Field: Islandora Solr: mods_abstract_ms
$handler->display->display_options['fields']['mods_abstract_ms']['id'] = 'mods_abstract_ms';
$handler->display->display_options['fields']['mods_abstract_ms']['table'] = 'islandora_solr';
$handler->display->display_options['fields']['mods_abstract_ms']['field'] = 'mods_abstract_ms';
$handler->display->display_options['fields']['mods_abstract_ms']['label'] = '';
$handler->display->display_options['fields']['mods_abstract_ms']['exclude'] = TRUE;
$handler->display->display_options['fields']['mods_abstract_ms']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['mods_abstract_ms']['link_to_object'] = 0;
// Field: Islandora Solr: mods_extension_pull_quote_ms
$handler->display->display_options['fields']['mods_extension_pull_quote_ms']['id'] = 'mods_extension_pull_quote_ms';
$handler->display->display_options['fields']['mods_extension_pull_quote_ms']['table'] = 'islandora_solr';
$handler->display->display_options['fields']['mods_extension_pull_quote_ms']['field'] = 'mods_extension_pull_quote_ms';
$handler->display->display_options['fields']['mods_extension_pull_quote_ms']['label'] = '';
$handler->display->display_options['fields']['mods_extension_pull_quote_ms']['exclude'] = TRUE;
$handler->display->display_options['fields']['mods_extension_pull_quote_ms']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['mods_extension_pull_quote_ms']['link_to_object'] = 0;
// Field: Islandora Solr: TN Image
$handler->display->display_options['fields']['TN Image']['id'] = 'TN Image';
$handler->display->display_options['fields']['TN Image']['table'] = 'islandora_solr';
$handler->display->display_options['fields']['TN Image']['field'] = 'TN Image';
$handler->display->display_options['fields']['TN Image']['label'] = '';
$handler->display->display_options['fields']['TN Image']['exclude'] = TRUE;
$handler->display->display_options['fields']['TN Image']['element_label_colon'] = FALSE;
// Field: Islandora Solr: PID
$handler->display->display_options['fields']['PID']['id'] = 'PID';
$handler->display->display_options['fields']['PID']['table'] = 'islandora_solr';
$handler->display->display_options['fields']['PID']['field'] = 'PID';
$handler->display->display_options['fields']['PID']['label'] = '';
$handler->display->display_options['fields']['PID']['alter']['alter_text'] = TRUE;
$handler->display->display_options['fields']['PID']['alter']['text'] = '<div class="wrapper"><div class="left"><a href="/islandora/object/[PID]' . $manage . '"><img src="/islandora/object/[PID]/datastream/TN/view" title="[fgs_label_s]" alt="[PID]"></a></div><div class="right"><div id="collection-view_teaser-creators" class="collection-value">[mods_extension_creators_ss]</div><div id="collection-view-teaser-title" class="collection-value"><a href="/islandora/object/[PID]' . $manage . '" title="[fgs_label_s]">[fgs_label_s]</a></div><div id="collection-view-teaser-abstract" class="collection-value">[mods_abstract_ms]</a></div><div id="collection-view-teaser-pull-quote" class="collection-value">[mods_extension_pull_quote_ms]</a></div></div><hr />';
$handler->display->display_options['fields']['PID']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['PID']['link_to_object'] = 0;
// Loop through the defined collection landing pages ----------------------------------------------------- !!!!
foreach ($collections as $pid => $collection) {
if (isset($collection['banner'])) {
$view = grid_view_handler($pid, $collection, $view, $manage);
} else {
$view = list_view_handler($pid, $collection, $view, $manage);
}
watchdog('dg7', "dg7_collection view display was created for $pid.", NULL, WATCHDOG_NOTICE);
}
// Add this new view definition.
$views[$view->name] = $view;
return $views;
}
/**
* Handler code for collection 'list' views in hook_view_default_views_alter (below).
*/
function list_view_handler( $pid, $collection, &$view, $manage ) {
$handler = $view->new_display('page', $collection['title'], $pid);
$handler->display->display_options['defaults']['header'] = FALSE;
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
// Header: Global: Text area
$handler->display->display_options['header']['area']['id'] = 'area';
$handler->display->display_options['header']['area']['table'] = 'views';
$handler->display->display_options['header']['area']['field'] = 'area';
$handler->display->display_options['header']['area']['empty'] = TRUE;
$handler->display->display_options['header']['area']['content'] = '<div class="intro-text intro-text-no-form">
<h1 style="text-align: center; margin-top: 0px; margin-bottom: 20px">'. $collection['label'] . '</h1><p class="collection-banner-text">' . $collection['abstract'] . '</p></div>';
$handler->display->display_options['header']['area']['format'] = 'php_code';
$handler->display->display_options['defaults']['fields'] = FALSE;
// No results behavior: Global: Text area
$handler->display->display_options['empty']['area']['id'] = 'area';
$handler->display->display_options['empty']['area']['table'] = 'views';
$handler->display->display_options['empty']['area']['field'] = 'area';
$handler->display->display_options['empty']['area']['empty'] = TRUE;
$handler->display->display_options['empty']['area']['content'] = 'This collection contains no visible items at this time. Our collection visibility sometimes changes with time so please check back here at a later date. If you feel that this message is incorrect please use the "Report a Problem" link at the bottom of the page to let us know. Thank you.';
// Field: Islandora Solr: mods_extension_creators_ss
$handler->display->display_options['fields']['mods_extension_creators_ss']['id'] = 'mods_extension_creators_ss';
$handler->display->display_options['fields']['mods_extension_creators_ss']['table'] = 'islandora_solr';
$handler->display->display_options['fields']['mods_extension_creators_ss']['field'] = 'mods_extension_creators_ss';
$handler->display->display_options['fields']['mods_extension_creators_ss']['label'] = '';
$handler->display->display_options['fields']['mods_extension_creators_ss']['exclude'] = TRUE;
$handler->display->display_options['fields']['mods_extension_creators_ss']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['mods_extension_creators_ss']['link_to_object'] = 0;
// Field: Islandora Solr: fgs_label_s
$handler->display->display_options['fields']['fgs_label_s']['id'] = 'fgs_label_s';
$handler->display->display_options['fields']['fgs_label_s']['table'] = 'islandora_solr';
$handler->display->display_options['fields']['fgs_label_s']['field'] = 'fgs_label_s';
$handler->display->display_options['fields']['fgs_label_s']['label'] = '';
$handler->display->display_options['fields']['fgs_label_s']['exclude'] = TRUE;
$handler->display->display_options['fields']['fgs_label_s']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['fgs_label_s']['link_to_object'] = 0;
// Field: Islandora Solr: mods_abstract_ms
$handler->display->display_options['fields']['mods_abstract_ms']['id'] = 'mods_abstract_ms';
$handler->display->display_options['fields']['mods_abstract_ms']['table'] = 'islandora_solr';
$handler->display->display_options['fields']['mods_abstract_ms']['field'] = 'mods_abstract_ms';
$handler->display->display_options['fields']['mods_abstract_ms']['label'] = '';
$handler->display->display_options['fields']['mods_abstract_ms']['exclude'] = TRUE;
$handler->display->display_options['fields']['mods_abstract_ms']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['mods_abstract_ms']['link_to_object'] = 0;
// Field: Islandora Solr: mods_extension_pull_quote_ms
$handler->display->display_options['fields']['mods_extension_pull_quote_ms']['id'] = 'mods_extension_pull_quote_ms';
$handler->display->display_options['fields']['mods_extension_pull_quote_ms']['table'] = 'islandora_solr';
$handler->display->display_options['fields']['mods_extension_pull_quote_ms']['field'] = 'mods_extension_pull_quote_ms';
$handler->display->display_options['fields']['mods_extension_pull_quote_ms']['label'] = '';
$handler->display->display_options['fields']['mods_extension_pull_quote_ms']['exclude'] = TRUE;
$handler->display->display_options['fields']['mods_extension_pull_quote_ms']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['mods_extension_pull_quote_ms']['link_to_object'] = 0;
// Field: Islandora Solr: TN Image
$handler->display->display_options['fields']['TN Image']['id'] = 'TN Image';
$handler->display->display_options['fields']['TN Image']['table'] = 'islandora_solr';
$handler->display->display_options['fields']['TN Image']['field'] = 'TN Image';
$handler->display->display_options['fields']['TN Image']['label'] = '';
$handler->display->display_options['fields']['TN Image']['exclude'] = TRUE;
$handler->display->display_options['fields']['TN Image']['element_label_colon'] = FALSE;
// Field: Islandora Solr: PID
$handler->display->display_options['fields']['PID']['id'] = 'PID';
$handler->display->display_options['fields']['PID']['table'] = 'islandora_solr';
$handler->display->display_options['fields']['PID']['field'] = 'PID';
$handler->display->display_options['fields']['PID']['label'] = '';
$handler->display->display_options['fields']['PID']['alter']['alter_text'] = TRUE;
$handler->display->display_options['fields']['PID']['alter']['text'] = '<div class="wrapper"><div class="left"><a href="/islandora/object/[PID]' . $manage . '"><img src="/islandora/object/[PID]/datastream/TN/view" title="[fgs_label_s]" alt="[PID]"></a></div><div class="right"><div id="collection-view_teaser-creators" class="collection-value">[mods_extension_creators_ss]</div><div id="collection-view-teaser-title" class="collection-value"><h3><a href="/islandora/object/[PID]' . $manage . '" title="[fgs_label_s]">[fgs_label_s]</a></h3></div><div id="collection-view-teaser-abstract" class="collection-value">[mods_abstract_ms]</a></div><div id="collection-view-teaser-pull-quote" class="collection-value">[mods_extension_pull_quote_ms]</a></div></div></div><hr />';
$handler->display->display_options['fields']['PID']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['PID']['link_to_object'] = 0;
$handler->display->display_options['defaults']['filter_groups'] = FALSE;
$handler->display->display_options['defaults']['filters'] = FALSE;
// Filter criterion: Islandora Solr: RELS_EXT_isMemberOfCollection_uri_ms Do NOT use isMemberOfCollection_uri_s as it's single-valued.
$handler->display->display_options['filters']['RELS_EXT_isMemberOfCollection_uri_ms']['id'] = 'RELS_EXT_isMemberOfCollection_uri_ms';
$handler->display->display_options['filters']['RELS_EXT_isMemberOfCollection_uri_ms']['table'] = 'islandora_solr';
$handler->display->display_options['filters']['RELS_EXT_isMemberOfCollection_uri_ms']['field'] = 'RELS_EXT_isMemberOfCollection_uri_ms';
$handler->display->display_options['filters']['RELS_EXT_isMemberOfCollection_uri_ms']['value'] = 'info:fedora/' . $pid;
$handler->display->display_options['path'] = 'islandora/object/' . $pid;
return $view;
}
/**
* Handler code for collection 'grid' views in hook_view_default_views_alter (below).
*/
function grid_view_handler( $pid, $collection, &$view, $manage ) {
if (!isset($collection['title'])) { drupal_set_message("Collection title is missing for $pid", 'warning'); }
if (!isset($collection['id'])) { drupal_set_message("Collection ID (id) is missing for $pid", 'warning'); }
if (!isset($collection['description'])) { drupal_set_message("Collection description is missing for $pid", 'warning'); }
$handler = $view->new_display('page', $collection['title'], $collection['id']);
$handler->display->display_options['display_description'] = "This is a new page view specifically for the " . $collection['description'] . " and its immediate subordinates.";
$handler->display->display_options['defaults']['style_plugin'] = FALSE;
$handler->display->display_options['style_plugin'] = 'views_bootstrap_thumbnail_plugin_style';
$handler->display->display_options['style_options']['columns_horizontal'] = '-1';
$handler->display->display_options['style_options']['columns_vertical'] = '4';
$handler->display->display_options['style_options']['clear_columns'] = FALSE;
$handler->display->display_options['style_options']['columns_xs'] = '12';
$handler->display->display_options['style_options']['columns_sm'] = '12';
$handler->display->display_options['style_options']['columns_md'] = '6';
$handler->display->display_options['style_options']['columns_lg'] = '4';
$handler->display->display_options['pager']['options']['items_per_page'] = '12';
$handler->display->display_options['defaults']['style_options'] = FALSE;
$handler->display->display_options['defaults']['row_plugin'] = FALSE;
$handler->display->display_options['row_plugin'] = 'fields';
$handler->display->display_options['defaults']['row_options'] = FALSE;
$handler->display->display_options['defaults']['header'] = FALSE;
/* Header: Global: Text area */
$handler->display->display_options['header']['area']['id'] = 'area';
$handler->display->display_options['header']['area']['table'] = 'views';
$handler->display->display_options['header']['area']['field'] = 'area';
$handler->display->display_options['header']['area']['empty'] = TRUE;
$handler->display->display_options['header']['area']['content'] = '<script type="text/javascript">
function lastRow() {
var lastRowDesktop = jQuery(\'#views-bootstrap-thumbnail-1 .row\').children().length % 3;
var lastRowTablet = jQuery(\'#views-bootstrap-thumbnail-1 .row\').children().length % 2;
if (lastRowTablet == 1 && jQuery(\'.device-md\').is(\':visible\')) {
jQuery(\'#views-bootstrap-thumbnail-1 .row\').children().slice(-1).addClass(\'col-md-offset-3\');
}
else if (lastRowDesktop == 2 && jQuery(\'.device-lg\').is(\':visible\')) {
jQuery(\'#views-bootstrap-thumbnail-1 .row\').children().slice(-2, -1).addClass(\'col-lg-offset-2\');
}
else if (lastRowDesktop == 1 && jQuery(\'.device-lg\').is(\':visible\')) {
jQuery(\'#views-bootstrap-thumbnail-1 .row\').children().slice(-1).addClass(\'col-lg-offset-4\');
}
}
jQuery(document).ready(function() {
lastRow();
jQuery(\'#views-bootstrap-thumbnail-1 img\').addClass(\'img-responsive\');
jQuery(\'#edit-terms-0-field\').val(\'catch_all_fields_mt\');
});
jQuery( window ).resize(function() {
jQuery(\'div\').removeClass(\'col-md-offset-3 col-lg-offset-2 col-lg-offset-4 \');
lastRow();
});
</script>
<div class="intro-text intro-text-no-form">
<h1 style="text-align: center; margin-top:0px; margin-bottom:20px;">' . $collection['banner'] . '</h1>
<p class="collection-banner-text">' . $collection['abstract'] . '</p></div><h2 style="margin-top: 25px;">Browse by Collection</h2>';
$handler->display->display_options['header']['area']['format'] = 'php_code';
$handler->display->display_options['defaults']['footer'] = FALSE;
$handler->display->display_options['defaults']['fields'] = FALSE;
// Field: Islandora Solr: PID
$handler->display->display_options['fields']['PID']['id'] = 'PID';
$handler->display->display_options['fields']['PID']['table'] = 'islandora_solr';
$handler->display->display_options['fields']['PID']['field'] = 'PID';
$handler->display->display_options['fields']['PID']['label'] = '';
$handler->display->display_options['fields']['PID']['exclude'] = TRUE;
$handler->display->display_options['fields']['PID']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['PID']['link_to_object'] = 0;
// Field: Islandora Solr: fgs_label_s
$handler->display->display_options['fields']['fgs_label_s']['id'] = 'fgs_label_s';
$handler->display->display_options['fields']['fgs_label_s']['table'] = 'islandora_solr';
$handler->display->display_options['fields']['fgs_label_s']['field'] = 'fgs_label_s';
$handler->display->display_options['fields']['fgs_label_s']['label'] = '';
$handler->display->display_options['fields']['fgs_label_s']['exclude'] = TRUE;
$handler->display->display_options['fields']['fgs_label_s']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['fgs_label_s']['link_to_object'] = 0;
// Field: Islandora Solr: TN Image
$handler->display->display_options['fields']['TN Image']['id'] = 'TN Image';
$handler->display->display_options['fields']['TN Image']['table'] = 'islandora_solr';
$handler->display->display_options['fields']['TN Image']['field'] = 'TN Image';
$handler->display->display_options['fields']['TN Image']['label'] = '';
$handler->display->display_options['fields']['TN Image']['alter']['alter_text'] = TRUE;
$handler->display->display_options['fields']['TN Image']['alter']['text'] = '<a class="collection-tile-text" id="grid_"[PID] href="/islandora/object/[PID]' . $manage . '"><div class="views-field-TN-Image"><img src="/islandora/object/[PID]/datastream/TN/view" alt="[fgs_label_s]"/></div><h3 class="collection-tile">[fgs_label_s]</h3></a>';
$handler->display->display_options['fields']['TN Image']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['TN Image']['element_default_classes'] = FALSE;
$handler->display->display_options['defaults']['filter_groups'] = FALSE;
$handler->display->display_options['defaults']['filters'] = FALSE;
// Sort criterion has been removed so that Solr queries control the order.
// Filter criterion: Islandora Solr: RELS_EXT_isMemberOfCollection_uri_ms
$handler->display->display_options['filters']['RELS_EXT_isMemberOfCollection_uri_ms']['id'] = 'RELS_EXT_isMemberOfCollection_uri_ms';
$handler->display->display_options['filters']['RELS_EXT_isMemberOfCollection_uri_ms']['table'] = 'islandora_solr';
$handler->display->display_options['filters']['RELS_EXT_isMemberOfCollection_uri_ms']['field'] = 'RELS_EXT_isMemberOfCollection_uri_ms';
$handler->display->display_options['filters']['RELS_EXT_isMemberOfCollection_uri_ms']['value'] = 'info:fedora/' . $pid;
$handler->display->display_options['path'] = 'islandora/object/' . $pid;
/* On DGAdmin append "/manage" to the path. Don't do this on DG!
if ($_SERVER['SERVER_NAME'] === 'dgadmin.grinnell.edu') {
$handler->display->display_options['path'] = 'islandora/object/' . $pid . "/manage";
} else {
$handler->display->display_options['path'] = 'islandora/object/' . $pid;
}
*/
return $view;
}
/**
* Build and execute Apache Solr query to fetch all collection CModel objects.
*
* Returns an associative array for all collectionCModel objects as:
* $collections[pid] with keys 'label', 'abstract', 'path' and 'thumbnail'
*
* Note that collection objects which are 'dark', aka hidden from public view, will NOT be
* returned by this query!
*
*/
function dg7_collections_list( ) {
$solr = new IslandoraSolrQueryProcessor( );
$query = "RELS_EXT_hasModel_uri_s:info\:fedora/islandora\:collectionCModel";
$solr->buildQuery($query);
$solr->solrLimit = "99"; // must be greater than total number of collections AND it must be set between buildQuery and executeQuery!
$solr->executeQuery(FALSE);
$response = $solr->islandoraSolrResult['response'];
$numFound = $response['numFound'];
if ($numFound < 1) {
return "Error searching Solr index in " . __FUNCTION__ . ".";
} else {
$collections = array( );
$objects = $response['objects'];
foreach ($objects as $obj) {
$pid = $obj['PID'];
$collections[$pid] = array( 'label' => $obj['object_label'], 'path' => $obj['object_url'], 'thumbnail' => $obj['thumbnail_url']);
if (isset($obj['solr_doc']['dc.description'])) {
$collections[$pid] ['abstract'] = $obj['solr_doc']['dc.description'][0];
} else {
$msg = "Collection $pid has no dc.description in " . __FUNCTION__ . ".";
drupal_set_message($msg, 'warning');
}
$collections[$pid]['id'] = "display_" . $pid;
$collections[$pid]['title'] = "display_" . $pid;
$collections[$pid]['description'] = "display_" . $pid;
}
// Make sure we have a $collections[] entry for islandora:root!
$collections['islandora:root'] = array( 'id' => 'display_islandora:root', 'title' => 'display_islandora:root', 'description' => 'display_islandora:root', 'label' => 'Welcome to Digital Grinnell', 'path' => 'islandora/object', 'abstract' => 'Digital Grinnell contributes to “free inquiry and the open exchange of ideas” through the preservation and publication of scholarship created by Grinnell College students, faculty, and staff, as well as selected material that illuminates the College’s history and other activities.' );
return $collections;
}
}
/**
* Implements hook_webform_submission_actions for Digital Grinnell.
*
* Provides links to frequently used admin functions.
*
* @TODO: This function should be moved to islandora_webform_webform_submission_actions.
*
*/
function dg7_webform_submission_actions($node, $submission) {
$actions= array();
// https://digitalx.grinnell.edu/islandora_webform_submission/ingest/76?destination=node/1934626/submission/76
if (webform_results_access($node)) {
$actions['submissions'] = array(
'title' => t('List ALL Submissions'),
'href' => 'islandora/object/' . $submission->islandora_object->id . '/submissions',
'query' => drupal_get_destination(),
);
$actions['ingest'] = array(
'title' => t('Ingest this Submission'),
'href' => 'islandora_webform_submission/ingest/' . $submission->sid . '?destination=node/' . $node->vid . '/submission/' . $submission->sid,
'query' => drupal_get_destination(),
);
}
return $actions;
}
/**
* Implements hook_preprocess_theme().
*
* Lifted from the thread at
* https://groups.google.com/forum/#!searchin/islandora/mods$20display$20bookreader/islandora/PDjLlE_IrPk/H2Cjl38JeAgJ
*
*/
function dg7_preprocess_islandora_internet_archive_bookreader(array &$variables) {
module_load_include('inc', 'islandora_internet_archive_bookreader', 'includes/utilities');
$object = $variables['object'];
// Add the following two lines of code (and corresponding additions to
// ../sites/default/modules/contrib/islandora_mods_display/theme/islandora-mods-display-display-template.tpl.php
// to facilitate MODS Metadata display below the bookreader widget...just
// like all other content types.
module_load_include('inc', 'islandora', 'includes/metadata');
$variables['metadata'] = islandora_retrieve_metadata_markup($object);
}
/**
* Implements hook_preprocess( ).
*
* This is a good place to implement custom pre- or post-processing for
* ingest operations.
*
* @param array &$variables
* Array of variables passed to the hook. If applicable, the Islandora object
* PID being processed is held in $variables['islandora_object']->objectId.
* @param string $hook
* The name of the module calling this instance of the hook. For Islandora ingest
* this value will be something like 'islandora_large_image', or the name of
* some other Islandora solution pack.
*
*/
function dg7_preprocess(&$variables, $hook) {
return;
/*
static $previous;
$is_islandora = (stripos("_$hook", 'islandora_') === 1);
if ($is_islandora) {
$pid = (isset($variables['islandora_object']) ? $variables['islandora_object']->id : 'Undefined');
drupal_set_message(__FUNCTION__ . ' called for ' . $hook . ' with PID = '.$pid, 'status');
switch ($hook) {
case 'islandora_basic_image':
case 'islandora_audio':
case 'islandora_large_image':
case 'islandora_binary_object':
case 'islandora_book':
case 'islandora_pdf':
case 'islandora_video':
case 'islandora_web_archive':
// Many operations call this hook twice. The following logic is included for
// cases where only ONE response is necessary.
$thisTime = $hook.'_'.$pid;
if ($thisTime != $previous) { // only do the following ONCE per object!
drupal_set_message(__FUNCTION__ . ' responding to ' . $hook . ' with PID = '.$pid, 'status');
$previous = $thisTime;
// Check for an existing MODS record. If one exists, see if the object has a handle yet.
if (isset($variables['islandora_object']->datastreams['MODS'])) {
};
}
break;
}
}
return; */
}
/**
* Implements hook_form_alter.
*
* This function implements hook_form_alter with intent to change the behavior
* of the Advanced Search form/block, user login, and others in Digital Grinnell.
*
* @param $form
* @param $form_state
* @param $form_id
*/
function dg7_form_alter(&$form, &$form_state, $form_id) {
global $user;
// p($form_id);
// p($form_state);
// p($form);
// The big switch...
switch($form_id) {
case 'islandora_multi_importer_form':
// dg7_form_islandora_multi_importer_form_alter($form, $form_state, $form_id);
break;
// User login form
case 'user_login_block': // MAM...20-Jan-2016... Do NOT block the user/login page!
$form['name']['#weight'] = 1;
$form['pass']['#weight'] = 2;
$msg = t("User login is not required to access our collection; however, some content and features require a Grinnell.edu login.");
$form['message']['#type'] = 'markup';
$form['message']['#markup'] = $msg;
$form['message']['#weight'] = -99; // top of the form?
break;
// User register form...block it!
case 'user_register_form':
if ($user->uid != '1') {
$form['#access'] = FALSE;
drupal_add_http_header('Status', '410 Gone');
exit(); // may want drupal_exit instead; not sure of other hook_inits()s should run
}
break;
// islandora_solr_advanced_search_form.
case 'islandora_solr_advanced_search_form':
dg7_islandora_solr_advanced_search_form_alter_helper($form);
break;
}
return;
}
/**
* Helper function for dg7_form_alter and solr_advanced_search_form.
*
* @TODO... add a 'search help' link to the bottom of the form/block.
*
* @param $form
* The target form array.
*/
function dg7_islandora_solr_advanced_search_form_alter_helper(&$form) {
module_load_include('inc', 'islandora_solr_collection_search', 'islandora_solr_collection_search');
// Find the current collection scope, if any...
if (module_exists('islandora_solr_collection_search')) {
// islandora_solr_collection_search_sync( );
// $scope = (isset($_SESSION['islandora_solr_collection_search']['collection']) ? $_SESSION['islandora_solr_collection_search']['collection'] : FALSE);
$scope = session_cache_get('islandora_solr_collection_search-collection');
}
else {
$scope = dg7_solr_collection_search_sync();
}
// Reset the $form['terms'][x]['field'['#options'] to their default values (as configured in
// the Advanced Search block portion of #overlay=admin/islandora/search/islandora_solr/settings).
foreach ($form['terms'] as $index => &$term) {
if (is_int($index) && $term['field']['#type'] === 'select') { // find any/all 'select' fields to alter, and remove them
unset($term['field']['#options']);
$term['field']['#options'] = islandora_solr_get_fields('search_fields');
}
}
// Now, loop through each search term and set or unset options which are collection-specific.
foreach ($form['terms'] as $index => &$term) {
if (is_int($index) && $term['field']['#type'] === 'select') { // find any/all 'select' fields to alter
// The following switch/case statements should, based on collection, remove (unset) configured
// fields that should be hidden, and it can be used to change the label of particular fields.
// That is ALL. Don't define additional fields here!
switch ($scope) { // Switch on $scope (collection).
case 'grinnell:faulconer': // The Faulconer Art collection
case 'grinnell:faulconer-suppressed': // Suppressed Faulconer Art
case 'grinnell:soviet-graphic-art': // The Faulconer's Soviet Graphic Art collection
case 'grinnell:recent-art-acquisitions': // The Faulconer's Recent Acquisitions collection
unset($term['field']['#options']['dc.description']); // Abstract
unset($term['field']['#options']['dc.coverage']); // Coverage
unset($term['field']['#options']['dc.relation']); // Relations
$term['field']['#options']['dc.contributor'] = "Artist";
$term['field']['#options']['mods_subject_topic_mt'] = "Nationality";
break;
case 'grinnell:studio-student-art': // Studio Student Art... preliminary decision made to make this behave like a hybrid of artwork and the default.
unset($term['field']['#options']['dc.coverage']); // Coverage
unset($term['field']['#options']['dc.relation']); // Relations
$term['field']['#options']['dc.contributor'] = "Artist";
break;
default: // If none of the above...leave the defaults intact minus the Faulconer and Studio Student Art stuff.
unset($term['field']['#options']['mods_relatedItem_admin_note_location_mt']); // Location
unset($term['field']['#options']['mods_physicalDescription_form_mt']); // Medium
unset($term['field']['#options']['mods_identifier_local_ms']); // Accession Number
unset($term['field']['#options']['mods_note_credits_mt']); // Credit Line
break;
}
}
}
/* Last order of business...if we are in a collection scope, add the checkbox control.
if ($scope && module_exists('islandora_solr_collection_search')) {
islandora_solr_collection_search_form_add_scope_control($scope, $form, $form_state);
} */
return;
}
/**
* Returns associated collection PID (or label) from the page request, or FALSE
* if we are not in a collection object or collection search page.
*
* This is a dg7 copy of islandora_solr_collection_search_sync. As such it
* provides and tracks its own $_SESSION variable.
*
* This function is NOT NEEDED if the islandora_solr_collection_search module is
* installed and enabled.
*
*/
function dg7_solr_collection_search_sync( ) {
global $user;
static $previous;
$page = $_GET['q'];
// If this is an ajax call...return NULL since $_SESSION is unreliable.
if ($page === 'system/ajax') {
// $pid = $_SESSION['dg7']['collection'];
$pid = session_cache_get('dg7-collection');
// drupal_set_message(__FUNCTION__." -ajax call- returning ".$pid, 'status');
return $pid;
}
// If this is the same page and user as last request...make a quick exit.
if (!is_null($previous)) {
if ($previous['uid'] = $user->uid && $previous['page'] = $page && isset($previous['pid'])) {
// drupal_set_message(__FUNCTION__." -previous- returning ".$previous['pid'], 'status');
// $_SESSION['dg7']['collection'] = $previous['pid'];
if ($user->uid > 0) { session_cache_set('dg7-collection', $previous['pid']); }
return $previous['pid'];
}
}
// Save some data for the next call to this function.
$previous['page'] = $page;
$previous['uid'] = $user->uid;
////////////////////////////////////////////////////////////////////////
// Need some operations to 'reset' things and get them back in sync.
// One such operation is any visit to the <front> page. If we landed there unset $_SESSION[$_module].
if (drupal_is_front_page( )) {
$previous['pid'] = $pid = FALSE;
// drupal_set_message(__FUNCTION__." -front page- returning FALSE", 'status');
// $_SESSION['dg7']['collection'] = $pid;
if ($user->uid > 0) { session_cache_set('dg7-collection', $pid); }
return $pid;
}
// Another such operation is any visit to the default or 'base' search page...
$base = variable_get('islandora_solr_base_query', '*:*');
if ($page === 'islandora/search/'.$base) {
$previous['pid'] = $pid = FALSE;
// drupal_set_message(__FUNCTION__." -base query- returning FALSE", 'status');
// $_SESSION['dg7']['collection'] = $pid;
if ($user->uid > 0) { session_cache_set('dg7-collection', $pid); }
return $pid;
}
// Examine the address of the page we're on, and if it is a collection-related page...return so.
// If preg_match === 1 then we have identified a probable /islandora/object/<collection> page.
// Return the collection PID that was found.
$matches = array( );
$pattern1 = '/^islandora\/object\/(\w+)\:(\D+)$/'; // Tests for an object page with a non-numeric PID...it's a collection!
if (preg_match($pattern1, $page, $matches) === 1) {
if ($matches[1] === 'islandora' && $matches[2] === 'root') { // if we matched islandora:root... return FALSE.
// drupal_set_message(__FUNCTION__." -root collection- returning ".$previous['pid'], 'status');
// $_SESSION['dg7']['collection'] = FALSE;
if ($user->uid > 0) { session_cache_set('dg7-collection', FALSE); }
return ($previous['pid'] = FALSE);
}
$previous['pid'] = $pid = $matches[1] . ':' . $matches[2];
// drupal_set_message(__FUNCTION__." -islandora object- returning ".$pid, 'status');
// $_SESSION['dg7']['collection'] = $pid;
if ($user->uid > 0) { session_cache_set('dg7-collection', $pid); }
return $pid;
}
// Nope, check for a $pattern2 match...
// If preg_match === 1 here then we found an /islandora/search/ page. Preserve the status quo.
$pattern2 = '/^islandora\/search\//'; // Tests for any search page...
if (preg_match($pattern2, $page) === 1 && ($user->uid > 0)) {
// If we already have collection_search control return information from it.
// $pid = $_SESSION['dg7']['collection'] = (isset($previous['pid']) ? $previous['pid'] : FALSE );
$pid = session_cache_set('dg7-collection', (isset($previous['pid']) ? $previous['pid'] : FALSE ));
// drupal_set_message(__FUNCTION__." -islandora search- returning ".$pid, 'status');
return $pid;
}
// If we are anywhere else, unset the $_SESSION variable and return FALSE.
// drupal_set_message(__FUNCTION__." -reset- returning FALSE", 'status');
// $_SESSION['dg7']['collection'] = FALSE;
if ($user->uid > 0) { session_cache_set('dg7-collection', FALSE); }
return ($previous['pid'] = $pid = FALSE);
}
/**
* Implements hook_islandora_solr_query_alter().
*
* The hook implementation does two things:
* 1) Sets the implict Solr search behavior to AND instead of OR.
* 2) Sets collection-specific sort order when the query has a collection focus.
*
* @param $isq
* The IslandoraSolrQueryProcessor passed by reference.
*/
function dg7_islandora_solr_query_alter(&$isq) {
// Set the AND operator.
$isq->solrParams['q.op'] = 'AND';
// Determine if this is a collection query.
$collection = FALSE;
if (isset($isq->internalSolrParams['f']) && isset($isq->solrParams['fq'])) {
foreach ($isq->solrParams['fq'] as $fq) {
// drupal_set_message(__FUNCTION__ . " in foreach loop fq = '$fq'.", 'status');
if (strstr($fq, 'RELS_EXT_isMemberOfCollection') && (strpos($fq, '/') != FALSE)) {
list($junk, $tail) = explode('/', $fq);
$collection = trim(str_replace('\\', '', $tail), ')' );
// $msg = __FUNCTION__ . ' called with collection = ' . $collection;
// drupal_set_message($msg, 'status');
break;
}
}
}
// Now, set the sort order. Note that sort should be a csv string, not an array!
$isq->solrParams['sort'] = 'mods_extension_primarySort_ss asc'; // everything sorts by mods_extension_primarySort_ss first!
switch ($collection) {
// Sort by date then hidden_creators
case 'grinnell:alumni-oral-histories': // Alumni Oral Histories
case 'grinnell:phpp-oral-history' : // PHPP Oral History
$isq->solrParams['sort'] .= ', mods_originInfo_dateCreated_sort asc';
$isq->solrParams['sort'] .= ', mods_extension_hidden_creators_ss asc';
break;
// Sort by date then label.
case 'grinnell:phpp': // The Poweshiek History Preservation Project
case 'grinnell:phpp-community': // PHPP Community Contributions
case 'grinnell:phpp-dcl': // PHPP Drake Community Library Archives
case 'grinnell:phpp-ghm': // PHPP Grinnell Historical Museum
case 'grinnell:college-history': // The Early College History collection
case 'grinnell:college-handbooks': // The College Handbooks collection
case 'grinnell:gwcc': // The George Washington Cook Correspondence
case 'grinnell:postcards': // Historic Iowa Postcards
case 'grinnell:geology': // Geology (Fossils) Collection
case 'grinnell:physics-museum': // Physics Museum
case 'grinnell:grinnell-in-china': // Grinnell In China
case 'grinnell:ancient-coins': // Ancient Coins
case 'grinnell:digital-stories-social-justice': // Digital Stores for Social Justice
$isq->solrParams['sort'] .= ', mods_originInfo_dateCreated_sort asc';
$isq->solrParams['sort'] .= ', fgs_label_s asc';
break;
// Sort by date (index), otherDate, then label.
case 'grinnell:jimmy-ley': // The Jimmy Ley Collection
$isq->solrParams['sort'] .= ', mods_originInfo_dateCreated_sort asc';
$isq->solrParams['sort'] .= ', mods_originInfo_displayLabel_Date_Created_dateOther_ss asc';
$isq->solrParams['sort'] .= ', fgs_label_s asc';
break;
// Sort by creators(s), then date, then label.
case 'grinnell:gic': // The Grinnell In China collection
case 'grinnell:faculty-scholarship': // The Faculty Scholarship collection
case 'grinnell:student-scholarship': // The Student Scholarship collection
case 'grinnell:curricular-materials': // The Syllabi and Curricular Materials collection
case 'grinnell:faulconer': // The Faulconer Art collection
case 'grinnell:soviet-graphic-art': // The Faulconer's Soviet Graphic Art sub-collection
case 'grinnell:recent-art-acquisitions': // The Faulconer's Recent Acquisitions sub-collection
case 'grinnell:faulconer-suppressed':
case 'grinnell:studio-student-art': // Studio Student Art sub-collection
// case 'grinnell:db2d': // Digital Bridges to Dance sub-collection...reverted back to default sort on 8-Jul-2020
$isq->solrParams['sort'] .= ', mods_extension_creators_ss asc';
$isq->solrParams['sort'] .= ', mods_originInfo_dateCreated_sort asc';
$isq->solrParams['sort'] .= ', fgs_label_s asc';
break;
// Sort by label then date.
default: // Not entering a specialized collection.
$isq->solrParams['sort'] .= ', fgs_label_s asc';
$isq->solrParams['sort'] .= ', mods_originInfo_dateCreated_sort asc';
break;
}
// drupal_set_message('<pre> isq after query_alter: '. print_r($isq, true) .'</pre>');
return;
}
/**
* Implements hook_views_api( ).
*
*/
function dg7_views_api( ) {
$return = array(
'api' => '3.0',
'path' => drupal_get_path('module', 'dg7') . '/includes/views',
);
return $return;
}
/**
* Implements hook_theme_registry_alter().
*
* This code tells Drupal to override the islandora-solr-teaser.tpl.php file with
* a copy found in this module's "templates" folder. Pulled (and corrected) from
* http://www.midwesternmac.com/blogs/jeff-geerling/overriding-template-file
*
*
function dg7_theme_registry_alter(&$theme_registry) {
// Override the default islandora-solr-teaser.tpl.php with our own.
if (isset($theme_registry['islandora_solr_teaser'])) { $module_path = drupal_get_path('module', 'dg7');
// $theme_registry['islandora_solr_teaser']['theme path'] = $module_path;
$theme_registry['islandora_solr_teaser']['path'] = $module_path;
// $theme_registry['islandora_solr_teaser']['template'] = $module_path . '/templates/islandora-solr-teaser';
$theme_registry['islandora_solr_teaser']['template'] = 'templates/islandora-solr-teaser';
}
return;
} */
/**
* No longer needed as of 9-August-2017! We now use hook_islandora_solr_query_alter instead.
* Implements hook_islandora_solr_views_query_alter.
* This CUSTOM hook is called from execute() in ..islandora_solr_views/islandora_solr_views_query.inc
*/
/**
* Implementation of hook_form_FORM_ID_alter().
* Moved to islandora_solr_collection_search.module on 27-Aug-2015.
*/
/**
* The following executes a SPARQL query via Tuque and returns the results as an associative array.
*
* @param string $query
* The SPARQL query to be executed.
*
*
function dg7_sparql_query($query) {
$tuque = islandora_get_tuque_connection( );
$results = $tuque->repository->ri->sparqlQuery($query);
return $results;
}
global $user;
// Fetch some pertinent user data.
if ($user->uid != 0) {
$userClause = "(bound(?user) && ?user='{$user->name}') || ";
} else {
$userClause = " ";
}
$rc = "(bound(?role) && (?role = ";
foreach ($user->roles as $ur) {
$rc .= "'$ur' || ";
}
$rolesClause = trim($rc," |")."))";
$collection_query = <<<EOQ
SELECT DISTINCT ?object ?title
FROM <#ri>
WHERE {
?object ?collection_predicate <info:fedora/islandora:root> ;
<fedora-model:label> ?title ;
<fedora-model:hasModel> <info:fedora/islandora:collectionCModel> . ?object <fedora-model:state> <fedora-model:Active>
OPTIONAL {{?object <info:fedora/fedora-system:def/relations-external#isConstituentOf> ?compound} UNION {?object <http://islandora.ca/ontology/relsext#isViewableByRole> ?role} UNION {?object <http://islandora.ca/ontology/relsext#isViewableByUser> ?user}}
FILTER(regex(str(?object), "info:fedora/{$namespace}:"))
FILTER(sameTerm(?collection_predicate, <fedora-rels-ext:isMemberOfCollection>) || sameTerm(?collection_predicate, <fedora-rels-ext:isMemberOf>))
FILTER(!bound(?compound))
FILTER((!bound(?role) && !bound(?user)) || {$userClause} (bound(?role) && ({$rolesClause})))
} ORDER BY ?title
EOQ;
$results = dg7_sparql_query($collection_query);
foreach ($results as $result) {
$id = $result['object']['value'];
list($ns,$collection) = explode(':',$id);
$search_collection = '*'.$collection;
// $collections[$search_collection] = $result['title']['value'];
$collections[$search_collection] = $collection;
}
return $collections;
}
/* The following query was captured from the islandora_solr module as a SPARQL example which is permissions (XACML) aware.
SELECT DISTINCT ?object ?title ?owner ?date_modified
FROM <#ri>
WHERE {
?object ?collection_predicate <info:fedora/islandora:root> ;
<fedora-model:label> ?title ;
<fedora-model:ownerId> ?owner ;
<fedora-view:lastModifiedDate> ?date_modified ;
<fedora-model:hasModel> ?model . ?object <fedora-model:state> <fedora-model:Active> .
OPTIONAL {{?object <info:fedora/fedora-system:def/relations-external#isConstituentOf> ?compound} UNION {?object <http://islandora.ca/ontology/relsext#isViewableByRole> ?role} UNION {?object <http://islandora.ca/ontology/relsext#isViewableByUser> ?user}}
FILTER(regex(str(?object), "info:fedora/grinnell:")) FILTER(sameTerm(?collection_predicate, <fedora-rels-ext:isMemberOfCollection>) || sameTerm(?collection_predicate, <fedora-rels-ext:isMemberOf>)) FILTER(!bound(?compound)) FILTER((!bound(?role) && !bound(?user)) || (bound(?user) && ?user='anonymous') || (bound(?role) && (?role='anonymous user')))
}ORDER BY ?title
*/
/**
* Implementation of hook_init( ).
*/
function dg7_init( ) { return; }
/**
* Implementation of hook_cron( ).
*/
function dg7_cron( ) { return; }
/**
* Set default advanced Solr search options for all 'select' controls.
*
* @param array $form
* An associative array containing form structure.
* @param array $form_state
* An associative array containing form state.
*
function dg7_set_default_advanced_Solr_search_options(&$form, &$form_state) {
foreach ($form['terms'] as $index => &$term) {
if (is_int($index) && $term['field']['#type'] === 'select') {
$term['field']['#options'] = array();
$term['field']['#options']['catch_all_fields_mt'] = "Keyword";
$term['field']['#options']['dc.title'] = "Title";
$term['field']['#options']['dc.contributor'] = "Creator/Contributor";