d36deaba85479a22c6b0146044424b8c5c977562
6 * Contains the content type plugin for a mini panel. While this does not
7 * need to be broken out into a .inc file, it's convenient that we do so
8 * that we don't load code unneccessarily. Plus it demonstrates plugins
9 * in modules other than Panels itself.
14 * Specially named hook. for .inc file. This looks a little silly due to the
15 * redundancy, but that's really just because the content type shares a
16 * name with the module.
18 function panels_mini_panels_mini_ctools_content_types() {
20 'title' => t('Mini panels'),
21 'content type' => 'panels_mini_panels_mini_content_type_content_type',
26 * Return each available mini panel available as a subtype.
28 function panels_mini_panels_mini_content_type_content_type($subtype_id, $plugin) {
29 $mini = panels_mini_load($subtype_id);
30 return _panels_mini_panels_mini_content_type_content_type($mini);
34 * Return each available mini panel available as a subtype.
36 function panels_mini_panels_mini_content_type_content_types($plugin) {
38 foreach (panels_mini_load_all() as
$mini) {
39 $type = _panels_mini_panels_mini_content_type_content_type($mini);
41 $types[$mini->name
] = $type;
48 * Return an info array describing a single mini panel.
50 function _panels_mini_panels_mini_content_type_content_type($mini) {
51 if (!empty($mini->disabled
)) {
55 $title = filter_xss_admin($mini->admin_title
);
58 // For now mini panels will just use the contrib block icon.
59 'icon' => 'icon_mini_panel.png',
60 'description' => $title,
61 'category' => !empty($mini->category
) ?
$mini->category
: t('Mini panel'),
63 if (!empty($mini->requiredcontexts
)) {
64 $type['required context'] = array();
65 foreach ($mini->requiredcontexts as
$context) {
66 $info = ctools_get_context($context['name']);
67 // TODO: allow an optional setting
68 $type['required context'][] = new
ctools_context_required($context['identifier'], $info['context name']);
75 * Render a mini panel called from a panels display.
77 function panels_mini_panels_mini_content_type_render($subtype, $conf, $panel_args, &$contexts) {
78 static
$viewing = array();
79 $mini = panels_mini_load($subtype);
83 if (!empty($viewing[$mini->name
])) {
87 // Load up any contexts we might be using.
88 $context = ctools_context_match_required_contexts($mini->requiredcontexts
, $contexts);
89 $mini->context
= $mini->display
->context
= ctools_context_load_contexts($mini, FALSE
, $context);
91 if (empty($mini) || !empty($mini->disabled
)) {
94 $viewing[$mini->name
] = TRUE
;
96 $mini->display
->args
= $panel_args;
97 $mini->display
->css_id
= panels_mini_get_id($subtype);
98 $mini->display
->owner
= $mini;
99 // unique ID of this mini.
100 $mini->display
->owner
->id
= $mini->name
;
102 $block = new
stdClass();
103 $block->module
= 'panels_mini';
104 $block->delta
= $subtype;
105 $block->content
= panels_render_display($mini->display
);
106 $block->title
= $mini->display
->get_title();
108 unset($viewing[$mini->name
]);
113 * Edit form for the mini panel content type.
115 function panels_mini_panels_mini_content_type_edit_form($form, &$form_state) {
116 // Empty form to ensure we have the override title + context gadgets.
121 * Provide the administrative title of a mini panel.
123 function panels_mini_panels_mini_content_type_admin_title($subtype, $conf) {
124 $mini = panels_mini_load($subtype);
126 return t('Deleted/missing mini panel @name', array('@name' => $subtype));
129 $title = filter_xss_admin($mini->admin_title
);
131 $title = t('Untitled mini panel');