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 ));
2010-07-06 16:46:04 +00:00
/* $documents = array ();
2010-07-02 03:43:58 +00:00
$i = 0 ;
foreach ( $files as $file ) {
$fileName = $file [ 'file_name' ];
2010-07-06 16:46:04 +00:00
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-07-06 16:46:04 +00:00
*/
2010-03-10 06:41:50 +00:00
$this -> _helper -> layout () -> disableLayout ();
$this -> _helper -> viewRenderer -> setNoRender ();
2010-07-06 16:46:04 +00:00
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' );
2011-10-21 02:37:08 +00:00
$subpath = ( int ) $this -> _request -> getParam ( 'subpath' );
2010-07-06 16:46:04 +00:00
//$subPath=urldecode($getUrl);
//$depth=substr_count($subPath,'/');
2011-10-21 02:37:08 +00:00
$depth = ( int ) $this -> _request -> getParam ( 'depth' );
2010-07-06 16:46:04 +00:00
$depth ++ ;
2011-10-21 02:37:08 +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= " . $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-06 16:46:04 +00:00
/*
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-06 16:46:04 +00:00
} */
2010-07-02 03:43:58 +00:00
$this -> _helper -> layout () -> disableLayout ();
$this -> _helper -> viewRenderer -> setNoRender ();
2010-07-06 16:46:04 +00:00
echo Zend_Json :: encode ( $files );
2010-07-02 03:43:58 +00:00
}
2010-07-06 16:46:04 +00:00
}