mysite_content_settings_form($edit)
mysite.module, line 2080
FormsAPI for mysite_content_settings()
This function will invoke type-specific form additions if present. See mysite_type_profile_content_form() for an example.
$data Array with information from the {mysite_data} table for this given content.
function mysite_content_settings_form($edit) {
// the default elements are simply the title and format, other plugins may add elements
$form['data']['title'] = array(
'#type' => 'textfield',
'#title' => t('Content title'),
'#size' => '40',
'#maxsize' => '240',
'#default_value' => $edit['title']
);
$form['data']['original'] = array(
'#type' => 'value',
'#value' => $edit['title']
);
$form['data']['uid'] = array(
'#type' => 'value',
'#value' => $edit['uid']
);
// let the administrator lock this item
if (user_access('administer mysite') && $edit['uid'] == 0) {
$form['data']['locked'] = array(
'#type' => 'checkbox',
'#title' => t('Lock item'),
'#description' => t('Check this option to display this content to all users at all times.'),
'#default_value' => $edit['locked'],
);
}
// let the user change region (see http://drupal.org/node/155172)
$layout = mysite_get_layout($edit['uid']);
$options = ($layout['regions']);
$form['data']['position'] = array(
'#type' => 'select',
'#title' => t('Page region'),
'#options' => $options,
'#default_value' => $edit['position']
);
$form['data']['position_original'] = array(
'#type' => 'value',
'#value' => $edit['position']
);
// formats for the item -- test the data for format options
$func = 'mysite_type_'. $edit['type'] .'_data';
mysite_load_includes('types', $edit['type']);
$content = $func($edit['type_id']);
// if the content item returns a 'content' element, it cannot be formatted
if (empty($content['items'][0]['content'])) {
$options = array();
$formats = mysite_load_includes('formats'); // these, too
foreach ($formats as $format) {
$data = module_invoke('mysite_theme', $format);
$options[$format] = $data['format'];
$desc[$format] = $data['sample'];
}
if ($options != array('default')) {
$form['data']['format'] = array(
'#type' => 'radios',
'#title' => t('Content format'),
'#default_value' => $edit['format'],
'#options' => $options,
'#description' => array('desc' => t('Select a format.'), 'samples' => $desc)
);
}
}
else {
$form['data']['format'] = array(
'#type' => 'value',
'#value' => $edit['format']
);
}
$form['data']['format_original'] = array(
'#type' => 'value',
'#value' => $edit['format']
);
$form['data']['sort_original'] = array(
'#type' => 'value',
'#value' => $edit['sort']
);
// get elements from plugins, in needed
mysite_load_includes('types', $edit['type']);
if (function_exists('mysite_type_'. $edit['type'] .'_content_form')) {
$extra = module_invoke('mysite_type', $edit['type'] .'_content_form', $edit);
$form['data'] = array_merge($form['data'], $extra);
}
$form['data']['mid'] = array(
'#type' => 'value',
'#value' => $edit['mid']
);
$form['data']['type'] = array(
'#type' => 'value',
'#value' => $edit['type']
);
$form['data']['type_id'] = array(
'#type' => 'value',
'#value' => $edit['type_id']
);
$form['data']['uid'] = array(
'#type' => 'value',
'#value' => $edit['uid']
);
// take the user back where they came from
$return = 'view';
$uri = explode('/', referer_uri());
if (end($uri) == 'content') {
$return = 'content';
}
// take the admin user to the admin screen
$uid = $edit['uid'];
if ($edit['uid'] == 0) {
$uid = 'admin';
$return = 'content';
}
$form['#redirect'] = 'mysite/'. $uid .'/'. $return .'/'. $edit['page'];
$form['data']['submit'] = array(
'#name' => 'submit',
'#type' => 'submit',
'#value' => t('Save settings')
);
return $form;
}