123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343 |
- <?php
- function content_type_extras_settings() {
- $defaults = content_type_extras_get_default();
- // Get all available user roles
- $roles = user_roles();
- $admin_role = variable_get('user_admin_role', 0);
-
- if ($admin_role != 0) {
- $roles[$admin_role] .= t(' <em>(administrator role)</em>');
- }
-
- $form = array(
- 'intro' => array(
- '#markup' => t('Set the default settings for all new content types below. These settings can be overridden on the content type page.'),
- ),
- 'content_type_extras' => array(
- '#type' => 'vertical_tabs',
- 'submission' => array(
- '#type' => 'fieldset',
- '#title' => t('Submission form settings'),
- '#attached' => array(
- 'js' => array(
- 'vertical-tabs' => drupal_get_path('module', 'content_type_extras') . '/js/content_type_extras.vertical_tabs.js',
- ),
- ),
- '#weight' => 0,
- 'title_label' => array(
- '#type' => 'textfield',
- '#title' => t('Title field label'),
- '#default_value' => $defaults['title_label'],
- '#required' => 1,
- ),
- 'node_preview' => array(
- '#type' => 'radios',
- '#title' => t('Preview before submitting'),
- '#options' => array(
- t('Disabled'),
- t('Optional'),
- t('Required'),
- ),
- '#default_value' => $defaults['node_preview'],
- ),
- 'content_type_extras_preview_button' => array(
- '#type' => 'textfield',
- '#title' => t('Preview button value'),
- '#description' => t('The name of the Preview button that will display on the content edit form if enabled'),
- '#default_value' => $defaults['content_type_extras_preview_button'],
- '#required' => 1,
- ),
- 'content_type_extras_save_and_new' => array(
- '#type' => 'radios',
- '#title' => t('Save and New button'),
- '#options' => array(
- t('Disabled'),
- t('Enabled'),
- ),
- '#default_value' => $defaults['content_type_extras_save_and_new'],
- ),
- 'content_type_extras_save_and_new_button' => array(
- '#type' => 'textfield',
- '#title' => t('Save and New button value'),
- '#description' => t('The name of the Save and New button that will display on the content edit form if enabled'),
- '#default_value' => $defaults['content_type_extras_save_and_new_button'],
- '#required' => 1,
- ),
- 'content_type_extras_save_and_edit' => array(
- '#type' => 'radios',
- '#title' => t('Save and Edit button'),
- '#options' => array(
- t('Disabled'),
- t('Enabled'),
- ),
- '#default_value' => $defaults['content_type_extras_save_and_edit'],
- ),
- 'content_type_extras_save_and_edit_button' => array(
- '#type' => 'textfield',
- '#title' => t('Save and Edit button value'),
- '#description' => t('The name of the Save and Edit button that will display on the content edit form if enabled'),
- '#default_value' => $defaults['content_type_extras_save_and_edit_button'],
- '#required' => 1,
- ),
- 'content_type_extras_cancel' => array(
- '#type' => 'radios',
- '#title' => t('Cancel button'),
- '#options' => array(
- t('Disabled'),
- t('Enabled'),
- ),
- '#default_value' => $defaults['content_type_extras_cancel'],
- )
- ),
- 'workflow' => array(
- '#type' => 'fieldset',
- '#title' => t('Publishing options'),
- '#weight' => 10,
- 'node_options' => array(
- '#type' => 'checkboxes',
- '#title' => t('Default options'),
- '#options' => array(
- 'status' => t('Published'),
- 'promote' => t('Promoted to front page'),
- 'sticky' => t('Sticky at top of lists'),
- 'revision' => t('Create new revision'),
- ),
- '#default_value' => $defaults['node_options'],
- ),
- ),
- 'display' => array(
- '#type' => 'fieldset',
- '#title' => t('Display settings'),
- '#weight' => 20,
- 'node_submitted' => array(
- '#type' => 'checkbox',
- '#title' => t('Display author and date information.'),
- '#description' => t('Author username and publish date will be displayed.'),
- '#default_value' => $defaults['node_submitted'],
- ),
- ),
- 'user_permissions' => array(
- '#type' => 'fieldset',
- '#title' => t('User permissions'),
- '#tree' => TRUE,
- '#weight' => 30,
- 'intro' => array(
- '#markup' => '<p>' . t('These permissions set the defaults for <em>new</em> content types. They do not change global permissions for all content types.'),
- ),
- 'create_roles' => array(
- '#type' => 'checkboxes',
- '#title' => t('Roles that can CREATE content'),
- '#options' => $roles,
- '#default_value' => $defaults['user_permissions']['create_roles'],
- ),
- 'edit_roles' => array(
- '#type' => 'checkboxes',
- '#title' => t('Roles that can EDIT any content'),
- '#options' => $roles,
- '#default_value' => $defaults['user_permissions']['edit_roles'],
- ),
- 'delete_roles' => array(
- '#type' => 'checkboxes',
- '#title' => t('Roles that can DELETE any content'),
- '#options' => $roles,
- '#default_value' => $defaults['user_permissions']['delete_roles'],
- ),
- ),
- 'extras' => array(
- '#type' => 'fieldset',
- '#title' => t('Extra settings'),
- '#weight' => 40,
- 'content_type_forms' => array(
- '#type' => 'fieldset',
- '#title' => t('Content type forms'),
- '#weight' => 0,
- 'content_type_extras_descriptions_required' => array(
- '#type' => 'checkbox',
- '#title' => t('Make description field on all content types required'),
- '#description' => t('Drupal by default does not require that the description field be filled in. Enabling this option will make the description field required.'),
- '#default_value' => $defaults['content_type_extras_descriptions_required'],
- ),
- 'content_type_extras_remove_body' => array(
- '#type' => 'checkbox',
- '#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."),
- '#title' => t('Remove body field from content types'),
- '#default_value' => $defaults['content_type_extras_remove_body'],
- ),
- ),
- 'node_titles' => array(
- '#type' => 'fieldset',
- '#title' => t('Node titles'),
- '#weight' => 1,
- 'content_type_extras_title_hide' => array(
- '#type' => 'checkbox',
- '#title' => t('Hide title on node view'),
- '#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.'),
- '#default_value' => $defaults['content_type_extras_title_hide'],
- ),
- 'content_type_extras_title_hide_css' => array(
- '#type' => 'checkbox',
- '#title' => t('Hide titles with CSS'),
- '#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.'),
- '#default_value' => $defaults['content_type_extras_title_hide_css'],
- ),
- 'content_type_extras_title_hide_front' => array(
- '#type' => 'checkbox',
- '#title' => t('Hide node title on front page'),
- '#description' => t('If checked, the node title on the front page will be hidden, regardless of what content type it is associated with'),
- '#default_value' => $defaults['content_type_extras_title_hide_front'],
- ),
- ),
- 'form_buttons' => array(
- '#type' => 'fieldset',
- '#title' => t('Form buttons'),
- '#weight' => 2,
- 'content_type_extras_top_buttons' => array(
- '#type' => 'checkboxes',
- '#title' => t('Show form buttons at top of:'),
- '#description' => t('Select the areas to duplicate form submission buttons on the top of the page.'),
- '#options' => array(
- 'manage_fields' => t('Manage fields form'),
- 'node_edit' => t('Node edit form'),
- ),
- '#default_value' => $defaults['content_type_extras_top_buttons'],
- ),
- ),
- ),
- ),
- );
-
- if (module_exists('comment')) {
- $form['content_type_extras']['comment'] = array(
- '#type' => 'fieldset',
- '#title' => t('Comment settings'),
- '#tree' => TRUE,
- '#weight' => 25,
- 'comment' => array(
- '#type' => 'select',
- '#title' => t('Default comment setting for new content types'),
- '#default_value' => $defaults['comment']['comment'],
- '#options' => array(
- COMMENT_NODE_OPEN => t('Open'),
- COMMENT_NODE_CLOSED => t('Closed'),
- COMMENT_NODE_HIDDEN => t('Hidden'),
- ),
- ),
- 'default_mode' => array(
- '#type' => 'checkbox',
- '#title' => t('Threading'),
- '#default_value' => $defaults['comment']['default_mode'],
- '#description' => t('Show comment replies in a threaded list.'),
- ),
- 'default_per_page' => array(
- '#type' => 'select',
- '#title' => t('Comments per page'),
- '#default_value' => $defaults['comment']['default_per_page'],
- '#options' => _comment_per_page(),
- ),
- 'anonymous' => array(
- '#type' => 'select',
- '#title' => t('Anonymous commenting'),
- '#default_value' => $defaults['comment']['anonymous'],
- '#options' => array(
- COMMENT_ANONYMOUS_MAYNOT_CONTACT => t('Anonymous posters may not enter their contact information'),
- COMMENT_ANONYMOUS_MAY_CONTACT => t('Anonymous posters may leave their contact information'),
- COMMENT_ANONYMOUS_MUST_CONTACT => t('Anonymous posters must leave their contact information'),
- ),
- '#access' => user_access('post comments', drupal_anonymous_user()),
- ),
- 'subject_field' => array(
- '#type' => 'checkbox',
- '#title' => t('Allow comment title'),
- '#default_value' => $defaults['comment']['subject_field'],
- ),
- 'form_location' => array(
- '#type' => 'checkbox',
- '#title' => t('Show reply form on the same page as comments'),
- '#default_value' => $defaults['comment']['form_location'],
- ),
- 'preview' => array(
- '#type' => 'radios',
- '#title' => t('Preview comment'),
- '#default_value' => $defaults['comment']['preview'],
- '#options' => array(
- DRUPAL_DISABLED => t('Disabled'),
- DRUPAL_OPTIONAL => t('Optional'),
- DRUPAL_REQUIRED => t('Required'),
- ),
- ),
- );
- }
-
- if (module_exists('xmlsitemap')) {
- $form['content_type_extras']['xmlsitemap_settings'] = array(
- '#type' => 'fieldset',
- '#title' => t('XML Sitemap'),
- '#tree' => TRUE, // Set to TRUE to match node_type_form for saving settings
- '#weight' => 35,
- 'status' => array(
- '#type' => 'select',
- '#title' => t('Inclusion'),
- '#options' => array(
- 1 => t('Included'),
- 0 => t('Excluded'),
- ),
- '#default_value' => $defaults['xmlsitemap_settings']['status'],
- ),
- 'priority' => array(
- '#type' => 'select',
- '#title' => t('Default priority'),
- '#options' => array(
- '1.0' => t('1.0 (highest)'),
- '0.9' => '0.9',
- '0.8' => '0.8',
- '0.7' => '0.7',
- '0.6' => '0.6',
- '0.5' => t('0.5 (normal)'),
- '0.4' => '0.4',
- '0.3' => '0.3',
- '0.2' => '0.2',
- '0.1' => '0.1',
- '0.0' => t('0.0 (lowest)'),
- ),
- '#default_value' => $defaults['xmlsitemap_settings']['priority'],
- '#states' => array(
- 'invisible' => array(
- 'select[name="xmlsitemap_settings[status]"]' => array('value' => '0'),
- ),
- ),
- ),
- );
- }
-
- if (module_exists('fpa')) {
- $form['content_type_extras']['extras']['content_type_forms']['content_type_extras_user_permissions_select'] = array(
- '#type' => 'radios',
- '#title' => t('Select which user interface to use to manage permissions on node type forms'),
- '#options' => array(
- 'cte' => t('Content Type: Extras'),
- 'fpa' => t('Fast Permissions Administration (FPA)'),
- ),
- '#default_value' => $defaults['content_type_extras_user_permissions_select'],
- );
- }
-
- $form['actions'] = array(
- 'submit' => array(
- '#type' => 'submit',
- '#value' => t('Save configuration'),
- ),
- );
-
- return $form;
- }
- function content_type_extras_settings_submit(&$form, &$form_state) {
- $values = $form_state['values'];
- unset($values['submit'], $values['form_build_id'], $values['form_token'], $values['form_id'], $values['op']);
- variable_set('content_type_extras_default_settings', $values);
- drupal_set_message(t('Default content type settings saved.'));
- $form_state['redirect'] = 'admin/structure/types';
- }
|