function biblio_ui_manage_biblio in Bibliography Module 7.3
Form for creating a biblio entry.
1 string reference to 'biblio_ui_manage_biblio'
- biblio_ui_menu in modules/
biblio_ui/ biblio_ui.module - Implements hook_menu().
File
- modules/
biblio_ui/ biblio_ui.module, line 433 - Main functionality file for the biblio UI module.
Code
function biblio_ui_manage_biblio($form, &$form_state, $type) {
global $user;
$account = user_load($user->uid);
$biblio = !is_object($type) ? biblio_create($type) : $type;
$form_state['#entity'] = $biblio;
$form['title'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#required' => TRUE,
'#weight' => -10,
'#default_value' => !empty($biblio->title) ? $biblio->title : '',
);
field_attach_form('biblio', $biblio, $form, $form_state);
// Show publication year only if biblio status is "published".
$form['biblio_year']['#states'] = array(
'visible' => array(
':input[name="biblio_status[und]"]' => array(
'value' => 'published',
),
),
);
$form['additional_settings'] = array(
'#type' => 'vertical_tabs',
'#weight' => 99,
);
$form['owner'] = array(
'#type' => 'fieldset',
'#title' => t('Authoring information'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#group' => 'additional_settings',
'#attributes' => array(
'class' => array(
'biblio-form-owner',
),
),
'#attached' => array(
'js' => array(
drupal_get_path('module', 'biblio_ui') . '/js/biblio_ui.js',
array(
'type' => 'setting',
'data' => array(
'anonymous' => variable_get('anonymous', t('Anonymous')),
),
),
),
),
'#weight' => 90,
);
$form['owner']['name'] = array(
'#type' => 'textfield',
'#title' => t('Created by'),
'#maxlength' => 60,
'#autocomplete_path' => 'user/autocomplete',
'#default_value' => !empty($biblio->uid) ? user_load($biblio->uid)->name : $account->name,
'#weight' => -1,
'#description' => t('Leave blank for %anonymous.', array(
'%anonymous' => variable_get('anonymous', t('Anonymous')),
)),
);
// Add the path field to the Biblio form. This is based on the path module
// function path_form_node_form_alter().
$path = array();
if (!empty($form['#entity']->bid)) {
$conditions = array(
'source' => 'biblio/' . $form['#entity']->bid,
);
$langcode = entity_language('biblio', $form['#entity']);
if ($langcode && $langcode != LANGUAGE_NONE) {
$conditions['language'] = $langcode;
}
$path = path_load($conditions);
if ($path === FALSE) {
$path = array();
}
}
$path += array(
'pid' => NULL,
'source' => isset($form['#entity']->bid) ? 'biblio/' . $form['#entity']->bid : NULL,
'alias' => '',
'language' => isset($langcode) ? $langcode : LANGUAGE_NONE,
);
$form['path'] = array(
'#type' => 'fieldset',
'#title' => t('URL path settings'),
'#collapsible' => TRUE,
'#collapsed' => empty($path['alias']),
'#group' => 'additional_settings',
'#attributes' => array(
'class' => array(
'path-form',
),
),
'#attached' => array(
'js' => array(
drupal_get_path('module', 'path') . '/path.js',
),
),
'#access' => user_access('create url aliases') || user_access('administer url aliases'),
'#weight' => 30,
'#tree' => TRUE,
'#element_validate' => array(
'path_form_element_validate',
),
);
$form['path']['alias'] = array(
'#type' => 'textfield',
'#title' => t('URL alias'),
'#default_value' => $path['alias'],
'#maxlength' => 255,
'#description' => t('Optionally specify an alternative URL by which this content can be accessed. For example, type "about" when writing an about page. Use a relative path and don\'t add a trailing slash or the URL alias won\'t work.'),
);
$form['path']['pid'] = array(
'#type' => 'value',
'#value' => $path['pid'],
);
$form['path']['source'] = array(
'#type' => 'value',
'#value' => $path['source'],
);
$form['path']['language'] = array(
'#type' => 'value',
'#value' => $path['language'],
);
$form['published'] = array(
'#type' => 'fieldset',
'#title' => t('Published'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#group' => 'additional_settings',
'#weight' => 100,
);
$timestamp_property = empty($biblio->is_new) ? 'changed' : 'created';
$form['published']['created'] = array(
'#type' => 'textfield',
'#date_format' => 'Y-m-d G:i',
'#title' => t('Published time'),
'#default_value' => date('Y-m-d H:i', $biblio->{$timestamp_property}),
);
$form['actions'] = array(
'#type' => 'actions',
'submit' => array(
'#type' => 'submit',
'#value' => t('Save'),
),
'cancel' => array(
'#markup' => l(t('Cancel'), 'biblio'),
),
);
return $form;
}