Re: Tree functions



On 25 Mar, 21:37, "jodleren" <sonn...@xxxxxx> wrote:
Hello!

I need a tree (of folders), can anyone give me some ideas/input, how
do I control collapse, explode etc?

Showing the entire tree will be too much, so I need to show a part of
it only....

BR
Sonnich

You could use jquery's tree view:
http://be.twixt.us/jquery/treeView.php

with an XHR call.

An example would be a tree of mp3s to be browsed.

You could return using XHR the exact folders paths as xhtml snippets,
(or pure json if a purist)
<ul>
<li><a class="dir" href="/path/to/folder">/path/to/folder</a></li>
<li><a class="file" href="/path/to/folder/track01.mp3">/path/to/
folder/track01.mp3</a></li>
</ul>

you would insert this into the DOM at the node clicked on, and bind an
onclick even to the link.
I guess you could use jQuery of prototype/scriptaculous, perhaps
behaviour to bind based on className

when clicked it would XHR to list.php which returns the next snippet,
or sends the URL to an embedded player.

You would get the actual tree like so, sorry for any typos:

function returnData($strDir,$strReturnType)
{
$arrResults = array();
$entry = '';
$d = '';
$boolDirs = false;
$boolFiles = false;
if($strReturnType =='files')
{
$boolFiles = true;
}
else
{
$boolDirs = true;
}
$d = dir($strDir);
while ( false !== ($entry = $d->read()) )
{
if( $boolDirs )
{
if( is_dir($strDir.$entry) && ($entry!='.') && ($entry!='..') )
{
$arrResults[] = $entry;
}
}
else
{
if( !is_dir($strDir.$entry)
&& (strpos($entry,'tmp') === false)
&& ($entry!='404.mp3'))
{
$arrResults[] = $entry;
}
}
}
$d->close();
return $arrResults;
}

calling it like this:

$arrResults = returnData($strDir,$strReturnType);
$arrResultsFiles = returnData($strDir,"files");

it's inefficient I guess, but would get you what you need


For a more apache based way, you could use javascript to hijack the
link returning false, but using XHR to request the page which
using rewrites would change the requested path from
/music/path/to/folder to
/list.php?path=/music/path/to/folder

I guess the key is hijacking the links, so your javascript is
unobtrusive, and using javascript/rewrites to request the appropriate
data, which you then insert as first child of the parent node (you
clicked on)
Fisheye has uses something similar to browse the code
http://fisheye5.cenqua.com
bottom left

.



Relevant Pages

  • [GIT PATCH] block,scsi,ide: unify sector and data_len
    ... please pull from the following git tree. ... nr_sectors could be zero while data_len contains the request length. ... This patchset contains the following ten patches. ...
    (Linux-Kernel)
  • Re: GENES REUNITED
    ... enquirers, particularly beginners who haven't got past their ... Just "Can I see your tree?". ... The request I got from both individuals was a single line "Please give ... tree with no explanation was not quite the way to go about getting ...
    (soc.genealogy.britain)
  • Re: Servlet design question
    ... objects involved in request processing. ... I'm building a tree from ... just chuck it a reference to my wrapper. ... > servlet, unless you want to use a field just temporarily so that other ...
    (comp.lang.java.programmer)
  • Re: Exchange 2007 public folder error
    ... CN=Your Exchange Org ... highlight CN=Public Folders and select properties. ... By default you can only have 1 MAPI PF Tree. ...
    (microsoft.public.exchange.admin)
  • Parsing Path Data into Tree Structure
    ... for a way of creating a tree structure to display folders and titles ... of images contained in those folders. ... very plain text string describing a path and parse that into a tree to ... I won't bore you with since its jscript and not perl) ...
    (comp.lang.perl.misc)