Zend Framework1.6が出たのでCHMを作ってみる。

まずは、ドキュメントをダウンロード

http://framework.zend.com/download/current/

Documentationの下にあるDownloadをクリック

日本語のzipをクリック

CHMコンパイルする前に一手間加える。

ダウンロードした圧縮ファイルの中身には、
CHMコンパイルする為の設定ファイルが存在します。
設定ファイル

  1. htmlhelp.hhp
  2. toc.hhc

ただこのままコンパイルすると出来上がるCHMファイルは文字化けしています。
なので、以下のスクリプトで文字化け対策を施した設定ファイルを生成することにします。

make_htmlhelp_ja.hhp.php

<?php
if (!is_file('htmlhelp.hhp')) {
    echo 'Not Found htmlhelp.hhp'."\r\n";
    echo 'Please press Ctrl + C'."\r\n";
    file_get_contents('php://stdin');
    exit;
}
if (!is_file('toc.hhc')) {
    echo 'Not Found toc.hhc'."\r\n";
    echo 'Please press Ctrl + C'."\r\n";
    file_get_contents('php://stdin');
    exit;
}
$buff = to_sjis('htmlhelp.hhp', 'UTF-8');
$buff = str_replace('toc.hhc', 'toc_ja.hhc', $buff);
file_put_contents('htmlhelp_ja.hhp', $buff);


$buff = to_sjis('toc.hhc', 'UTF-8');
file_put_contents('toc_ja.hhc', $buff);

function to_sjis($file, $encoding)
{
    $keys['iso-8859-1'] = 'SJIS';
    $buff = strtr(file_get_contents($file), $keys);
    $utf8_buff = html_entity_decode($buff, ENT_NOQUOTES, $encoding);
    $sjis_buff = mb_convert_encoding($utf8_buff, 'SJIS', $encoding);
    //
    return $sjis_buff;
}

このスクリプトhtmlhelp.hhpと同じディレクトリに保存して
実行すると・・・

  1. htmlhelp_ja.hhp
  2. toc_ja.hhc

というファイルを生成します。