2024年2月9日发(作者:)

if($a == $b) return 0;return ($a>$b)? 1:-1;}class chmBuilder{// const version = 0.1;public $chm_name;public $chm_path;public $chm_hhp;public $chm_hhc;public $chm_hhk;public $chm_uninclude_dirs;public $chm_uninclude_files;public $chm_image_type;public $chm_first_open;public $chm_title;public function __construct($chm_name='your_chm',$chm_path='',$chm_uninclude_dirs,$chm_uninclude_files){$this->chm_name = $chm_name;$this->chm_path = $chm_path;$this->chm_uninclude_dirs = $chm_uninclude_dirs;$this->chm_uninclude_files = $chm_uninclude_files;$this->chm_image_type = 'Folder';}public function build(){$this->buildHhp();$this->buildHhc();$this->buildHhk();}public function buildHhp(){$manual_files = listDir($this->chm_path);$files = implode(PHP_EOL, $manual_files);$this->chm_first_open = iconv('UTF-8', 'GB2312', $this->chm_first_open);$this->chm_title = iconv('UTF-8', 'GB2312', $this->chm_title);$tpl = <<[OPTIONS]

Compatibility=1.1 or laterCompiled file={$this->chm_path}/{$this->chm_name}.chmContents file={$this->chm_hhc}.hhcCOPYRIGHT=lay compile progress=NoDefault topic={$this->chm_first_open}Error log file=chm_l-text search=YesIndex file={$this->chm_hhk}.hhkImageType={$this->chm_image_type}Language=0x804Title={$this->chm_title}[FILES]{$files}eof;file_put_contents("{$this->chm_path}/{$this->chm_hhp}.hhp", $tpl);}public function buildHhc(){$list = array();$file_tree = listDirTree($this->chm_path,"{$this->chm_hhp} {$this->chm_uninclude_dirs}{$this->chm_uninclude_files}");uksort($file_tree, 'cmp');foreach ($file_tree as $key => $value) {if(is_string($value)){$title = explode(DIRECTORY_SEPARATOR, $value);$title = array_pop($title);$title = rtrim($title,'.html');$list[] = < $val) {$title = explode(DIRECTORY_SEPARATOR, $val);$title = array_pop($title);$title = rtrim($title,'.html');

$child[] = <

{$child}eof;}}$list = implode(PHP_EOL, $list);$tpl = <{$list}eof;file_put_contents("{$this->chm_path}/{$this->chm_hhc}.hhc", $tpl);}public function buildHhk(){$list = array();$file_tree = listDir($this->chm_path);foreach ($file_tree as $key => $value) {if(is_string($value)){if(stripos($value, '.html')){$title = explode(DIRECTORY_SEPARATOR, $value);$title = array_pop($title);$title = rtrim($title,'.html');$list[] = <{$list}