Source for file Html.php
Documentation is available at Html.php
* Copyright (c) 2008, Laurent Laville <pear@laurent-laville.org>
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the authors nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* @package PHP_CompatInfo
* @author Laurent Laville <pear@laurent-laville.org>
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @version CVS: $Id: Html.php,v 1.12 2008/07/22 20:26:19 farell Exp $
* @link http://pear.php.net/package/PHP_CompatInfo
* @since File available since Release 1.8.0b4
require_once 'HTML/Table.php';
require_once 'HTML/CSS.php';
* Html renderer for PHP_CompatInfo component.
* The PHP_CompatInfo_Renderer_Html class is a concrete implementation
* of PHP_CompatInfo_Renderer abstract class. It simply display results
* as web/html content with help of PEAR::Html_Table
* @package PHP_CompatInfo
* @author Laurent Laville <pear@laurent-laville.org>
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @version Release: @package_version@
* @link http://pear.php.net/package/PHP_CompatInfo
* @since Class available since Release 1.8.0b4
* Style sheet for the custom layout
* Html Renderer Class constructor (ZE1) for PHP4
* @param object &$parser Instance of the parser (model of MVC pattern)
* @param array $conf A hash containing any additional configuration
* @since version 1.8.0b4 (2008-06-18)
* Html Renderer Class constructor (ZE2) for PHP5+
* @param object &$parser Instance of the parser (model of MVC pattern)
* @param array $conf A hash containing any additional configuration
* @since version 1.8.0b4 (2008-06-18)
$defaults = array ('tdwidth' => array (18 , 4 , 2 , 7 , 13 ));
* Display final results, when data source parsing is over.
* @since version 1.8.0b4 (2008-06-18)
$o = $this->args['output-level'];
// protect against invalid data source
print 'Invalid data source';
$src = $this->_parser->dataSource;
if ($src['dataType'] == 'directory') {
$dir = $src['dataSource'];
} elseif ($src['dataType'] == 'file') {
$file = $src['dataSource'];
$string = $src['dataSource'];
$hdr_col1 = 'Source code';
$dataTable = new HTML_Table ();
$thead = & $dataTable->getHeader ();
$tbody = & $dataTable->getBody ();
$tfoot = & $dataTable->getFooter ();
$atr = array ('scope="col"');
$hdr[] = 'Constants/Tokens';
$thead->addRow ($hdr, $atr);
$ext = implode("<br/>", $info['extensions']);
$ds = DIRECTORY_SEPARATOR;
$title = $src['dataCount'] . ' file';
if ($src['dataCount'] > 1 ) {
} elseif (isset ($file)) {
$title = '1 chunk of code';
$data = array ('Summary: '. $title . ' parsed');
if (empty ($info['max_version'])) {
$data[] = $info['version'];
$data[] = implode("<br/>", array ($info['version'],
$data[] = $info['cond_code'][0 ];
$data[] = implode("<br/>", $info['constants']);
$data[] = implode("<br/>", $info['tokens']);
// summarize : print only summary for directory without files details
if ($this->args['summarize'] === false && isset ($dir)) {
// display result of parsing multiple files
unset ($info['max_version']);
unset ($info['functions']);
unset ($info['extensions']);
unset ($info['constants']);
unset ($info['cond_code']);
$ignored = $info['ignored_files'];
unset ($info['ignored_files']);
unset ($info['ignored_functions']);
unset ($info['ignored_extensions']);
unset ($info['ignored_constants']);
foreach ($info as $file => $info) {
continue; // skip this (invalid) file
$ext = implode("<br/>", $info['extensions']);
$tbody->addRow (array ($path), array ('class' => 'dirname',
'colspan' => count($hdr)));
if (empty ($info['max_version'])) {
$data[] = $info['version'];
$data[] = implode("<br/>", array ($info['version'],
$data[] = $info['cond_code'][0 ];
$data[] = implode("<br/>", $info['constants']);
$data[] = implode("<br/>", $info['tokens']);
} elseif ($this->args['summarize'] === false && !isset ($dir)) {
// display result of parsing a single file, or a chunk of code
$tbody->addRow (array ($path), array ('class' => 'dirname',
'colspan' => count($hdr)));
// display only result summary of parsing a data source
} elseif (isset ($file)) {
$tbody->addRow (array ($path), array ('class' => 'dirname',
'colspan' => count($hdr)));
$evenRow = array ('class' => 'even');
$tbody->altRowAttributes (1 , $evenRow, $oddRow, true );
echo $this->toHtml($dataTable);
* Returns the custom style sheet
* Returns the custom style sheet to use for layout
* @param int $destination (optional) Destination of css content
* @param mixed $extra (optional) Additional data depending of destination
* @since version 1.8.0b4 (2008-06-18)
$css->parseFile ($this->css);
$tdw = $this->conf['tdwidth'];
$o = $this->args['output-level'];
$css->setStyle ('.outer td.dirname', 'width', $em. 'em');
$css->setStyle ('.outer '. $td, 'width', $tdw[1 ]. 'em');
$css->setStyle ('.outer '. $td, 'width', $tdw[2 ]. 'em');
$css->setStyle ('.outer '. $td, 'width', $tdw[3 ]. 'em');
$css->setStyle ('.outer '. $td, 'width', $tdw[4 ]. 'em');
$css->setStyle ('.outer td', 'width', $em . 'em');
case 1: // embedded styles
$styles = $css->toString ();
case 2: // save only to file
case 3: // apply a user function
* Set a custom style sheet
* Set a custom style sheet to use your own styles
* @param string $css (optional) File to read user-defined styles from
* @return bool True if custom styles, false if default styles applied
* @since version 1.8.0b4 (2008-06-18)
// default stylesheet is into package data directory
$css = '@data_dir@' . DIRECTORY_SEPARATOR
. '@package_name@' . DIRECTORY_SEPARATOR
* Returns HTML code of parsing result
* @param object $obj instance of HTML_Table
* @since version 1.8.0b4 (2008-06-18)
if (!isset ($this->css)) {
// when no user-styles defined, used the default values
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<title>PHP_CompatInfo</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
Documentation generated on Fri, 01 Aug 2008 11:30:25 -0400 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.
|