content_type_extras.admin.inc 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. <?php
  2. function content_type_extras_settings() {
  3. $defaults = content_type_extras_get_default();
  4. // Get all available user roles
  5. $roles = user_roles();
  6. $admin_role = variable_get('user_admin_role', 0);
  7. if ($admin_role != 0) {
  8. $roles[$admin_role] .= t(' <em>(administrator role)</em>');
  9. }
  10. $form = array(
  11. 'intro' => array(
  12. '#markup' => t('Set the default settings for all new content types below. These settings can be overridden on the content type page.'),
  13. ),
  14. 'content_type_extras' => array(
  15. '#type' => 'vertical_tabs',
  16. 'submission' => array(
  17. '#type' => 'fieldset',
  18. '#title' => t('Submission form settings'),
  19. '#attached' => array(
  20. 'js' => array(
  21. 'vertical-tabs' => drupal_get_path('module', 'content_type_extras') . '/js/content_type_extras.vertical_tabs.js',
  22. ),
  23. ),
  24. '#weight' => 0,
  25. 'title_label' => array(
  26. '#type' => 'textfield',
  27. '#title' => t('Title field label'),
  28. '#default_value' => $defaults['title_label'],
  29. '#required' => 1,
  30. ),
  31. 'node_preview' => array(
  32. '#type' => 'radios',
  33. '#title' => t('Preview before submitting'),
  34. '#options' => array(
  35. t('Disabled'),
  36. t('Optional'),
  37. t('Required'),
  38. ),
  39. '#default_value' => $defaults['node_preview'],
  40. ),
  41. 'content_type_extras_preview_button' => array(
  42. '#type' => 'textfield',
  43. '#title' => t('Preview button value'),
  44. '#description' => t('The name of the Preview button that will display on the content edit form if enabled'),
  45. '#default_value' => $defaults['content_type_extras_preview_button'],
  46. '#required' => 1,
  47. ),
  48. 'content_type_extras_save_and_new' => array(
  49. '#type' => 'radios',
  50. '#title' => t('Save and New button'),
  51. '#options' => array(
  52. t('Disabled'),
  53. t('Enabled'),
  54. ),
  55. '#default_value' => $defaults['content_type_extras_save_and_new'],
  56. ),
  57. 'content_type_extras_save_and_new_button' => array(
  58. '#type' => 'textfield',
  59. '#title' => t('Save and New button value'),
  60. '#description' => t('The name of the Save and New button that will display on the content edit form if enabled'),
  61. '#default_value' => $defaults['content_type_extras_save_and_new_button'],
  62. '#required' => 1,
  63. ),
  64. 'content_type_extras_save_and_edit' => array(
  65. '#type' => 'radios',
  66. '#title' => t('Save and Edit button'),
  67. '#options' => array(
  68. t('Disabled'),
  69. t('Enabled'),
  70. ),
  71. '#default_value' => $defaults['content_type_extras_save_and_edit'],
  72. ),
  73. 'content_type_extras_save_and_edit_button' => array(
  74. '#type' => 'textfield',
  75. '#title' => t('Save and Edit button value'),
  76. '#description' => t('The name of the Save and Edit button that will display on the content edit form if enabled'),
  77. '#default_value' => $defaults['content_type_extras_save_and_edit_button'],
  78. '#required' => 1,
  79. ),
  80. 'content_type_extras_cancel' => array(
  81. '#type' => 'radios',
  82. '#title' => t('Cancel button'),
  83. '#options' => array(
  84. t('Disabled'),
  85. t('Enabled'),
  86. ),
  87. '#default_value' => $defaults['content_type_extras_cancel'],
  88. )
  89. ),
  90. 'workflow' => array(
  91. '#type' => 'fieldset',
  92. '#title' => t('Publishing options'),
  93. '#weight' => 10,
  94. 'node_options' => array(
  95. '#type' => 'checkboxes',
  96. '#title' => t('Default options'),
  97. '#options' => array(
  98. 'status' => t('Published'),
  99. 'promote' => t('Promoted to front page'),
  100. 'sticky' => t('Sticky at top of lists'),
  101. 'revision' => t('Create new revision'),
  102. ),
  103. '#default_value' => $defaults['node_options'],
  104. ),
  105. ),
  106. 'display' => array(
  107. '#type' => 'fieldset',
  108. '#title' => t('Display settings'),
  109. '#weight' => 20,
  110. 'node_submitted' => array(
  111. '#type' => 'checkbox',
  112. '#title' => t('Display author and date information.'),
  113. '#description' => t('Author username and publish date will be displayed.'),
  114. '#default_value' => $defaults['node_submitted'],
  115. ),
  116. ),
  117. 'user_permissions' => array(
  118. '#type' => 'fieldset',
  119. '#title' => t('User permissions'),
  120. '#tree' => TRUE,
  121. '#weight' => 30,
  122. 'intro' => array(
  123. '#markup' => '<p>' . t('These permissions set the defaults for <em>new</em> content types. They do not change global permissions for all content types.'),
  124. ),
  125. 'create_roles' => array(
  126. '#type' => 'checkboxes',
  127. '#title' => t('Roles that can CREATE content'),
  128. '#options' => $roles,
  129. '#default_value' => $defaults['user_permissions']['create_roles'],
  130. ),
  131. 'edit_roles' => array(
  132. '#type' => 'checkboxes',
  133. '#title' => t('Roles that can EDIT any content'),
  134. '#options' => $roles,
  135. '#default_value' => $defaults['user_permissions']['edit_roles'],
  136. ),
  137. 'delete_roles' => array(
  138. '#type' => 'checkboxes',
  139. '#title' => t('Roles that can DELETE any content'),
  140. '#options' => $roles,
  141. '#default_value' => $defaults['user_permissions']['delete_roles'],
  142. ),
  143. ),
  144. 'extras' => array(
  145. '#type' => 'fieldset',
  146. '#title' => t('Extra settings'),
  147. '#weight' => 40,
  148. 'content_type_forms' => array(
  149. '#type' => 'fieldset',
  150. '#title' => t('Content type forms'),
  151. '#weight' => 0,
  152. 'content_type_extras_descriptions_required' => array(
  153. '#type' => 'checkbox',
  154. '#title' => t('Make description field on all content types required'),
  155. '#description' => t('Drupal by default does not require that the description field be filled in. Enabling this option will make the description field required.'),
  156. '#default_value' => $defaults['content_type_extras_descriptions_required'],
  157. ),
  158. 'content_type_extras_remove_body' => array(
  159. '#type' => 'checkbox',
  160. '#description' => t("Drupal by default automatically creates a body field for each content type. Enabling this option will remove the body field from a newly created content type. This option can be overridden on a per content type basis."),
  161. '#title' => t('Remove body field from content types'),
  162. '#default_value' => $defaults['content_type_extras_remove_body'],
  163. ),
  164. ),
  165. 'node_titles' => array(
  166. '#type' => 'fieldset',
  167. '#title' => t('Node titles'),
  168. '#weight' => 1,
  169. 'content_type_extras_title_hide' => array(
  170. '#type' => 'checkbox',
  171. '#title' => t('Hide title on node view'),
  172. '#description' => t('If checked, node titles will be hidden by default. Users with the <a href="/admin/people/permissions#module-content_type_extras">appropriate permission</a> can override this on a per-node basis.'),
  173. '#default_value' => $defaults['content_type_extras_title_hide'],
  174. ),
  175. 'content_type_extras_title_hide_css' => array(
  176. '#type' => 'checkbox',
  177. '#title' => t('Hide titles with CSS'),
  178. '#description' => t('If checked, any node titles that are selected to be hidden will be hidden with CSS so that they render in HTML for devices like screenreaders.'),
  179. '#default_value' => $defaults['content_type_extras_title_hide_css'],
  180. ),
  181. 'content_type_extras_title_hide_front' => array(
  182. '#type' => 'checkbox',
  183. '#title' => t('Hide node title on front page'),
  184. '#description' => t('If checked, the node title on the front page will be hidden, regardless of what content type it is associated with'),
  185. '#default_value' => $defaults['content_type_extras_title_hide_front'],
  186. ),
  187. ),
  188. 'form_buttons' => array(
  189. '#type' => 'fieldset',
  190. '#title' => t('Form buttons'),
  191. '#weight' => 2,
  192. 'content_type_extras_top_buttons' => array(
  193. '#type' => 'checkboxes',
  194. '#title' => t('Show form buttons at top of:'),
  195. '#description' => t('Select the areas to duplicate form submission buttons on the top of the page.'),
  196. '#options' => array(
  197. 'manage_fields' => t('Manage fields form'),
  198. 'node_edit' => t('Node edit form'),
  199. ),
  200. '#default_value' => $defaults['content_type_extras_top_buttons'],
  201. ),
  202. ),
  203. ),
  204. ),
  205. );
  206. if (module_exists('comment')) {
  207. $form['content_type_extras']['comment'] = array(
  208. '#type' => 'fieldset',
  209. '#title' => t('Comment settings'),
  210. '#tree' => TRUE,
  211. '#weight' => 25,
  212. 'comment' => array(
  213. '#type' => 'select',
  214. '#title' => t('Default comment setting for new content types'),
  215. '#default_value' => $defaults['comment']['comment'],
  216. '#options' => array(
  217. COMMENT_NODE_OPEN => t('Open'),
  218. COMMENT_NODE_CLOSED => t('Closed'),
  219. COMMENT_NODE_HIDDEN => t('Hidden'),
  220. ),
  221. ),
  222. 'default_mode' => array(
  223. '#type' => 'checkbox',
  224. '#title' => t('Threading'),
  225. '#default_value' => $defaults['comment']['default_mode'],
  226. '#description' => t('Show comment replies in a threaded list.'),
  227. ),
  228. 'default_per_page' => array(
  229. '#type' => 'select',
  230. '#title' => t('Comments per page'),
  231. '#default_value' => $defaults['comment']['default_per_page'],
  232. '#options' => _comment_per_page(),
  233. ),
  234. 'anonymous' => array(
  235. '#type' => 'select',
  236. '#title' => t('Anonymous commenting'),
  237. '#default_value' => $defaults['comment']['anonymous'],
  238. '#options' => array(
  239. COMMENT_ANONYMOUS_MAYNOT_CONTACT => t('Anonymous posters may not enter their contact information'),
  240. COMMENT_ANONYMOUS_MAY_CONTACT => t('Anonymous posters may leave their contact information'),
  241. COMMENT_ANONYMOUS_MUST_CONTACT => t('Anonymous posters must leave their contact information'),
  242. ),
  243. '#access' => user_access('post comments', drupal_anonymous_user()),
  244. ),
  245. 'subject_field' => array(
  246. '#type' => 'checkbox',
  247. '#title' => t('Allow comment title'),
  248. '#default_value' => $defaults['comment']['subject_field'],
  249. ),
  250. 'form_location' => array(
  251. '#type' => 'checkbox',
  252. '#title' => t('Show reply form on the same page as comments'),
  253. '#default_value' => $defaults['comment']['form_location'],
  254. ),
  255. 'preview' => array(
  256. '#type' => 'radios',
  257. '#title' => t('Preview comment'),
  258. '#default_value' => $defaults['comment']['preview'],
  259. '#options' => array(
  260. DRUPAL_DISABLED => t('Disabled'),
  261. DRUPAL_OPTIONAL => t('Optional'),
  262. DRUPAL_REQUIRED => t('Required'),
  263. ),
  264. ),
  265. );
  266. }
  267. if (module_exists('xmlsitemap')) {
  268. $form['content_type_extras']['xmlsitemap_settings'] = array(
  269. '#type' => 'fieldset',
  270. '#title' => t('XML Sitemap'),
  271. '#tree' => TRUE, // Set to TRUE to match node_type_form for saving settings
  272. '#weight' => 35,
  273. 'status' => array(
  274. '#type' => 'select',
  275. '#title' => t('Inclusion'),
  276. '#options' => array(
  277. 1 => t('Included'),
  278. 0 => t('Excluded'),
  279. ),
  280. '#default_value' => $defaults['xmlsitemap_settings']['status'],
  281. ),
  282. 'priority' => array(
  283. '#type' => 'select',
  284. '#title' => t('Default priority'),
  285. '#options' => array(
  286. '1.0' => t('1.0 (highest)'),
  287. '0.9' => '0.9',
  288. '0.8' => '0.8',
  289. '0.7' => '0.7',
  290. '0.6' => '0.6',
  291. '0.5' => t('0.5 (normal)'),
  292. '0.4' => '0.4',
  293. '0.3' => '0.3',
  294. '0.2' => '0.2',
  295. '0.1' => '0.1',
  296. '0.0' => t('0.0 (lowest)'),
  297. ),
  298. '#default_value' => $defaults['xmlsitemap_settings']['priority'],
  299. '#states' => array(
  300. 'invisible' => array(
  301. 'select[name="xmlsitemap_settings[status]"]' => array('value' => '0'),
  302. ),
  303. ),
  304. ),
  305. );
  306. }
  307. if (module_exists('fpa')) {
  308. $form['content_type_extras']['extras']['content_type_forms']['content_type_extras_user_permissions_select'] = array(
  309. '#type' => 'radios',
  310. '#title' => t('Select which user interface to use to manage permissions on node type forms'),
  311. '#options' => array(
  312. 'cte' => t('Content Type: Extras'),
  313. 'fpa' => t('Fast Permissions Administration (FPA)'),
  314. ),
  315. '#default_value' => $defaults['content_type_extras_user_permissions_select'],
  316. );
  317. }
  318. $form['actions'] = array(
  319. 'submit' => array(
  320. '#type' => 'submit',
  321. '#value' => t('Save configuration'),
  322. ),
  323. );
  324. return $form;
  325. }
  326. function content_type_extras_settings_submit(&$form, &$form_state) {
  327. $values = $form_state['values'];
  328. unset($values['submit'], $values['form_build_id'], $values['form_token'], $values['form_id'], $values['op']);
  329. variable_set('content_type_extras_default_settings', $values);
  330. drupal_set_message(t('Default content type settings saved.'));
  331. $form_state['redirect'] = 'admin/structure/types';
  332. }