Beispiel #1
0
 function execute()
 {
     if (!is_dir($this->_source_dir)) {
         throw new Command_Exception("Invalid source dir: \"{$this->_source_dir}\".");
     }
     echo "processing source documents...";
     $book = new Doc_Book(Helper_YAML::load("{$this->_source_dir}/toc.yaml"), $this->_source_dir);
     echo "ok\n";
     $this->_output_dir = "{$this->_output_dir}/{$book->name}";
     if (!is_dir($this->_output_dir)) {
         Helper_FileSys::mkdirs($this->_output_dir);
     }
     $this->_output_dir = trim(realpath($this->_output_dir), '/\\');
     switch ($this->_docmode) {
         case 'online':
             $this->_buildOnlineDocuments($book);
             break;
         case 'chm':
             $this->_buildCHMDocuments($book);
             break;
         case 'pdf':
             $this->_buildPDFDocuments($book);
             break;
         case 'html':
         default:
             exit('invalid docmode:' . $this->_docmode);
     }
 }
Beispiel #2
0
 function execute()
 {
     if (!is_dir($this->_source_dir)) {
         throw new Command_Exception("Invalid source dir: \"{$this->_source_dir}\".");
     }
     if (!is_dir($this->_output_dir)) {
         Helper_FileSys::mkdirs($this->_output_dir);
     }
     echo "processing source codes...";
     $model = $this->_buildModel();
     echo "ok\n";
     $errors = $model->lastErrors();
     if (!empty($errors)) {
         $this->_displayErrors($errors);
     }
     switch ($this->_docmode) {
         case 'online':
             $this->_buildOnlineDocuments($model);
             break;
         case 'offline':
             $this->_buildOfflineDocuments($model);
             break;
     }
 }
Beispiel #3
0
 /**
  * 建立需要的目录路径
  *
  * @param string $dir
  */
 protected function _createDirs($dir)
 {
     $dir = str_replace('/\\', DS, strtolower($dir));
     if (!file_exists($dir)) {
         Helper_FileSys::mkdirs($dir, 0777);
         $dir = realpath($dir);
         $this->_log('Create directory "%s" successed.', $dir);
     }
 }
Beispiel #4
0
 /**
  * 移动上传文件到指定位置和文件名
  *
  * @param string $dest_path 目的地路径
  *
  * @return Helper_Uploader_File 连贯接口
  */
 function move($dest_path)
 {
     $test = pathinfo($dest_path);
     if (!isset($test['extension'])) {
         $dest_path = $dest_path . '.' . $this->extname();
     }
     if (!is_dir($path = $test['dirname'])) {
         Helper_FileSys::mkdirs($path);
     }
     if ($this->_file['is_moved']) {
         $ret = rename($this->filepath(), $dest_path);
     } else {
         $this->_file['is_moved'] = true;
         if (stripos(PHP_OS, 'WIN') !== false) {
             $src_path = iconv("UTF-8", "gbk//IGNORE", $this->filepath());
             $dest_path = iconv("UTF-8", "gbk//IGNORE", $dest_path);
             $ret = move_uploaded_file($src_path, $dest_path);
         } else {
             $ret = move_uploaded_file($this->filepath(), $dest_path);
         }
         if (!$ret) {
             $ret = rename($this->filepath(), $dest_path);
         }
     }
     if ($ret) {
         //chown($dest_path,'www-data');
         $this->_file['full_path'] = $dest_path;
     }
     return $this;
 }