function _file_admin_add_file_admin_fieldset in File admin 7
Helper to build the Workflow fieldset.
See also
file_admin_form_file_entity_edit_alter()
file_admin_form_file_entity_add_upload_alter()
2 calls to _file_admin_add_file_admin_fieldset()
- file_admin_form_file_entity_add_upload_alter in ./
file_admin.module - Implements hook_form_FORM_ID_alter().
- file_admin_form_file_entity_edit_alter in ./
file_admin.module - Implements hook_form_FORM_ID_alter().
File
- ./
file_admin.module, line 201 - Enhances file administration by adding published, promote, and sticky fields.
Code
function _file_admin_add_file_admin_fieldset(&$form, $form_state, $file) {
$file->date = format_date($file->created, 'custom', 'Y-m-d H:i:s O');
if (!isset($form['additional_settings'])) {
$form['additional_settings'] = array(
'#type' => 'vertical_tabs',
'#attached' => array(
'js' => array(
drupal_get_path('module', 'file_admin') . '/file_admin.js',
),
),
);
}
// Basic file information.
// This element is just a value so it is not even sent to the client.
$form['created'] = array(
'#type' => 'value',
'#value' => isset($file->created) ? $file->created : NULL,
);
// In some cases this fieldset will be provided by file_entity.
// @see file_entity_edit().
if (!isset($form['user'])) {
// File user information for administrators.
$form['user'] = array(
'#type' => 'fieldset',
'#access' => user_access('administer files'),
'#title' => t('User information'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#group' => 'additional_settings',
'#attributes' => array(
'class' => array(
'file-form-user',
),
),
'#attached' => array(
'js' => array(
drupal_get_path('module', 'file_entity') . '/file_entity.js',
array(
'type' => 'setting',
'data' => array(
'anonymous' => variable_get('anonymous', t('Anonymous')),
),
),
),
),
'#weight' => 90,
);
$form['user']['name'] = array(
'#type' => 'textfield',
'#title' => t('Associated with'),
'#maxlength' => 60,
'#autocomplete_path' => 'user/autocomplete',
'#default_value' => !empty($file->uid) ? user_load($file->uid)->name : '',
'#weight' => -1,
'#description' => t('Leave blank for %anonymous.', array(
'%anonymous' => variable_get('anonymous', t('Anonymous')),
)),
);
}
$form['user']['date'] = array(
'#type' => 'textfield',
'#title' => t('Posted on'),
'#maxlength' => 25,
'#description' => t('Format: %time. The date format is YYYY-MM-DD and %timezone is the time zone offset from UTC. Leave blank to use the time of form submission.', array(
'%time' => !empty($file->date) ? date_format(date_create($file->date), 'Y-m-d H:i:s O') : format_date($file->created, 'custom', 'Y-m-d H:i:s O'),
'%timezone' => !empty($file->date) ? date_format(date_create($file->date), 'O') : format_date($file->created, 'custom', 'O'),
)),
'#default_value' => !empty($file->date) ? $file->date : '',
);
// File options for administrators.
$form['options'] = array(
'#type' => 'fieldset',
'#access' => user_access('administer files'),
'#title' => t('Workflow'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#group' => 'additional_settings',
'#attributes' => array(
'class' => array(
'file-entity-form-options',
),
),
'#attached' => array(
'js' => array(
drupal_get_path('module', 'file_admin') . '/file_admin.js',
),
),
'#weight' => 95,
);
$form['options']['published'] = array(
'#type' => 'checkbox',
'#title' => t('Published'),
'#default_value' => $file->published,
);
$form['options']['promote'] = array(
'#type' => 'checkbox',
'#title' => t('Promoted'),
'#default_value' => $file->promote,
);
$form['options']['sticky'] = array(
'#type' => 'checkbox',
'#title' => t('Sticky at the top of lists'),
'#default_value' => $file->sticky,
);
if (isset($form['actions']['submit']['#validate'])) {
$form['actions']['submit']['#validate'][] = 'file_admin_file_entity_edit_validate';
}
else {
$form['#validate'][] = 'file_admin_file_entity_edit_validate';
}
}