- <?php
- * @file
- * Contains the embed display plugin.
- */
-
- * The plugin that handles an embed display.
- *
- * @ingroup views_display_plugins
- */
- class views_plugin_display_embed extends views_plugin_display {
-
- * @var bool
- * Whether this display has custom settings that override the view options.
- */
- protected $has_override_options = FALSE;
-
-
- * Overrides views_plugin_display::option_definition().
- */
- public function option_definition() {
- $options = parent::option_definition();
-
- $options['inherit_path'] = array('default' => 1);
-
- return $options;
- }
-
-
- * Returns the structure necessary for a block.
- */
- public function execute() {
- $output = NULL;
-
-
- $rendered_view = $this->view->render();
- if (!empty($this->view->result) || $this->get_option('empty') || !empty($this->view->style_plugin->definition['even empty'])) {
- $output = array(
- 'content' => $rendered_view,
- 'subject' => filter_xss_admin($this->view->get_title()),
- );
- }
- return $output;
- }
-
-
- * Provide the summary for page options in the views UI.
- *
- * This output is returned as an array.
- */
- public function options_summary(&$categories, &$options) {
-
- parent::options_summary($categories, $options);
-
- $categories['embed'] = array(
- 'title' => t('Embed settings'),
- 'column' => 'second',
- 'build' => array(
- '#weight' => -10,
- ),
- );
- $options['inherit_path'] = array(
- 'category' => 'embed',
- 'title' => t('Inherits path'),
- 'value' => $this->get_option('inherit_path') ? t('Yes') : t('No'),
- );
- }
-
-
- * Provide the default form for setting options.
- */
- public function options_form(&$form, &$form_state) {
-
- parent::options_form($form, $form_state);
-
- switch ($form_state['section']) {
- case 'inherit_path':
- $form['#title'] .= t('Inherit path from the page.');
-
- $form['inherit_path'] = array(
- '#type' => 'radios',
- '#options' => array(1 => t('Yes'), 0 => t('No')),
- '#default_value' => $this->get_option('inherit_path'),
- '#description' => t('If yes, all links generated by Views, such as more links, summary links, and exposed input links will go to the current page.'),
- );
- break;
- case 'exposed_form_options':
- $this->view->init_handlers();
- if (!$this->uses_exposed() && parent::uses_exposed()) {
- $form['exposed_form_options']['warning'] = array(
- '#weight' => -10,
- '#markup' => '<div class="messages warning">' . t('Exposed filters in embed displays may require "Use AJAX" to be set to work correctly.') . '</div>',
- );
- }
- break;
- }
- }
-
-
- * Perform any necessary changes to the form values prior to storage.
- * There is no need for this function to actually store the data.
- */
- public function options_submit(&$form, &$form_state) {
-
- parent::options_submit($form, $form_state);
- switch ($form_state['section']) {
- case 'inherit_path':
- case 'exposed_form_options':
- $this->set_option($form_state['section'], $form_state['values'][$form_state['section']]);
- break;
- }
- }
-
-
- * Returns the path to the current page if inherit_path is set.
- */
- public function get_path() {
- if ($this->get_option('inherit_path')) {
- return $_GET['q'];
- }
- return '';
- }
-
-
- * Returns the URL for this display.
- */
- public function get_url() {
- if ($this->get_option('inherit_path')) {
- return $this->get_path();
- }
- return parent::get_url();
- }
-
-
- * Check to see if the display can put the exposed form in a block.
- */
- public function uses_exposed_form_in_block() {
- return (bool) $this->get_option('inherit_path');
- }
- }