function feeds_oai_pmh_ajax_callback in Feeds OAI-PMH Fetcher and Parser 7
Callback function for AJAX setSpec element in form.
1 string reference to 'feeds_oai_pmh_ajax_callback'
- FeedsOAIHTTPFetcher::sourceForm in ./
FeedsOAIHTTPFetcher.inc - Expose source form.
File
- ./
feeds_oai_pmh.module, line 52
Code
function feeds_oai_pmh_ajax_callback($form, $form_state) {
require_once drupal_get_path('module', 'feeds_oai_pmh') . '/feeds_oai_pmh.inc';
// Validate the repository.
$oai_source_url = $form_state['values']['feeds']['FeedsOAIHTTPFetcher']['source'];
$result = feeds_oai_pmh_identify($oai_source_url);
if ($result['status'] == 0) {
// OAI-PMH Identify verb returned OK.
// Change the form's set element.
$form['feeds']['FeedsOAIHTTPFetcher']['set']['#options'] = feeds_oai_pmh_sets_options($result['repository']['sets']);
$set = $form_state['values']['feeds']['FeedsOAIHTTPFetcher']['set'];
if ($set) {
$form['feeds']['FeedsOAIHTTPFetcher']['set']['#default_value'] = $set;
}
if (isset($result['repository']['earliest_timestamp']) && $result['repository']['earliest_timestamp'] > 0) {
$date = format_date((int) $result['repository']['earliest_timestamp'], 'custom', 'M d, Y');
$form['feeds']['FeedsOAIHTTPFetcher']['dates']['#description'] = t('Note: earliest record reported by repository is @date', array(
'@date' => $date,
));
}
}
else {
// Empty sets.
$form['feeds']['FeedsOAIHTTPFetcher']['set']['#options'] = feeds_oai_pmh_sets_options(array());
$form['feeds']['FeedsOAIHTTPFetcher']['dates']['#description'] = '';
drupal_set_message($result['output'], 'error');
}
return $form['feeds']['FeedsOAIHTTPFetcher'];
}