function _w3c_validator_validate_uri in W3C Validator 7
Same name and namespace in other branches
- 6 w3c_validator.module \_w3c_validator_validate_uri()
Validate a URI using the configured validator endpoint.
Parameters
string $uri:
Return value
void
2 calls to _w3c_validator_validate_uri()
- _w3c_validator_full_validation_operation in ./
w3c_validator.module - Check and save the validation result of a URI.
- _w3c_validator_uri_validator_form_submit in ./
w3c_validator.uri_validator.page.inc - Validate a uri and store the result.
File
- ./
w3c_validator.module, line 215
Code
function _w3c_validator_validate_uri($uri, $verbose = 0) {
// Retrieve the validation method
$method = variable_get('w3c_validator_method', 'w3c_markup_validator');
// Retrieve full URI :
$uri = url($uri, array(
'absolute' => TRUE,
));
// If php_tidy is not nabled on server,
// switch to w3C_markup_validator anyway.
$tidy_available = function_exists('tidy_get_output');
if (!$tidy_available) {
$method = 'w3c_markup_validator';
}
// If the method to validate is W3C HTML Validator :
if ($method == 'w3c_markup_validator') {
$baseUrl = variable_get('w3c_validator_api_endpoint_uri', 'http://validator.w3.org/check');
$validator = new W3CvalidatorAPI($baseUrl);
$result = $validator
->validate($uri);
}
if ($verbose) {
if (!isset($result->uri)) {
// If here : the process has failed due to misconfigurtion.
drupal_set_message(t('An error has occured while validating this url (@url).', array(
'@url' => $uri,
)) . '<br/>' . t('Please check the following before retry : ') . '<br/><ul><li>' . t('is your URL correct ?') . '</li><li>' . t('is your server able to send external GET request ?') . '</li><li>' . t('is your server being a proxy - thus is this proxy setted in your server configuration ?') . '</li></ul>', 'error');
}
else {
if ($result->validity) {
drupal_set_message(t('This page (@url) as been verified and is valid !', array(
'@url' => $uri,
)), 'status');
}
else {
drupal_set_message(t('This page (@url) as been verified but is invalid : @error_count errors, @warning_count warnings found !', array(
'@url' => $uri,
'@error_count' => $result->error_count,
'@warning_count' => $result->warning_count,
)), 'warning');
drupal_set_message(t('You can view the validation errors in the <a href="@link-page">validator result page</a> or check <a href="@link-all">all site validations<a>.', array(
'@link-page' => url('validator', array(
'query' => array(
'uri' => $uri,
),
)),
'@link-all' => url('admin/reports/w3c_validator'),
)), 'warning');
}
}
}
return $result;
}