blob: 0321a119c36aa6d240fb3ab6f53de5aec51828e0 (
plain)
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
|
<?php
/**
* @file
* Definition of MediaBrowserView.
*/
/**
* Media browser plugin for displaying a specific view and display.
*/
class MediaBrowserView extends MediaBrowserPlugin {
/**
* The view object from views_get_view() for this plugin.
*
* @var view
*/
protected $view;
/**
* Implements MediaBrowserPluginInterface::__construct().
*/
public function __construct($info, $params) {
parent::__construct($info, $params);
// Set up the view object with the proper display.
if ($view = views_get_view($info['view_name'])) {
$display_id = !empty($info['view_display_id']) ? $info['view_display_id'] : NULL;
if ($view->set_display($display_id)) {
$this->view = $view;
}
}
}
/**
* Implements MediaBrowserPluginInterface::access().
*/
public function access($account = NULL) {
return !empty($this->view) && $this->view->access($this->view->current_display, $account);
}
/**
* Implements MediaBrowserPlugin::view().
*/
public function view() {
if (!empty($this->view)) {
$build['#markup'] = $this->view->preview();
// Allow the View title to override the plugin title.
if ($title = $this->view->get_title()) {
$build['#title'] = $title;
}
return $build;
}
}
}
|