cvs: pear /Tree/examples/TreeEditor_MemoryNested index.php index.tpl

From: Date: Fri, 23 Aug 2002 22:26:03 +0000
Subject: cvs: pear /Tree/examples/TreeEditor_MemoryNested index.php index.tpl
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-5916@lists.php.net to get a copy of this message
cain Fri Aug 23 18:26:03 2002 EDT Modified files: /pear/Tree/examples/TreeEditor_MemoryNested index.php index.tpl Log: - let user switch between DB and Filesystem mode Index: pear/Tree/examples/TreeEditor_MemoryNested/index.php diff -u pear/Tree/examples/TreeEditor_MemoryNested/index.php:1.1 pear/Tree/examples/TreeEditor_MemoryNested/index.php:1.2 --- pear/Tree/examples/TreeEditor_MemoryNested/index.php:1.1 Fri Aug 23 13:18:28 2002 +++ pear/Tree/examples/TreeEditor_MemoryNested/index.php Fri Aug 23 18:26:03 2002 @@ -1,7 +1,7 @@ <?php // - // $Id: index.php,v 1.1 2002/08/23 17:18:28 cain Exp $ + // $Id: index.php,v 1.2 2002/08/23 22:26:03 cain Exp $ // ################################################## @@ -28,35 +28,54 @@ $modifiers = new SimpleTemplate_Filter_Modifier($tpl->options); $tpl->registerPrefilter(array(&$modifiers,'imgSrc'),array(dirname(__FILE__),'http://'.$HTTP_HOST.dirname($PHP_SELF))); - ################################################## - # - # actual tree stuff, using Dynamic_DBnested - # - define('TABLE_TREE','TreeEditor_MemoryNested'); - define('DB_DSN','mysql://root@localhost/test'); - - require_once('treeClass.php'); - $options = array( 'table' => TABLE_TREE , 'order' => 'name'); - $tree = new treeClass( 'DBnested' , DB_DSN , $options ); - -# to let it work on the filesystem :-) -# $options = array( 'order' => 'name'); -# $tree = new treeClass( 'Filesystem' , '/home/wk/tmp' , $options ); - - $tree->setup(); - $tree->setRemoveRecursively(); + // session stuff to save the opened folders etc. session_start(); if(!session_is_registered('session')) { $session = new stdClass; // standard PHP-class constructor session_register('session'); $session->data = array(); + $session->use = 'Filesystem'; } else // since the class is read from the session it is not automatically made global { $session = &$_SESSION['session']; } + + // set the source to use + if( $_REQUEST['use_DB'] ) + $session->use = 'DB'; + if( $_REQUEST['use_Filesystem'] ) + $session->use = 'Filesystem'; + + ################################################## + # + # actual tree stuff, using Dynamic_DBnested + # + define('TABLE_TREE','TreeEditor_MemoryNested'); + define('DB_DSN','mysql://root@localhost/test'); + + require_once('treeClass.php'); + if( $session->use == 'DB' ) + { + $options = array( 'table' => TABLE_TREE , 'order' => 'name'); + $tree = new treeClass( 'DBnested' , DB_DSN , $options ); + } + else + { + # to let it work on the filesystem :-) + $options = array( 'order' => 'name'); + $tree = new treeClass( 'Filesystem' , '/home/cain/tmp' , $options ); + } + + if( PEAR::isError($res=$tree->setup()) ) + { + $methodFailed = true; + $results[] = $res; + } + + $tree->setRemoveRecursively(); // detect action Index: pear/Tree/examples/TreeEditor_MemoryNested/index.tpl diff -u pear/Tree/examples/TreeEditor_MemoryNested/index.tpl:1.1 pear/Tree/examples/TreeEditor_MemoryNested/index.tpl:1.2 --- pear/Tree/examples/TreeEditor_MemoryNested/index.tpl:1.1 Fri Aug 23 13:18:28 2002 +++ pear/Tree/examples/TreeEditor_MemoryNested/index.tpl Fri Aug 23 18:26:03 2002 @@ -32,6 +32,7 @@ </style> <form method="post" action="{$_SERVER['PHP_SELF']}"> + {if($session->action == 'cut')} <img src="cut"> &nbsp; <img src="copy"> &nbsp; @@ -46,6 +47,25 @@ <img src="delete"> &nbsp; {else} <input id="delete" src="delete" name="action_delete" type="image" class="button" onmousedown="document.getElementById('delete').style.border='1px inset black'" title="delete"> + + &nbsp; + <img src="" width="1" height="22" class="button"> &nbsp; + + &nbsp; + work on: &nbsp; + <input type="submit" value="DB" name="use_DB"> + &nbsp; + <input type="submit" value="Filesystem" name="use_Filesystem"> + + <br><br> + + current tree instanciation used: + <code> + {if( $session->use == 'DB' )} + $tree = new treeClass( 'DBnested' , 'mysql://root@localhost/test' , array('table'=&gt;TABLE_TREE , 'order' =&gt; 'name') ); + {else} + $tree = new treeClass( 'Filesystem' , '/home/cain/tmp' ,array('order' =&gt; 'name') ); + </code> <hr>

« previous php.pear.cvs (#5916) next »