forked from charvolant/bigstuff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
526 lines (491 loc) · 23 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
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
<?php
require_once LIB_DIR . '/globals.php';
/* The namespace/name pairs for DC terms metadata */
global $AUTHOR_ELEMENT, $TITLE_ELEMENT, $DATE_ELEMENT, $PUBLISHER_ELEMENT, $SOURCE_ELEMENT;
$AUTHOR_ELEMENT = array('Dublin Core', 'Creator');
$TITLE_ELEMENT = array('Dublin Core', 'Title');
$DATE_ELEMENT = array('Dublin Core', 'Date');
$PUBLISHER_ELEMENT = array('Dublin Core', 'Publisher');
$SOURCE_ELEMENT = array('Dublin Core', 'Source');
global $EDITOR_ELEMENT, $JOURNAL_ELEMENT, $BOOK_ELEMENT, $INSTITUTION_ELEMENT, $VOLUME_ELEMENT;
global $NUMBER_ELEMENT, $PAGES_ELEMENT, $DOI_ELEMENT, $ISBN_ELEMENT, $URL_ELEMENT, $LOCAL_URL_ELEMENT;
global $DIRECTOR_ELEMENT, $PRODUCER_ELEMENT;
$EDITOR_ELEMENT = array('Item Type Metadata', 'Editor');
$JOURNAL_ELEMENT = array('Item Type Metadata', 'Journal');
$BOOK_ELEMENT = array('Item Type Metadata', 'Book');
$INSTITUTION_ELEMENT = array('Item Type Metadata', 'Institution');
$VOLUME_ELEMENT = array('Item Type Metadata', 'Volume');
$NUMBER_ELEMENT = array('Item Type Metadata', 'Number');
$PAGES_ELEMENT = array('Item Type Metadata', 'Pages');
$DOI_ELEMENT = array('Item Type Metadata', 'DOI');
$ISBN_ELEMENT = array('Item Type Metadata', 'ISBN');
$URL_ELEMENT = array('Item Type Metadata', 'URL');
$LOCAL_URL_ELEMENT = array('Item Type Metadata', 'Local URL');
$DIRECTOR_ELEMENT = array('Item Type Metadata', 'Director');
$PRODUCER_ELEMENT = array('Item Type Metadata', 'Producer');
/** Wrap the sortable shortcodes */
add_shortcode('items', 'bigstuff_sortable_items_shortcode');
add_shortcode('collections', 'bigstuff_sortable_collections_shortcode');
/**
* Get a theme option wuith a default value
*
* @param string $option The theme option name
* @param $def The default value if the option is not set
* @param string|null $theme The theme name (defaults to the current theme)
* @return string
*/
function get_theme_option_with_default($option, $def, $theme = null) {
$value = get_theme_option($option, $theme);
if ($value == null || strlen($value) == 0)
$value = $def;
return $value;
}
/**
* Try and extract a year from a date.
* <p>
* This uses the PHP parse_date function.
* Finding a year is conditional on the date being in a parsable for, otherwise the entire date is returned.
*
* @param string|null $date The date (null or 'na' for no date)
* @return string
*/
function get_year($date) {
if ($date == null || $date == 'na')
return null;
$parse = date_parse($date);
if ($parse['error_count'] > 0)
return $date;
$year = $parse['year'];
if ($year != null && strlen($year) > 0)
return $year;
return $date;
}
/**
* Get metadata, returning null if the metadata element is absent
*
* @param Record $item The item
* @param string|array $key The metadata key
* @param array $options Metadata options
* @return The metadata values
*
* @see metadata
*/
function safe_metadata($item, $key, $options = null) {
try {
return strip_formatting(metadata($item, $key, $options));
} catch (Omeka_View_Exception $ex) {
return null;
} catch (Omeka_Record_Exception $ex) {
return null;
}
}
/**
* Add an element to a citation and return the constructed citation.
* <p>
* Elements that return null or emprty strings or
*
* @param string $citation The current citation string
* @param Item item The
* @param array|string $element The element name to add (null, empty or 'na') for none
* @param string|null $begin A prefix to the element, if the element is included
* @param string|null $end A suffix to the element, if the element is included
* @param string|null $separator
*
* @return string
*/
function add_element($citation, $element, $begin = null, $end = null, $separator = ', ') {
if ($element == null)
return $citation;
if (is_array($element))
$element = join(', ', $element);
$element = trim($element);
if (strlen($element) == 0 || $element == 'na')
return $citation;
if ($separator && strlen($citation) > 0)
$citation .= $separator;
if ($begin)
$citation .= $begin;
$citation .= $element;
if ($end)
$citation .= $end;
return $citation;
}
/**
* Make an article citation
*
* @param Item $item The item
* @param boolean $html Use html formatting
* @param boolean $full Full citation
* @return string
*/
function make_article_citation($item, $html, $full) {
global $AUTHOR_ELEMENT, $DATE_ELEMENT, $TITLE_ELEMENT, $JOURNAL_ELEMENT, $PUBLISHER_ELEMENT, $LOCATION_ELEMENT, $VOLUME_ELEMENT, $NUMBER_ELEMENT, $PAGES_ELEMENT, $DOI_ELEMENT;
$collection = get_collection_for_item($item);
$citation = add_element('', safe_metadata($item, $AUTHOR_ELEMENT));
if (!$full)
$citation = add_element($citation, safe_metadata($item, $TITLE_ELEMENT), $html ? '<em>' : null, $html ? '</em>' : null);
else {
$citation = add_element($citation, get_year(safe_metadata($item, $DATE_ELEMENT)), null, null, ' ');
$citation = add_element($citation, safe_metadata($item, $TITLE_ELEMENT), '\'', '\'');
$journal = safe_metadata($item, $JOURNAL_ELEMENT);
if (!$journal && $collection)
$journal = safe_metadata($collection, $TITLE_ELEMENT);
$citation = add_element($citation, $journal, $html ? '<em>' : null, $html ? '</em>' : null);
$vnp = add_element('', safe_metadata($item, $VOLUME_ELEMENT));
$vnp = add_element($vnp, safe_metadata($item, $NUMBER_ELEMENT), '(', ')', null);
$vnp = add_element($vnp, safe_metadata($item, $PAGES_ELEMENT), null, null, ':');
$citation = add_element($citation, $vnp);
$publisher = safe_metadata($item, $PUBLISHER_ELEMENT);
if (!$publisher && $collection)
$publisher = safe_metadata($collection, $PUBLISHER_ELEMENT);
$citation = add_element($citation, $publisher);
$location = safe_metadata($item, $LOCATION_ELEMENT);
if (!$location && $collection)
$location = safe_metadata($collection, $LOCATION_ELEMENT);
$citation = add_element($citation, $location);
$citation = add_element($citation, safe_metadata($item, $DOI_ELEMENT), $html ? '<span class="citation-url">' : null, $html ? '</span>' : null);
}
return $citation;
}
/**
* Make a conference paper citation
*
* @param Item $item The item
* @param boolean $html Use html formatting
* @param boolean $full Full citation
* @return string
*/
function make_paper_citation($item, $html, $full) {
global $AUTHOR_ELEMENT, $DATE_ELEMENT, $TITLE_ELEMENT, $BOOK_ELEMENT, $EDITOR_ELEMENT, $PUBLISHER_ELEMENT, $LOCATION_ELEMENT, $PAGES_ELEMENT, $DOI_ELEMENT;
$collection = get_collection_for_item($item);
$citation = add_element('', safe_metadata($item, $AUTHOR_ELEMENT));
if (!$full)
$citation = add_element($citation, safe_metadata($item, $TITLE_ELEMENT), $html ? '<em>' : null, $html ? '</em>' : null);
else {
$citation = add_element($citation, get_year(safe_metadata($item, $DATE_ELEMENT)), null, null, ' ');
$citation = add_element($citation, safe_metadata($item, $TITLE_ELEMENT), '\'', '\'');
$conference = safe_metadata($item, $BOOK_ELEMENT);
if (!$conference && $collection)
$conference = safe_metadata($collection, $TITLE_ELEMENT);
$citation = add_element($citation, $conference, $html ? __('in') . ' <em>' : null, $html ? '</em>' : null);
$editor = safe_metadata($item, $EDITOR_ELEMENT);
if (!$editor && $collection)
$editor = safe_metadata($collection, $AUTHOR_ELEMENT);
$citation = add_element($citation, $editor, __('ed. '));
$citation = add_element($citation, safe_metadata($item, $PAGES_ELEMENT));
$publisher = safe_metadata($item, $PUBLISHER_ELEMENT);
if (!$publisher && $collection)
$publisher = safe_metadata($collection, $PUBLISHER_ELEMENT);
$citation = add_element($citation, $publisher);
$location = safe_metadata($item, $LOCATION_ELEMENT);
if (!$location && $collection)
$location = safe_metadata($collection, $LOCATION_ELEMENT);
$citation = add_element($citation, $location);
$citation = add_element($citation, safe_metadata($item, $DATE_ELEMENT));
$citation = add_element($citation, safe_metadata($item, $DOI_ELEMENT), $html ? '<span class="citation-url">' : null, $html ? '</span>' : null);
}
return $citation;
}
/**
* Make a book citation
*
* @param Item $item The item
* @param boolean $html Use html formatting
* @param boolean $full Full citation
* @return string
*/
function make_book_citation($item, $html, $full) {
global $AUTHOR_ELEMENT, $DATE_ELEMENT, $TITLE_ELEMENT, $EDITOR_ELEMENT, $VOLUME_ELEMENT, $PUBLISHER_ELEMENT, $LOCATION_ELEMENT, $PAGES_ELEMENT, $ISBN_ELEMENT;
$citation = add_element('', safe_metadata($item, $AUTHOR_ELEMENT));
if ($full)
$citation = add_element($citation, get_year(safe_metadata($item, $DATE_ELEMENT)), null, null, ' ');
$citation = add_element($citation, safe_metadata($item, $TITLE_ELEMENT), $html ? '<em>' : null, $html ? '</em>' : null);
if ($full) {
$citation = add_element($citation, safe_metadata($item, $VOLUME_ELEMENT), __('vol. '));
$citation = add_element($citation, safe_metadata($item, $EDITOR_ELEMENT), __('ed. '));
$citation = add_element($citation, safe_metadata($item, $PAGES_ELEMENT), __('pp. '));
$citation = add_element($citation, safe_metadata($item, $PUBLISHER_ELEMENT));
$citation = add_element($citation, safe_metadata($item, $LOCATION_ELEMENT));
$citation = add_element($citation, safe_metadata($item, $ISBN_ELEMENT), $html ? '<span class="citation-url">' : null, $html ? '</span>' : null);
}
return $citation;
}
/**
* Make a manual citation
*
* @param Item $item The item
* @param boolean $html Use html formatting
* @param boolean $full Full citation
* @return string
*/
function make_manual_citation($item, $html, $full) {
global $AUTHOR_ELEMENT, $DATE_ELEMENT, $TITLE_ELEMENT, $NUMBER_ELEMENT, $INSTITUTION_ELEMENT, $DOI_ELEMENT;
$citation = '';
if ($full) {
$citation = add_element($citation, safe_metadata($item, $AUTHOR_ELEMENT));
$citation = add_element($citation, get_year(safe_metadata($item, $DATE_ELEMENT)), null, null, ' ');
}
$citation = add_element($citation, safe_metadata($item, $TITLE_ELEMENT), $html ? '<em>' : null, $html ? '</em>' : null);
if ($full) {
$citation = add_element($citation, safe_metadata($item, $NUMBER_ELEMENT));
$citation = add_element($citation, safe_metadata($item, $INSTITUTION_ELEMENT));
$citation = add_element($citation, safe_metadata($item, $DOI_ELEMENT), $html ? '<span class="citation-url">' : null, $html ? '</span>' : null);
}
return $citation;
}
/**
* Make a thesis citation
*
* @param Item $item The item
* @param boolean $html Use html formatting
* @param boolean $full Full citation
* @return string
*/
function make_thesis_citation($item, $html, $full) {
global $AUTHOR_ELEMENT, $DATE_ELEMENT, $TITLE_ELEMENT, $NUMBER_ELEMENT, $INSTITUTION_ELEMENT, $LOCATION_ELEMENT, $DOI_ELEMENT;
$citation = add_element('', safe_metadata($item, $AUTHOR_ELEMENT));
if (!$full)
$citation = add_element($citation, safe_metadata($item, $TITLE_ELEMENT), $html ? '<em>' : null, $html ? '</em>' : null);
else {
$citation = add_element($citation, get_year(safe_metadata($item, $DATE_ELEMENT)), null, null, ' ');
$citation = add_element($citation, safe_metadata($item, $TITLE_ELEMENT), $html ? '<em>' : null, $html ? '</em>, thesis' : null);
$citation = add_element($citation, safe_metadata($item, $NUMBER_ELEMENT));
$citation = add_element($citation, safe_metadata($item, $INSTITUTION_ELEMENT));
$citation = add_element($citation, safe_metadata($item, $LOCATION_ELEMENT));
$citation = add_element($citation, safe_metadata($item, $DOI_ELEMENT), $html ? '<span class="citation-url">' : null, $html ? '</span>' : null);
}
return $citation;
}
/**
* Make an report citation
*
* @param Item $item The item
* @param boolean $html Use html formatting
* @param boolean $full Full citation
* @return string
*/
function make_report_citation($item, $html, $full) {
global $AUTHOR_ELEMENT, $DATE_ELEMENT, $TITLE_ELEMENT, $NUMBER_ELEMENT, $INSTITUTION_ELEMENT, $DOI_ELEMENT;
$citation = '';
if ($full) {
$citation = add_element($citation, safe_metadata($item, $AUTHOR_ELEMENT));
$citation = add_element($citation, get_year(safe_metadata($item, $DATE_ELEMENT)), null, null, ' ');
}
$citation = add_element($citation, safe_metadata($item, $TITLE_ELEMENT), $html ? '<em>' : null, $html ? '</em>' : null);
if ($full) {
$citation = add_element($citation, safe_metadata($item, $NUMBER_ELEMENT));
$citation = add_element($citation, safe_metadata($item, $INSTITUTION_ELEMENT));
$citation = add_element($citation, safe_metadata($item, $DOI_ELEMENT), $html ? '<span class="citation-url">' : null, $html ? '</span>' : null);
}
return $citation;
}
/**
* Make a generic text citation
*
* @param Item $item The item
* @param boolean $html Use html formatting
* @param boolean $full Full citation
* @return string
*/
function make_text_citation($item, $html, $full) {
global $AUTHOR_ELEMENT, $DATE_ELEMENT, $TITLE_ELEMENT, $PUBLISHER_ELEMENT, $DOI_ELEMENT;
$citation = add_element('', safe_metadata($item, $AUTHOR_ELEMENT));
$citation = add_element($citation, safe_metadata($TITLE_ELEMENT), $html ? '<em>' : null, $html ? '</em>' : null);
if ($full) {
$citation = add_element($citation, safe_metadata($item, $PUBLISHER_ELEMENT));
$citation = add_element($citation, safe_metadata($item, $DATE_ELEMENT));
$citation = add_element($citation, safe_metadata($item, $DOI_ELEMENT), $html ? '<span class="citation-url">' : null, $html ? '</span>' : null);
}
return $citation;
}
/**
* Make a website citation
*
* @param Item $item The item
* @param boolean $html Use html formatting
* @param boolean $full Full citation
* @return string
*/
function make_website_citation($item, $html, $full) {
global $DATE_ELEMENT, $TITLE_ELEMENT, $SOURCE_ELEMENT, $LOCAL_URL_ELEMENT;
$citation = add_element("", safe_metadata($item, $TITLE_ELEMENT));
if ($full) {
$source = safe_metadata($item, $SOURCE_ELEMENT);
$local = safe_metadata($item, $LOCAL_URL_ELEMENT);
$citation = add_element($citation, $local ? $local : $source, $html ? '<span class="citation-url">' : null, $html ? '</span>' : null);
$citation = add_element($citation, safe_metadata($item, $DATE_ELEMENT));
}
return $citation;
}
/**
* Make an hyperlink citation
*
* @param Item $item The item
* @param boolean $html Use html formatting
* @param boolean $full Full citation
* @return string
*/
function make_hyperlink_citation($item, $html, $full) {
global $DATE_ELEMENT, $TITLE_ELEMENT, $URL_ELEMENT;
$citation = add_element("", safe_metadata($item, $TITLE_ELEMENT));
if ($full) {
$citation = add_element($citation, safe_metadata($item, $URL_ELEMENT), $html ? '<span class="citation-url">' : null, $html ? '</span>' : null);
$citation = add_element($citation, safe_metadata($item, $DATE_ELEMENT), __('accessed '));
}
return $citation;
}
/**
* Make a moving image citation
*
* @param Item $item The item
* @param boolean $html Use html formatting
* @param boolean $full Full citation
* @return string
*/
function make_moving_image_citation($item, $html, $full) {
global $AUTHOR_ELEMENT, $DATE_ELEMENT, $TITLE_ELEMENT, $DIRECTOR_ELEMENT, $PRODUCER_ELEMENT, $PUBLISHER_ELEMENT;
$citation = add_element("", safe_metadata($item, $TITLE_ELEMENT));
if ($full) {
$citation = add_element($citation, safe_metadata($item, $AUTHOR_ELEMENT));
$citation = add_element($citation, safe_metadata($item, $DIRECTOR_ELEMENT), __('dir. '));
$citation = add_element($citation, safe_metadata($item, $PRODUCER_ELEMENT), __('prod. '));
$citation = add_element($citation, safe_metadata($item, $PUBLISHER_ELEMENT));
$citation = add_element($citation, get_year(safe_metadata($item, $DATE_ELEMENT)));
}
return $citation;
}
/**
* Make a still image citation
*
* @param Item $item The item
* @param boolean $html Use html formatting
* @param boolean $full Full citation
* @return string
*/
function make_still_image_citation($item, $html, $full) {
global $AUTHOR_ELEMENT, $DATE_ELEMENT, $TITLE_ELEMENT, $PUBLISHER_ELEMENT;
$citation = add_element("", safe_metadata($item, $TITLE_ELEMENT));
if ($full) {
$citation = add_element($citation, safe_metadata($item, $AUTHOR_ELEMENT));
$citation = add_element($citation, safe_metadata($item, $PUBLISHER_ELEMENT));
$citation = add_element($citation, get_year(safe_metadata($item, $DATE_ELEMENT)));
}
return $citation;
}
/**
* Make a generic citation
*
* @param Item $item The item
* @param boolean $html Use html formatting
* @param boolean $full Full citation
* @return string
*/
function make_default_citation($item, $html, $full) {
global $AUTHOR_ELEMENT, $DATE_ELEMENT, $TITLE_ELEMENT, $PUBLISHER_ELEMENT, $NUMBER_ELEMENT, $INSTITUTION_ELEMENT, $LOCATION_ELEMENT, $PAGES_ELEMENT, $URL_ELEMENT, $DOI_ELEMENT;
$citation = add_element("", safe_metadata($item, $AUTHOR_ELEMENT));
$citation = add_element($citation, safe_metadata($item, $TITLE_ELEMENT), $html ? '<em>' : null, $html ? '</em>' : null);
if ($full) {
$citation = add_element($citation, safe_metadata($item, $NUMBER_ELEMENT));
$citation = add_element($citation, safe_metadata($item, $INSTITUTION_ELEMENT));
$citation = add_element($citation, safe_metadata($item, $PUBLISHER_ELEMENT));
$citation = add_element($citation, safe_metadata($item, $LOCATION_ELEMENT));
$citation = add_element($citation, safe_metadata($item, $PAGES_ELEMENT), 'pp. ');
$citation = add_element($citation, safe_metadata($item, $URL_ELEMENT), $html ? '<span class="citation-url">' : null, $html ? '</span>' : null);
$citation = add_element($citation, safe_metadata($item, $DATE_ELEMENT));
$citation = add_element($citation, safe_metadata($item, $DOI_ELEMENT), $html ? '<span class="citation-url">' : null, $html ? '</span>' : null);
}
return $citation;
}
/**
* Make a citation for an item.
* <p>
* The item type is used to determine what sort of citation should be generated.
*
* @param Item $item The item
* @param boolean $html Use html formatting
* @param boolean $full Full citation
* @return string
*/
function make_citation($item, $html = true, $full = true) {
$type = $item->getItemType();
$type = $type ? $type->name : 'Unknown';
if ($type == get_theme_option_with_default('Article Item Type', 'Article'))
return make_article_citation($item, $html, $full);
if ($type == get_theme_option_with_default('Conference Paper Type', 'Conference Paper'))
return make_paper_citation($item, $html, $full);
if ($type == get_theme_option_with_default('Book Item Type', 'Book'))
return make_book_citation($item, $html, $full);
if ($type == get_theme_option_with_default('Manual Item Type', 'Manual'))
return make_manual_citation($item, $html, $full);
if ($type == get_theme_option_with_default('Thesis Item Type', 'Thesis'))
return make_thesis_citation($item, $html, $full);
if ($type == get_theme_option_with_default('Report Item Type', 'Report'))
return make_book_citation($item, $html, $full);
if ($type == get_theme_option_with_default('Text Item Type', 'Text'))
return make_book_citation($item, $html, $full);
if ($type == get_theme_option_with_default('Website Item Type', 'Website'))
return make_website_citation($item, $html, $full);
if ($type == get_theme_option_with_default('Hyperlink Item Type', 'Hyperlink'))
return make_hyperlink_citation($item, $html, $full);
if ($type == get_theme_option_with_default('Moving Image Item Type', 'Moving Image'))
return make_moving_image_citation($item, $html, $full);
if ($type == get_theme_option_with_default('Still Image Item Type', 'Still Image'))
return make_still_image_citation($item, $html, $full);
return make_default_citation($item, $html, $full);
}
/**
* Find an item that can be used as a 'hero shot'.
* <p>
* Featured collections are searched randomly until an item with an image is found.
*
* @return Item
*/
function get_random_hero_shot() {
foreach (get_records('Collection', array('featured' => true, 'sort_field' => 'random')) as $collection) {
foreach (get_records('Item', array('collection' => $collection->id, 'hasImage' => true, 'sort_field' => 'random')) as $item)
return $item;
}
return null;
}
function bigstuff_sortable_items_shortcode($args, $view) {
$sortable = isset($args['sortable']) ? $args['sortable'] : get_theme_option_with_default('sortable_shortcodes', '1');
if (!$sortable)
return Omeka_View_Helper_Shortcodes::shortcodeItems($args, $view);
$sortLinks = array(
__('Title') =>'Dublin Core,Title',
__('Creator') => 'Dublin Core,Creator',
__('Date') => 'Dublin Core,Date',
__('Date Added') => 'added'
);
if (Zend_Controller_Front::getInstance()->getRequest()->getParam('sort_field') !== null)
$args['sort'] = Zend_Controller_Front::getInstance()->getRequest()->getParam('sort_field');
if (Zend_Controller_Front::getInstance()->getRequest()->getParam('sort_dir') !== null)
$args['order'] = Zend_Controller_Front::getInstance()->getRequest()->getParam('sort_dir');
$content = '<div class="item-shortcode">';
$content .= '<div id="sort-links"><span class="sort-label">' . __('Sort by: ') . '</span>' . browse_sort_links($sortLinks) . '</div>';
$content .= '<div class="item-list">';
$content .= Omeka_View_Helper_Shortcodes::shortcodeItems($args, $view);
$content .= '</div></div>';
return $content;
}
function bigstuff_sortable_collections_shortcode($args, $view) {
$sortable = isset($args['sortable']) ? $args['sortable'] : get_theme_option_with_default('sortable_shortcodes', '1');
if (!$sortable)
return Omeka_View_Helper_Shortcodes::shortcodeCollections($args, $view);
$sortLinks = array(
__('Title') =>'Dublin Core,Title',
__('Creator') => 'Dublin Core,Creator',
__('Date') => 'Dublin Core,Date',
__('Date Added') => 'added'
);
if (Zend_Controller_Front::getInstance()->getRequest()->getParam('sort_field') !== null)
$args['sort'] = Zend_Controller_Front::getInstance()->getRequest()->getParam('sort_field');
if (Zend_Controller_Front::getInstance()->getRequest()->getParam('sort_dir') !== null)
$args['order'] = Zend_Controller_Front::getInstance()->getRequest()->getParam('sort_dir');
$content = '<div class="item-shortcode">';
$content .= '<div id="sort-links"><span class="sort-label">' . __('Sort by: ') . '</span>' . browse_sort_links($sortLinks) . '</div>';
$content .= '<div class="item-list">';
$content .= Omeka_View_Helper_Shortcodes::shortcodeCollections($args, $view);
$content .= '</div></div>';
return $content;
}