-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfunctions.php
211 lines (185 loc) · 6.86 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
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
<?php
function use_foundation_navigation($ulClass) {
$view = get_view();
$nav = new Omeka_Navigation;
$nav->loadAsOption(Omeka_Navigation::PUBLIC_NAVIGATION_MAIN_OPTION_NAME);
$nav->addPagesFromFilter(Omeka_Navigation::PUBLIC_NAVIGATION_MAIN_FILTER_NAME);
$html = $view->navigation()->menu($nav)->setPartial('common/foundation-nav.php')->setUlClass($ulClass)->render();
$view->navigation()->menu($nav)->setPartial(null);
return $html;
}
function foundation_exhibit_page_tree($exhibit, $currentPage = null) {
$view = get_view();
$pages = $exhibit->PagesByParent;
if (!($pages && isset($pages[0]))) {
return '';
}
$view->_exhibit = $exhibit;
$view->_pages = $pages;
$ancestorIds = array();
if ($currentPage) {
$pagesById = $view->_exhibit->PagesById;
$currentId = $currentPage->parent_id;
while ($currentId) {
$currentPage = $pagesById[$currentId];
$ancestorIds[$currentPage->id] = $currentPage->id;
$currentId = $currentPage->parent_id;
}
}
$html = '<ul class="vertical menu"';
foreach ($pages[0] as $topPage) {
if ($currentPage && $topPage->id === $currentPage->id) {
$html = '<li class="current">';
} else if ($ancestorIds && isset($ancestorIds[$topPage->id])) {
$html = '<li class="parent">';
} else {
$html = '<li>';
}
$html .= '<a href="' . exhibit_builder_exhibit_uri($view->_exhibit, $topPage) . '">'
. metadata($topPage, 'menu_title') .'</a>';
if (isset($view->_pages[$page->id])) {
$html .= '<ul>';
foreach ($view->_pages[$page->id] as $childPage) {
$html .= $view->_renderPageBranch($childPage, $currentPage, $ancestorIds);
}
$html .= '</ul>';
}
$html .= '</li>'; }
$html .= '</ul>';
return $html;
}
function foundation_homepage_intro_background() {
$backgroundImage = get_theme_option('Homepage Intro Background');
if ($backgroundImage) {
$storage = Zend_Registry::get('storage');
$backgroundImage = $storage->getUri($storage->getPathByType($backgroundImage, 'theme_uploads'));
return $backgroundImage;
}
}
function foundation_random_featured_records_html($recordType)
{
$html = '';
$recordSinglePartial = [
'exhibit' => 'exhibit-builder/exhibits/single.php',
'collection' => 'collections/single.php',
'item' => 'items/single.php',
];
$featuredRecords = get_records(ucfirst($recordType), array('featured' => 1,
'sort_field' => 'random'), 1);
if ($featuredRecords) {
foreach ($featuredRecords as $featuredRecord) {
$html .= get_view()->partial($recordSinglePartial[$recordType], array(
$recordType => $featuredRecord,
'thumbnailSize' => 'fullsize',
'featured' => 'featured',
));
}
}
if ($recordType == 'exhibit') {
$html = apply_filters('exhibit_builder_display_random_featured_exhibit', $html);
}
return $html;
}
/**
* Returns a breadcrumb for a given page.
*
* @uses public_url(), html_escape()
* @param integer|null The id of the page. If null, it uses the current simple page.
* @param string $separator The string used to separate each section of the breadcrumb.
* @param boolean $includePage Whether to include the title of the current page.
*/
function foundation_breadcrumbs($pageId = null, $seperator=null, $includePage=true)
{
$html = '';
if ($seperator) {
$html .= '<style>.breadcrumbs li:not(:last-child)::after { content: "' . $seperator . '"; }</style>';
}
$html .= '<nav aria-label="You are here:" role="navigation"><ul class="breadcrumbs">';
if ($pageId === null) {
$page = get_current_record('simple_pages_page', false);
} else {
$page = get_db()->getTable('SimplePagesPage')->find($pageId);
}
if ($page) {
$ancestorPages = get_db()->getTable('SimplePagesPage')->findAncestorPages($page->id);
$bPages = array_merge(array($page), $ancestorPages);
// make sure all of the ancestors and the current page are published
foreach($bPages as $bPage) {
if (!$bPage->is_published) {
$html = '';
return $html;
}
}
// find the page links
$pageLinks = array();
foreach($bPages as $bPage) {
if ($bPage->id == $page->id) {
if ($includePage) {
$pageLinks[] = '<li><span class="current">' . html_escape($bPage->title) . '</span></li>';
}
} else {
$pageLinks[] = '<li><a href="' . public_url($bPage->slug) . '">' . html_escape($bPage->title) . '</a></li>';
}
}
$pageLinks[] = '<li><a href="'. public_url('') . '">' . __('Home') . '</a></li>';
// create the bread crumb
$html .= implode('', array_reverse($pageLinks));
}
$html .= '</ul></nav>';
return $html;
}
function foundation_display_attached_media($item, $layout) {
$html = '';
$view = get_view();
switch ($layout) {
case 'lightgallery':
$html .= lightgallery($item->Files);
break;
case 'lightgallery-list':
$html .= lightgallery_other_files($item->Files);
break;
case 'list':
$html .= $view->partial('common/media-list.php', [
'files' => $item->Files,
]);
break;
case 'grid':
$html .= item_image_gallery(array(
'wrapper' => array(
'class' => 'media-grid'
),
'linkWrapper' => array(
'class' => 'item-file',
),
'link' => array(
'class' => 'thumbnail',
),
));
break;
case 'embed':
$html .= '<div id="item-images" class="media-embed">';
$html .= files_for_item(array(
'imageSize' => 'fullsize',
));
$html .= '</div>';
break;
}
return $html;
}
function foundation_mobile_theme_logo() {
$logo = get_theme_option('mobile_logo');
if ($logo) {
$storage = Zend_Registry::get('storage');
$uri = $storage->getUri($storage->getPathByType($logo, 'theme_uploads'));
return '<img src="' . $uri . '" alt="' . option('site_title') . '" />';
}
}
function foundation_theme_banner()
{
$banner = get_theme_option('Banner');
$view = get_view();
$storage = Zend_Registry::get('storage');
$uri = $storage->getUri($storage->getPathByType($banner, 'theme_uploads'));
return $uri;
}
add_translation_source(dirname(__FILE__) . '/languages');