westdc-zf1/application/default/controllers/FilelistController.php

66 lines
2.6 KiB
PHP
Raw Normal View History

2010-03-10 06:41:50 +00:00
<?php
class FilelistController extends Zend_Controller_Action {
2011-10-20 15:04:09 +00:00
function preDispatch()
{
$this->db=Zend_Registry::get('db');
}
2010-03-10 06:41:50 +00:00
function indexAction() {
$uuid=$this->_request->getParam('uuid');
2011-10-20 15:04:09 +00:00
$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();
2010-07-02 03:43:58 +00:00
$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++;
}
2010-06-22 04:07:24 +00:00
}
2010-07-02 03:43:58 +00:00
}
*/
2010-03-10 06:41:50 +00:00
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender();
echo Zend_Json::encode($files);
2010-03-10 06:41:50 +00:00
}
2010-07-02 03:43:58 +00:00
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));
/*
2010-07-02 03:43:58 +00:00
$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++;
}
}
}
} */
2010-07-02 03:43:58 +00:00
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender();
echo Zend_Json::encode($files);
2010-07-02 03:43:58 +00:00
}
}