Given a CSS file, test to make sure it is valid CSS.

Paramètres

string $filename: The name of the file.

array $validator_options: List of options to pass along to the CSS Validator.

Return value

array Info from the w3c server.

1 call to advagg_validator_test_css_file_w3c()
advagg_validator_test_css_files dans advagg_validator/advagg_validator.inc
Test all given files with the w3c validator.

Fichier

advagg_validator/advagg_validator.inc, line 156

Code

function advagg_validator_test_css_file_w3c($filename, array &$validator_options = array()) {
    // Get CSS files contents.
    $validator_options['text'] = (string) @advagg_file_get_contents($filename);
    // Add in defaults.
    $validator_options += array(
        'output' => 'soap12',
        'warning' => '1',
        'profile' => 'css3',
        'usermedium' => 'all',
        'lang' => 'en',
    );
    // Build request URL.
    // API Documentation http://jigsaw.w3.org/css-validator/api.html
    $request_url = 'http://jigsaw.w3.org/css-validator/validator';
    $query = http_build_query($validator_options, '', '&');
    $url = $request_url . '?' . $query;
    // Send request.
    $result = drupal_http_request($url);
    if (!empty($result->data) && $result->code == 200) {
        // Parse XML and return info.
        $return = advagg_validator_parse_soap_response_w3c($result->data);
        $return['filename'] = $filename;
        if (isset($validator_options['text'])) {
            unset($validator_options['text']);
        }
        $return['options'] = $validator_options;
        return $return;
    }
    return array(
        'error' => t('W3C Server did not return a 200 or request data was empty.'),
    );
}