From 58f59344753a41bed97f933eabc928814f0a5749 Mon Sep 17 00:00:00 2001 From: wlx Date: Wed, 2 Jun 2010 04:08:21 +0000 Subject: [PATCH] divide the file with directory --- .../controllers/FilelistController.php | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/application/default/controllers/FilelistController.php b/application/default/controllers/FilelistController.php index cf69e017..6e2113da 100644 --- a/application/default/controllers/FilelistController.php +++ b/application/default/controllers/FilelistController.php @@ -4,10 +4,27 @@ class FilelistController extends Zend_Controller_Action { $uuid=$this->_request->getParam('uuid'); $filelist=new FilelistTable(); $adapter=$filelist->getAdapter(); - $db=$adapter->query("select file_name,file_path from westdc_fileinfo where meta_uuid='$uuid'"); + $db=$adapter->query("select file_name,file_path,id,meta_uuid from westdc_fileinfo where meta_uuid='$uuid' order by id"); $files=$db->fetchAll(); + $documents=array(); + $i=0; + foreach($files as $file){ + $fileName = $file['file_name']; + $filePath = $file['file_path']; + $id = $file['id']; + $pathArray = explode("/",$fileName); + if(substr($fileName,-1)=='/'&&empty($pathArray[2])){ + $documents[$i] = $file; + $i++; + }else{ + if(empty($pathArray[2])){ + $documents[$i]=$file; + $i++; + } + } + } $this->_helper->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(); - echo Zend_Json::encode($files); + echo Zend_Json::encode($documents); } }