You are here

function ctools_custom_content_type_get_conf in Chaos Tool Suite (ctools) 7

Same name and namespace in other branches
  1. 6 plugins/content_types/custom/custom.inc \ctools_custom_content_type_get_conf()

Given a subtype and a $conf, return the actual settings to use.

The actual settings may be stored directly in the pane or this may be a pointer to re-usable content that may be in the database or in an export. We have to determine from the subtype whether or not it is local or shared custom content.

4 calls to ctools_custom_content_type_get_conf()
ctools_custom_content_type_admin_info in plugins/content_types/custom/custom.inc
Callback to provide administrative info. In this case we'll render the content as long as it's not PHP, which is too risky to render here.
ctools_custom_content_type_admin_title in plugins/content_types/custom/custom.inc
Callback to provide the administrative title of the custom content.
ctools_custom_content_type_edit_form in plugins/content_types/custom/custom.inc
Returns an edit form for the custom type.
ctools_custom_content_type_render in plugins/content_types/custom/custom.inc
Output function for the 'custom' content type. Outputs a custom based on the module and delta supplied in the configuration.

File

plugins/content_types/custom/custom.inc, line 112
Custom content type.

Code

function ctools_custom_content_type_get_conf($subtype, $conf) {
  if ($subtype['name'] != 'custom') {
    $settings = $subtype['content']->settings;
    $settings['custom_type'] = 'fixed';
    $settings['content'] = $subtype['content'];
  }
  else {

    // This means they created it as custom content and then set it as
    // reusable. Since we're not allowed to change the subtype, we're
    // still stored as though we are local, but are pointing off to
    // non-local.
    if (!empty($conf['name']) && module_exists('ctools_custom_content')) {
      ctools_include('export');
      $content = ctools_export_crud_load('ctools_custom_content', $conf['name']);
      if ($content) {
        $settings = $content->settings;
        $settings['custom_type'] = 'fixed';
        $settings['content'] = $content;
        $settings['admin_title'] = $content->admin_title;
      }
      else {
        $content = ctools_export_crud_new('ctools_custom_content');
        $content->name = $conf['name'];
        $settings = array(
          'admin_title' => t('Missing/deleted content'),
          'title' => '',
          'title_heading' => '',
          'body' => '',
          'format' => filter_default_format(),
          'substitute' => TRUE,
          'custom_type' => 'fixed',
          'content' => $content,
        );
      }
    }
    else {
      $settings = $conf;
      $settings['custom_type'] = 'local';
    }
  }

  // Correct for an error that came in because filter format changed.
  if (is_array($settings['body'])) {
    $settings['format'] = $settings['body']['format'];
    $settings['body'] = $settings['body']['value'];
  }
  return $settings;
}