function _linkit_result_from_url in Linkit 7.2
Retrieve the result object from an absolute URL. This function calls the enabled plugins' "path info callback" to look for a result object. Both internal and external paths work.
Parameters
$url: An absolute URL.
Return value
A result object. This is an associative array which consists of:
- title: The title of the result
- description: The description of the result (may contain HTML).
- path: The target path which will be inserted as the href in the link.
- addClass: A CSS class that will be added to the DOM result item.
1 call to _linkit_result_from_url()
- _linkit_autocomplete in ./
linkit.module - Autocomplete callback function.
File
- ./
linkit.module, line 443 - Main file for linkit module.
Code
function _linkit_result_from_url($url, $enabled_plugins) {
if (!($path_info = linkit_scan_url($url))) {
return FALSE;
}
// Do we have Clean URLS activated.
$clean_urls = !empty($GLOBALS['conf']['clean_url']);
// Set default options to pass with the url() function.
$url_options = array(
'alias' => TRUE,
);
// Add the URL frament.
$url_options['fragment'] = isset($path_info['fragment']) ? $path_info['fragment'] : '';
// Add the URL query.
$url_options['query'] = isset($path_info['query']) ? $path_info['query'] : '';
$result = array();
if (isset($path_info['system_path']) && (bool) $path_info['system_path']) {
$menu_item = menu_get_item($path_info['system_path']);
$result = array(
'path' => url($path_info['system_path'], $url_options),
'title' => $menu_item['title'] ? check_plain($menu_item['title']) : check_plain($path_info['system_path']),
'description' => t('This is an internal path.'),
'addClass' => 'status-ok',
);
}
elseif ($path_info['target'] == 'internal') {
$result = array(
'path' => url($path_info['path'], $url_options),
'title' => t('Page not found'),
'description' => t('This page does not exist or you do not have access to it.'),
'addClass' => 'status-warning',
);
}
elseif ($path_info['target'] == 'external') {
$result = array(
'title' => t('No information available'),
'description' => t("This is an external URL, but we don't know where it leads."),
'path' => $path_info['url'],
'addClass' => 'status-notice',
);
}
return $result;
}