Source for file HTMLframesConverter.inc
Documentation is available at HTMLframesConverter.inc
* HTML original framed output converter, modified to use Smarty Template.
* This Converter takes output from the {@link Parser} and converts it to HTML-ready output for use with {@link Smarty}.
* phpDocumentor :: automatic documentation generator
* Copyright (c) 2002-2006 Gregory 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 Gregory Beaver <cellog@php.net>
* @copyright 2002-2006 Gregory Beaver
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @version CVS: $Id: HTMLframesConverter.inc,v 1.16 2007/04/19 20:20:57 ashnazg Exp $
* @link http://www.phpdoc.org
* @link http://pear.php.net/PhpDocumentor
* @see parserDocBlock, parserInclude, parserPage, parserClass
* @see parserDefine, parserFunction, parserMethod, parserVar
* This Converter takes output from the {@link Parser} and converts it to HTML-ready output for use with {@link Smarty}.
* @see parserDocBlock, parserInclude, parserPage, parserClass, parserDefine, parserFunction, parserMethod, parserVar
* @author Greg Beaver <cellog@php.net>
* @version $Id: HTMLframesConverter.inc,v 1.16 2007/04/19 20:20:57 ashnazg Exp $
* This converter knows about the new root tree processing
* In order to fix PEAR Bug #6389
* Smarty Converter 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 HTMLdefaultConverter 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
* sets {@link $base_dir} to $targetDir
function HTMLframesConverter(&$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('HTMLframes_outputfilter');
$this->writefile($this->getFileSourceName($path).
'.html',$templ->fetch('filesource.tpl'));
$templ->assign('source',$source);
$templ->assign('title',$title);
$templ->assign('file',$path);
$templ->assign("subdir",'../');
$templ->register_outputfilter('HTMLframes_outputfilter');
$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 '<div class="src-code"><ol>' .
parent::ProgramExample($example, $tutorial, $inlinesourceparse, $class, $linenum, $filesourcepath)
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('HTMLframes_outputfilter');
$this->writefile($this->class .
'.html',$this->class_data->fetch('class.tpl'));
* Writes out the template file of {@link $page_data} and unsets the template to save memory
$this->page_data->register_outputfilter('HTMLframes_outputfilter');
$this->writefile($this->page .
'.html',$this->page_data->fetch('page.tpl'));
* @return string <a href="'.$link.'">'.$text.'</a>
return '<a href="'.
$link.
'">'.
$text.
'</a>';
foreach($o1 as $subpackage =>
$links)
for($i=
0;$i<
count($links);$i++
)
$left[$package][$subpackage]['files'][] =
array("link" =>
$this->getId($links[$i]), "title" =>
$links[$i]->name);
$interfaces =
$classes =
false;
foreach($o1 as $subpackage =>
$links)
for($i=
0;$i<
count($links);$i++
)
$class =
$this->classes->getClassByPackage($links[$i]->name, $links[$i]->package);
$isinterface =
$isclass =
false;
if ($class->isInterface()) {
if ($class && isset
($class->docblock) &&
$class->docblock->hasaccess) {
$left[$package][$subpackage]['classes'][] =
array("link" =>
$this->getId($links[$i]),
"title" =>
$links[$i]->name,
'is_interface' =>
$isinterface,
"access" =>
$class->docblock->tags['access'][0]->value,
"abstract" => isset
($class->docblock->tags['abstract'][0]));
$left[$package][$subpackage]['classes'][] =
array("link" =>
$this->getId($links[$i]),
"title" =>
$links[$i]->name,
'is_interface' =>
$isinterface,
"abstract" => isset
($class->docblock->tags['abstract'][0]));
foreach($o1 as $subpackage =>
$links)
for($i=
0;$i<
count($links);$i++
)
$left[$package][$subpackage]['functions'][] =
array("link" =>
$this->getId($links[$i]), "title" =>
$links[$i]->name);
foreach($left as $package =>
$r)
if (isset
($this->package_pages[$package])) $pd =
$package.
'/package_'.
$package.
'.html';