You are here

function _views_content_views_update_conf in Chaos Tool Suite (ctools) 7

Same name and namespace in other branches
  1. 6 views_content/plugins/content_types/views.inc \_views_content_views_update_conf()

Update the $conf to deal with updates from Drupal 5.

Parameters

&$conf: The $conf array to modify.

$subtype: The subtype in use. This should just be the view name, but in older versions it was the view name with a dash and the display ID. If this is the case, we can use it to correct the 'display' setting in the $conf.

Return value

The $view with the initialized display. If the $view could not be loaded, the name attempted will be loaded for use in errors. Correct error checking on this function checks against is_object().

4 calls to _views_content_views_update_conf()
views_content_views_content_type_admin_info in views_content/plugins/content_types/views.inc
Returns the administrative title for a type.
views_content_views_content_type_admin_title in views_content/plugins/content_types/views.inc
Returns the administrative title for a type.
views_content_views_content_type_edit_form in views_content/plugins/content_types/views.inc
Returns an edit form for a block.
views_content_views_content_type_render in views_content/plugins/content_types/views.inc
Output function for the 'views' content type.

File

views_content/plugins/content_types/views.inc, line 504

Code

function _views_content_views_update_conf(&$conf, $subtype) {
  $plugin = ctools_get_content_type('views');

  // Special: Existing content types get a different default than new ones:
  if (!empty($conf) && !isset($conf['override_pager_settings'])) {
    $conf['override_pager_settings'] = TRUE;
  }

  // Make sure that our defaults are always set if there is no
  // previous setting. This helps updates go more smoothly.
  foreach ($plugin['defaults'] as $key => $value) {
    if (!isset($conf[$key])) {
      $conf[$key] = $value;
    }
  }
  if (strpos($subtype, '-')) {
    list($name, $display) = explode('-', $subtype);
    $view = views_get_view($name);
    if (!isset($conf['display'])) {
      $conf['display'] = $display;
    }
  }
  else {
    $name = $subtype;
    $view = views_get_view($subtype);
    $display = isset($conf['display']) ? $conf['display'] : 'default';
  }
  if (empty($view)) {
    return $name;
  }
  $view
    ->set_display($display);

  // $view->current_display will now reflect this value.
  // If set NOT to override, go ahead and refresh from the view.
  if (empty($conf['override_pager_settings'])) {
    if (method_exists($view, 'init_pager')) {
      $pager = $view->display_handler
        ->get_option('pager');
      $conf['use_pager'] = $pager['type'] != 'none' && $pager['type'] != 'some';
      $conf['pager_id'] = isset($pager['options']['id']) ? $pager['options']['id'] : 0;
      $conf['offset'] = isset($pager['options']['offset']) ? $pager['options']['offset'] : 0;
      $conf['nodes_per_page'] = isset($pager['options']['items_per_page']) ? $pager['options']['items_per_page'] : 0;
    }
    else {
      $conf['use_pager'] = $view->display_handler
        ->get_option('use_pager');
      $conf['pager_id'] = $view->display_handler
        ->get_option('element_id');
      $conf['nodes_per_page'] = $view->display_handler
        ->get_option('items_per_page');
      $conf['offset'] = $view->display_handler
        ->get_option('offset');
    }
  }
  return $view;
}