Source for file PDFdefaultConverter.inc
Documentation is available at PDFdefaultConverter.inc
* Outputs documentation in PDF format
* 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 Greg Beaver <cellog@php.net>
* @copyright 2002-2006 Gregory Beaver
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @version CVS: $Id: PDFdefaultConverter.inc,v 1.7 2007/05/31 02:02:42 ashnazg Exp $
* @link http://www.phpdoc.org
* @link http://pear.php.net/PhpDocumentor
* The Cezpdf class library
include_once('phpDocumentor/Converters/PDF/default/class.phpdocpdf.php');
* This Converter takes output from the {@link Parser} and converts it to PDF-ready output for use with {@link Cezpdf}.
* @author Greg Beaver <cellog@php.net>
* @version $Id: PDFdefaultConverter.inc,v 1.7 2007/05/31 02:02:42 ashnazg Exp $
* @todo Implement links to conflicts/inheritance
* default PDF Converter wants elements sorted by type as well as alphabetically
* @see Converter::$sort_page_contents_by_type
var $leftindex = array('classes' => false, 'pages' => false, 'functions' => false, 'defines' => false, 'globals' => false);
/** @var string always PDF */
/** @var string always default */
* Source files for appendix C are stored here
* Format: array(array(package => packagename, code => array(highlightedsource code 1, ...)))
* @see Converter::Converter()
function PDFdefaultConverter(&$allp, &$packp, &$classes, &$procpages, $po, $pp, $qm, $targetDir, $templateDir, $title)
Converter::Converter($allp, $packp, $classes, $procpages, $po, $pp, $qm, $targetDir, $templateDir, $title);
// put a line top and bottom on all the pages
$this->pdf->ezSetMargins(50,70,50,50);
$this->pdf->ezText($template->fetch('footer.tpl'));
$template->assign('title',$title);
$this->pdf->ezText($template->fetch('title_page.tpl'));
$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']);
$this->_sourcecode[$pathinfo['package']][] = $templ->fetch('filesource.tpl');
$templ->assign('source',$source);
$templ->assign('title',$title);
$templ->assign('file',$path);
$this->pdf->ezText($templ->fetch('examplesource.tpl'));
// var_dump(htmlentities('<c:ilink:'.$this->getFileSourceName($path).'>Source Code for this file</c:ilink>'));
return '<c:ilink:'. $this->getFileSourceName($path). '>Source Code for this file</c:ilink>';
* 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 '<c:ilink:' . $this->getFileSourceName($sourcefile, $anchor). '>' . $text . '</c:ilink>';
return '</text><pdffunction:addDestination arg="'. $this->getFileSourceName($sourcefile, $anchor). '" arg="FitH" arg=$this->y /><text size="8">';
* Returns a bookmark using Cezpdf 009
* @param abstractLink a descendant of abstractlink should be passed, and never text
* @param string text to display in the link
function returnSee(&$element, $eltext = false)
if (!$element) return false;
$eltext = $element->title;
$eltext .= $element->class. '::';
$eltext .= $element->name;
if ($element->type == 'function' || $element->type == 'method') $eltext .= '()';
return '<c:ilink:'. urlencode($element->type. $element->package. $element->subpackage. $element->name. $element->section). '>'. $eltext. '</c:ilink>';
return '<c:ilink:'. urlencode($element->type. $element->package. $element->path). '>'. $eltext. '</c:ilink>';
return '<c:ilink:'. urlencode($element->type. $element->package. $element->name). '>'. $eltext. '</c:ilink>';
return '<c:ilink:'. urlencode($element->type. $element->package. $element->class. '::'. $element->name). '>'. $eltext. '</c:ilink>';
* @return string <c:alink:$link>$text</c:alink>
return "<c:alink:$link>$text</c:alink>";
* Convert README/INSTALL/CHANGELOG file contents to output format
* @param README|INSTALL|CHANGELOG
* @param string contents of the file
if (!$element->docblock) return;
if ($element->type == 'page' || $element->type == 'class') $nopackage = false;
$tagses = $element->docblock->listTags();
$names = array('staticvar' => 'Static Variable','deprec' => 'Deprecated','abstract' => 'Abstract Element','todo' => 'TODO');
$tags[] = array('keyword' => 'Package','data' => $element->docblock->package);
if (!empty($element->docblock->subpackage)) $tags[] = array('keyword' => 'Sub-Package','data' => $element->docblock->subpackage);
if ($element->docblock->var)
$a = $element->docblock->var->Convert($this);
$tags[] = array('keyword' => 'Var', 'data' => $a);
if ($element->docblock->funcglobals)
foreach($element->docblock->funcglobals as $global => $val)
if ($a = $this->getGlobalLink($global,$element->docblock->package))
$tags[] = array('keyword' => 'Global Variable Used','data' => $val[0]. ' '. $global. ': '. $val[1]->Convert($this));
if ($element->docblock->statics)
foreach($element->docblock->statics as $static => $val)
$a = $val->Convert($this);
$tags[] = array('keyword' => 'Static Variable Used','data' => $val->converted_returnType. ' '. $static. ': '. $a);
if ($element->docblock->properties)
foreach($element->docblock->properties as $property => $val)
$a = $val->Convert($this);
$tags[] = array('keyword' => ucfirst($val->keyword),'data' => $val->converted_returnType. ' '. $property. ': '. $a);
if (isset ($names[$tag->keyword])) $tag->keyword = $names[$tag->keyword];
$tags[] = array("keyword" => ucfirst($tag->keyword),"data" => $tag->Convert($this));
foreach($element->docblock->unknown_tags as $keyword => $t)
$utags[] = array('keyword' => $keyword, 'data' => $tag->Convert($this));
if ($element->type == 'packagepage') return;
$sdesc = $element->docblock->getSDesc($this);
$desc = $element->docblock->getDesc($this);
$template->assign('utags',$utags);
$template->assign('tags',$tags);
$template->assign('sdesc',$sdesc);
$template->assign('desc',$desc);
if (false) // $element->type != 'page')
if ($element->type != 'var' && $element->type != 'method')
$this->pdf->addDestination(urlencode($element->type. $element->docblock->package. $element->name),'FitH',$this->pdf->y);
$this->pdf->addDestination(urlencode($element->type. $element->docblock->package. $element->class. '::'. $element->name),'FitH',$this->pdf->y);
$this->pdf->addDestination(urlencode('page'. $element->parent->package. $element->parent->getPath()),'FitH',$this->pdf->y);
$this->pdf->ezText($template->fetch('docblock.tpl'));
if ($element->type != 'function' && $element->type != 'method') return;
if (count($element->docblock->params))
if (count($element->docblock->params))
foreach($element->docblock->params as $param => $val)
$a = $val->Convert($this);
$params[] = array("name" => $param,"type" => $val->converted_returnType,"description" => $a);
$template->assign('params',$params);
$this->pdf->ezText($template->fetch('params.tpl'));
if ($element->docblock->sdesc)
$sdesc = $element->docblock->sdesc->Convert($this);
$template->assign('linenumber',$element->getLineNumber());
$template->assign('slink',$this->getSourceAnchor($element->getPath(),$element->getLineNumber(),$element->getLineNumber(),true));
$template->assign('slink', false);
$template->assign('dest', urlencode($element->type. $element->docblock->package. $element->name));
$template->assign('type',$element->getDataType($this));
$template->assign('name',$element->name);
$template->assign('value',$this->getGlobalValue($element->getValue()));
$template->assign('sdesc',$sdesc);
$this->pdf->ezText($template->fetch('global.tpl'));
if ($element->docblock->sdesc)
$sdesc = $element->docblock->sdesc->Convert($this);
if (count($element->docblock->params))
foreach($element->docblock->params as $param => $val)
$a = $val->Convert($this);
$params[$param] = array("var" => $param,"datatype" => $val->converted_returnType,"data" => $a);
if ($element->docblock->return)
if (!$element->docblock->return->returnType) $element->docblock->return->returnType = 'void';
$template->assign('class',$this->class);
$template->assign('constructor',$element->isConstructor);
$template->assign('dest', urlencode($element->type. $element->docblock->package. $element->class. '::'. $element->name));
$template->assign('linenumber',$element->getLineNumber());
$template->assign('slink',$this->getSourceAnchor($element->getPath(),$element->getLineNumber(),$element->getLineNumber(),true));
$template->assign('slink',false |