You are here

function total_control_views_add_display in Total Control Admin Dashboard 7.2

Same name and namespace in other branches
  1. 6.2 includes/total_control.inc \total_control_views_add_display()

Adds view displays.

Parameters

$content_type: The human readable name of the content type

$machine_type: The machine readable name of the content type

1 call to total_control_views_add_display()
total_control_add_type_submit in includes/total_control.inc
Submit function for content type form

File

includes/total_control.inc, line 86
Helper functions for total control.

Code

function total_control_views_add_display($content_type = '', $machine_type = '') {
  if ($machine_type = '') {
    drupal_set_message(t('no content type provided'), 'error');
    return;
  }

  // Get total control settings.
  $auto_page_default = variable_get('total_control_auto_pages', array());
  $auto_pane_default = variable_get('total_control_auto_panels', array());
  if (!empty($auto_page_default) && array_key_exists('type', $auto_page_default) && !($auto_page_default['type'] === 0)) {

    // Add page display.
    $view = views_get_view('control_content');
    if (!array_key_exists('page_tc_' . $machine_type, $view->display)) {
      total_control_add_views_page_display($view, $content_type, $machine_type);
      $defaults = variable_get('total_control_type_pages', array());
      if (array_key_exists($machine_type, $defaults) || $defaults[$machine_type] != $machine_type) {
        $defaults[$machine_type] = $machine_type;
        $defaults = variable_set('total_control_type_pages', $defaults);
      }
    }
    else {
      drupal_set_message(t('Total Control was unable to create your
        administrative page view because a view already exists with the name:
        !name', array(
        '!name' => 'page_tc_' . $machine_type,
      )));
    }
  }
  if (!empty($auto_pane_default) && array_key_exists('type', $auto_pane_default) && !($auto_pane_default['type'] === 0)) {

    // Add pane display.
    $paneview = views_get_view('control_content_panes');
    if (!array_key_exists('pane_tc_' . $machine_type, $paneview->display)) {
      total_control_add_views_pane_display($paneview, $content_type, $machine_type);
      $defaults = variable_get('total_control_type_panes', array());
      $defaults[$machine_type] = $machine_type;
      $defaults = variable_set('total_control_type_panes', $defaults);
    }
    else {
      drupal_set_message(t('Total Control was unable to create your
        administrative pane view because a view already exists with the name:
        !name', array(
        '!name' => 'pane_tc_' . $machine_type,
      )));
    }
  }
  return;
}