Projet

Général

Profil

Paste
Télécharger (1,53 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / ctools / plugins / content_types / term_context / term_description.inc @ c304a780

1
<?php
2

    
3
/**
4
 * @file
5
 * Plugins are described by creating a $plugin array which will be used
6
 * by the system that includes this file.
7
 */
8

    
9
$plugin = array(
10
  'single' => TRUE,
11
  'title' => t('Term description'),
12
  'icon' => 'icon_term.png',
13
  'description' => t('Term description.'),
14
  'required context' => new ctools_context_required(t('Term'), array('term', 'taxonomy_term')),
15
  'category' => t('Taxonomy term'),
16
);
17

    
18
function ctools_term_description_content_type_render($subtype, $conf, $panel_args, $context) {
19
  $term = isset($context->data) ? clone $context->data : NULL;
20
  $block = new stdClass();
21
  $block->module = 'node_type';
22

    
23
  if (!empty($term)) {
24
    $block->title = $term->name;
25
    $block->content = check_markup($term->description, $term->format, '', TRUE);
26
    $block->delta = $term->tid;
27

    
28
    if (user_access('administer taxonomy')) {
29
      $block->admin_links['update'] = array(
30
        'title' => t('Edit term'),
31
        'alt' => t("Edit this term"),
32
        'href' => "taxonomy/term/$term->tid/edit",
33
        'query' => drupal_get_destination(),
34
      );
35
    }
36
  }
37
  else {
38
    $block->title = '';
39
    $block->content = t('Term description goes here.');
40
    $block->delta = 'unknown';
41
  }
42

    
43
  return $block;
44
}
45

    
46
function ctools_term_description_content_type_admin_title($subtype, $conf, $context) {
47
  return t('"@s" term description', array('@s' => $context->identifier));
48
}
49

    
50
function ctools_term_description_content_type_edit_form($form, &$form_state) {
51
  // Provide a blank form so we have a place to have context setting.
52
  return $form;
53
}