cvs: pear /HTML_CSS/examples CSS_parseData.php

From: Date: Thu, 15 Dec 2005 20:33:27 +0000
Subject: cvs: pear /HTML_CSS/examples CSS_parseData.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-36885@lists.php.net to get a copy of this message
farell Thu Dec 15 20:33:27 2005 EDT Added files: /pear/HTML_CSS/examples CSS_parseData.php Log: example of solution to use new feature : parse multiple data sources ( a list of filename and string ) http://cvs.php.net/viewcvs.cgi/pear/HTML_CSS/examples/CSS_parseData.php?view=markup&rev=1.1 Index: pear/HTML_CSS/examples/CSS_parseData.php +++ pear/HTML_CSS/examples/CSS_parseData.php <?php /** * Tell whether a value return by HTML_CSS is an error. * Solution to use HTML_CSS::isError() method. * * @category HTML * @package HTML_CSS * @subpackage Examples * @author Laurent Laville <pear@laurent-laville.org> * @version CVS: $Id: CSS_parseData.php,v 1.1 2005/12/15 20:33:27 farell Exp $ * @link http://pear.php.net/package/HTML_CSS * @since File available since Release 1.0.0RC2 */ require_once 'HTML/CSS.php'; function myErrorHandler($code, $level) { return PEAR_ERROR_PRINT; // always print all error messages } /* body { font-size: 1em; } ---- print.css ---- *{ margin: 4px; padding: 0px; } body{ font-family: Tahoma, Verdana, Helvetica, Arial, sans-serif; text-align:center; background-color:#fff; } ---- default.css ---- *{ margin: 0px; padding: 0px; } body{ font-family: Lucida Grande, Tahoma, Verdana, Arial, sans-serif; text-align:center; background-color:#fff; } */ $styles = array( "body { font-size: 1em; }", "print.css", "default.css" ); $prefs = array( 'push_callback' => 'myErrorHandler', ); $attribs = null; $css = new HTML_CSS($attribs, $prefs); $res = $css->parseData($styles); if ($css->isError($res)) { $line = __LINE__ - 1; $style = 'background-color:red; color:yellow; font-weight:bold; padding:0.4em;'; echo '<p style="'.$style.'">Error message detected by isError() at line ' . $line . '</p>'; } print 'Still alive !'; ?>

« previous php.pear.cvs (#36885) next »