1<?php 2/** 3 * @license GPL 3 (http://www.gnu.org/licenses/gpl.html) 4 * @author Martin Schulte <lebowski[at]corvus[dot]uberspace[dot]de>, 2013 5 */ 6 7// Prepare 8global $conf; 9 10if(!defined('DOKU_INC')) define('DOKU_INC', dirname(__FILE__).'/../../../../'); 11define('DOKU_DISABLE_GZIP_OUTPUT', 1); 12// $conf and classpathes 13require_once(DOKU_INC.'inc/init.php'); 14 15 16// db access 17 18$helper = new helper_plugin_owncloud(); 19if(isset($_POST['fileid']) && $_POST['fileid'] > 0){ 20 $dir = $helper->getFilenameForID($_POST['fileid']); 21}else{ 22 $dir = urldecode($_POST['dir']); 23 $dir = $helper->wikiIDToPath($dir); 24} 25$dir = trim($dir,'/'); 26 27$fullpath = $conf['mediadir'].'/'.$dir; 28$metapath = $conf['mediametadir'].'/'.$dir; 29 30$level = 'level0'; 31if(isset($_POST['level'])){ 32 $levelInt = (intval(str_replace('level','',$_POST['level']))); 33 if($levelInt != 0){ 34 $level = ""; 35 for($i = 0; $i <= $levelInt; $i++) $level .= "level$i "; 36 $padding = 'style="padding-left:'.($levelInt*($helper->getConf('marginFilelist'))).'px;"'; 37 } 38} 39 40if(file_exists($fullpath)){ 41 $dircontent = scandir($fullpath); 42 natcasesort($dircontent); // sort by name 43 $files = array(); 44 $folders = array(); 45 foreach($dircontent as $file ){ 46 if($file == '.' || $file == '..') continue; 47 if(is_dir($fullpath.'/'.$file)){ 48 array_push($folders, $file); 49 }else{ 50 array_push($files, $file); 51 } 52 } 53 54 if(empty($folders) && empty($files)) echo '<tr class="collapsed row '.$level.'"><td colspan="5" '.$padding.' ><div style="color:grey">'.($helper->getLang('emptyFolder')).'</div></td></tr>'; 55 $nr = 1; 56 foreach($folders as $folder){ 57 $link = $helper->internalmedia(0,$helper->pathToWikiID($dir.'/'.$folder)); 58 $mtime = strftime($conf['dformat'],filemtime($fullpath.'/'.$folder)); 59 $title = $helper->_media($helper->getLastfileid(), $helper->pathToWikiID($dir.'/'.$folder), NULL, NULL, NULL, NULL, NULL, false); 60 $url = $helper->ml($helper->pathToWikiID($dir.'/'.$file), array('fileid'=>($helper->getLastfileid())),false); 61 $download = $helper->_formatLink(array('title'=>$title,'url'=>$url, 'class'=>"media mediafile detail")); 62 echo '<tr class="collapsed row'.$nr.' '.$level.'">'; 63 echo '<td class="col0" '.$padding.'> '.$link.' </td><td class="col1"> </td><td class="col2 fileinfo">'.$mtime.'</td><td class="col3 fileinfo"> -- </td><td class="col4 centeralign">'.$download.'</td>'; 64 echo '</tr>'; 65 $nr++; 66 } 67 foreach($files as $file){ 68 $filesize = filesize_h(filesize($fullpath.'/'.$file)); 69 $mtime = strftime($conf['dformat'],filemtime($fullpath.'/'.$file)); 70 71 $detail = $helper->internalmedia(0,$helper->pathToWikiID($dir.'/'.$file),NULL,NULL,16,NULL,NULL,'linkonly'); 72 $title = $helper->_media($helper->getLastfileid(), $helper->pathToWikiID($dir.'/'.$file), NULL, NULL, NULL, NULL, NULL, false); 73 $url = $helper->ml($helper->pathToWikiID($dir.'/'.$file), array('fileid'=>($helper->getLastfileid())),true); 74 $download = $helper->_formatLink(array('title'=>'download: '.$title,'url'=>$url, 'class'=>"media mediafile download")); 75 /*if(file_exists($metapath.'/'.$file.'.changes')){ 76 $meta = file($metapath.'/'.$file.'.changes'); 77 $authors = array(); 78 foreach($meta as $onemeta){ 79 $line = explode("\t", $onemeta); 80 if($line[4] != "" && !in_array($line[4],$authors)) array_push($authors,$line[4]); 81 } 82 $authorsString = implode(", ", $authors); 83 }*/ 84 list($authorsString,$desc,$count) =$helper->getAuthorsAndDescOfMediafile($dir.'/'.$file); 85 86 echo '<tr title="'.$desc.'" class="row'.$nr.' '.$level.'">'; 87 echo '<td class="col0" '.$padding.'> '.$detail.' </td><td class="col1 fileinfo">'.$authorsString.'</td><td class="col2 fileinfo">'.$mtime.'</td><td class="col3 fileinfo">'.$filesize.'</td><td class="col4 centeralign">'.$download.'</td>'; 88 echo '</tr>'; 89 $nr++; 90 } 91 //echo '</table></div>'; 92 /*if(file_exists($conf['mediametadir']."/"."vwiki/graph.png.changes")) $a = file($conf['mediametadir']."/"."vwiki/graph.png.changes"); 93 foreach($a as $aa){ 94 $array = explode("\t", $aa); 95 96 echo $array[4]."<br>"; 97 }*/ 98} 99 100 101 102 103?> 104 105 106 107 108