| Project: | W3C Validator |
| Version: | 6.x-1.2 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
Hi,
I created a module that uses yours as a dependancy, W3C Analyzer. The module enables people to analyze their content through three methods: url input, raw text and the body field during node edit.
Currently I am calling your _w3c_validator_validate_uri(); to get the data. The one problem is this function only takes a uri as an argument. This works fine for the url input option, however to get the raw text and node edit options working I need a way to submit text to your function.
I was wondering if you could split functions to have one for a url input and one for html. The simple way to do this would be to take:
function _w3c_validator_validate_uri_tidy($uri) {
if (empty($uri)) {
return FALSE;
}
// Create a token for this request
$token = w3c_validator_create_access_token($uri);
// The token is used as a header to allow validation of authenticated pages, see hook_init
$response = drupal_http_request($uri, array('w3c-validator-token' => $token));
$html = $response->data;
$config = array(
// 'input-xml' => TRUE,
);
$tidy = new tidy();
$tidy->parseString($html, $config);
...and split it into:
function _w3c_validator_validate_uri_tidy($uri) {
if (empty($uri)) {
return FALSE;
}
// Create a token for this request
$token = w3c_validator_create_access_token($uri);
// The token is used as a header to allow validation of authenticated pages, see hook_init
$response = drupal_http_request($uri, array('w3c-validator-token' => $token));
$html = $response->data;
return $html;
}
function _w3c_validator_validate_html_tidy($html)
$config = array(
// 'input-xml' => TRUE,
);
$tidy = new tidy();
$tidy->parseString($html, $config);
...Then of course the call would be:
$function_url = '_w3c_validator_validate_uri_'. $method;
$function_html = '_w3c_validator_validate_html_'. $method;
if (function_exists($function_uri) && function_exists($function_html)) {
$html = $function_uri($uri);
return $function_html($html);
}The other way would be to add a boolean argument to the current function that could switch the first parameter to treated as text and not a uri.
Thanks,
Tom