You are here

class MediaBrowserView in D7 Media 7.3

Same name and namespace in other branches
  1. 7.4 includes/MediaBrowserView.inc \MediaBrowserView
  2. 7.2 includes/MediaBrowserView.inc \MediaBrowserView

Media browser plugin for displaying a specific view and display.

Hierarchy

Expanded class hierarchy of MediaBrowserView

1 string reference to 'MediaBrowserView'
media_media_browser_plugin_info in ./media.media.inc
Implements hook_media_browser_plugin_info().

File

includes/MediaBrowserView.inc, line 11
Definition of MediaBrowserView.

View source
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;
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MediaBrowserPlugin::$info protected property The plugin metadata array from hook_media_browser_plugin_info().
MediaBrowserPlugin::$params protected property The parameters for current media browser from media_get_browser_params().
MediaBrowserView::$view protected property The view object from views_get_view() for this plugin.
MediaBrowserView::access public function Implements MediaBrowserPluginInterface::access(). Overrides MediaBrowserPlugin::access
MediaBrowserView::view public function Implements MediaBrowserPlugin::view(). Overrides MediaBrowserPlugin::view
MediaBrowserView::__construct public function Implements MediaBrowserPluginInterface::__construct(). Overrides MediaBrowserPlugin::__construct