Esempio n. 1
0
 public function export()
 {
     $condition['project_id'] = Request::input('project_id');
     //todo
     $projectName = 'catphp';
     $fields = array('name', '_id', 'content');
     $rs = $this->mongo->find('document', $condition, array('sort' => array('sort' => 1)), $fields);
     $mk = new Parsedown();
     $docs = array();
     foreach ($rs as $row) {
         $doc = array();
         $doc['name'] = $row['name'];
         $doc['content'] = $mk->parse($row['content']);
         $docs[] = $doc;
     }
     $this->assign("docs", $docs);
     $content = $this->render('views/document.html', false);
     // $this->staticize('runtime/index.html');
     $download_config = CatConfig::getInstance(APP_PATH . '/config/download.conf.php');
     $download_zip_name = APP_PATH . '/runtime/' . $projectName . date('YmdHis') . '.zip';
     $zip = new Zip($download_zip_name, ZipArchive::OVERWRITE);
     $zip->addContent($content, 'index.html');
     foreach ($download_config->get('default') as $file) {
         $zip->addFile(APP_PATH . '/runtime/' . $file, $file);
     }
     $zip->close();
     $this->download($download_zip_name, $projectName . '.zip');
     // $this->zip($this->render('views/document.html'));
     // var_dump($download_config->get('default'));
 }