-
Notifications
You must be signed in to change notification settings - Fork 11
/
functions.php
82 lines (67 loc) · 2.62 KB
/
functions.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
<?php
function bigpicture_random_featured_records_html($recordType, $featuredRecords, $countStart)
{
$html = '';
$i = $countStart;
if ($featuredRecords) {
foreach ($featuredRecords as $featuredRecord) {
$html .= get_view()->partial('common/featured.php', array('recordType' => $recordType, 'featuredRecord' => $featuredRecord, 'slideCount' => $i));
$i++;
}
}
if ($recordType == 'exhibit') {
$html = apply_filters('exhibit_builder_display_random_featured_exhibit', $html);
}
return $html;
}
function bigpicture_get_random_featured_records($recordType, $num = 0, $hasImage = true)
{
return get_records($recordType, array('featured' => 1,
'sort_field' => 'random',
'hasImage' => $hasImage), $num);
}
function bigpicture_featured_html() {
$recordTypes = ['Exhibit', 'Collection', 'Item'];
$html = '';
$countStart = 0;
foreach ($recordTypes as $recordType) {
if ($recordType == 'Exhibit' && plugin_is_active('ExhibitBuilder')) {
continue;
}
$randomRecords = null;
$randomRecords = bigpicture_get_random_featured_records($recordType);
if ((get_theme_option("Display Featured $recordType") !== '0') && ($randomRecords !== null)) {
$html .= bigpicture_random_featured_records_html(strtolower($recordType), $randomRecords, $countStart);
$countStart = $countStart + count($randomRecords);
}
}
return $html;
}
function bigpicture_check_for_featured_records() {
$recordTypes = ['Exhibit', 'Collection', 'Item'];
$featuredPresent = false;
foreach ($recordTypes as $recordType) {
if (get_theme_option('display_featured_' . strtolower($recordType)) == '1') {
if ($recordType == 'Exhibit' && plugin_is_active('ExhibitBuilder')) {
continue;
}
$randomRecords = bigpicture_get_random_featured_records($recordType);
if (count($randomRecords) > 0) {
$featuredPresent = true;
break;
}
}
}
return $featuredPresent;
}
function bigpicture_get_square_thumbnail_url($file, $view) {
if ($file->hasThumbnail()) {
$squareThumbnail = file_display_url($file, 'square_thumbnail');
} else {
$mimeType = $file->mime_type;
$fileType = (strpos($mimeType, 'image')) ? 'image' : 'video';
$squareThumbnail = $view->baseUrl() . '/application/views/scripts/images/fallback-' . $fileType . '.png';
}
return $squareThumbnail;
}
?>