page_title.admin.inc 3.28 KB
Newer Older
1
<?php
2
// $Id$
3

4
5
6
7
/**
 * @file
 * Admin include file.
 */
8
9
10
11
12
13
14
15

/**
 * Displays the form for the standard settings tab.
 *
 * @return
 *   array A structured array for use with Forms API.
 */
function page_title_admin_settings() {
16
17
  // Define a default looking 'form element' for setting.
  $showfield_form_element = array('#type' => 'checkbox', );
18
19


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
  // Define a default looking 'form element' for setting.
  $pattern_form_element = array(
    '#type' => 'textfield',
    '#size' => 30,
    '#maxlength' => 256,
  );


  // Set the theme callback for the patterns section
  $form['patterns'] = array(
    '#type' => 'fieldset',
    '#title' => t('Page Title Patterns'),
    '#collapsible' => TRUE,
    '#theme' => 'page_title_admin_settings'
  );


  // Define the 'default' token patterns
  $form['patterns']['pattern'] = array(
    'page_title_default' => array(
      '#title' => t('Default'),
      '#default_value' => variable_get('page_title_default', '[page-title] | [site-name]'),
      '#required' => TRUE,
    ) + $pattern_form_element,
    'page_title_front' => array(
      '#title' => t('Frontpage'),
      '#default_value' => variable_get('page_title_front', '[site-name] | [site-slogan]'),
    ) + $pattern_form_element,
    'page_title_user' => array(
      '#title' => t('User Profile'),
      '#default_value' => variable_get('page_title_user', ''),
    ) + $pattern_form_element,
  );


  // Define the "showfield" checkbox for the user profile page
  $form['patterns']['showfield']['page_title_user_showfield'] = array(
    '#default_value' => variable_get('page_title_user_showfield', 0),
  ) + $showfield_form_element;


  // Definate the patterns per-node-type
62
63
  $types = node_get_types();
  foreach ($types as $type) {
64
    // Define the node-type key
65
    $key = 'page_title_type_'. $type->type;
66
67
68
69
70
71
72
73
74
75

    // Pattern entry
    $form['patterns']['pattern'][$key] = array(
      '#title' => t('Content Type - %type', array('%type' => $type->name)),
      '#default_value' => variable_get($key, ''),
    ) + $pattern_form_element;

    $form['patterns']['showfield'][$key .'_showfield'] = array(
      '#default_value' => variable_get($key .'_showfield', 0),
    ) + $showfield_form_element;
76
77
78
  }


79
80
81
82
83
84
  // Definate the patterns per-vocab-type - if Taxonomy Module is enabled
  if (module_exists('taxonomy')) {
    $vocabs = taxonomy_get_vocabularies();
    foreach ($vocabs as $vocab) {
      // Define the vocab key
      $key = 'page_title_vocab_'. $vocab->vid;
85

86
87
88
89
90
      // Pattern entry
      $form['patterns']['pattern'][$key] = array(
        '#title' => t('Vocabulary - %vocab_name', array('%vocab_name' => $vocab->name)),
        '#default_value' => variable_get($key, ''),
      ) + $pattern_form_element;
91

92
93
94
95
96
97
98
99
100
      $form['patterns']['showfield'][$key .'_showfield'] = array(
        '#default_value' => variable_get($key .'_showfield', 0),
      ) + $showfield_form_element;
    }
  }


  // Add the token help to a collapsed fieldset at the end of the configuration page.
  $form['token_help'] = array(
101
    '#type' => 'fieldset',
102
103
104
    '#title' => t('Available Tokens List'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
105
  );
106
107
108
  $form['token_help']['content'] = array(
    '#type' => 'markup',
    '#value' => theme('token_help'),
109
110
  );

111
  // Return the form with the system buttons & action added to it
112
113
114
  return system_settings_form($form);
}