-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCuratescapeJSONPlugin.php
53 lines (41 loc) · 1.26 KB
/
CuratescapeJSONPlugin.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
<?php
class CuratescapeJSONPlugin extends Omeka_Plugin_AbstractPlugin
{
protected $_filters = array(
'response_contexts',
'action_contexts',
'items_browse_per_page',
'search_texts_browse_per_page' );
public function filterItemsBrowsePerPage( $perPage ){
if( isset($_GET["output"]) && $_GET["output"] == 'mobile-json'){
$perPage=null; // no pagination
}
return $perPage;
}
public function filterSearchTextsBrowsePerPage( $perPage ){
if( isset($_GET["output"]) && $_GET["output"] == 'mobile-json'){
$perPage=null; // no pagination
}
return $perPage;
}
public function filterResponseContexts( $contexts )
{
$contexts['mobile-json'] = array(
'suffix' => 'mjson',
'headers' => array( 'Content-Type' => 'application/json','Access-Control-Allow-Origin'=>'*' ) );
return $contexts;
}
public function filterActionContexts( $contexts, $args ) {
$controller = $args['controller'];
if( is_a( $controller, 'ItemsController' ) or
is_a( $controller, 'TourBuilder_ToursController' ) or
is_a( $controller, 'SearchController' ) or
is_a( $controller, 'SimplePages_PageController' ) )
{
$contexts['browse'][] = 'mobile-json' ;
$contexts['show'][] = 'mobile-json' ;
$contexts['index'][] = 'mobile-json' ;
}
return $contexts;
}
}