66 lines
2.6 KiB
PHP
66 lines
2.6 KiB
PHP
<?php
|
|
class FilelistController extends Zend_Controller_Action {
|
|
function preDispatch()
|
|
{
|
|
$this->db=Zend_Registry::get('db');
|
|
}
|
|
|
|
function indexAction() {
|
|
$uuid=$this->_request->getParam('uuid');
|
|
$sql="select f.filename,f.id,s.uuid,f.depth from datafile f,dataset s where s.id=f.dsid and s.uuid=? and f.depth=1 and f.filename<>'/uuid.txt' order by f.isdir desc,f.filename";
|
|
$files=$this->db->fetchAll($this->db->quoteInto($sql,$uuid));
|
|
/* $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=(int)$this->_request->getParam('subpath');
|
|
//$subPath=urldecode($getUrl);
|
|
//$depth=substr_count($subPath,'/');
|
|
$depth=(int)$this->_request->getParam('depth');
|
|
$depth++;
|
|
$sql="select f.filename,f.id,s.uuid,f.depth from datafile f,dataset s where s.id=f.dsid and s.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=$this->db->fetchAll($this->db->quoteInto($sql,$uuid));
|
|
/*
|
|
$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);
|
|
}
|
|
|
|
} |