Source for file CHMdefaultConverter.inc
Documentation is available at CHMdefaultConverter.inc
* CHM (Compiled Help Manual) output converter for Smarty Template.
* phpDocumentor :: automatic documentation generator
* Copyright (c) 2003-2006 Andrew Eddie, Greg Beaver
* This library is free software; you can redistribute it
* and/or modify it under the terms of the GNU Lesser General
* Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* @author Joshua Eichorn <jeichorn@phpdoc.org>
* @author Greg Beaver <cellog@php.net>
* @copyright 2000-2006 Joshua Eichorn, Gregory Beaver
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @version CVS: $Id: CHMdefaultConverter.inc,v 1.12 2007/04/19 20:20:57 ashnazg Exp $
* @link http://www.phpdoc.org
* @link http://pear.php.net/PhpDocumentor
* Generates files that MS HTML Help Worshop can use to create a MS Windows
* compiled help file (CHM)
* The free MS HTML Help compiler takes the project file (phpdoc.hhp) and reads
* the table of contents file specified in the project (which is always contents.hhc
* in phpDocumentor). When the converter reaches stable state, it will also
* output an index file index.hhk. The free download for MS HTML Help Workshop
* @link http://www.microsoft.com/downloads/release.asp?releaseid=33071 MS HTML Help Workshop download
* @author Greg Beaver <cellog@php.net>
* @version $Revision: 1.12 $
* CHMdefaultConverter wants elements sorted by type as well as alphabetically
* @see Converter::$sort_page_contents_by_type
* indexes of elements by package that need to be generated
var $leftindex =
array('classes' =>
true, 'pages' =>
true, 'functions' =>
true, 'defines' =>
false, 'globals' =>
false);
* output directory for the current procedural page being processed
* target directory passed on the command-line.
* {@link $targetDir} is malleable, always adding package/ and package/subpackage/ subdirectories onto it.
* output directory for the current class being processed
* array of converted package page names.
* Used to link to the package page in the left index
* @var array Format: array(package => 1)
* controls formatting of parser informative output
* "Converting /path/to/file.php... Procedural Page Elements... Classes..."
* Since CHMdefaultConverter outputs files while converting, it needs to send a \n to start a new line. However, if there
* is more than one class, output is messy, with multiple \n's just between class file output. This variable prevents that
* contains all of the template procedural page element loop data needed for the current template
* contains all of the template class element loop data needed for the current template
* Table of Contents entry for index.hhk
* sets {@link $base_dir} to $targetDir
function CHMdefaultConverter(&$allp, &$packp, &$classes, &$procpages, $po, $pp, $qm, $targetDir, $templateDir, $title)
Converter::Converter($allp, $packp, $classes, $procpages,$po, $pp, $qm, $targetDir, $templateDir, $title);
* @deprecated in favor of PHP 4.3.0+ tokenizer-based source highlighting
$sourcecode =
str_replace('<code>','<pre>',$sourcecode);
$sourcecode =
str_replace('</code>','</pre>',$sourcecode);
* @param string full path to the source file
* @param string fully highlighted source code
$pathinfo =
$this->proceduralpages->getPathInfo($path, $this);
$templ->assign('source',$value);
$templ->assign('package',$pathinfo['package']);
$templ->assign('subpackage',$pathinfo['subpackage']);
$templ->assign('name',$pathinfo['name']);
$templ->assign('source_loc',$pathinfo['source_loc']);
$templ->assign('docs',$pathinfo['docs']);
$templ->assign("subdir",'../');
$templ->register_outputfilter('CHMdefault_outputfilter');
$templ->assign('source',$source);
$templ->assign('title',$title);
$templ->assign('file',$path);
$templ->assign("subdir",'../');
$templ->register_outputfilter('CHMdefault_outputfilter');
$pathinfo =
$this->proceduralpages->getPathInfo($path, $this);
$this->addSourceTOC($title,'exsource_'.
$path,$pathinfo['package'],$pathinfo['subpackage'], false);
$this->writefile('exsource_'.
$path.
'.html',$templ->fetch('examplesource.tpl'));
* Retrieve a Converter-specific anchor to a segment of a source code file
* parsed via a {@tutorial tags.filesource.pkg} tag.
* @param string full path to source file
* @param string name of anchor
* @param string link text, if this is a link
* @param boolean returns either a link or a destination based on this
* @return string link to an anchor, or the anchor
return '<a name="a'.
$anchor.
'"></a>';
* Return a line of highlighted source code with formatted line number
* If the $path is a full path, then an anchor to the line number will be
* @param integer line number
* @param string highlighted source code line
* @param false|stringfull path to @filesource file this line is a part of,
* if this is a single line from a complete file.
* @return string formatted source code line with line number
function sourceLine($linenumber, $line, $path =
false)
return '<li><div class="src-line">' .
$this->getSourceAnchor($path, $linenumber) .
return '<li><div class="src-line">' .
str_replace("\n",'',$line) .
* Used to convert the <<code>> tag in a docblock
function ProgramExample($example, $tutorial =
false, $inlinesourceparse =
null/*false*/,
$class =
null/*false*/, $linenum =
null/*false*/, $filesourcepath =
null/*false*/)
return $this->curname .
'.html';
* Uses htmlspecialchars() on the input
return str_replace(array(' ',"\t"), array(' ', ' '),
* Use the template tutorial_toc.tpl to generate a table of contents for HTML
* @return string table of contents formatted for use in the current output format
* @param array format: array(array('tagname' => section, 'link' => returnsee link, 'id' => anchor name, 'title' => from title tag),...)
$template->assign('toc',$toc);
return $template->fetch('tutorial_toc.tpl');
if (!isset
($this->package_index))
if (!isset
($start)) $start =
$key;
$this->package_index[] =
array('link' =>
"li_$key.html", 'title' =>
$key);
$templ->assign("packageindex",$this->package_index);
$templ->assign("subdir",'');
* Writes out the template file of {@link $class_data} and unsets the template to save memory
* @see registerCurrentClass()
* @see parent::endClass()
$this->class_data->register_outputfilter('CHMdefault_outputfilter');
* Writes out the template file of {@link $page_data} and unsets the template to save memory
$this->page_data->register_outputfilter('CHMdefault_outputfilter');
* @return string <a href="'.$link.'">'.$text.'</a>
return '<a href="'.
$link.
'">'.
$text.
'</a>';
* CHMdefaultConverter chooses to format both package indexes and the complete index here
* This function formats output for the elementindex.html and pkgelementindex.html template files. It then
* writes them to the target directory
* @see generateElementIndex(), generatePkgElementIndex()
for($i=
0;$i<
count($package_indexes);$i++
)
$this->package =
$package_indexes[$i]['package'];
$template->assign("index",$package_indexes[$i]['pindex']);
$template->assign("package",$package_indexes[$i]['package']);
$template->assign("letters",$mletters[$package_indexes[$i]['package']]);
$template->assign("title","Package ".
$package_indexes[$i]['package'].
" Element Index");
$template->assign("subdir",'../');
$template->register_outputfilter('CHMdefault_outputfilter');
$this->addTOC($package_indexes[$i]['package'].
" Alphabetical Index",'elementindex_'.
$package_indexes[$i]['package'],$package_indexes[$i]['package'],'');
$this->writefile('elementindex_'.
$package_indexes[$i]['package'].
'.html',$template->fetch('pkgelementindex.tpl'));
* CHMdefaultConverter uses this function to format template index.html and packages.html
* This function generates the package list from {@link $all_packages}, eliminating any
* packages that don't have any entries in their package index (no files at all, due to @ignore
* or other factors). Then it uses the default package name as the first package index to display.
* It sets the right pane to be either a blank file with instructions on making package-level docs,
* or the package-level docs for the default package.
* @global string Used to set the starting package to display
global $phpDocumentor_DefaultPackageName;
$template->assign("index",$elindex);
$template->assign("letters",$mletters);
$template->assign("title","Element Index");
$template->assign("date",date("r",time()));
$template->register_outputfilter('CHMdefault_outputfilter');
$this->addTOC("Alphabetical Index Of All Elements",'elementindex',"Index",'');
$this->writefile('elementindex.html',$template->fetch('elementindex.tpl'));
usort($this->package_index,"CHMdefault_pindexcmp");