Projet

Général

Profil

Révision e4c061ad

Ajouté par Assos Assos il y a plus de 9 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/ctools/plugins/content_types/page/page_site_name.inc
7 7
 */
8 8

  
9 9
/**
10
 * Plugins are described by creating a $plugin array which will be used
11
 * by the system that includes this file.
10
 * Plugins are described by creating a $plugin array which will be used by the
11
 * system that includes this file.
12 12
 */
13 13
$plugin = array(
14 14
  'title' => t('Site name'),
15 15
  'single' => TRUE,
16 16
  'icon' => 'icon_page.png',
17
  'description' => t('The name of the site.'),
17
  'description' => t('The name of the site, optionally links to the front page.'),
18 18
  'category' => t('Page elements'),
19 19
  'render last' => TRUE,
20
  'defaults' => array(
21
    'linked' => FALSE,
22
  ),
20 23
);
21 24

  
25
/**
26
 * Settings form for the Site Name pane.
27
 */
28
function ctools_page_site_name_content_type_edit_form($form, &$form_state) {
29
  $conf = $form_state['conf'];
30

  
31
  $form['linked'] = array(
32
    '#title' => t('Linked'),
33
    '#description' => t('Link the site name to the home page.'),
34
    '#type' => 'checkbox',
35
    '#default_value' => isset($conf['linked']) ? $conf['linked'] : FALSE,
36
  );
37

  
38
  return $form;
39
}
40

  
41
/**
42
 * The submit form stores the data in $conf.
43
 */
44
function ctools_page_site_name_content_type_edit_form_submit($form, &$form_state) {
45
  foreach (array_keys($form_state['plugin']['defaults']) as $key) {
46
    if (isset($form_state['values'][$key])) {
47
      $form_state['conf'][$key] = $form_state['values'][$key];
48
    }
49
  }
50
}
51

  
22 52
/**
23 53
 * Output function for the 'page_site_name' content type.
24 54
 *
......
26 56
 */
27 57
function ctools_page_site_name_content_type_render($subtype, $conf, $panel_args) {
28 58
  $block = new stdClass();
59

  
29 60
  $block->content = filter_xss_admin(variable_get('site_name', 'Drupal'));
30 61

  
62
  // Optionally link the site name to the homepage.
63
  if (!empty($conf['linked'])) {
64
    $block->content = l($block->content, '<front>');
65
  }
66

  
31 67
  return $block;
32 68
}

Formats disponibles : Unified diff