content_type_extras.admin.inc 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  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. 'configuration' => array(
  205. '#type' => 'fieldset',
  206. '#title' => t('Configuration settings'),
  207. '#weight' => 50,
  208. 'content_type_extras_excluded_node_forms' => array(
  209. '#type' => 'textarea',
  210. '#title' => t('Excluded node forms'),
  211. '#description' => t('Enter the node form ids that you would like to exclude from being processed by Content Type: Extras, one per line.<br><strong>Note:</strong> \'subscriptions_ui_node_form\' and \'field_collection_item_form\' will always be added to prevent errors.'),
  212. '#default_value' => implode("\n", $defaults['content_type_extras_excluded_node_forms']),
  213. ),
  214. ),
  215. ),
  216. );
  217. if (module_exists('comment')) {
  218. $form['content_type_extras']['comment'] = array(
  219. '#type' => 'fieldset',
  220. '#title' => t('Comment settings'),
  221. '#tree' => TRUE,
  222. '#weight' => 25,
  223. 'comment' => array(
  224. '#type' => 'select',
  225. '#title' => t('Default comment setting for new content types'),
  226. '#default_value' => $defaults['comment']['comment'],
  227. '#options' => array(
  228. COMMENT_NODE_OPEN => t('Open'),
  229. COMMENT_NODE_CLOSED => t('Closed'),
  230. COMMENT_NODE_HIDDEN => t('Hidden'),
  231. ),
  232. ),
  233. 'default_mode' => array(
  234. '#type' => 'checkbox',
  235. '#title' => t('Threading'),
  236. '#default_value' => $defaults['comment']['default_mode'],
  237. '#description' => t('Show comment replies in a threaded list.'),
  238. ),
  239. 'default_per_page' => array(
  240. '#type' => 'select',
  241. '#title' => t('Comments per page'),
  242. '#default_value' => $defaults['comment']['default_per_page'],
  243. '#options' => _comment_per_page(),
  244. ),
  245. 'anonymous' => array(
  246. '#type' => 'select',
  247. '#title' => t('Anonymous commenting'),
  248. '#default_value' => $defaults['comment']['anonymous'],
  249. '#options' => array(
  250. COMMENT_ANONYMOUS_MAYNOT_CONTACT => t('Anonymous posters may not enter their contact information'),
  251. COMMENT_ANONYMOUS_MAY_CONTACT => t('Anonymous posters may leave their contact information'),
  252. COMMENT_ANONYMOUS_MUST_CONTACT => t('Anonymous posters must leave their contact information'),
  253. ),
  254. '#access' => user_access('post comments', drupal_anonymous_user()),
  255. ),
  256. 'subject_field' => array(
  257. '#type' => 'checkbox',
  258. '#title' => t('Allow comment title'),
  259. '#default_value' => $defaults['comment']['subject_field'],
  260. ),
  261. 'form_location' => array(
  262. '#type' => 'checkbox',
  263. '#title' => t('Show reply form on the same page as comments'),
  264. '#default_value' => $defaults['comment']['form_location'],
  265. ),
  266. 'preview' => array(
  267. '#type' => 'radios',
  268. '#title' => t('Preview comment'),
  269. '#default_value' => $defaults['comment']['preview'],
  270. '#options' => array(
  271. DRUPAL_DISABLED => t('Disabled'),
  272. DRUPAL_OPTIONAL => t('Optional'),
  273. DRUPAL_REQUIRED => t('Required'),
  274. ),
  275. ),
  276. );
  277. }
  278. if (module_exists('xmlsitemap')) {
  279. $form['content_type_extras']['xmlsitemap_settings'] = array(
  280. '#type' => 'fieldset',
  281. '#title' => t('XML Sitemap'),
  282. '#tree' => TRUE, // Set to TRUE to match node_type_form for saving settings
  283. '#weight' => 35,
  284. 'status' => array(
  285. '#type' => 'select',
  286. '#title' => t('Inclusion'),
  287. '#options' => array(
  288. 1 => t('Included'),
  289. 0 => t('Excluded'),
  290. ),
  291. '#default_value' => $defaults['xmlsitemap_settings']['status'],
  292. ),
  293. 'priority' => array(
  294. '#type' => 'select',
  295. '#title' => t('Default priority'),
  296. '#options' => array(
  297. '1.0' => t('1.0 (highest)'),
  298. '0.9' => '0.9',
  299. '0.8' => '0.8',
  300. '0.7' => '0.7',
  301. '0.6' => '0.6',
  302. '0.5' => t('0.5 (normal)'),
  303. '0.4' => '0.4',
  304. '0.3' => '0.3',
  305. '0.2' => '0.2',
  306. '0.1' => '0.1',
  307. '0.0' => t('0.0 (lowest)'),
  308. ),
  309. '#default_value' => $defaults['xmlsitemap_settings']['priority'],
  310. '#states' => array(
  311. 'invisible' => array(
  312. 'select[name="xmlsitemap_settings[status]"]' => array('value' => '0'),
  313. ),
  314. ),
  315. ),
  316. );
  317. }
  318. if (module_exists('scheduler')) {
  319. $form['content_type_extras']['scheduler_settings'] = array(
  320. '#type' => 'fieldset',
  321. '#title' => t('Scheduler'),
  322. '#tree' => TRUE, // Set to TRUE to match node_type_form for saving settings
  323. '#weight' => 35,
  324. 'publish_enable' => array(
  325. '#type' => 'checkbox',
  326. '#title' => t('Enable Scheduled publishing for new content types'),
  327. '#default_value' => $defaults['scheduler_settings']['publish_enable'],
  328. ),
  329. 'publish_touch' => array(
  330. '#type' => 'checkbox',
  331. '#title' => t('Change content creation time to match the scheduled publish time for new content types'),
  332. '#default_value' => $defaults['scheduler_settings']['publish_touch'],
  333. ),
  334. 'publish_require' => array(
  335. '#type' => 'checkbox',
  336. '#title' => t('Require scheduled publishing for new content types'),
  337. '#default_value' => $defaults['scheduler_settings']['publish_require'],
  338. ),
  339. 'publish_revision' => array(
  340. '#type' => 'checkbox',
  341. '#title' => t('Create a new revision on publishing for new content types'),
  342. '#default_value' => $defaults['scheduler_settings']['publish_revision'],
  343. ),
  344. 'unpublish_enable' => array(
  345. '#type' => 'checkbox',
  346. '#title' => t('Enable scheduled unpublishing for new content types'),
  347. '#default_value' => $defaults['scheduler_settings']['unpublish_enable'],
  348. ),
  349. 'unpublish_require' => array(
  350. '#type' => 'checkbox',
  351. '#title' => t('Require scheduled unpublishing for new content types'),
  352. '#default_value' => $defaults['scheduler_settings']['unpublish_require'],
  353. ),
  354. 'unpublish_revision' => array(
  355. '#type' => 'checkbox',
  356. '#title' => t('Create a new revision on unpublishing for new content types'),
  357. '#default_value' => $defaults['scheduler_settings']['unpublish_revision'],
  358. ),
  359. );
  360. }
  361. if (module_exists('fpa')) {
  362. $form['content_type_extras']['extras']['content_type_forms']['content_type_extras_user_permissions_select'] = array(
  363. '#type' => 'radios',
  364. '#title' => t('Select which user interface to use to manage permissions on node type forms'),
  365. '#options' => array(
  366. 'cte' => t('Content Type: Extras'),
  367. 'fpa' => t('Fast Permissions Administration (FPA)'),
  368. ),
  369. '#default_value' => $defaults['content_type_extras_user_permissions_select'],
  370. );
  371. }
  372. $form['actions'] = array(
  373. 'submit' => array(
  374. '#type' => 'submit',
  375. '#value' => t('Save configuration'),
  376. ),
  377. );
  378. return $form;
  379. }
  380. function content_type_extras_settings_submit(&$form, &$form_state) {
  381. $values = $form_state['values'];
  382. // Place the values of content_type_extras_excluded_node_forms into an array
  383. $values['content_type_extras_excluded_node_forms'] = explode("\n", $values['content_type_extras_excluded_node_forms']);
  384. unset($values['submit'], $values['form_build_id'], $values['form_token'], $values['form_id'], $values['op']);
  385. variable_set('content_type_extras_default_settings', $values);
  386. drupal_set_message(t('Default content type settings saved.'));
  387. $form_state['redirect'] = 'admin/structure/types';
  388. }