function shorten_form_shorten_submit in Shorten URLs 6
Same name and namespace in other branches
- 7.2 shorten.module \shorten_form_shorten_submit()
- 7 shorten.module \shorten_form_shorten_submit()
Submit function for the Shorten form.
File
- ./
shorten.module, line 476 - Shortens URLs via external services.
Code
function shorten_form_shorten_submit($form, &$form_state) {
$service = '';
if ($form_state['values']['service']) {
$service = $form_state['values']['service'];
}
$shortened = shorten_url($form_state['values']['url_' . $form_state['storage']['step']], $service);
if ($form_state['values']['service']) {
$_SESSION['shorten_service'] = $form_state['values']['service'];
}
drupal_set_message(t('%original was shortened to %shortened', array(
'%original' => $form_state['values']['url_' . $form_state['storage']['step']],
'%shortened' => $shortened,
)));
$form_state['rebuild'] = TRUE;
if (empty($form_state['storage'])) {
$form_state['storage'] = array();
}
$form_state['storage']['short_url'] = $shortened;
$form_state['storage']['service'] = $form_state['values']['service'];
if (isset($form_state['storage']['step'])) {
$form_state['storage']['step']++;
}
else {
$form_state['storage']['step'] = 0;
}
}