コード例 #1
0
dumpHelper('$tree->getChildren(' . $id . ')', 'dump the children of "myElement"');
// you can also use:    $tree->data[$id]['children']
$id = $tree->getIdByPath('myElement/subElement');
dumpHelper('$tree->getNext(' . $id . ')', 'dump the "next" of "myElement/subElement"', true);
// you can also use:    $tree->data[$id]['next']
$id = $tree->getIdByPath('myElement/anotherSubElement');
dumpHelper('$tree->getPrevious(' . $id . ')', 'dump the "previous" of "myElement/anotherSubElement"', true);
// you can also use:    $tree->data[$id]['previous']
$id = $tree->getIdByPath('myElement');
$element = $tree->data[$id]['child']['next']['parent'];
// refer to yourself again, in a very complicated way :-)
dumpHelper('$element[\'id\']', 'demo of using the internal array, for referencing tree-nodes, see the code');
$id = $tree->getIdByPath('myElement');
$element = $tree->data[$id]['child']['next'];
// refer to the second child of 'myElement'
dumpHelper('$element[\'id\']', 'demo2 of using the internal array, for referencing tree-nodes, see the code');
/*
    $id = $tree->getIdByPath('myElement/anotherSubElement');
    $tree->move( $id , 0 );
    $tree->setup(); // rebuild the structure again, since we had changed it
    dumpAllNicely( 'dump all, after "myElement/anotherSubElement" was moved under the root' );

    $moveId = $tree->getIdByPath('myElement');
    $id = $tree->getIdByPath('anotherSubElement');
    $tree->move( $moveId , $id );
    $tree->setup(); // rebuild the structure again, since we had changed it
    dumpAllNicely( 'dump all, after "myElement" was moved under the "anotherSubElement"' );
*/
$tree->setRemoveRecursively(true);
$tree->remove($rootId);
print '<font color="red">ALL ELEMENTS HAVE BEEN REMOVED (uncomment this part to keep them in the DB after running this test script)</font>';
コード例 #2
0
ファイル: Memory_XML.php プロジェクト: vojtajina/sitellite
$id = $tree->getIdByPath('simpletemplate');
dumpHelper(array($tree->getChild($id)), 'dump the child of "simpletemplate"');
// you can also use:    $tree->data[$id]['child']
$id = $tree->getIdByPath('simpletemplate/prefilter');
dumpHelper($tree->getChildren($id), 'dump the children of "simpletemplate/prefilter"');
// you can also use:    $tree->data[$id]['children']
$id = $tree->getIdByPath('simpletemplate/options');
dumpHelper(array($tree->getNext($id)), 'dump the "next" of "simpletemplate/options"');
// you can also use:    $tree->data[$id]['next']
$id = $tree->getIdByPath('simpletemplate/prefilter');
dumpHelper(array($tree->getPrevious($id)), 'dump the "previous" of "simpletemplate/prefilter"');
// you can also use:    $tree->data[$id]['previous']
$id = $tree->getIdByPath('simpletemplate/preFilter');
$element = $tree->data[$id]['child']['next']['next'];
// refer to the third child of 'SimpleTemplate/preFilter/register'
dumpHelper($element['id'], 'demo of using the internal array, for referencing tree-nodes');
/*
NOT IMPLEMENTED YET

    $id = $tree->getIdByPath('myElement/anotherSubElement');
    $tree->move( $id , 0 );
    $tree->setup(); // rebuild the structure again, since we had changed it
    dumpAllNicely( 'dump all, after "myElement/anotherSubElement" was moved under the root' );

    $moveId = $tree->getIdByPath('myElement');
    $id = $tree->getIdByPath('anotherSubElement');
    $tree->move( $moveId , $id );
    $tree->setup(); // rebuild the structure again, since we had changed it
    dumpAllNicely( 'dump all, after "myElement" was moved under the "anotherSubElement"' );