Same name in other branches
  1. 8.x-1.x src/Plugin/QuickContent/QuickNodeContent.php \Drupal\quicktabs\Plugin\QuickContent\QuickNodeContent

Class for tab content of type "node" - this is for rendering a node as tab content.

Hierarchy

Expanded class hierarchy of QuickNodeContent

1 string reference to 'QuickNodeContent'
quicktabs_quicktabs_contents dans ./quicktabs.module
Implements hook_quicktabs_contents().

Fichier

plugins/QuickNodeContent.inc, line 7

View source
class QuickNodeContent extends QuickContent {
    public static function getType() {
        return 'node';
    }
    public function optionsForm($delta, $qt) {
        $tab = $this->settings;
        $form = array();
        $form['node']['nid'] = array(
            '#type' => 'textfield',
            '#title' => t('Node'),
            '#description' => t('The node ID of the node.'),
            '#maxlength' => 10,
            '#size' => 20,
            '#default_value' => isset($tab['nid']) ? $tab['nid'] : '',
        );
        $entity_info = entity_get_info('node');
        $view_modes = array();
        foreach ($entity_info['view modes'] as $view_mode_name => $view_mode) {
            $view_modes[$view_mode_name] = $view_mode['label'];
        }
        $form['node']['view_mode'] = array(
            '#type' => 'select',
            '#title' => t('View mode'),
            '#options' => $view_modes,
            '#default_value' => isset($tab['view_mode']) ? $tab['view_mode'] : 'full',
        );
        $form['node']['hide_title'] = array(
            '#type' => 'checkbox',
            '#title' => t('Hide the title of this node'),
            '#default_value' => isset($tab['hide_title']) ? $tab['hide_title'] : 1,
        );
        return $form;
    }
    public function render($hide_empty = FALSE, $args = array()) {
        if ($this->rendered_content) {
            return $this->rendered_content;
        }
        $item = $this->settings;
        if (!empty($args)) {
            // The args have been passed in from an ajax request.
            // The first element of the args array is the qt_name, which we don't need
            // for this content type.
            array_shift($args);
            list($item['nid'], $item['view_mode'], $item['hide_title']) = $args;
        }
        $output = array();
        if (isset($item['nid'])) {
            $node = node_load($item['nid']);
            if (!empty($node)) {
                if (node_access('view', $node)) {
                    $buildmode = $item['view_mode'];
                    $nstruct = node_view($node, $buildmode);
                    if ($item['hide_title']) {
                        $nstruct['#node']->title = NULL;
                    }
                    $output = $nstruct;
                }
                elseif (!$hide_empty) {
                    $output = array(
                        '#markup' => theme('quicktabs_tab_access_denied', array(
                            'tab' => $item,
                        )),
                    );
                }
            }
        }
        return $output;
    }
    public function getAjaxKeys() {
        return array(
            'nid',
            'view_mode',
            'hide_title',
        );
    }
    public function getUniqueKeys() {
        return array(
            'nid',
        );
    }

}

Members

Titre Trier par ordre décroissant Modifiers Object type Résumé Overriden Title Overrides
QuickContent::$rendered_content protected property A render array of the contents.
QuickContent::$settings protected property An array containing the information that defines the tab content, specific
to its type.
QuickContent::$title protected property Used as the title of the tab.
QuickContent::factory public static function Instantiate a content type object.
QuickContent::getSettings public function Accessor for the tab settings. Overrides QuickContentRenderable::getSettings
QuickContent::getTitle public function Accessor for the tab title. Overrides QuickContentRenderable::getTitle
QuickContent::__construct public function Constructor 2
QuickNodeContent::getAjaxKeys public function Returns an array of keys to use for constructing the correct arguments for
an ajax callback to retrieve content of this type. The order of the keys
returned affects the order of the args passed in to the render method when
called via ajax (see the…
Overrides QuickContentRenderable::getAjaxKeys
QuickNodeContent::getType public static function Returns the short type name of the content plugin, e.g. 'block', 'node',
'prerendered'.
Overrides QuickContentRenderable::getType
QuickNodeContent::getUniqueKeys public function Returns an array of keys, sufficient to represent the content uniquely. Overrides QuickContentRenderable::getUniqueKeys
QuickNodeContent::optionsForm public function Method for returning the form elements to display for this tab type on
the admin form.
Overrides QuickContent::optionsForm
QuickNodeContent::render public function Renders the content. Overrides QuickContentRenderable::render