Location: PHPKode > projects > PHPfaces - User Interface Framework > demo/article_browser/index.php
<?php

require("../../core/PHPfaces.class.php");
require("BrowserEvents.class.php");

$ui = new PHPfaces();

$browser = new PForm('browser');

$explorer = new PTree('explorer');
		
$node1 = new PTreeNode('node1', 'Articles');
$node1->setExpanded(true);

$explorer->addNode($node1);	

$tblArticles = new PTable('tblArticles', 0, 4);
$txtArticle = new PTextField('txtArticle', '', 30);
$txtDescr = new PTextField('txtDescr', '', 30);
$txtPrice = new PTextField('txtPrice', '', 12);
$cbColor = new PComboBox('cbColor');

$butAdd = new PButton('butAdd', 'Add');
$butAdd->setEvent(new ButAddEvent());

$cbColor->addOption('black', 'black');
$cbColor->addOption('green', 'green');
$cbColor->addOption('blue', 'blue');
$cbColor->addOption('red', 'red');

$tblArticles->setHeader(0, 'ArticleNo');
$tblArticles->setHeader(1, 'Description');
$tblArticles->setHeader(2, 'Price');
$tblArticles->setHeader(3, 'Color');

addInitialRow('A0001', 'Desktop PC', '990.00', 'black');
addInitialRow('A0002', 'Notebook', '1200.00', 'blue');
addInitialRow('BA00001', 'Optical Mouse', '20.00', 'red');
addInitialRow('BB00001', 'Mousepad', '5.99', 'green');

$browser->assign($tblArticles);
$browser->assign($txtArticle);
$browser->assign($txtDescr);
$browser->assign($txtPrice);
$browser->assign($cbColor);
$browser->assign($butAdd);

$browser->assign($explorer);

function addInitialRow($article, $descr, $price, $color) {
	global $tblArticles, $node1;
	
	$tblArticles->addRow(array($article, $descr, $price, $color));
	
	$new1 = new PTreeNode($article, $article);

    $new1->addNode(new PTreeNode('node_'.$descr, 'Descr: '.$descr));
    $new1->addNode(new PTreeNode('node_'.$price, 'Price: '.$price));
    $new1->addNode(new PTreeNode('node_'.$color, 'Color: '.$color));

    $node1->addNode($new1);
}

$index = new Smarty();

$index->template_dir = "";
$index->force_compile = TRUE;
$index->compile_dir = $ui->getPath().'temp/smarty/templates_c';
$index->assign('head', $ui->fetchHeader());
$index->assign('form', $browser->fetchForm());
		
$index->display('index.tpl');

?>
Return current item: PHPfaces - User Interface Framework