term_description.inc 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * Plugins are described by creating a $plugin array which will be used
  4. * by the system that includes this file.
  5. */
  6. $plugin = array(
  7. 'single' => TRUE,
  8. 'title' => t('Term description'),
  9. 'icon' => 'icon_term.png',
  10. 'description' => t('Term description.'),
  11. 'required context' => new ctools_context_required(t('Term'), array('term', 'taxonomy_term')),
  12. 'category' => t('Taxonomy term'),
  13. );
  14. function ctools_term_description_content_type_render($subtype, $conf, $panel_args, $context) {
  15. $term = isset($context->data) ? clone $context->data : NULL;
  16. $block = new stdClass();
  17. $block->module = 'node_type';
  18. if (!empty($term)) {
  19. $block->title = $term->name;
  20. $block->content = check_markup($term->description, $term->format, '', TRUE);
  21. $block->delta = $term->tid;
  22. if (user_access('administer taxonomy')) {
  23. $block->admin_links['update'] = array(
  24. 'title' => t('Edit term'),
  25. 'alt' => t("Edit this term"),
  26. 'href' => "taxonomy/term/$term->tid/edit",
  27. 'query' => drupal_get_destination(),
  28. );
  29. }
  30. }
  31. else {
  32. $block->title = '';
  33. $block->content = t('Term description goes here.');
  34. $block->delta = 'unknown';
  35. }
  36. return $block;
  37. }
  38. function ctools_term_description_content_type_admin_title($subtype, $conf, $context) {
  39. return t('"@s" term description', array('@s' => $context->identifier));
  40. }
  41. function ctools_term_description_content_type_edit_form($form, &$form_state) {
  42. // provide a blank form so we have a place to have context setting.
  43. return $form;
  44. }