Git - Framework SuperObject

fso: / output.php [ Download ]

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php

if ( !class_exists('FSO') )
    die('Framework SuperObject base class must be loaded to use its modules!');

/**
 * Output class
 *
 * Class for handling output functions such as output buffering, etc.
 */
class Output extends FSO_Module
{
    private $validatrix;

    //  {{{ public function __construct($validatrix_path)
    
    public function __construct($validatrix_path)
    {
        parent::__construct();
        ob_start();
        $vp = rtrim(realpath($validatrix_path), '/');
        $this->validatrix = "$vp/onsgmls -s -c $vp/xhtml.soc -D $vp/DTD/ -E 1";
    }

    //  }}}
    //  {{{ destructor

    /**
     * Destructor
     *
     * Do the validatrix thing and send the output
     */
    public function __destruct()
    {
        ob_end_flush();
    }

    //  }}}
    //  {{{ public function validatrix()

    /**
     * Run the validatrix and put the results in the document
     *
     * Pass a string in via $extra if you need to add more to make the
     * document complete.  Returns true if the XHTML is valid, otherwise
     * false.
     *
     * @param       string      $extra
     * @return      boolean
     */
    public function validatrix($extra = '')
    {
        $pipe = popen($this->validatrix, 'w');
        fwrite($pipe, ob_get_contents());
        fwrite($pipe, $extra);
        return pclose($pipe) == 0;
    }

    //  }}}
}

?>