<?php
/* project: Class tree - basic features, file: basictree.php */
//Include pclib framework
require 'pclib/pclib.php';
//Create pclib application
$app = new PCApp('demo');
$datasource = 'pdo_mysql://user:password@localhost/test';
$app->db = new PCDb($datasource);
print '<h2>Tree from text file</h2>';
$tree1 = new PCTree;
$tree1->values['CSS_CLASS'] = 'pctree';
$text = file_get_contents('data/tree.txt');
$tree1->importText($text);
print $tree1;
print '<h2>Tree from database table (TREE_LOOKUPS by default)</h2>';
$tree_id = 1;
$tree2 = new PCTree;
$tree2->values['CSS_CLASS'] = 'pctree';
$tree2->load($tree_id, 1);
print $tree2;
print '<h2>Use your own css-class</h2>';
$tree2->values['CSS_CLASS'] = 'pcmenu';
print $tree2;
// You must add tree initialization into your application javascript file:
?>
<script language="Javascript">
window.onload = function() { pclib.initTree(); }
</script>
<?php
Elapsed time: 18.05 ms