page_title.admin.inc 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * @file
  4. * Admin include file.
  5. */
  6. /**
  7. * Displays the form for the standard settings tab.
  8. *
  9. * @return
  10. * array A structured array for use with Forms API.
  11. */
  12. function page_title_admin_settings() {
  13. // Set the page title - the page is a local task now.
  14. drupal_set_title(t('Page titles'));
  15. // Set the theme callback for the patterns section
  16. $form['patterns'] = array(
  17. '#theme' => 'page_title_admin_settings',
  18. );
  19. $all_settings = page_title_get_settings();
  20. foreach ($all_settings as $key => $settings) {
  21. $form['patterns']['pattern'][$key] = array(
  22. '#title' => t($settings['label'], $settings['label arguments']),
  23. '#default_value' => variable_get($key, $settings['default']),
  24. '#required' => $settings['required'],
  25. '#description' => t($settings['description'], $settings['description arguments']),
  26. '#weight' => $settings['weight'],
  27. '#token_types' => $settings['scopes'],
  28. '#element_validate' => array('token_element_validate'),
  29. '#type' => 'textfield',
  30. '#size' => 30,
  31. '#maxlength' => 255,
  32. );
  33. $form['patterns']['scope'][$key] = array(
  34. '#markup' => implode('<br />', array_map('_page_title_scope_t', $settings['scopes'])),
  35. );
  36. if ($settings['show field']) {
  37. $form['patterns']['showfield'][$key . '_showfield'] = array(
  38. '#type' => 'checkbox',
  39. '#default_value' => variable_get($key . '_showfield', 0),
  40. );
  41. }
  42. }
  43. // Add the token help to a collapsed fieldset at the end of the configuration page.
  44. $form['token_help'] = array(
  45. '#type' => 'fieldset',
  46. '#title' => t('Available Tokens List'),
  47. '#collapsible' => TRUE,
  48. '#collapsed' => TRUE,
  49. );
  50. $form['token_help']['content'] = array(
  51. '#theme' => 'token_tree',
  52. '#token_types' => array('node', 'comment', 'term', 'vocabulary', 'user'),
  53. );
  54. $form = system_settings_form($form);
  55. return $form;
  56. }
  57. function _page_title_scope_t($item) {
  58. return t(drupal_ucfirst($item));
  59. }