Пример #1
0
 /**
  * 首页
  */
 public function actionIndex()
 {
     $templateDir = Yii::app()->basePath . '/views';
     $fileList = XUtils::getDir($templateDir);
     foreach ((array) $fileList as $key => $file) {
         $files[] = array('fileName' => $file, 'subFileList' => XUtils::getFile($templateDir . '/' . $file));
     }
     $data['fileList'] = $files;
     $this->render('index', $data);
 }
Пример #2
0
 /**
  * 批量操作
  *
  */
 public function actionBatch()
 {
     $command = trim($this->_gets->getParam('command'));
     switch ($command) {
         case 'deleteFile':
             parent::_acl('template_delete');
             $fileName = trim($this->_gets->getParam('fileName'));
             empty($fileName) && XUtils::message('error', '未选择记录');
             $filePath = $this->_themePath . DS . 'views' . DS . XUtils::b64decode($fileName);
             @unlink($filePath);
             AdminLogger::_create(array('catalog' => 'delete', 'intro' => '删除模板:' . XUtils::b64decode($fileName)));
             $this->redirect(array('index'));
             break;
         case 'deleteFolder':
             parent::_acl('template_folder_delete');
             $folderName = trim($this->_gets->getParam('folderName'));
             empty($folderName) && XUtils::message('error', '未选择记录');
             $folderPath = $this->_themePath . DS . 'views' . DS . $folderName;
             if (is_dir($folderPath)) {
                 $fileList = XUtils::getFile($folderPath);
                 foreach ((array) $fileList as $row) {
                     @unlink($folderPath . DS . $row);
                 }
             }
             if (rmdir($folderPath)) {
                 AdminLogger::_create(array('catalog' => 'delete', 'intro' => '删除文件夹:' . $folderName));
                 XUtils::message('success', '目录 ' . $folderName . ' 删除完成', $this->createUrl('index'));
             } else {
                 XUtils::message('errorBack', '目录删除失败,请删除此目录下所有文件再删除此目录');
             }
             break;
         default:
             throw new CHttpException(404, '错误的操作类型:' . $command);
             break;
     }
 }