function panels_get_available_content_types in Panels 5.2
Same name and namespace in other branches
- 6.2 includes/plugins.inc \panels_get_available_content_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
2 calls to panels_get_available_content_types()
- panels_add_content in includes/
display_edit.inc - panels_common_get_allowed_types in includes/
common.inc - Based upon the settings, get the allowed types for this node.
File
- includes/
plugins.inc, line 449 - plugins.inc
Code
function panels_get_available_content_types($contexts = NULL, $has_content = FALSE, $allowed_types = NULL, $default_types = NULL) {
$content_types = panels_get_content_types();
$available = array();
foreach ($content_types as $id => $type) {
foreach (panels_ct_get_types($type) as $cid => $cinfo) {
// exclude items that require content if we're saying we don't
// provide it.
if (!empty($cinfo['requires content']) && !$has_content) {
continue;
}
// Check to see if the content type can be used in this context.
if (!empty($cinfo['required context'])) {
if (!panels_context_filter($contexts, $cinfo['required context'])) {
continue;
}
}
// Check to see if the passed-in allowed types allows this content.
if ($allowed_types) {
$key = $id . '-' . $cid;
if (!isset($allowed_types[$key])) {
$allowed_types[$key] = isset($default_types[$id]) ? $default_types[$id] : $default_types['other'];
}
if (!$allowed_types[$key]) {
continue;
}
}
// If we made it through all the tests, then we can use this content.
$available[$id][$cid] = $cinfo;
}
}
return $available;
}