コード例 #1
0
 protected function handleList()
 {
     $arrFiles = array();
     $fk = $this->getQuery('fileKey');
     if (($stateVar = $this->getQuery('stateVar')) && ($files = Yii::app()->user->getState($stateVar))) {
         if ($fk !== null) {
             $files = array_filter($files, function ($file) use($fk) {
                 return $file['key'] == $fk;
             });
         }
         foreach ($files as $marker => $file) {
             $arrFiles[] = array("name" => $file['name'], "type" => $file['mime'], "size" => $file['size'], "url" => $this->getPublicPathTmp() . DIRECTORY_SEPARATOR . $file['filename'], "thumbnail_url" => $this->controller->createUrl($this->getId(), array('_m' => XUpload::TYPE_METHOD_THUMB, '_mrk' => $marker, '_sv' => $stateVar)), "delete_url" => $this->getController()->createUrl($this->getId(), array("_m" => XUpload::TYPE_METHOD_DELETE, "_mrk" => $marker, '_sv' => $stateVar)), "delete_type" => "POST");
         }
     }
     if (($modelID = $this->getQuery('modelID')) && ($modelName = $this->getQuery('modelName'))) {
         $files = XFiles::getAllFileInfoList($modelID, $modelName, $fk);
         foreach ($files as $file) {
             $arrFiles[] = array("name" => $file['real_name'] . '.' . $file['extension'], "type" => $file['mime'], "size" => $file['size'], "url" => FPM::originalSrc($file['id']), "thumbnail_url" => $this->controller->createUrl($this->getId(), array('_m' => XUpload::TYPE_METHOD_THUMB, '_fid' => $file['id'])), "delete_url" => $this->getController()->createUrl($this->getId(), array("_m" => XUpload::TYPE_METHOD_DELETE, '_fid' => $file['id'])), "delete_type" => "POST");
         }
     }
     echo json_encode($arrFiles);
     return true;
 }