mysite_configure_form()
mysite.module, line 1380
FormsAPI for mysite_configure().
function mysite_configure_form() {
$form['mysite'] = array(
'#type' => 'fieldset',
'#title' => t('Display Settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['mysite']['mysite_sitename'] = array(
'#type' => 'textfield', '#title' => t('MySite Sitename'),
'#default_value' => variable_get('mysite_sitename', t('My !site', array('!site' => variable_get('site_name', 'drupal')))),
'#size' => 40, '#maxlength' => 80,
'#description' => t('Enter the title string to be used for MySite menu items and page titles.')
);
$form['mysite']['mysite_list'] = array(
'#type' => 'radios', '#title' => t('MySite Behavior'), '#default_value' => variable_get('mysite_list', 0),
'#options' => array(0 => t('Go to user MySite page'), 1 => t('Show list of all user mysites')),
'#description' => t('Create an overview page with links to all custom user MySite pages?')
);
$form['mysite']['mysite_private_status'] = array(
'#type' => 'radios', '#title' => t('MySite Privacy'), '#default_value' => variable_get('mysite_private_status', 1),
'#options' => array(1 => t('Default setting is "public"'), 0 => t('Default setting is "private"')),
'#description' => t('When creating new user MySite pages, should they default to public or private?')
);
// Note: fullscreen printing is a TRUE/FALSE option. FALSE == 0 == strip blocks from output.
$form['mysite']['mysite_fullscreen'] = array(
'#type' => 'radios', '#title' => t('MySite Page Setup'), '#default_value' => variable_get('mysite_fullscreen', 1),
'#options' => array(1 => t('Show MySite within normal site theme'), 0 => t('Show MySite pages full screen')),
'#description' => t('The full screen option will remove the left and right rail regions from a MySite page view.')
);
$form['mysite']['mysite_confirm_delete'] = array(
'#type' => 'radios', '#title' => t('MySite Item Deletion'), '#default_value' => variable_get('mysite_confirm_delete', 0),
'#options' => array(0 => t('Delete items on request'), 1 => t('Prompt user to confirm deletions')),
'#description' => t('Should users be asked to confirm the deletion of content? Users may choose to ignore the prompt.')
);
$form['mysite']['mysite_links'] = array(
'#type' => 'radios', '#title' => t('MySite Node Links'), '#default_value' => variable_get('mysite_links', 1),
'#options' => array(1 => t('Show links on all node views'), 2 => t('Show links on full page view only'), 0 => t('Do not show MySite links')),
'#description' => t('Should MySite add content-sensitive action links to nodes?')
);
$form['mysite_content'] = array(
'#type' => 'fieldset',
'#title' => t('Content Settings'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
// types configuration based on includes found
$types = mysite_get_includes('types');
$sort = array();
foreach ($types as $key => $type) {
$info = NULL;
mysite_load_includes('types', $key, $load_all = TRUE);
$info = module_invoke('mysite_type', $key, $get_options = FALSE);
if (is_array($info) && !empty($info['include'])) {
$sort[$key] = $info;
}
}
// sort the options and get the category labels for display
$options = mysite_sort_options($sort);
$labels = $options['category_labels'];
unset($options['category_labels']);
// warn the admin of additional configuration. See mysite_type_hook_active() for details.
$current_types = variable_get('mysite_content', array());
$message = NULL;
$i = 0;
$label = '';
foreach ($options as $key => $value) {
if (function_exists('mysite_type_'. $key .'_active')) {
$active = module_invoke('mysite_type', $key .'_active', $key);
// if this is false, then activation failed
if (!$active[$key]) {
$message .= '<li>'. $options[$key]['data'] .'<br /><em>'. $active['message'] .'</em></li>';
unset($options[$key]);
unset($current_types[$key]);
unset($labels[$i]);
}
}
$i++;
}
// takes the options array and appends category titles as needed.
$title = t('MySite Content Types');
foreach ($options as $key => $value) {
$val = $value['data'];
$data[$key] = $val;
}
// reset the variable since we removed inactive types
variable_set('mysite_content', $current_types);
$form['mysite_content']['mysite_content'] = array(
'#type' => 'checkboxes',
'#title' => $title,
'#default_value' => variable_get('mysite_content', NULL),
'#options' => $data,
'#description' => array('text' => t("Which types of content can users add to a MySite collection?"), 'labels' => $labels)
);
if (!empty($message)) {
$form['mysite_content']['mysite_content_message'] = array(
'#prefix' => '<p><b>'. t('Disabled Content Types:') .'</b><ul>',
'#value' => $message,
'#suffix' => '</ul><div class="description">'. t('The options listed above require additional configuration before they can be activated.') .'</div></p>'
);
}
$form['mysite_browser'] = array(
'#type' => 'fieldset',
'#title' => t('Content Browser'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
// these settings only matter if MySite Icons is turned on
if (module_exists('mysite_icon')) {
$form['mysite_browser']['mysite_browser'] = array(
'#type' => 'radios',
'#title' => t('Content Browsing'), '#default_value' => variable_get('mysite_browser', 'table'),
'#options' => array('table' => t('Display a text-only table'), 'rows' => t('Display rows of icons')),
'#description' => t("Show users a table of text or an icon panel?")
);
$form['mysite_browser']['mysite_browser_max'] = array(
'#type' => 'select',
'#title' => t('Content Layout'), '#default_value' => variable_get('mysite_browser_max', 4),
'#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)),
'#description' => t("Items per row for the icon panel.")
);
}
$form['mysite_browser']['mysite_browser_pager'] = array(
'#type' => 'select',
'#title' => t('Items per Page'), '#default_value' => variable_get('mysite_browser_pager', 25),
'#options' => drupal_map_assoc(array(10, 25, 50)),
'#description' => t("Content choices to show per page.")
);
$form['mysite_max'] = array(
'#type' => 'fieldset',
'#title' => t('User Limits'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
// how much content can a user have?
$options = drupal_map_assoc(array(5, 10, 20));
$form['mysite_max']['mysite_items'] = array(
'#type' => 'select',
'#title' => t('Item Count'), '#default_value' => variable_get('mysite_items', 10),
'#options' => $options,
'#description' => t("How many items can users add to a MySite collection?")
);
$options = drupal_map_assoc(array(3, 5, 10, 15, 20));
$form['mysite_max']['mysite_elements'] = array(
'#type' => 'select',
'#title' => t('Element Count'), '#default_value' => variable_get('mysite_elements', 5),
'#options' => $options,
'#description' => t("How many story elements should be displayed per item?")
);
$options = drupal_map_assoc(array(1, 3, 5, 8, 10, 15, 20));
$form['mysite_max']['mysite_pages'] = array(
'#type' => 'select',
'#title' => t('Page Count'), '#default_value' => variable_get('mysite_pages', 5),
'#options' => $options,
'#description' => t("How many pages may a MySite user create?")
);
// icons usage. mysite comes with GPL icons.
$form['mysite_icons'] = array(
'#type' => 'fieldset',
'#title' => t('Action Buttons'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$icons = drupal_get_path('module', 'mysite') .'/plugins/icons/';
$up = theme_image($icons .'up.png', 'move item up', 'move item up', NULL, TRUE);
$down = theme_image($icons .'down.png', 'move item down', 'move item down', NULL, TRUE);
$remove = theme_image($icons .'cancel.png', 'remove item', 'remove item', NULL, TRUE);
$configure = theme_image($icons .'settings.png', 'configure item', 'configure item', NULL, TRUE);
$form['mysite_icons']['mysite_use_icons'] = array(
'#type' => 'radios',
'#title' => t('Action Labels'), '#default_value' => variable_get('mysite_use_icons', 1),
'#options' => array(1 => t('Icons'), 0 => t('Text'), 2 => 'Icons and Text'),
'#prefix' => '<p>'. t('The action button icon set: ') . $up .' '. $down .' '. $remove .' '. $configure .'</p>',
'#description' => t("Use the provided icon set for actions?")
);
// cache settings. These may help high-traffic sites.
$form['mysite_cache'] = array(
'#type' => 'fieldset',
'#title' => t('Cache Settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
// clear the mysite_cache if it is disabled.
$caching = variable_get('mysite_cache', 0);
if ($caching == 0) {
cache_clear_all('mysite:', 'cache', TRUE);
}
$options = array('0' => t('Cache Off'), '300' => t('5 min.'), '900' => t('15 min.'), '1800' => t('30 min.'), '3600' => t('1 hour'));
$form['mysite_cache']['mysite_cache'] = array(
'#type' => 'select',
'#title' => t('MySite Cache'), '#default_value' => $caching,
'#options' => $options,
'#description' => t("Set the cache duration for user MySite page views. Recommended for high-traffic sites.")
);
// default page settings.
$default = variable_get('mysite_default_user', NULL);
$form['mysite_default'] = array(
'#type' => 'fieldset',
'#title' => t('Default Page Settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['mysite_default']['mysite_default_user'] = array(
'#type' => 'textfield',
'#title' => t('MySite Default User'),
'#size' => 5,
'#default_value' => $default,
'#description' => t("Optional: Enter the UID of the user to display at http://example.com/mysite-default.")
);
return system_settings_form($form);
}