| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: sitedoc.admin.inc,v 1.1.2.1.2.4 2008/08/22 16:57:14 nancyw Exp $ 3 4 // @file sitedoc.admin.inc 5 6 /********************************/ 7 /** Main settings function **/ 8 /********************************/ 9 function sitedoc_settings_page() { 10 return drupal_get_form('sitedoc_settings_form'); 11 } 12 13 function sitedoc_settings_form(&$form_state) { 14 drupal_add_css(drupal_get_path('module', 'sitedoc') .'/sitedoc.css'); 15 $sitedoc_settings = variable_get('sitedoc_settings', array()); 16 17 // Sections Fieldset 18 $form['sections'] = array( 19 '#type' => 'fieldset', 20 '#title' => t('Show Sections'), 21 '#weight' => -5, 22 '#collapsible' => FALSE, 23 '#collapsed' => FALSE, 24 '#prefix' => '<div class="sitedoc_sections_block">', 25 '#suffix' => '', 26 ); 27 28 $form['sections']['drupal_section'] = array( 29 '#type' => 'checkbox', 30 '#title' => t('Include Basic Drupal information?'), 31 '#prefix' => '<div class="sitedoc_sections">', 32 // '#suffix' => '</div>', 33 '#default_value' => $sitedoc_settings['drupal_section'], 34 ); 35 36 $kill_time = drupal_map_assoc(array(0, 1800, 3600, 7200, 10800, 14400, 18000, 21600, 32400, 43200, 86400, 172800), 'format_interval'); 37 $kill_time['0'] = t('Never'); 38 $form['sections']['kill_cron'] = array( 39 '#type' => 'select', 40 '#options' => $kill_time, 41 '#title' => t('Delete Cron variables after'), 42 '#prefix' => '<div class="sitedoc_options">', 43 '#suffix' => '</div></div>', 44 '#default_value' => $sitedoc_settings['kill_cron'], 45 ); 46 47 $form['sections']['table_section'] = array( 48 '#type' => 'checkbox', 49 '#title' => t('Include Table Summary?'), 50 '#prefix' => '<div class="sitedoc_sections">', 51 // '#suffix' => '</div>', 52 '#default_value' => $sitedoc_settings['table_section'], 53 ); 54 55 $form['sections']['show_indexes'] = array( 56 '#type' => 'checkbox', 57 '#title' => t('Show indexes?'), 58 '#prefix' => '<div class="sitedoc_options">', 59 '#suffix' => '</div>', 60 '#default_value' => $sitedoc_settings['show_indexes'], 61 ); 62 63 $form['sections']['optimize_tables'] = array( 64 '#type' => 'checkbox', 65 '#title' => t('Release overhead?'), 66 '#prefix' => '<div class="sitedoc_options">', 67 '#suffix' => '</div></div>', 68 '#description' => t('(SQL intensive - uses OPTIMIZE)'), 69 '#default_value' => $sitedoc_settings['optimize_tables'], 70 ); 71 72 $form['sections']['node_section'] = array( 73 '#type' => 'checkbox', 74 '#title' => t('Include Node Summary?'), 75 '#prefix' => '<div class="sitedoc_sections">', 76 // '#suffix' => '</div>', 77 '#description' => t('(SQL intensive)'), 78 '#default_value' => $sitedoc_settings['node_section'], 79 ); 80 81 $form['sections']['node_show_size'] = array( 82 '#type' => 'textfield', 83 '#title' => t('Show nodes exceeding (KB)'), 84 '#prefix' => '<div class="sitedoc_options">', 85 '#suffix' => '</div>', 86 '#default_value' => $sitedoc_settings['node_show_size'], 87 '#size' => 8, 88 '#maxlength' => 7, 89 ); 90 91 $form['sections']['node_max_size'] = array( 92 '#type' => 'textfield', 93 '#title' => t('Warn if nodes exceed (KB)'), 94 '#prefix' => '<div class="sitedoc_options">', 95 '#suffix' => '</div>', 96 '#default_value' => $sitedoc_settings['node_max_size'], 97 '#size' => 8, 98 '#maxlength' => 7, 99 ); 100 101 $form['sections']['include_node_access'] = array( 102 '#type' => 'checkbox', 103 '#title' => t('Include node access summary?'), 104 '#prefix' => '<div class="sitedoc_options">', 105 '#suffix' => '</div>', 106 '#default_value' => $sitedoc_settings['include_node_access'], 107 ); 108 109 $form['sections']['include_comment_count'] = array( 110 '#type' => 'checkbox', 111 '#title' => t('Include comment count on nodes?'), 112 '#prefix' => '<div class="sitedoc_options">', 113 '#suffix' => '</div></div>', 114 '#default_value' => $sitedoc_settings['include_comment_count'], 115 ); 116 117 $form['sections']['variables_section'] = array( 118 '#type' => 'checkbox', 119 '#title' => t('Include System Variables?'), 120 '#prefix' => '<div class="sitedoc_sections">', 121 '#suffix' => '</div>', 122 '#description' => t('(CPU intensive)'), 123 '#default_value' => $sitedoc_settings['variables_section'], 124 ); 125 126 $form['sections']['module_section'] = array( 127 '#type' => 'checkbox', 128 '#title' => t('Include Module summary?'), 129 '#prefix' => '<div class="sitedoc_sections">', 130 // '#suffix' => '</div>', 131 '#default_value' => $sitedoc_settings['module_section'], 132 ); 133 134 $form['sections']['module_suppress'] = array( 135 '#type' => 'checkbox', 136 '#title' => t('Exclude disabled modules?'), 137 '#prefix' => '<div class="sitedoc_options">', 138 '#suffix' => '</div>', 139 '#default_value' => $sitedoc_settings['module_suppress'], 140 ); 141 142 $module_sort_order = array( 143 0 => 'package, project, module', 144 1 => 'path, module', 145 ); 146 147 $form['sections']['module_sort_order'] = array( 148 '#type' => 'radios', 149 '#title' => t('List sort order'), 150 '#options' => $module_sort_order, 151 '#prefix' => '<div class="sitedoc_options">', 152 '#suffix' => '</div></div>', 153 '#default_value' => $sitedoc_settings['module_sort_order'], 154 ); 155 156 $form['sections']['content_section'] = array( 157 '#type' => 'checkbox', 158 '#title' => t('Include Content Type summary?'), 159 '#prefix' => '<div class="sitedoc_sections">', 160 '#suffix' => '</div>', 161 '#default_value' => $sitedoc_settings['content_section'], 162 ); 163 164 if (module_exists('taxonomy')) { 165 $form['sections']['vocabulary_section'] = array( 166 '#type' => 'checkbox', 167 '#title' => t('Include Vocabulary summary?'), 168 '#prefix' => '<div class="sitedoc_sections">', 169 '#description' => t('(may be CPU and SQL intensive)'), 170 '#default_value' => $sitedoc_settings['vocabulary_section'], 171 ); 172 173 $form['sections']['orphan_term_node'] = array( 174 '#type' => 'checkbox', 175 '#title' => t('Check for orphan Term_nodes?'), 176 '#prefix' => '<div class="sitedoc_options">', 177 '#suffix' => '</div>', 178 '#description' => t('(may be SQL intensive)'), 179 '#default_value' => $sitedoc_settings['orphan_term_node'], 180 ); 181 182 $form['sections']['delete_orphan_term_nodes'] = array( 183 '#type' => 'checkbox', 184 '#title' => t('Delete orphan term nodes?'), 185 '#prefix' => '<div class="sitedoc_options">', 186 '#suffix' => '</div></div>', 187 '#default_value' => $sitedoc_settings['delete_orphan_term_nodes'], 188 ); 189 } /* end if taxo exists */ 190 191 $form['sections']['theme_section'] = array( 192 '#type' => 'checkbox', 193 '#title' => t('Include Themes?'), 194 '#prefix' => '<div class="sitedoc_sections">', 195 '#suffix' => '</div>', 196 '#default_value' => $sitedoc_settings['theme_section'], 197 ); 198 199 $form['sections']['block_section'] = array( 200 '#type' => 'checkbox', 201 '#title' => t('Include Blocks and Boxes?'), 202 '#prefix' => '<div class="sitedoc_sections">', 203 '#default_value' => $sitedoc_settings['block_section'], 204 ); 205 206 $form['sections']['block_warn'] = array( 207 '#type' => 'checkbox', 208 '#title' => t('Warn on missing theme for blocks?'), 209 '#prefix' => '<div class="sitedoc_options">', 210 '#suffix' => '</div>', 211 '#description' => t('This allows the module to display a warning message if a block exists for a missing theme.'), 212 '#default_value' => $sitedoc_settings['block_warn'], 213 ); 214 215 $form['sections']['block_delete'] = array( 216 '#type' => 'checkbox', 217 '#title' => t('Delete the orphan blocks?'), 218 '#prefix' => '<div class="sitedoc_options">', 219 '#suffix' => '</div></div>', 220 '#description' => t('Delete the blocks with a missing theme.'), 221 '#default_value' => $sitedoc_settings['block_delete'], 222 ); 223 224 $form['sections']['roles_section'] = array( 225 '#type' => 'checkbox', 226 '#title' => t('Include Roles and Permissions?'), 227 '#prefix' => '<div class="sitedoc_sections">', 228 '#default_value' => $sitedoc_settings['roles_section'], 229 ); 230 231 $form['sections']['role_users'] = array( 232 '#type' => 'checkbox', 233 '#title' => t('Show list of users for each role?'), 234 '#prefix' => '<div class="sitedoc_options">', 235 '#suffix' => '</div>', 236 '#description' => t('Displays the list of users assigned the role.'), 237 '#default_value' => $sitedoc_settings['role_users'], 238 ); 239 240 $form['sections']['role_perms_list'] = array( 241 '#type' => 'checkbox', 242 '#title' => t('Show role permissions as a list?'), 243 '#prefix' => '<div class="sitedoc_options">', 244 '#suffix' => '</div></div>', 245 '#description' => t('If not chosen, the roles will be shown as a stream.'), 246 '#default_value' => $sitedoc_settings['role_perms_list'], 247 ); 248 249 if (module_exists('contact')) { 250 $form['sections']['contacts_section'] = array( 251 '#type' => 'checkbox', 252 '#title' => t('Include Contacts?'), 253 '#prefix' => '<div class="sitedoc_sections">', 254 '#suffix' => '</div>', 255 '#default_value' => $sitedoc_settings['contacts_section'], 256 ); 257 } 258 259 if (module_exists('profile')) { 260 $form['sections']['profile_fields_section'] = array( 261 '#type' => 'checkbox', 262 '#title' => t('Include Profile Fields?'), 263 '#prefix' => '<div class="sitedoc_sections">', 264 '#suffix' => '</div>', 265 '#default_value' => $sitedoc_settings['profile_fields_section'], 266 ); 267 } 268 269 if (module_exists('path')) { 270 $form['sections']['url_alias_section'] = array( 271 '#type' => 'checkbox', 272 '#title' => t('Include URL Aliases?'), 273 '#prefix' => '<div class="sitedoc_sections">', 274 '#suffix' => '</div>', 275 '#description' => t('(SQL intensive)'), 276 '#default_value' => $sitedoc_settings['url_alias_section'], 277 ); 278 } 279 280 $form['sections']['input_format_section'] = array( 281 '#type' => 'checkbox', 282 '#title' => t('Include Input Formats and Filters?'), 283 '#prefix' => '<div class="sitedoc_sections">', 284 '#suffix' => '</div>', 285 '#default_value' => $sitedoc_settings['input_format_section'], 286 ); 287 288 // Update Button 289 $form['submit'] = array( 290 '#type' => 'submit', 291 '#value' => t('Save configuration'), 292 '#weight' => 5, 293 '#prefix' => '</div><div class="clear-block"></div>' 294 ); 295 296 return $form; 297 } 298 299 /** 300 * Save the settings values. 301 */ 302 function sitedoc_settings_form_submit($form, &$form_state) { 303 // update the settings array and save it 304 $settings = variable_get('sitedoc_settings', array()); 305 306 $settings['drupal_section'] = $form_state['values']['drupal_section']; 307 $settings['kill_cron'] = $form_state['values']['kill_cron']; 308 $settings['table_section'] = $form_state['values']['table_section']; 309 $settings['show_indexes'] = $form_state['values']['show_indexes']; 310 $settings['optimize_tables'] = $form_state['values']['optimize_tables']; 311 $settings['node_section'] = $form_state['values']['node_section']; 312 $settings['include_comment_count'] = $form_state['values']['include_comment_count']; 313 $settings['include_node_access'] = $form_state['values']['include_node_access']; 314 $settings['node_show_size'] = $form_state['values']['node_show_size']; 315 $settings['node_max_size'] = $form_state['values']['node_max_size']; 316 $settings['module_section'] = $form_state['values']['module_section']; 317 $settings['module_suppress'] = $form_state['values']['module_suppress']; 318 $settings['module_sort_order'] = $form_state['values']['module_sort_order']; 319 $settings['content_section'] = $form_state['values']['content_section']; 320 $settings['vocabulary_section'] = $form_state['values']['vocabulary_section']; 321 $settings['orphan_term_node'] = $form_state['values']['orphan_term_node']; 322 $settings['delete_orphan_term_nodes'] = $form_state['values']['delete_orphan_term_nodes']; 323 $settings['theme_section'] = $form_state['values']['theme_section']; 324 $settings['variables_section'] = $form_state['values']['variables_section']; 325 $settings['block_section'] = $form_state['values']['block_section']; 326 $settings['block_warn'] = $form_state['values']['block_warn']; 327 $settings['block_delete'] = $form_state['values']['block_delete']; 328 $settings['roles_section'] = $form_state['values']['roles_section']; 329 $settings['role_users'] = $form_state['values']['role_users']; 330 $settings['role_perms_list'] = $form_state['values']['role_perms_list']; 331 $settings['contacts_section'] = $form_state['values']['contacts_section']; 332 $settings['profile_fields_section'] = $form_state['values']['profile_fields_section']; 333 $settings['url_alias_section'] = $form_state['values']['url_alias_section']; 334 $settings['input_format_section'] = $form_state['values']['input_format_section']; 335 336 variable_set('sitedoc_settings', $settings); 337 338 drupal_set_message(t('Configuration has been updated. ') . l(t('Run now'), 'admin/build/sitedoc'), 'status'); 339 } 340 341 function sitedoc_archive_form(&$form_state) { 342 drupal_add_css(drupal_get_path('module', 'sitedoc') .'/sitedoc.css'); 343 $sitedoc_settings = variable_get('sitedoc_settings', array()); 344 345 $save_time = drupal_map_assoc(array(0, 3600, 7200, 14400, 21600, 43200, 86400, 172800, 259200, 604800), 'format_interval'); 346 $save_time['0'] = t('Never'); 347 $save_time['999999'] = t('Always'); 348 349 $form['archive_frequency'] = array( 350 '#type' => 'select', 351 '#options' => $save_time, 352 '#title' => t('Archive frequency'), 353 '#prefix' => '<div class="sitedoc_archive">', 354 '#suffix' => '</div>', 355 '#default_value' => $sitedoc_settings['archive_frequency'], 356 '#description' => t('The Site Documentation module will run at the next scheduled Cron run after this period has elapsed. A zero value suppresses creation of an archive. "Always" means a file will be created every time Cron runs.'), 357 ); 358 359 $form['archive_directory'] = array( 360 '#type' => 'textfield', 361 '#title' => t('Archive directory'), 362 '#prefix' => '<div class="sitedoc_archive">', 363 '#suffix' => '</div>', 364 '#default_value' => $sitedoc_settings['archive_directory'], 365 '#description' => t('This is directory within \'!filepath\' where the Site Documentation module will place the archive file. The current date will be appended to the file name.', array('!filepath' => file_directory_path())), 366 ); 367 368 // Add the Buttons 369 $form['save'] = array( 370 '#type' => 'submit', 371 '#value' => t('Save configuration'), 372 '#weight' => 5, 373 '#prefix' => '<div class="clear-block"></div>' 374 ); 375 376 // If $form_values exists, then we've been here before (submitted), so now add a "run cron" button. 377 if ($sitedoc_settings['archive_frequency'] > 0) { 378 $form['cron'] = array( 379 '#type' => 'submit', 380 '#value' => t('Run Cron Now'), 381 '#weight' => 6, 382 ); 383 } 384 385 return $form; 386 } 387 388 /** 389 * Validate the submission. 390 */ 391 function sitedoc_archive_form_validate($form, &$form_state) { 392 $archive_path = file_directory_path() .'/'. $form_state['values']['archive_directory']; 393 if (!file_check_directory($archive_path, TRUE, 'archive_directory')) { 394 form_set_error('archive_directory', t('The archive path could not be found or could not be created.')); 395 } // end path not found 396 } 397 398 /** 399 * Save the settings values. 400 */ 401 function sitedoc_archive_form_submit($form, &$form_state) { 402 switch ($form_state['values']['op']) { 403 case t('Run Cron Now'): 404 drupal_goto('admin/reports/status/run-cron'); 405 break; 406 407 case t('Save configuration'): 408 // update the settings array and save it 409 $sitedoc_settings = variable_get('sitedoc_settings', array()); 410 $sitedoc_settings['archive_frequency'] = $form_state['values']['archive_frequency']; 411 $sitedoc_settings['archive_directory'] = $form_state['values']['archive_directory']; 412 413 variable_set('sitedoc_settings', $sitedoc_settings); 414 415 drupal_set_message(t('Configuration has been updated. ') . l(t('Run now'), 'admin/build/sitedoc'), 'status'); 416 } 417 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |