Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/**
3
 * Get the Compatibility info for a list of files into a directory
4
 * Output is produced by a custom renderer (html2).
5
 * Rather than write your own stylesheet, you may use the default one, and
6
 * change some colors on the fly.
7
 *
8
 * This example show the new options|features available with API 1.8.0
9
 *
10
 * PHP versions 4 and 5
11
 *
12
 * @category PHP
13
 * @package  PHP_CompatInfo
14
 * @author   Laurent Laville <pear@laurent-laville.org>
15
 * @license  http://www.opensource.org/licenses/bsd-license.php  BSD
16
 * @version  CVS: $Id: pci180_parsedir_tohtml.php,v 1.2 2008/07/22 20:26:45 farell Exp $
17
 * @link     http://pear.php.net/package/PHP_CompatInfo
18
 * @since    version 1.8.0b4 (2008-06-18)
19
 * @ignore
20
 */
21
 
22
require_once 'PHP/CompatInfo.php';
23
require_once 'PHP/CompatInfo/Renderer.php';
24
require_once 'PHP/CompatInfo/Renderer/Html.php';
25
 
26
/**
27
 * Custom html layout
28
 *
29
 * @ignore
30
 */
31
class PHP_CompatInfo_Renderer_Html2 extends PHP_CompatInfo_Renderer_Html
32
{
33
    /**
34
     * Html2 Renderer Class constructor
35
     *
36
     * @param object &$parser Instance of the parser (model of MVC pattern)
37
     * @param array  $conf    A hash containing any additional configuration
38
     *
39
     * @access public
40
     * @since  version 1.8.0b4 (2008-06-18)
41
     */
42
    function PHP_CompatInfo_Renderer_Html2(&$parser, $conf)
43
    {
44
        parent::__construct($parser, $conf);
45
        // use default stylesheet (pci.css)
46
        $this->setStyleSheet();  // Important: do not remove it
47
    }
48
 
49
    /**
50
     * Returns HTML code of parsing result
51
     *
52
     * @param object $obj instance of HTML_Table
53
     *
54
     * @access public
55
     * @return string
56
     */
57
    function toHtml($obj)
58
    {
59
        $styles = $this->getStyleSheet(3, array(&$this, '_getStyles'));
60
 
61
        $body = $obj->toHtml();
62
 
63
        $html = <<<HTML
64
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
65
    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
66
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
67
<head>
68
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
69
<meta name="author" content="Laurent Laville" />
70
<title>my PCI widget</title>
71
<link rel="stylesheet" type="text/css" href="yoursite.css" />
72
<link rel="stylesheet" type="text/css" href="$styles" />
73
</head>
74
<body>
75
 
76
<div id="header">
77
<h1>Laurent-Laville.org</h1>
78
</div>
79
 
80
<div id="footer">
81
</div>
82
 
83
<div id="contents">
84
 
85
<div class="outer">
86
<div class="inner">
87
$body
88
</div>
89
</div>
90
 
91
</div>
92
 
93
</body>
94
</html>
95
HTML;
96
        return $html;
97
    }
98
 
99
    /**
100
     * User callback to modify stylesheet object
101
     *
102
     * @param object $css Instance of HTML_CSS
103
     * @return string
104
     * @access private
105
     */
106
    function _getStyles($css)
107
    {
108
        $stylesheet = 'pciskin.css';
109
        $css->setStyle('.inner', 'height', '12em');
110
        $css->setStyle('.inner .even', 'background-color', '#449922');
111
        $css->setStyle('.inner .even', 'color', '#FFFFFF');
112
        $css->setStyle('.outer thead td', 'background-color', '#006600');
113
        $css->setStyle('.outer tfoot td', 'background-color', '#006600');
114
        $css->toFile(dirname(__FILE__) . DIRECTORY_SEPARATOR . $stylesheet);
115
        return $stylesheet;
116
    }
117
}
118
 
119
/*
120
  Display parsing result of directory '$source' with a website integration
121
  look and feel.
122
 */
123
$driverType    = 'html2';
124
$driverOptions = array('args' => array('output-level' => 18));
125
 
126
$compatInfo = new PHP_CompatInfo($driverType, $driverOptions);
127
 
128
$source = 'C:\wamp\tmp\Services_W3C_CSSValidator-0.1.0';
129
$compatInfo->parseData($source);
130
?>