Media Library in Sidebar as Recursive Tree view (solved)
Posted: Sun Oct 10, 2010 12:02 am
RE: Media Library in Sidebar as Recursive Tree view (solved)
I saved this code in the root of serendipity as test.php, which does what I need
How can I put this into a plugin?
Which hook do i need to use, to enable me to move it about the sidebar via the admin area and to display it bottom right side of the blog...?
Regards,
Lee
I saved this code in the root of serendipity as test.php, which does what I need
Code: Select all
<style "text/css">
a:link,
a:active,
a:visited {
color: #235587;
text-decoration: none;
}
a:hover {
color: #5f90ba;
text-decoration: underline;
}
blockquote {
border-left: 4px solid #2a5a8a;
padding-left: 10px;
}
body {
text-align: left;
font-family: "trebuchet ms", "bitstream vera sans", arial, sans-serif;
font-size: 12;
color: #333;
}
</style>
<?php
$path = "uploads"; //define the path as relative
$webpath ="uploads"; //not needed
$dir_handle = @opendir($path) or die("Unable to open $path"); //using the opendir function
function num_files($dir, $recursive=false, $counter=0) {
static $counter;
if(is_dir($dir)) {
if($dh = opendir($dir)) {
while(($file = readdir($dh)) !== false) {
if($file != "." && $file != ".." && !strpos($file, '..',1) && !strpos($file, 'serendipityThumb',1) && $file !='Thumb.db' ) {
$counter = (is_dir($dir."/".$file)) ? num_files($dir."/".$file, $recursive, $counter) : $counter+1;
}
}
closedir($dh);
}
}
return $counter;
}
// Usage:
$nfiles = num_files($path, false, 0); // count all files that resides under $path, including subdirs
echo "<strong>$path/</strong> ($nfiles)<br/><br/>";
list_dir($dir_handle,$path);
function list_dir($dir_handle,$path)
{
// print_r ($dir_handle);
//running the while loop
while (false !== ($file = readdir($dir_handle))) {
$dir =$path.'/'.$file;
if(is_dir($dir) && $file != '.' && $file !='..' )
{
echo "<br><strong>uploads/$file/</strong><br>";
$handle = @opendir($dir) or die("unable to open file $file");
list_dir($handle, $dir);
}
elseif($file != '.' && $file !='..' && !strpos($file, '..',1) && !strpos($file, 'serendipityThumb',1) && $file !='Thumb.db' && $file !='*')
{
echo " <a href='$dir' target='_blank' >$file</a> \n<br>";
}
}
closedir($dir_handle); //closing the directory
}
?>
Which hook do i need to use, to enable me to move it about the sidebar via the admin area and to display it bottom right side of the blog...?
Regards,
Lee