<?php
include("CSSTree.inc.php");
// dummy data
$ddata=array("border"=>"1px solid black");
$ddata2=array("border"=>"2px solid silver");
// cssfile to read from
$cssfile='example.css';
// init the tree (Tree.inc.php), available from:
// http://www.phpclasses.org/browse/package/2817.html
$null=null;
$tree = new CSSTree($null,"");
// parse the css-file and generate tree structure
$tree=&$tree->parseFile($cssfile);
echo '<h2>File content</h2>';
echo '<pre>';
include($cssfile);
echo '</pre>';
// get a child by its name
echo ' selecting an item by name... <br> ';
$item=&$tree->getChildByName('P');
// check if this is existent, if not, false is return value
if ($item){
echo ' properties of selected item '.
$item->tagname.': '.
$item->renderCSSProperties();
echo '<br>';
// add a property
$item->setProperty('color', 'black');
}
// lets have a look at the structure
echo '<pre>';
$tree->echoStructure();
echo '</pre>';
// add some childs
$tmp=&$tree->addChild('custom1',$ddata);
$tmp=&$tmp->addChild('custom2',$ddata2);
echo '<h2>______echoStructure()_____</h2>';
echo '<pre>';
echo $tree->echoStructure();
echo '</pre>';
echo '<h2>_____renderCSSProperties______</h2>';
echo '<p>This is what you need for tags (<div style="">)</p>';
echo '<pre>';
echo $tmp->renderCSSProperties();
echo '</pre>';
echo '<h2>_____renderCSS()______</h2>';
echo '<p>This is what you need in the header section <style></p>';
echo '<pre>';
echo $tmp->renderCSS();
echo '</pre>';
echo '<h2>______renderCSSAll()_____</h2>';
echo '<p>This is what you need in a css-file</p>';
echo '<pre>';
echo $tree->renderCSSAll();
echo '</pre>';
?>
|