function ctools_content_process

Provide defaults for a content type.

Currently we check for automatically named callbacks to make life a little easier on the developer.

1 string reference to 'ctools_content_process'
ctools_content_plugin_type in includes/content.plugin-type.inc
@file Contains plugin type registration information for the content tool.

File

includes/content.inc, line 18

Code

function ctools_content_process(&$plugin, $info) {
    $function_base = $plugin['module'] . '_' . $plugin['name'] . '_content_type_';
    if (empty($plugin['render callback']) && function_exists($function_base . 'render')) {
        $plugin['render callback'] = $function_base . 'render';
    }
    if (empty($plugin['admin title'])) {
        if (function_exists($function_base . 'admin_title')) {
            $plugin['admin title'] = $function_base . 'admin_title';
        }
        else {
            $plugin['admin title'] = $plugin['title'];
        }
    }
    if (empty($plugin['admin info']) && function_exists($function_base . 'admin_info')) {
        $plugin['admin info'] = $function_base . 'admin_info';
    }
    if (!isset($plugin['edit form']) && function_exists($function_base . 'edit_form')) {
        $plugin['edit form'] = $function_base . 'edit_form';
    }
    if (!isset($plugin['add form']) && function_exists($function_base . 'add_form')) {
        $plugin['add form'] = $function_base . 'add_form';
    }
    if (!isset($plugin['add form']) && function_exists($function_base . 'edit_form')) {
        $plugin['add form'] = $function_base . 'edit_form';
    }
    if (!isset($plugin['description'])) {
        $plugin['description'] = '';
    }
    if (!isset($plugin['icon'])) {
        $plugin['icon'] = ctools_content_admin_icon($plugin);
    }
    // Another ease of use check:
    if (!isset($plugin['content types'])) {
        // If a subtype plugin exists, try to use it. Otherwise assume single.
        if (function_exists($function_base . 'content_types')) {
            $plugin['content types'] = $function_base . 'content_types';
        }
        else {
            $type = array(
                'title' => $plugin['title'],
                'description' => $plugin['description'],
                'icon' => ctools_content_admin_icon($plugin),
                'category' => $plugin['category'],
            );
            if (isset($plugin['required context'])) {
                $type['required context'] = $plugin['required context'];
            }
            if (isset($plugin['top level'])) {
                $type['top level'] = $plugin['top level'];
            }
            $plugin['content types'] = array(
                $plugin['name'] => $type,
            );
            if (!isset($plugin['single'])) {
                $plugin['single'] = TRUE;
            }
        }
    }
}