function ctools_content_get_available_types
Get an array of all available content types that can be fed into the display editor for the add content list.
Parameters
$context: If a context is provided, content that requires that context can apepar.
$has_content: Whether or not the display will have incoming content
$allowed_types: An array of allowed content types (pane types) keyed by content_type . '-' . sub_type
$default_types: A default allowed/denied status for content that isn't known about
File
-
includes/
content.inc, line 703
Code
function ctools_content_get_available_types($contexts = NULL, $has_content = FALSE, $allowed_types = NULL, $default_types = NULL) {
$plugins = ctools_get_content_types();
$available = array();
foreach ($plugins as $id => $plugin) {
foreach (ctools_content_get_subtypes($plugin) as $subtype_id => $subtype) {
// Exclude items that require content if we're saying we don't
// provide it.
if (!empty($subtype['requires content']) && !$has_content) {
continue;
}
// Check to see if the content type can be used in this context.
if (!empty($subtype['required context'])) {
if (!ctools_context_match_requirements($contexts, $subtype['required context'])) {
continue;
}
}
// Check to see if the passed-in allowed types allows this content.
if ($allowed_types) {
$key = $id . '-' . $subtype_id;
if (!isset($allowed_types[$key])) {
$allowed_types[$key] = isset($default_types[$id]) ? $default_types[$id] : $default_types['other'];
}
if (!$allowed_types[$key]) {
continue;
}
}
// Check if the content type provides an access callback.
if (isset($subtype['create content access']) && function_exists($subtype['create content access']) && !$subtype['create content access']($plugin, $subtype)) {
continue;
}
// If we made it through all the tests, then we can use this content.
$available[$id][$subtype_id] = $subtype;
}
}
return $available;
}