html5_tools.admin.inc 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <?php
  2. /**
  3. * @file
  4. * Admin page callbacks for the html5_tools module.
  5. */
  6. /**
  7. * HTML5 Tools configuration page.
  8. */
  9. function html5_tools_admin_settings() {
  10. $form['html5_tools_forms'] = array(
  11. '#type' => 'fieldset',
  12. '#title' => t("Override Drupal's forms with their HTML5 counterparts"),
  13. '#collapsible' => FALSE,
  14. );
  15. $form['html5_tools_forms']['html5_tools_override_system_site_information_form'] = array(
  16. '#type' => 'checkbox',
  17. '#default_value' => variable_get('html5_tools_override_system_site_information_form', 1),
  18. '#title' => t('Site information'),
  19. '#description' => t('Modify the site configuration email textfield to an email field.'),
  20. );
  21. $form['html5_tools_forms']['html5_tools_override_search_block_form'] = array(
  22. '#type' => 'checkbox',
  23. '#default_value' => variable_get('html5_tools_override_search_block_form', 1),
  24. '#title' => t('Search block'),
  25. '#description' => t('Modify the search block textfield to a search field.'),
  26. );
  27. $form['html5_tools_forms']['html5_tools_override_search_form'] = array(
  28. '#type' => 'checkbox',
  29. '#default_value' => variable_get('html5_tools_override_search_form', 1),
  30. '#title' => t('Search form'),
  31. '#description' => t('Modify the search form textfield to a search field.'),
  32. );
  33. $form['html5_tools_forms']['html5_tools_override_user_register_form'] = array(
  34. '#type' => 'checkbox',
  35. '#default_value' => variable_get('html5_tools_override_user_register_form', 1),
  36. '#title' => t('User registration'),
  37. '#description' => t('Modify the user registration textfield to an email field.'),
  38. );
  39. $form['html5_tools_forms']['html5_tools_override_contact_forms'] = array(
  40. '#type' => 'checkbox',
  41. '#default_value' => variable_get('html5_tools_override_contact_forms', 1),
  42. '#title' => t('Contact forms'),
  43. '#description' => t("Modify contact form's textfields to email fields."),
  44. );
  45. $form['html5_tools_head_markup'] = array(
  46. '#type' => 'fieldset',
  47. '#title' => t('Simplify &lt;head&gt; markup'),
  48. '#collapsible' => FALSE,
  49. );
  50. $form['html5_tools_head_markup']['html5_tools_override_doctype'] = array(
  51. '#type' => 'checkbox',
  52. '#default_value' => variable_get('html5_tools_override_doctype', 1),
  53. '#title' => t('Simplify doctype'),
  54. '#description' => t('Replaces html.tpl.php with a custom html.tpl.php which has the proper html5 doctype. This settings will not take effect if your theme has its own html.tpl.php.'),
  55. );
  56. $form['html5_tools_head_markup']['html5_tools_override_style_tags'] = array(
  57. '#type' => 'checkbox',
  58. '#default_value' => variable_get('html5_tools_override_style_tags', 1),
  59. '#title' => t('Simplify style tags'),
  60. '#description' => t('Removes the type attribute from links to stylesheets. The format for HTML5 is <em>&lt;link rel="stylesheet" href="file.css" /&gt;</em>. The <em>type="text/css"</em> is unnecessary.'),
  61. );
  62. $form['html5_tools_head_markup']['html5_tools_override_script_tags'] = array(
  63. '#type' => 'checkbox',
  64. '#default_value' => variable_get('html5_tools_override_script_tags', 1),
  65. '#title' => t('Simplify javascript tags'),
  66. '#description' => t('Removes the type attribute from the &lt;script&gt; tag. The format for HTML5 is <em>&lt;script src="file.js"&gt;&lt;/script&gt;</em>. The <em>type="text/javascript"</em> is unnecessary. All browsers will assume it is javascript.'),
  67. );
  68. $form['html5_tools_head_markup']['html5_tools_override_meta_tags'] = array(
  69. '#type' => 'checkbox',
  70. '#default_value' => variable_get('html5_tools_override_meta_tags', 1),
  71. '#title' => t('Simplify meta tags'),
  72. '#description' => t('Alters the <em>http-equiv="content-type"</em> meta tag to make it shorter, removing the http-equiv and content attributes. They are unnecessary.'),
  73. );
  74. $form['html5_tools_head_markup']['html5_tools_add_chrome_frame_header'] = array(
  75. '#type' => 'checkbox',
  76. '#default_value' => variable_get('html5_tools_add_chrome_frame_header', 1),
  77. '#title' => t('Add Google Chrome Frame headers'),
  78. '#description' => t('Adds the X-UA-Compatible: IE=Edge,chrome=1 headers for IE browsers. This will not prompt the user to install !gcf, it\'ll just use it if available.', array(
  79. '!gcf' => l('Google Chrome Frame', 'http://code.google.com/chrome/chromeframe/'),
  80. )),
  81. );
  82. $form['html5_tools_overrides'] = array(
  83. '#type' => 'fieldset',
  84. '#title' => t('Convert other variables'),
  85. '#collapsible' => FALSE,
  86. );
  87. $form['html5_tools_overrides']['html5_tools_override_submitted'] = array(
  88. '#type' => 'checkbox',
  89. '#default_value' => variable_get('html5_tools_override_submitted', 1),
  90. '#title' => t('Alter publication date markup'),
  91. '#description' => t('Implements the new &lt;time&gt; element and it\'s <em>pubdate</em> attribute, altering content and comment publication dates with the new HTML5 format by overriding the <em>$submitted</em> variable.'),
  92. );
  93. if (module_exists('views')) {
  94. $form['html5_tools_overrides']['html5_tools_override_views_field_rewrite_elements'] = array(
  95. '#type' => 'checkbox',
  96. '#default_value' => variable_get('html5_tools_override_views_field_rewrite_elements', 0),
  97. '#title' => t('Make new Elements available in the Views UI'),
  98. '#description' => t('This will allow you to use new elements such as <em>&lt;article&gt;</em>, <em>&lt;aside&gt;</em>, etc from views when choosing the custom HTML field'),
  99. );
  100. }
  101. $form['html5_tools_help_text'] = array(
  102. '#markup' => t("If one of these is not working, it might be because your theme is overriding what is specified here. Themes always get the last say in how something is outputted. Check your theme's template.php file."),
  103. );
  104. $form['#submit'][] = 'html5_tools_admin_settings_submit';
  105. return system_settings_form($form);
  106. }
  107. /**
  108. * Handle submission of the html5_tools configuration page.
  109. */
  110. function html5_tools_admin_settings_submit($form, &$form_state) {
  111. if (!empty($form_state['values']['html5_tools_override_views_field_rewrite_elements'])) {
  112. variable_set('views_field_rewrite_elements', array(
  113. '' => t('- Use default -'),
  114. '0' => t('- None -'),
  115. 'div' => t('DIV'),
  116. 'span' => t('SPAN'),
  117. 'h1' => t('H1'),
  118. 'h2' => t('H2'),
  119. 'h3' => t('H3'),
  120. 'h4' => t('H4'),
  121. 'h5' => t('H5'),
  122. 'h6' => t('H6'),
  123. 'p' => t('P'),
  124. 'strong' => t('STRONG'),
  125. 'em' => t('EM'),
  126. 'article' => t('Article'),
  127. 'aside' => t('Aside'),
  128. 'footer' => t('Footer'),
  129. 'header' => t('Header'),
  130. 'menu' => t('Menu'),
  131. 'nav' => t('Nav'),
  132. ));
  133. }
  134. else {
  135. variable_del('views_field_rewrite_elements');
  136. }
  137. drupal_theme_rebuild();
  138. }