function ctools_content_get_subtypes

Get all of the individual subtypes provided by a given content type. This would be all of the blocks for the block type, or all of the views for the view type.

Parameters

$type: The content type to load.

Return value

An array of all subtypes available.

3 calls to ctools_content_get_subtypes()
ctools_content_get_all_types in includes/content.inc
Get an array of all content types that can be fed into the display editor for the add content list, regardless of availability.
ctools_content_get_available_types in includes/content.inc
Get an array of all available content types that can be fed into the display editor for the add content list.
ctools_content_get_subtype in includes/content.inc
Given a content type and a subtype id, return the information about that content subtype.

File

includes/content.inc, line 124

Code

function ctools_content_get_subtypes($type) {
    static $cache = array();
    $subtypes = array();
    if (is_array($type)) {
        $plugin = $type;
    }
    else {
        $plugin = ctools_get_content_type($type);
    }
    if (empty($plugin) || empty($plugin['name'])) {
        return;
    }
    if (isset($cache[$plugin['name']])) {
        return $cache[$plugin['name']];
    }
    if (isset($plugin['content types'])) {
        $function = $plugin['content types'];
        if (is_array($function)) {
            $subtypes = $function;
        }
        elseif (function_exists($function)) {
            // Cast to array to prevent errors from non-array returns.
            $subtypes = (array) $function($plugin);
        }
    }
    // Walk through the subtypes and ensure minimal settings are
    // retained.
    foreach ($subtypes as $id => $subtype) {
        // Ensure that the 'subtype_id' value exists.
        if (!isset($subtype['subtype_id'])) {
            $subtypes[$id]['subtype_id'] = $id;
        }
        // Use exact name since this is a modify by reference.
        ctools_content_prepare_subtype($subtypes[$id], $plugin);
    }
    $cache[$plugin['name']] = $subtypes;
    return $subtypes;
}