This repository has been archived by the owner on Jun 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
custom.php
284 lines (246 loc) · 8.53 KB
/
custom.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
<?php
/**
* "Thin" Theme for Neatline project
*
* Use this file to define customized helper functions, filters, or 'hacks'
* defined specifically for use in your Omeka theme. Note that helper functions
* that are designed for portability across themes should be grouped in to a
* plugin whenever possible.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* @package omeka
* @author "Scholars Lab"
* @copyright 2010 The Board and Visitors of the University of Virginia
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache 2.0
* @version Release: 0.0.1-pre
* @link http://www.scholarslab.org
*
* PHP version 5
*
*/
?>
<?php
// custom filters from Omeka core
//add_filter(array('Display', 'Item', 'Dublin Core', 'Title'));
define('EXHIBIT_BUILDER_THEME_DIR', 'exhibit-builder/exhibits');
/**
* Returns the style sheet for the theme. It will use the argument
* passed to the function first, then the theme_option for Style Sheet, then
* a default style sheet.
*
* @param $styleSheet The name of the style sheet to use. (null by default)
*
**/
function neatline_get_stylesheet($stylesheet = null)
{
if(!$stylesheet) {
// $styleSheet = get_theme_option('Style Sheet') ? get_theme_option('Style Sheet') : 'brown';
}
return get_theme_option('Style Sheet');
}
/**
* Overrides default dispaly_random_featured_item
*
* Returns the HTML markup for displaying a random featured item. Most
* commonly used on the home page of public themes.
*
* @since 0.10
* @param boolean $withImage Whether or not the featured item should have an
* image associated with it. If set to true, this will either display a
* clickable square thumbnail for an item, or it will display "You have no
* featured items." if there are none with images.
*
* @return string HTML
**/
function custom_display_random_featured_item($withImage=false)
{
$featuredItem = random_featured_item($withImage);
if ($featuredItem) {
$itemTitle = item('Dublin Core', 'Title', array(), $featuredItem);
$html = '<a href="' . record_uri($featuredItem, 'show') .'">';
if(item_has_thumbnail ($featuredItem)) {
$html .= item_square_thumbnail(array('width' => '60px', 'height' => '60px', 'class' => 'featured-image'), 0, $featuredItem);
}
$html .= '<span class="featured-caption-title">' . $itemTitle . '</span>';
if ($itemDescription = item('Dublin Core', 'Description', array('snippet'=>150), $featuredItem)) {
$html .= '<span class="featured-caption-desc">' . $itemDescription . '</span>';
}
$html .= '</a>';
} else {
$html .= '<p>No featured items are available.</p>';
}
return $html;
}
/**
*
* @param <type> $sources
* @param <type> $directory
* @return <type>
*/
function stylesheet_link_tag($sources, $options = array(), $directory='css')
{
foreach(explode(',', $sources) as $file){
$href = src(trim($file), $directory, 'css');
return "<link rel=\"stylesheet\" type=\"text/css\" href=\"$href\">\n";
}
}
function image_tag($file, $options = array(), $directory = 'images')
{
//TODO fix options array
return "<img src=\"" . src(trim($file), $directory) . " />";
}
function custom_nav(array $links, $style = '', $maxDepth = 0)
{
// Get the current uri from the request
$current = Zend_Controller_Front::getInstance()->getRequest()->getRequestUri();
$nav = '';
foreach( $links as $text => $uri ) {
// Get the subnavigation attributes and links
$subNavLinks = null;
if (is_array($uri)) {
$subNavLinks = $uri['subnav_links'];
if (!is_array($subNavLinks)) {
$subNavLinks = array();
}
$subNavAttributes = $uri['subnav_attributes'];
if (!is_array($subNavAttributes)) {
$subNavAttributes = array();
}
$uri = (string) $uri['uri'];
}
// Build a link if the uri is available, otherwise simply list the text without a hyperlink
$nav .= '<li class="' . $style . ' ' . text_to_id('nav', strtolower($text));
if ($uri == '') {
$nav .= '">' . html_escape($text);
} else {
// If the uri is the current uri, then give it the 'current' class
$nav .= (is_current_uri($uri) ? ' current':'') . '">' . '<a class="' . text_to_id('nav-anchor', strtolower($text)) . '" href="' . html_escape($uri) . '">' . html_escape($text) . '</a>';
}
// Display the subnavigation links if they exist and if the max depth has not been reached
if ($subNavLinks !== null && ($maxDepth === null || $maxDepth > 0)) {
$subNavAttributes = !empty($subNavAttributes) ? ' ' . _tag_attributes($subNavAttributes) : '';
$nav .= "\n" . '<ul' . $subNavAttributes . '>' . "\n";
if ($maxDepth === null) {
$nav .= nav($subNavLinks, null);
} else {
$nav .= nav($subNavLinks, $maxDepth - 1);
}
$nav .= '</ul>' . "\n";
}
$nav .= '</li>' . "\n";
}
return $nav;
}
/**
* Custom javascript include helper which allows a comma-separated list of
* javascripts to include
*
* <?php javascript_include_tag('script, plugins'); ?>
*
* @param string $sources Comma separated list of javascript files, without .js
* extension. Specifying 'default' will load the default javascript files in
* the $directory parameter.
* @param string $dir The directory in which to look for javascript files.
* Recommended to leave the default value.
*/
function javascript_include_tag($sources, $directory="javascripts")
{
// if(strcmp($sources, 'default')) {
// add add .js files in $directory
//$sources = ''; // reset sources variable
//$sources = custom_get_js_files(common($directory));
//}
foreach(explode(',', $sources) as $file){
$href = src(trim($file), $directory, 'js');
echo "<script type=\"text/javascript\" src=\"$href\"></script>\n";
}
}
function custom_get_js_files($directory)
{
$sources = '';
$dir = new DirectoryIterator($directory);
foreach($dir as $fileinfo) {
if(preg_match("/*.jpg/", $fileInfo->getFilename())) {
$sources .= $fileInfo->getFilename() . ",";
}
}
return $sources;
}
/**
* Create a nested navigation
* @param <type> $exhibit
* @param <type> $show_all_pages
*/
function neatline_nested_nav($exhibit = null, $show_all_pages = false)
{
if (!$exhibit) {
if (!($exhibit = exhibit_builder_get_current_exhibit())) {
return;
}
}
$html = '<ul class="exhibit-section-nav">';
foreach ($exhibit->Sections as $section) {
$html .= '<li class="exhibit-nested-section' . (exhibit_builder_is_current_section($section) ? ' current' : '') . '"><a class="exhibit-section-title" href="' . html_escape(exhibit_builder_exhibit_uri($exhibit, $section)) . '">' . html_escape($section->title) . '</a>';
if ($show_all_pages == true || exhibit_builder_is_current_section($section)) {
$html .= exhibit_builder_page_nav($section);
}
$html .= '</li>';
}
$html .= '</ul>';
return $html;
}
/**
* Overrides head/foot functions with Rails-esque partial loader
*
* @see common()
*
* @param string $file Relative path to partial
* @param array $vars
* @return void
*
*/
function partial($file, $vars = array())
{
common($file, $vars);
return;
}
/**
* Overrides head/foot functions with Rails-esque render function
*
* @see common()
*
* @param string $file Relative path to partial
* @param array $vars
* @return void
*
*/
function render($file, $vars = array())
{
common("_" . $file, $vars);
return;
}
/**
* Helper function to remove all whitespace and formatting before checking
* to see if the title is empty
*
* @param string $title Title string to check
*
* @return string The DC title, or string '[Untitled]'
*/
//function show_untitled_items($title)
//{
// var $prepTitle = trim(strip_formatting($title));
//
// if(empty($prepTitle)) {
// $title = '[Untitled]';
// }
//
// return $title;
//}