| 1 |
|
<?php |
| 2 |
|
// $Id$ |
| 3 |
|
|
| 4 |
|
/** |
| 5 |
|
* @file |
| 6 |
|
* This module displays customizable index pages for each node type, with |
| 7 |
|
* alphabetical, taxonomy, and user filters. |
| 8 |
|
*/ |
| 9 |
|
|
| 10 |
|
/** |
| 11 |
|
* Implementation of hook_form(). |
| 12 |
|
*/ |
| 13 |
|
function indexpage_admin_settings() { |
| 14 |
|
drupal_add_css(drupal_get_path('module', 'indexpage') . '/indexpage.css'); |
| 15 |
|
$yesno = array(1 => t('Yes'), 0 => t('No')); |
| 16 |
|
|
| 17 |
|
$form['general'] = array( |
| 18 |
|
'#type' => 'fieldset', |
| 19 |
|
'#title' => t('General settings'), |
| 20 |
|
'#collapsible' => TRUE, |
| 21 |
|
'#collapsed' => FALSE, |
| 22 |
|
); |
| 23 |
|
|
| 24 |
|
$form['general']['indexpage_description'] = array( |
| 25 |
|
'#type' => 'textarea', |
| 26 |
|
'#title' => t('Description text for main index page'), |
| 27 |
|
'#default_value' => variable_get('indexpage_description', ''), |
| 28 |
|
'#cols' => 60, |
| 29 |
|
'#rows' => 3, |
| 30 |
|
); |
| 31 |
|
|
| 32 |
|
$form['general']['indexpage_maxresults'] = array( |
| 33 |
|
'#type' => 'textfield', |
| 34 |
|
'#title' => t('Max number of results per page'), |
| 35 |
|
'#default_value' => variable_get('indexpage_maxresults', 10), |
| 36 |
|
'#size' => 2, |
| 37 |
|
'#maxlength' => 2, |
| 38 |
|
'#description' => t('This option determines how many items will show on the results page before a pager is added. It also makes term list fieldsets collapse when there are more that this many terms in the list.'), |
| 39 |
|
); |
| 40 |
|
|
| 41 |
|
$form['general']['indexpage_show_users'] = array( |
| 42 |
|
'#type' => 'radios', |
| 43 |
|
'#options' => $yesno, |
| 44 |
|
'#prefix' => '<div class="indexpage-radios">', |
| 45 |
|
'#suffix' => '</div>', |
| 46 |
|
'#title' => t('Show users who have submitted this content'), |
| 47 |
|
'#default_value' => (int) variable_get('indexpage_show_users', FALSE), |
| 48 |
|
'#description' => t('If this option is selected, an additional section with user names will be shown.'), |
| 49 |
|
); |
| 50 |
|
|
| 51 |
|
$form['general']['indexpage_suppress_unused'] = array( |
| 52 |
|
'#type' => 'radios', |
| 53 |
|
'#options' => $yesno, |
| 54 |
|
'#prefix' => '<div class="indexpage-radios">', |
| 55 |
|
'#suffix' => '</div>', |
| 56 |
|
'#title' => t('Suppress unused taxonomy terms'), |
| 57 |
|
'#default_value' => (int) variable_get('indexpage_suppress_unused', FALSE), |
| 58 |
|
'#description' => t('If this option is selected, terms with no associated nodes will not be shown.'), |
| 59 |
|
); |
| 60 |
|
|
| 61 |
|
$form['general']['indexpage_teaser_tooltip'] = array( |
| 62 |
|
'#type' => 'radios', |
| 63 |
|
'#options' => $yesno, |
| 64 |
|
'#prefix' => '<div class="indexpage-radios">', |
| 65 |
|
'#suffix' => '</div>', |
| 66 |
|
'#title' => t("Use the node's teaser as the link title"), |
| 67 |
|
'#default_value' => (int) variable_get('indexpage_teaser_tooltip', TRUE), |
| 68 |
|
'#description' => t('If this option is selected, the teaser for the node will be used for the link title (tooltip).'), |
| 69 |
|
); |
| 70 |
|
|
| 71 |
|
$form['general']['indexpage_show_count'] = array( |
| 72 |
|
'#type' => 'radios', |
| 73 |
|
'#options' => $yesno, |
| 74 |
|
'#prefix' => '<div class="indexpage-radios">', |
| 75 |
|
'#suffix' => '</div>', |
| 76 |
|
'#title' => t('Show counts'), |
| 77 |
|
'#default_value' => (int) variable_get('indexpage_show_count', TRUE), |
| 78 |
|
'#description' => t('Shows a count of how many nodes there are and how many are used by each term.'), |
| 79 |
|
); |
| 80 |
|
|
| 81 |
|
$form['general']['indexpage_show_untagged'] = array( |
| 82 |
|
'#type' => 'radios', |
| 83 |
|
'#options' => $yesno, |
| 84 |
|
'#prefix' => '<div class="indexpage-radios">', |
| 85 |
|
'#suffix' => '</div>', |
| 86 |
|
'#title' => t('Show untagged'), |
| 87 |
|
'#default_value' => (int) variable_get('indexpage_show_untagged', TRUE), |
| 88 |
|
'#description' => t('Shows a count of how many nodes that have no taxonomy term associated.'), |
| 89 |
|
); |
| 90 |
|
|
| 91 |
|
$form['general']['indexpage_show_description'] = array( |
| 92 |
|
'#type' => 'radios', |
| 93 |
|
'#options' => $yesno, |
| 94 |
|
'#prefix' => '<div class="indexpage-radios">', |
| 95 |
|
'#suffix' => '</div>', |
| 96 |
|
'#title' => t('Show term description'), |
| 97 |
|
'#default_value' => (int) variable_get('indexpage_show_description', FALSE), |
| 98 |
|
'#description' => t('Shows the description for the term in the term list.'), |
| 99 |
|
); |
| 100 |
|
|
| 101 |
|
$form['general']['indexpage_list_format'] = array( |
| 102 |
|
'#type' => 'radios', |
| 103 |
|
'#options' => array('list' => t('List'), 'table' => t('Table')), |
| 104 |
|
'#title' => t('Show terms list as'), |
| 105 |
|
'#default_value' => variable_get('indexpage_list_format', 'list'), |
| 106 |
|
'#description' => t('This determines how the list of terms will appear.'), |
| 107 |
|
'#prefix' => '<div class="indexpage-radios">', |
| 108 |
|
'#suffix' => '</div>', |
| 109 |
|
); |
| 110 |
|
|
| 111 |
|
$field_list = array( |
| 112 |
|
'uid' => t('Author'), |
| 113 |
|
'authors' => t('All Authors'), |
| 114 |
|
'terms' => t('Terms'), |
| 115 |
|
'type' => t('Node type'), |
| 116 |
|
'created' => t('Created date/time'), |
| 117 |
|
'changed' => t('Updated date/time'), |
| 118 |
|
'status' => t('Published'), |
| 119 |
|
'promote' => t('Promoted'), |
| 120 |
|
'sticky' => t('Sticky'), |
| 121 |
|
'language' => t('Language'), |
| 122 |
|
); |
| 123 |
|
if (module_exists('weight')) { |
| 124 |
|
$field_list['weight'] = t('Weight'); |
| 125 |
|
} |
| 126 |
|
|
| 127 |
|
$form['general']['indexpage_fields'] = array( |
| 128 |
|
'#type' => 'checkboxes', |
| 129 |
|
'#options' => $field_list, |
| 130 |
|
'#title' => t('Include extra fields on the result page'), |
| 131 |
|
'#default_value' => variable_get('indexpage_fields', array()), |
| 132 |
|
'#description' => t('Any selected fields will be included in the results list. The title will always be shown.'), |
| 133 |
|
'#prefix' => '<div class="indexpage-checkboxes">', |
| 134 |
|
'#suffix' => '</div>', |
| 135 |
|
); |
| 136 |
|
|
| 137 |
|
// Do a fieldset for each content type. |
| 138 |
|
$type_list = node_get_types('names'); |
| 139 |
|
$taxonomy_exists = module_exists('taxonomy'); |
| 140 |
|
|
| 141 |
|
foreach ($type_list as $type => $name) { |
| 142 |
|
$set = $type; |
| 143 |
|
$form[$set] = array( |
| 144 |
|
'#type' => 'fieldset', |
| 145 |
|
'#title' => t('Index page settings for !s', array('!s' => $type)), |
| 146 |
|
'#collapsible' => TRUE, |
| 147 |
|
'#collapsed' => TRUE, |
| 148 |
|
); |
| 149 |
|
|
| 150 |
|
$var_prefix = 'indexpage_' . $type; |
| 151 |
|
|
| 152 |
|
$form[$set][$var_prefix . '_name'] = array( |
| 153 |
|
'#type' => 'textfield', |
| 154 |
|
'#title' => t('Name to show for this node type'), |
| 155 |
|
'#default_value' => variable_get($var_prefix . '_name', $name), |
| 156 |
|
'#size' => 20, |
| 157 |
|
'#maxlength' => 50, |
| 158 |
|
); |
| 159 |
|
|
| 160 |
|
$form[$set][$var_prefix . '_enable'] = array( |
| 161 |
|
'#type' => 'checkbox', |
| 162 |
|
'#title' => t('Enable index page for this node type'), |
| 163 |
|
'#return_value' => 1, |
| 164 |
|
'#default_value' => variable_get($var_prefix . '_enable', 1), |
| 165 |
|
); |
| 166 |
|
|
| 167 |
|
$form[$set][$var_prefix . '_alphaindex'] = array( |
| 168 |
|
'#type' => 'checkbox', |
| 169 |
|
'#title' => t('Show alphabetical index for this node type'), |
| 170 |
|
'#return_value' => 1, |
| 171 |
|
'#default_value' => variable_get($var_prefix . '_alphaindex', 1), |
| 172 |
|
); |
| 173 |
|
|
| 174 |
|
if ($taxonomy_exists) { |
| 175 |
|
$form[$set][$var_prefix . '_vocfilter'] = array( |
| 176 |
|
'#type' => 'checkbox', |
| 177 |
|
'#title' => t('Show vocabulary filters for this node type'), |
| 178 |
|
'#return_value' => 1, |
| 179 |
|
'#default_value' => variable_get($var_prefix . '_vocfilter', 1), |
| 180 |
|
); |
| 181 |
|
} |
| 182 |
|
else { |
| 183 |
|
$form[$set][$var_prefix . '_vocfilter'] = array( |
| 184 |
|
'#type' => 'value', |
| 185 |
|
'#value' => FALSE, |
| 186 |
|
); |
| 187 |
|
} |
| 188 |
|
|
| 189 |
|
$form[$set][$var_prefix . '_page_text'] = array( |
| 190 |
|
'#type' => 'textarea', |
| 191 |
|
'#title' => t('Descriptive text to show at the top of the page.'), |
| 192 |
|
'#rows' => 3, |
| 193 |
|
'#default_value' => variable_get($var_prefix . '_page_text', NULL), |
| 194 |
|
); |
| 195 |
|
} |
| 196 |
|
|
| 197 |
|
$form['#submit'] = array('indexpage_settings_submit'); |
| 198 |
|
|
| 199 |
|
return system_settings_form($form); |
| 200 |
|
} |
| 201 |
|
|
| 202 |
|
function indexpage_settings_submit($form, &$form_state) { |
| 203 |
|
menu_rebuild(); |
| 204 |
|
} |