| 1 |
lars |
1 |
<?php
|
|
|
2 |
//
|
|
|
3 |
// $Id: index.php,v 1.3 2003/02/25 12:14:30 cain Exp $
|
|
|
4 |
//
|
|
|
5 |
ini_set('include_path',realpath(dirname(__FILE__).'/../../../').':'.realpath(dirname(__FILE__).'/../../../../includes').':'.ini_get('include_path'));
|
|
|
6 |
ini_set('error_reporting',E_ALL);
|
|
|
7 |
|
|
|
8 |
##################################################
|
|
|
9 |
#
|
|
|
10 |
# init template engine
|
|
|
11 |
#
|
|
|
12 |
// you need the template class from http://sf.net/projects/simpltpl
|
|
|
13 |
if (!@include('HTML/Template/Xipe.php')) {
|
|
|
14 |
print 'sorry, you need the template class PEAR::HTML_Template_Xipe<br>'.
|
|
|
15 |
'or if i have time i put the examples <a href="http://os.visionp.de/">here online</a>';
|
|
|
16 |
die();
|
|
|
17 |
}
|
|
|
18 |
require_once('HTML/Template/Xipe/Filter/TagLib.php');
|
|
|
19 |
$options = array( 'templateDir' => dirname(__FILE__) );
|
|
|
20 |
$tpl = new HTML_Template_Xipe($options);
|
|
|
21 |
|
|
|
22 |
|
|
|
23 |
##################################################
|
|
|
24 |
#
|
|
|
25 |
# actual tree stuff, using Dynamic_DBnested
|
|
|
26 |
#
|
|
|
27 |
require_once('Tree/Tree.php');
|
|
|
28 |
$tree = Tree::setup( 'Dynamic_DBnested' , 'mysql://root@localhost/test' , array('table'=>'Tree_Nested') );
|
|
|
29 |
|
|
|
30 |
if( @$_REQUEST['action_add'] )
|
|
|
31 |
{
|
|
|
32 |
$methodCall = "tree->add( {$_REQUEST['newData']} , {$_REQUEST['parentId']} , {$_REQUEST['prevId']} )";
|
|
|
33 |
$result = $tree->add( $_REQUEST['newData'] , $_REQUEST['parentId'] , $_REQUEST['prevId'] );
|
|
|
34 |
}
|
|
|
35 |
|
|
|
36 |
if( @$_REQUEST['action_remove'] )
|
|
|
37 |
{
|
|
|
38 |
$methodCall = "$tree->remove( {$_REQUEST['removeId']} )";
|
|
|
39 |
$result = $tree->remove( $_REQUEST['removeId'] );
|
|
|
40 |
}
|
|
|
41 |
|
|
|
42 |
if( @$_REQUEST['action_update'] )
|
|
|
43 |
{
|
|
|
44 |
$methodCall = "tree->update( {$_REQUEST['updateId']} , {$_REQUEST['updateData']} )";
|
|
|
45 |
$result = $tree->update( $_REQUEST['updateId'] , $_REQUEST['updateData'] );
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
if( @$_REQUEST['action_move'] )
|
|
|
49 |
{
|
|
|
50 |
$methodCall = "tree->move( {$_REQUEST['move_id']} , {$_REQUEST['move_newParentId']} , {$_REQUEST['move_newPrevId']} )";
|
|
|
51 |
$result = $tree->move( $_REQUEST['move_id'] , $_REQUEST['move_newParentId'] , $_REQUEST['move_newPrevId'] );
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
$methodFailed = false;
|
|
|
55 |
if( @PEAR::isError($result) )
|
|
|
56 |
$methodFailed = true;
|
|
|
57 |
|
|
|
58 |
$fid = @$_REQUEST['fid'];
|
|
|
59 |
if( !$fid )
|
|
|
60 |
$fid = $tree->getRootId();
|
|
|
61 |
|
|
|
62 |
$path = $tree->getPath( $fid );
|
|
|
63 |
$children = $tree->getChildren( $fid );
|
|
|
64 |
|
|
|
65 |
##################################################
|
|
|
66 |
#
|
|
|
67 |
# actual tree stuff to show the entire tree using Memory_DBnested
|
|
|
68 |
#
|
|
|
69 |
require_once('Tree/Tree.php');
|
|
|
70 |
$memTree = Tree::setup( 'Memory_DBnested' , 'mysql://root@localhost/test' ,
|
|
|
71 |
array('table'=>'Tree_Nested') );
|
|
|
72 |
|
|
|
73 |
$memTree->setup();
|
|
|
74 |
$entireTree = $memTree->getNode();
|
|
|
75 |
$treeDepth = $memTree->getDepth();
|
|
|
76 |
|
|
|
77 |
$tpl->compile('index.tpl');
|
|
|
78 |
include($tpl->compiledTemplate);
|
|
|
79 |
?>
|