You are here

public function PanelizerEntityDefault::settings_form in Panelizer 7.2

Same name and namespace in other branches
  1. 7.3 plugins/entity/PanelizerEntityDefault.class.php \PanelizerEntityDefault::settings_form()

Add entity specific form to the Panelizer settings form.

This is primarily to allow bundle selection per entity type.

Overrides PanelizerEntityInterface::settings_form

3 calls to PanelizerEntityDefault::settings_form()
PanelizerEntityNode::settings_form in plugins/entity/PanelizerEntityNode.class.php
Add entity specific form to the Panelizer settings form.
PanelizerEntityTaxonomyTerm::settings_form in plugins/entity/PanelizerEntityTaxonomyTerm.class.php
Add entity specific form to the Panelizer settings form.
PanelizerEntityUser::settings_form in plugins/entity/PanelizerEntityUser.class.php
Add entity specific form to the Panelizer settings form.
3 methods override PanelizerEntityDefault::settings_form()
PanelizerEntityNode::settings_form in plugins/entity/PanelizerEntityNode.class.php
Add entity specific form to the Panelizer settings form.
PanelizerEntityTaxonomyTerm::settings_form in plugins/entity/PanelizerEntityTaxonomyTerm.class.php
Add entity specific form to the Panelizer settings form.
PanelizerEntityUser::settings_form in plugins/entity/PanelizerEntityUser.class.php
Add entity specific form to the Panelizer settings form.

File

plugins/entity/PanelizerEntityDefault.class.php, line 1360
Base class for the Panelizer Entity plugin.

Class

PanelizerEntityDefault
Base class for the Panelizer Entity plugin.

Code

public function settings_form(&$form, &$form_state) {

  // Add entity settings
  // @todo change theme function name
  $form['entities'][$this->entity_type] = array(
    '#theme' => 'panelizer_settings_page_table',
    '#header' => array(
      array(
        'data' => $this
          ->entity_bundle_label(),
        'width' => '15%',
      ),
      t('Panelize'),
      t('Provide default panel'),
      t('Allow panel choice'),
      array(
        'data' => t('Operations'),
        'width' => '50%',
      ),
    ),
    '#columns' => array(
      'title',
      'status',
      'default',
      'choice',
      'links',
    ),
  );
  $entity_info = entity_get_info($this->entity_type);
  $bundles = $entity_info['bundles'];
  drupal_alter('panelizer_default_types', $bundles, $this->entity_type);
  foreach ($bundles as $bundle => $bundle_info) {
    $base_id = str_replace(array(
      '][',
      '_',
      ' ',
    ), '-', '#edit-entities-' . $this->entity_type . '-' . $bundle);
    $base_url = 'admin/config/content/panelizer/' . $this->entity_type . '/' . $bundle;
    $settings = !empty($this->plugin['bundles'][$bundle]) ? $this->plugin['bundles'][$bundle] : array(
      'status' => FALSE,
      'default' => FALSE,
      'choice' => FALSE,
    );
    $form['entities'][$this->entity_type][$bundle]['title'] = array(
      '#markup' => $bundle_info['label'],
    );
    $form['entities'][$this->entity_type][$bundle]['status'] = array(
      '#type' => 'checkbox',
      '#default_value' => !empty($settings['status']),
    );
    $form['entities'][$this->entity_type][$bundle]['default'] = array(
      '#type' => 'checkbox',
      '#default_value' => !empty($settings['default']),
      '#states' => array(
        'visible' => array(
          $base_id . '-status' => array(
            'checked' => TRUE,
          ),
        ),
      ),
    );
    $form['entities'][$this->entity_type][$bundle]['choice'] = array(
      '#type' => 'checkbox',
      '#default_value' => !empty($settings['choice']),
      '#states' => array(
        'visible' => array(
          $base_id . '-status' => array(
            'checked' => TRUE,
          ),
        ),
      ),
    );
    $form['entities'][$this->entity_type][$bundle]['links'] = array(
      '#prefix' => '<div class="container-inline">',
      '#suffix' => '</div>',
    );

    // Panelize is on all content types get this option
    if (!empty($settings['status'])) {
      $links_array = array(
        'settings' => array(
          'title' => t('allowed content'),
          'href' => $base_url . '/allowed',
        ),
      );
      $links = theme('links', array(
        'links' => $links_array,
        'attributes' => array(
          'class' => 'links inline',
        ),
      ));
    }
    else {
      $links = t('Save to access allowed content');
    }
    $form['entities'][$this->entity_type][$bundle]['links']['basic'] = array(
      '#type' => 'item',
      '#title' => $links,
      '#states' => array(
        'visible' => array(
          $base_id . '-status' => array(
            'checked' => TRUE,
          ),
        ),
      ),
    );

    // Panelize is enabled and a default panel will be provided
    if (!empty($settings['status']) && !empty($settings['default']) && empty($settings['choice'])) {
      $links_array = array(
        'settings' => array(
          'title' => t('settings'),
          'href' => $base_url . '/settings',
        ),
        'context' => array(
          'title' => t('context'),
          'href' => $base_url . '/context',
        ),
        'layout' => array(
          'title' => t('layout'),
          'href' => $base_url . '/layout',
        ),
        'content' => array(
          'title' => t('content'),
          'href' => $base_url . '/content',
        ),
      );
      $links = theme('links', array(
        'links' => $links_array,
        'attributes' => array(
          'class' => 'links inline',
        ),
      ));
    }
    else {
      $links = t('Save to access default panel');
    }
    $form['entities'][$this->entity_type][$bundle]['links']['default'] = array(
      '#type' => 'item',
      '#title' => $links,
      '#states' => array(
        'visible' => array(
          $base_id . '-status' => array(
            'checked' => TRUE,
          ),
          $base_id . '-default' => array(
            'checked' => TRUE,
          ),
          $base_id . '-choice' => array(
            'checked' => FALSE,
          ),
        ),
      ),
    );
    if (!empty($settings['status']) && !empty($settings['choice'])) {
      $links_array = array(
        'list' => array(
          'title' => t('list'),
          'href' => $base_url . '/list',
        ),
      );
      $links = theme('links', array(
        'links' => $links_array,
        'attributes' => array(
          'class' => 'links inline',
        ),
      ));
    }
    else {
      $links = t('Save to access panel list');
    }
    $form['entities'][$this->entity_type][$bundle]['links']['default2'] = array(
      '#type' => 'item',
      '#title' => $links,
      '#states' => array(
        'visible' => array(
          $base_id . '-status' => array(
            'checked' => TRUE,
          ),
          $base_id . '-choice' => array(
            'checked' => TRUE,
          ),
        ),
      ),
    );
  }
}