function sharedblocks_element_validate_url in Shared Blocks 7.2
1 string reference to 'sharedblocks_element_validate_url'
- sharedblocks_block_configure in ./
sharedblocks.module - Implements hook_block_configure.
File
- ./
sharedblocks.module, line 149
Code
function sharedblocks_element_validate_url(array $element, array &$form_state) {
if (!empty($element['#value'])) {
// Is the URL a valid external URL?
if (!valid_url($element['#value'], TRUE)) {
form_error($element, t('The URL %url is not valid.', array(
'%url' => $form_state['values']['url'],
)));
}
else {
// Does the URL return a valid shared block JSON array?
module_load_include('inc', 'sharedblocks', 'sharedblocks.subscribe');
$block_data = _sharedblocks_fetch_url($form_state['values']['url']);
if (empty($block_data)) {
form_error($element, t('Could not fetch block information from %url.', array(
'%url' => $form_state['values']['url'],
)));
}
}
}
}