view OnlineBufferValidator.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
line wrap: on
line source

<?php
include_once 'ScriptIncludeCache.inc';

/// @cond
$baseDir = dirname(__FILE__);
$cache = ScriptIncludeCache::instance(__FILE__);
$cache->includeOnce('Http.inc', $baseDir);
$cache->includeOnce('OnlineValidator.inc', $baseDir);
/// @endcond


/**
 * Defines a validator which uses an online validator and a buffer
 * with the content
 */
class OnlineBufferValidator extends OnlineValidator
{

  private $buffer;

  /**
   * Constructs an OnlineURIValidator
   *
   * @param $buffer The buffer to validate
   */
  function __construct($buffer)
  {
    $this->buffer = $buffer;
  }

  function check()
  {
    $params = array( 'fragment' => $this->buffer);

    $headers = Http::postHeaders($this->validator_url , $params, 2);
    return $headers['X-W3C-Validator-Status'] === "Valid";
  }
}
?>