65 lines
2.7 KiB
PHP
65 lines
2.7 KiB
PHP
<?php
|
|
class FilelistController extends Zend_Controller_Action {
|
|
function indexAction() {
|
|
$uuid=$this->_request->getParam('uuid');
|
|
$filelist=new FilelistTable();
|
|
$adapter=$filelist->getAdapter();
|
|
$db=$adapter->query("select f.filename,f.id,s.uuid,f.depth from datafile f,dataset s where s.id=f.dsid and s.uuid='$uuid' and f.depth=1 and f.filename<>'/uuid.txt' order by f.isdir desc,f.filename");
|
|
$files=$db->fetchAll();
|
|
/* $documents=array();
|
|
$i=0;
|
|
foreach($files as $file) {
|
|
$fileName=$file['file_name'];
|
|
if($fileName!=='/uuid.txt') {
|
|
$pathArray=explode("/",$fileName);
|
|
if(empty($pathArray[2])) {
|
|
$documents[$i] = $file;
|
|
$i++;
|
|
}
|
|
}
|
|
}
|
|
*/
|
|
$this->_helper->layout()->disableLayout();
|
|
$this->_helper->viewRenderer->setNoRender();
|
|
echo Zend_Json::encode($files);
|
|
}
|
|
function subAction() {
|
|
$uuid=$this->_request->getParam('uuid');
|
|
$subpath=$this->_request->getParam('subpath');
|
|
//$subPath=urldecode($getUrl);
|
|
//$depth=substr_count($subPath,'/');
|
|
$depth=$this->_request->getParam('depth');
|
|
$depth++;
|
|
$filelist=new FilelistTable();
|
|
$adapter=$filelist->getAdapter();
|
|
$db=$adapter->query("select f.filename,f.id,s.uuid,f.depth from datafile f,dataset s where s.id=f.dsid and s.uuid='".$uuid."' and f.depth=".$depth." and f.filename<>'/uuid.txt' and f.filename ilike (select filename from datafile where id=".$subpath.")||'%' order by f.isdir desc,f.filename");
|
|
$files=$db->fetchAll();
|
|
/*
|
|
$documents=array();
|
|
$i=0;
|
|
foreach($files as $subFile) {
|
|
if(substr($subFile['file_name'], 0,strlen($subPath))==$subPath) {// start with "/a/"
|
|
$subFilePath=str_replace($subPath, '', $subFile['file_name']);
|
|
if(!empty($subFilePath)) {
|
|
$pos = strpos($subFilePath, '/');
|
|
$pathArray=explode("/",$subFilePath);
|
|
|
|
if(empty($pathArray[1])) {
|
|
$documents[$i] = $subFile;
|
|
if ($pos === false) {
|
|
$documents[$i]['file_name']=$subPath.$pathArray[0];
|
|
} else {
|
|
$documents[$i]['file_name']=$subPath.$pathArray[0].'/';
|
|
}
|
|
$i++;
|
|
}
|
|
|
|
}
|
|
}
|
|
} */
|
|
$this->_helper->layout()->disableLayout();
|
|
$this->_helper->viewRenderer->setNoRender();
|
|
echo Zend_Json::encode($files);
|
|
}
|
|
|
|
} |