function _w3c_validator_display_result in W3C Validator 7
Build the validation result display.
Parameters
array $result:
boolean $need_validation (default is false):
Return value
array the new page part containing the result display
3 calls to _w3c_validator_display_result()
- theme_w3c_validator_site_validation_report_row in ./
w3c_validator.site_validation_report.page.inc - Format a w3c validation report page row.
- w3c_validator_uri_validator_page in ./
w3c_validator.uri_validator.page.inc - Page callback to validate an 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 326
Code
function _w3c_validator_display_result($result) {
$result->uri = url($result->uri, array(
'absolute' => TRUE,
));
$endpoint = variable_get('w3c_validator_api_endpoint_uri', 'http://validator.w3.org/check');
$check_url = $endpoint . '?uri=' . urlencode($result->uri);
// ---------------------------------------------------
// BUILD THE RESULT SUMMARY.
$headers = null;
$rows = array();
$rows[] = array(
t('URI'),
l($result->uri, $result->uri, array(
'attributes' => array(
'target' => '_new',
),
)),
);
$rows[] = array(
t('Validity'),
$result->validity == 'true' ? t('Valid') : t('Invalid'),
);
$rows[] = array(
t('Validator results'),
l($check_url, $check_url, array(
'attributes' => array(
'target' => '_new',
),
)),
);
$rows[] = array(
t('Doctype'),
$result->doctype,
);
$rows[] = array(
t('Summary'),
t(' Found @error_count Errors, @warning_count Warnings', array(
'@error_count' => $result->error_count,
'@warning_count' => $result->warning_count,
)),
);
if ($result->validity) {
$output = '<h2 class="title valid">' . t('This document was successfully checked !') . '</h2>';
}
else {
$output = '<h2 class="title invalid">' . t('Errors found while checking this document !') . '</h2>';
}
$output .= theme('table', array(
'header' => $headers,
'rows' => $rows,
'attributes' => array(
'class' => array(
'summary-table',
),
),
));
// ---------------------------------------------------
// BUILD ERRORS RESULTS.
$output .= '<h2>' . t('Errors') . '</h2>';
$result->errors = is_array($result->errors) ? $result->errors : unserialize($result->errors);
if (is_array($result->errors) && !empty($result->errors)) {
foreach ($result->errors as $error) {
$output .= '<div class="message-wrapper message-error">';
$output .= '<div class="message">' . '<span class="where">' . t('Line @line, Column @col:', array(
'@line' => $error->line,
'@col' => $error->col,
)) . '</span><span class="descr">' . t(' @descr', array(
'@descr' => $error->message,
)) . '</div>';
$output .= '<div class="source">' . $error->source . '</div>';
$output .= '</div>';
}
}
else {
$output .= t('No errors');
}
// ---------------------------------------------------
// BUILD WARNINGS RESULTS.
$output .= '<h2>' . t('Warnings') . '</h2>';
$result->warnings = is_array($result->warnings) ? $result->warnings : unserialize($result->warnings);
if (is_array($result->warnings) && !empty($result->warnings)) {
foreach ($result->warnings as $warning) {
$output .= '<div class="message-wrapper message-warning">';
$output .= '<div class="message">' . '<span class="where">' . t('Line @line, Column @col:', array(
'@line' => $warning->line,
'@col' => $warning->col,
)) . '</span><span class="descr">' . t(' @descr', array(
'@descr' => $warning->message,
)) . '</div>';
$output .= '<div class="source">' . $warning->source . '</div>';
$output .= '</div>';
}
}
else {
$output .= t('No warnings');
}
return $output;
}