Projet

Général

Profil

Paste
Télécharger (1,28 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / media / includes / MediaBrowserView.inc @ 1f623f01

1 85ad3d82 Assos Assos
<?php
2
3
/**
4
 * @file
5
 * Definition of MediaBrowserView.
6
 */
7
8
/**
9
 * Media browser plugin for displaying a specific view and display.
10
 */
11
class MediaBrowserView extends MediaBrowserPlugin {
12
  /**
13
   * The view object from views_get_view() for this plugin.
14
   *
15
   * @var view
16
   */
17
  protected $view;
18
19
  /**
20
   * Implements MediaBrowserPluginInterface::__construct().
21
   */
22
  public function __construct($info, $params) {
23
    parent::__construct($info, $params);
24
25
    // Set up the view object with the proper display.
26
    if ($view = views_get_view($info['view_name'])) {
27
      $display_id = !empty($info['view_display_id']) ? $info['view_display_id'] : NULL;
28
      if ($view->set_display($display_id)) {
29
        $this->view = $view;
30
      }
31
    }
32
  }
33
34
  /**
35
   * Implements MediaBrowserPluginInterface::access().
36
   */
37
  public function access($account = NULL) {
38
    return !empty($this->view) && $this->view->access($this->view->current_display, $account);
39
  }
40
41
  /**
42
   * Implements MediaBrowserPlugin::view().
43
   */
44
  public function view() {
45
    if (!empty($this->view)) {
46
      $build['#markup'] = $this->view->preview();
47
48
      // Allow the View title to override the plugin title.
49
      if ($title = $this->view->get_title()) {
50
        $build['#title'] = $title;
51
      }
52
53
      return $build;
54
    }
55
  }
56
}