diff --git a/application/default/controllers/ServiceController.php b/application/default/controllers/ServiceController.php index c4c06818..664830a3 100644 --- a/application/default/controllers/ServiceController.php +++ b/application/default/controllers/ServiceController.php @@ -632,51 +632,51 @@ class ServiceController extends Zend_Controller_Action echo Zend_Json::encode($msg); exit(); } - } - - function filelistAction() - { - $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)); - $this->_helper->layout()->disableLayout(); - $this->_helper->viewRenderer->setNoRender(); - echo Zend_Json::encode($files); - } - - function subfilelistAction() - { - $uuid=$this->_request->getParam('uuid'); - $subpath=(int)$this->_request->getParam('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)); - $this->_helper->layout()->disableLayout(); - $this->_helper->viewRenderer->setNoRender(); - echo Zend_Json::encode($files); - } - + } + + function filelistAction() + { + $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)); + $this->_helper->layout()->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + echo Zend_Json::encode($files); + } + + function subfilelistAction() + { + $uuid=$this->_request->getParam('uuid'); + $subpath=(int)$this->_request->getParam('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)); + $this->_helper->layout()->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + echo Zend_Json::encode($files); + } + /* * 附件下载 */ - function attachAction() + function attachAction() { - $zipuuid = $this->_request->getParam('zip'); + $zipuuid = $this->_request->getParam('zip'); $id=(int)$this->_request->getParam('id'); $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); if(!empty($zipuuid)) { $sql=$this->db->quoteInto("select a.*,md.title from mdattach m left join metadata md on m.uuid=md.uuid left join attachments a on m.id=a.id where m.uuid=? order by a.ts_created desc",$zipuuid); - $atts = $this->db->fetchAll($sql); + $atts = $this->db->fetchAll($sql); $title=$atts[0]['title']; - $zip = new ZipArchive(); - $url = tempnam($this->config->temp->path,$zipuuid);//创建临时文件 - $last_update=strtotime($atts[0]['ts_created']); - if (!file_exists($url) || (filemtime($fn)<$last_update)) + $zip = new ZipArchive(); + $url = tempnam($this->config->temp->path,$zipuuid);//创建临时文件 + $last_update=strtotime($atts[0]['ts_created']); + if (!file_exists($url) || (filemtime($fn)<$last_update)) { - if( $zip->open($url, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE) !== true ) + if( $zip->open($url, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE) !== true ) { throw new Exception("cannot open {$url} for writing."); } @@ -710,12 +710,12 @@ class ServiceController extends Zend_Controller_Action ->setHeader('Cache-Control','must-revalidate, post-check=0, pre-check=0') ->setHeader('Pragma','public') ->setBody($content); - } - elseif ($id>0) - { - //下载单个附件 + } + elseif ($id>0) + { + //下载单个附件 $sql=$this->db->quoteInto("select a.*,md.title from mdattach m left join metadata md on m.uuid=md.uuid left join attachments a on m.id=a.id where m.id=? order by a.ts_created desc",$id); - $atts = $this->db->fetchRow($sql); + $atts = $this->db->fetchRow($sql); $title=$atts['title']; $updates = array(); //统计被下载的附件ID //更新统计 @@ -735,7 +735,7 @@ class ServiceController extends Zend_Controller_Action ->setHeader('Expires',0) ->setHeader('Cache-Control','must-revalidate, post-check=0, pre-check=0') ->setHeader('Pragma','public') - ->setBody($content); + ->setBody($content); } else {