You are here

function _panels_mini_panels_mini_content_type_content_type in Panels 7.3

Same name and namespace in other branches
  1. 6.3 panels_mini/plugins/content_types/panels_mini.inc \_panels_mini_panels_mini_content_type_content_type()

Return an info array describing a single mini panel.

2 calls to _panels_mini_panels_mini_content_type_content_type()
panels_mini_panels_mini_content_type_content_type in panels_mini/plugins/content_types/panels_mini.inc
Return each available mini panel available as a subtype.
panels_mini_panels_mini_content_type_content_types in panels_mini/plugins/content_types/panels_mini.inc
Return each available mini panel available as a subtype.

File

panels_mini/plugins/content_types/panels_mini.inc, line 48
Contains the content type plugin for a mini panel. While this does not need to be broken out into a .inc file, it's convenient that we do so that we don't load code unnecessarily. Plus it demonstrates plugins in modules other than Panels itself.

Code

function _panels_mini_panels_mini_content_type_content_type($mini) {
  if (empty($mini)) {

    // The mini panel is deleted or missing.
    return;
  }
  if (!empty($mini->disabled)) {
    return;
  }
  $title = filter_xss_admin($mini->admin_title);
  $type = array(
    'title' => $title,
    // For now mini panels will just use the contrib block icon.
    'icon' => 'icon_mini_panel.png',
    'description' => $title,
    'category' => !empty($mini->category) ? $mini->category : t('Mini panel'),
  );
  if (!empty($mini->requiredcontexts)) {
    $type['required context'] = array();
    foreach ($mini->requiredcontexts as $context) {
      $info = ctools_get_context($context['name']);

      // Check if the required context is actually required.
      if (!empty($context['optional'])) {
        $type['required context'][] = new ctools_context_optional($context['identifier'], $info['context name']);
      }
      else {
        $type['required context'][] = new ctools_context_required($context['identifier'], $info['context name']);
      }
    }
  }
  return $type;
}