comparison OnlineURIValidator.inc @ 94:2370f4450983

Document functions and move a few functions to more appropriate places.
author Tom Fredrik Blenning Klaussen <bfg@blenning.no>
date Thu, 18 Oct 2012 17:33:34 +0200
parents 8aadd7a23b68
children
comparison
equal deleted inserted replaced
93:8aadd7a23b68 94:2370f4450983
6 $cache = ScriptIncludeCache::instance(__FILE__); 6 $cache = ScriptIncludeCache::instance(__FILE__);
7 $cache->includeOnce('Http.inc', $baseDir); 7 $cache->includeOnce('Http.inc', $baseDir);
8 $cache->includeOnce('OnlineValidator.inc', $baseDir); 8 $cache->includeOnce('OnlineValidator.inc', $baseDir);
9 /// @endcond 9 /// @endcond
10 10
11 11 /**
12 * Defines a validator which uses an online validator and a URI to the
13 * content
14 */
12 class OnlineURIValidator extends OnlineValidator 15 class OnlineURIValidator extends OnlineValidator
13 { 16 {
14 private $uri; 17 private $uri;
15 18
16 static function get_url_contents($url) 19 /**
17 { 20 * Constructs an OnlineURIValidator
18 $crl = curl_init(); 21 *
19 $timeout = 5; 22 * @param $uri The uri to validate
20 23 */
21 curl_setopt ($crl, CURLOPT_URL, $url);
22 curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
23 curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
24 $ret = curl_exec($crl);
25 curl_close($crl);
26 return $ret;
27 }
28
29 function __construct($uri) 24 function __construct($uri)
30 { 25 {
31 $this->uri = $uri; 26 $this->uri = $uri;
32 } 27 }
33 28
38 33
39 $headers = Http::getHeaders($this->validator_url . $query, 5); 34 $headers = Http::getHeaders($this->validator_url . $query, 5);
40 return $headers['X-W3C-Validator-Status'] === "Valid"; 35 return $headers['X-W3C-Validator-Status'] === "Valid";
41 } 36 }
42 37
38 /**
39 * Gets the URI for this validator
40 *
41 * @return string with the URI
42 */
43 function getUri() 43 function getUri()
44 { 44 {
45 return $this->uri; 45 return $this->uri;
46 } 46 }
47 47