function panels_renderer_editor::get_categories in Panels 7.3
Same name and namespace in other branches
- 6.3 plugins/display_renderers/panels_renderer_editor.class.php \panels_renderer_editor::get_categories()
Create a list of categories from all of the content type.
Return value
array An array of categories. Each entry in the array will also be an array with 'title' as the printable title of the category, and 'content' being an array of all content in the category. Each item in the 'content' array contain the array plugin definition so that it can be later found in the content array. They will be keyed by the title so that they can be sorted.
1 call to panels_renderer_editor::get_categories()
- panels_renderer_editor::ajax_select_content in plugins/
display_renderers/ panels_renderer_editor.class.php - AJAX command to present a dialog with a list of available content.
File
- plugins/
display_renderers/ panels_renderer_editor.class.php, line 643 - Class file to control the main Panels editor.
Class
- panels_renderer_editor
- @file Class file to control the main Panels editor.
Code
function get_categories($content_types) {
$categories = array();
$category_names = array();
foreach ($content_types as $type_name => $subtypes) {
foreach ($subtypes as $subtype_name => $content_type) {
list($category_key, $category) = $this
->get_category($content_type);
if (empty($categories[$category_key])) {
$categories[$category_key] = array(
'title' => $category,
'content' => array(),
);
$category_names[$category_key] = $category;
}
$content_title = filter_xss_admin($content_type['title']);
// Ensure content with the same title doesn't overwrite each other.
while (isset($categories[$category_key]['content'][$content_title])) {
$content_title .= '-';
}
$categories[$category_key]['content'][$content_title] = $content_type;
$categories[$category_key]['content'][$content_title]['type_name'] = $type_name;
$categories[$category_key]['content'][$content_title]['subtype_name'] = $subtype_name;
}
}
// Now sort.
natcasesort($category_names);
foreach ($category_names as $category => $name) {
$output[$category] = $categories[$category];
}
return $output;
}