function _shorten_service_form in Shorten URLs 6
Same name and namespace in other branches
- 8.2 shorten.module \_shorten_service_form()
- 8 shorten.module \_shorten_service_form()
- 7.2 shorten.module \_shorten_service_form()
- 7 shorten.module \_shorten_service_form()
Form which displays a list of URL shortening services.
Parameters
$last_service: The last service used on this page, if applicable.
1 call to _shorten_service_form()
- shorten_form_shorten in ./
shorten.module - Builds a form which allows shortening of a URL via the UI.
File
- ./
shorten.module, line 537 - Shortens URLs via external services.
Code
function _shorten_service_form($last_service = NULL) {
if (variable_get('shorten_show_service', FALSE) && _shorten_method_default() != 'none') {
$all_services = module_invoke_all('shorten_service');
$services = array();
$disallowed = variable_get('shorten_invisible_services', array());
foreach ($all_services as $key => $value) {
if (!$disallowed[$key]) {
$services[$key] = $key;
}
}
$default = variable_get('shorten_service', 'is.gd');
if ($default == 'none') {
$default = 'TinyURL';
}
//Remember the last service that was used.
if (isset($_SESSION['shorten_service']) && $_SESSION['shorten_service']) {
$default = $_SESSION['shorten_service'];
}
//Anonymous users don't have $_SESSION in Pressflow, so we use the last service used on this page, if applicable.
if (!empty($last_service)) {
$default = $last_service;
}
$count = count($services);
if ($count > 1) {
if (!$services[$default]) {
unset($default);
}
return array(
'#type' => 'select',
'#title' => t('Service'),
'#description' => t('The service to use to shorten the URL.'),
'#required' => TRUE,
'#default_value' => $default,
'#options' => $services,
);
}
elseif ($count) {
return array(
'#type' => 'value',
'#value' => array_pop($services),
);
}
return array(
'#type' => 'value',
'#value' => $default,
);
}
}