Source for file XMLDocBookpeardoc2Converter.inc
Documentation is available at XMLDocBookpeardoc2Converter.inc
* Outputs documentation in XML DocBook format, in the version expected by
* pear.php.net's documentation team
* 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
* @copyright 2002-2006 Gregory Beaver
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @version CVS: $Id: XMLDocBookpeardoc2Converter.inc 234423 2007-04-24 21:32:15Z ashnazg $
* @link http://www.phpdoc.org
* @link http://pear.php.net/PhpDocumentor
* This Converter takes output from the {@link Parser} and converts it to DocBook
* output for PEAR documentation.
* This Converter differs from the parent DocBook Converter in that it does not
* recognize the possibility of procedural pages or of functions! All functions
* must be defined as static methods for namespace purposes. In addition, all
* constants and global variables for a package are grouped together as per
* peardoc2 requirements. Include statements are not documented. If you want
* to document a normal project, don't use the peardoc2 converter, use the
* @version $Id: XMLDocBookpeardoc2Converter.inc 234423 2007-04-24 21:32:15Z ashnazg $
* This converter knows about the new root tree processing
* In order to fix PEAR Bug #6389
* XMLDocBookConverter wants elements sorted by type as well as alphabetically
* @see Converter::$sort_page_contents_by_type
var $name = 'DocBook/peardoc2';
* indexes of elements by package that need to be generated
var $leftindex = array('classes' => true, 'pages' => false, 'functions' => false, 'defines' => true, 'globals' => true);
* whether a @see is going to be in the {@link $base_dir}, or in a package/subpackage subdirectory of $base_dir
* name of current page being converted
* path of current page being converted
* name of current class being converted
* template for the procedural page currently being processed
* output directory for the current procedural page being processed
* Constants, used for constants.tpl
* Global Variables, used for globals.tpl
* 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
* template for the class currently 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)
* Contents of the packagename.xml file are stored in this template variable
* 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
* Pass elements by package, simplifies generation of package.xml/category.xml
* template options. Currently only 1 recognized option usepear
* usepear tells the getLink() function to return a package link to PEAR and PEAR_ERROR if possible, and to link directly
* to the fully-delimited link package#class.method or package#file.method in PEAR style, if possible, even if the
* package is not parsed. This will allow parsing of separate PEAR packages without parsing the entire thing at once!
* Used to re-format output so that it's easy for translators to handle
* @var XML_Beautifier|false
var $_beautifier = false;
* sets {@link $base_dir} to $targetDir
@include_once 'XML/Beautifier.php';
Converter::Converter($allp, $packp, $classes, $procpages,$po, $pp, $qm, $targetDir, $templateDir, $title);
require_once 'phpDocumentor/Converters/XML/DocBook/peardoc2/Beautifier.php';
$this->_beautifier->setOption('indent', ' ');
* do that stuff in $template_options
function &getLink($expr, $package = false, $packages = false)
return '<programlisting role="php"><![CDATA[
'. $sourcecode. ']]></programlisting>';
* Writes a file to target dir, beautify any .xml files first
* @param string file contents
* @param boolean true if the data is binary and not text
function writeFile($file,$data,$binary = false)
if ($this->_beautifier && substr($file, - 4) == '.xml') {
$ret = $this->_beautifier->formatString($data);
if (PEAR::isError($ret)) {
return parent::writeFile($file, $data, $binary);
* Used to convert the {@}example} inline tag in a docblock.
* By default, this just wraps ProgramExample
* @see XMLDocBookpeardoc2Converter::exampleProgramExample
* @param boolean true if this is to highlight a tutorial <programlisting>
$class = null/*false*/, $linenum = null/*false*/, $filesourcepath = null/*false*/)
return '<example><title>Example</title><programlisting role="php"><![CDATA[' .
$example . ']]></programlisting></example>';
$this->ProgramExample($example, $tutorial, $inlinesourceparse, $class, $linenum, $filesourcepath)
$this->_save_example = array($title, $source);
$source = $this->_save_example[1];
return '<para><example><title>' . $title . '</title>' . $source . '</example></para>';
return '<classname>'. $typename. '</classname>';
return '<function>'. $typename. '</function>';
return '<constant>'. $typename. '</constant>';
return '<varname>'. $typename. '</varname>';
* Writes out the template file of {@link $class_data} and unsets the template to save memory
* @see registerCurrentClass()
* @see parent::endClass()
* @todo move class summary into an array to be written out at the end
* of parsing each package
$this->writefile(strtolower($func[1] ). '.xml','<!-- $' . "Revision$ -->\n" . $func[0]->fetch('method.tpl'));
// code below is in packagename.xml handling, see Output()
/* $this->setTargetDir($this->base_dir . PATH_DELIMITER . strtolower($this->category) . PATH_DELIMITER . strtolower($this->class_dir));
$this->writefile(str_replace(array('_','.'),array('-','--'),strtolower($this->class)) . '.xml',$this->class_data->fetch('class.tpl'));*/
$this->packagexml->append('ids',$template_output);
* @param parserClass|false$element is false if this is the end of all conversion
if (!$element || $element->docblock->package != $this->package) // finished with package
'<!-- $' . "Revision$ -->\n" . $this->packagexml->fetch('package.tpl'));
$this->packagexml->assign('package',$element->docblock->package);
$this->packagexml->assign('package',$element->docblock->package);
* @return string <ulink url="'.$link.'">'.$text.'</ulink>
return '<ulink url="'. $link. '">'. $text. '</ulink>';
* Creates package/lang/categoryname/packagename.xml for each package
* This function takes an {@link abstractLink} descendant and returns an html link
* @param abstractLink a descendant of abstractlink should be passed, and never text
* @param string text to display in the link
* @param boolean this parameter is not used, and is deprecated
* @param boolean determines whether the returned text is enclosed in an <link> tag
function returnSee(&$element, $eltext = false, $local = true, $with_a = true)
if (!$element) return false;
$eltext = $element->title;
$eltext = '<classname>'. $element->name. '</classname>';
if ($element->type == 'var') $eltext .= '<varname>';
$eltext .= $element->class. '::';
if ($element->type == 'define')
if ($element->type == 'function')
$eltext .= $element->name;
if ($element->type == 'function' || $element->type == 'method') $eltext .= '</function>';
if ($element->type == 'var') $eltext .= '</varname>';
if ($element->type == 'define') $eltext .= '</constant>';
} elseif ($element->type == 'method')
$eltext = str_replace($element->name . '()', $element->name, $eltext);
if ($element->type == 'page' || $element->type == 'function' || $element->type == 'var')
{ // we ignore all procedural pages, instead, constant, function and
// global variable pages are output
if ($element->type == 'class')
return '<link linkend="'. $this->getId($element). '-summary">'. $eltext. '</link>';
return '<link linkend="'. $this->getId($element). '">'. $eltext. '</link>';
* Get the id value needed to allow linking
* @param mixed descendant of parserElement or parserData/parserPage
* @param boolean true to return the id for the package page
* @see parserElement, parserData, parserPage
* @return string the id value for this element type
function getId(&$el, $returnpackage = false)
$element = $this->addLink($el->parent);
} elseif (!is_a($el,'abstractlink'))
$element = $this->addLink($el);
if (!empty($element->subpackage))
$a = str_replace(array('_','.'),array('-','--'),$element->subpackage). '.';
if ($returnpackage) return 'package.'. strtolower($element->category. '.'. str_replace(array('_','.'),array('-','--'),$element->package));
return 'package.'. strtolower($element->category. '.'. str_replace(array('_','.'),array('-','--'),$element->package). '.'. $a. $element->fileAlias);
return 'package.'. strtolower($element->category. '.'. str_replace(array('_','.'),array('-','--'),$element->package). '.constants.details.'. $element->fileAlias);
return 'package.'. strtolower($element->category. '.'. str_replace(array('_','.'),array('-','--'),$element->package). '.globals.details.'. $element->fileAlias);
return 'package.'. strtolower($element->category. '.'. str_replace(array('_','.'),array('-','--'),$element->package). '.'. $a. str_replace(array('_','.'),array('-','--'),$element->name));
return 'package.'. strtolower($element->category. '.'. str_replace(array('_','.'),array('-','--'),$element->package). '.'. $a. $element->fileAlias. '.'. str_replace('_','-',$element->name));
return 'package.'. strtolower($element->category. '.'. str_replace(array('_','.'),array('-','--'),$element->package). '.'. $a. str_replace(array('_','.'),array('-','--'),$element->class). '.'. str_replace('_','-',$element->name));
return 'package.'. strtolower($element->category. '.'. str_replace(array('_','.'),array('-','--'),$element->package). '.'. $a. str_replace(array('_','.'),array('-','--'),$element->class). '-summary.vars.'. str_replace(array('$','_'),array('var--','-'),$element->name));
return 'package.'. strtolower($element->category. '.'. str_replace(array('_','.'),array('-','--'),$element->package). '.'. $a. str_replace(array('_','.'),array('-','--'),$element->name)). '-tutorial';
* Create errors.html template file output
* This method takes all parsing errors and warnings and spits them out ordered by file and line number.
* @global ErrorTracker We'll be using it's output facility
global $phpDocumentor_errors;
$warnings = $phpDocumentor_errors->returnWarnings();
$errors = $phpDocumentor_errors->returnErrors();
foreach($warnings as $warning)
$linenum .= ' on line '. $warning->linenum;
$files[$file]['warnings'][] = array('name' => $linenum, 'listing' => $warning->data);
foreach($errors as $error)
$linenum .= ' on line '. $error->linenum;
$files[$file]['errors'][] = array('name' => $linenum, 'listing' => $error->data);
foreach($allfiles as $file => $num)
usort($allfiles,'strnatcasecmp');
$allfiles[0] = "Post-parsing";
foreach($allfiles as $i => $a)
$allfiles[$i] = array('file' => $a);
foreach($files as $file => $data)
if ($file == '##none') $file = 'Post-parsing';
$template->assign("files",$allfiles);
$template->assign("all",$out);
$template->assign("title","phpDocumentor Parser Errors and Warnings");
$this->writefile("errors.html",$template->fetch('errors.tpl'));
$a->add('no exceptions thrown');
if (!$element->docblock->getKeyword('throws')) $element->docblock->addKeyword('throws',$a);
array('staticvar' => 'note','deprec' => 'deprecated',
'abstract' => 'abstract','TODO' => 'note', 'link' => 'see',
'uses' => 'see', 'usedby' => 'see', 'tutorial' => 'see',
'return' => 'returns', 'access' => false), $nopackage);
foreach($tags['tags'] as $tag)
if ($tag['keyword'] == 'return')
// hack because stupid Converter isn't doing its job
$tag['keyword'] = 'returns';
$ret[$tag['keyword']][] = $tag;
$tags['sdesc'] = $this->wordwrap($tags['sdesc']);
function getTutorialId($package,$subpackage,$tutorial,$id,$category)
$subpackage = (empty($subpackage) ? '' : '.'. $subpackage);
$id = (empty($id) ? '' : '.'. $id);
return 'package.'. strtolower($category. '.'. $package. $subpackage. str_replace(array('_','.'),array('-','--'),$tutorial). $id);
* 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 '<![CDATA['. $value. ']]>';
function ProgramExample($listing, $tutorial = false, $inlinesourceparse = null/*false*/,
$class = null/*false*/, $linenum = null/*false*/, $filesourcepath = null/*false*/, $origsource = null)
if ($origsource !== null) {
return '<programlisting role="php">' . $this->getCData($listing) . '</programlisting>';
* Does nothing - use tutorials for DocBook
* @param parserPackagePage
* Convert tutorials for output
$x = $element->Convert($this,false);
{ // add child tutorial list to the tutorial through a slight hack :)
if (!empty($element->subpackage)) $b = '.'. $element->subpackage;
foreach($element->ini['Linked Tutorials'] as $child)
$subtutorials .= ' &'. $element->category. '.'. $element->package. $b. '.'. str_replace(array('_','.'),array('-','--'),$child). '-'. $element->tutorial_type. "-tutorial;\n";
<title>Related Docs</title>
</refsect1></refentry>',$x);
$template->assign('contents',$x);
$contents = $template->fetch('tutorial.tpl');
'<!-- $' . "Revision$ -->\n" . $contents);
* Does nothing in this converter
if ($element->docblock->var)
$b = $element->docblock->var->converted_returnType;
// var_dump($this->getFormattedOverrides($element));
$this->class_summary->append('vars',array('sdesc' => $docblock['sdesc'],
'desc' => $docblock['desc'],
'tags' => $docblock['tags'],
'line_number' => $element->getLineNumber(),
'id' => $this->getId($element)));
$this->class_data->append('vars',array('sdesc' => $docblock['sdesc'],
'desc' => $docblock['desc'],
'tags' => $docblock['tags'],
'line_number' => $element->getLineNumber(),
'id' => $this->getId($element)));
* Converts class for template output
* @uses flushPackageXml() creates packagename.xml file when all classes in
* a package have been converted
$this->package = $element->docblock->package;
$this->class_data->assign("sdesc",$docblock['sdesc']);
$this->class_data->assign("desc",$docblock['desc']);
$this->class_data->assign("tags",$docblock['tags']);
$this->left[$this->package][] = array('link' => $this->getId($element). '-summary');
if ($t = $element->getTutorial())
$this->class_summary = &$this->newSmarty(true);
if ($t = $element->getTutorial())
$this->class_summary->assign("tutorial",$this->returnSee($t));
$this->class_summary->assign("class_name",$this->type_adjust($element->getName()));
$this->class_summary->assign("sdesc",$docblock['sdesc']);
$this->class_summary->assign("desc",$docblock['desc']);
$this->class_summary->assign("tags",$docblock['tags']);
$this->class_summary->assign("vars",array());
$this->class_summary->assign("methods",array());
$this->class_summary->assign("package",$element->docblock->package);
$this->class_summary->assign("source_location",$element->getSourceLocation($this,$this->template_options['usepear']));
$this->class_summary->assign("id",$this->getId($element). '-summary');
if (!empty($inherited_methods))
$this->class_summary->assign("imethods",$inherited_methods);
// variables are irrelevant in peardoc2
if (false)//!empty($inherited_vars))
$this->class_summary->assign("ivars",$inherited_vars);
* Converts method for template output
* @see prepareDocBlock(), parserMethod::getFunctionCall(), getFormattedDescMethods(), getFormattedOverrides()
if ($element->docblock->return)
$a = $element->docblock->return->Convert($this);
$returntype = $element->docblock->return->converted_returnType;
if ($returntype != $element->docblock->return->returnType)
$returntype = "<replaceable>$returntype</replaceable>";
if (count($element->docblock->params))
foreach($element->docblock->params as $param => $val)
$a = $val->Convert($this);
$c .= str_replace(array('true', 'false', 'null'), array('&true;', '&false;', '&null;'), $blah);
$params[$param] = array("var" => $param,"datatype" => str_replace(array('true', 'false', 'null'), array('&true;', '&false;', '&null;'),
$val->returnType), "cdatatype" => $val->converted_returnType,"data" => $this->wordwrap($c));
$call = $element->getIntricateFunctionCall($this, $params);
if (isset ($call['params']))
foreach($call['params'] as $i => $param)
if (!is_string($call['params'][$i]['default']))
$call['params'][$i]['default'] = str_replace(array('true', 'false', 'null'), array('&true;', '&false;', '&null;'), $param['default']);
$this->class_summary->append('methods',array('id' => $this->getId($element),
'sdesc' => $docblock['sdesc'],
'desc' => $docblock['desc'],
'tags' => $docblock['tags'],
'is_constructor' => $element->isConstructor,
'function_name' => $element->getName(),
'function_return' => $returntype,
'function_call' => $call,
'line_number' => $element->getLineNumber(),
$this->method_data[$i][0]->assign('sdesc',$docblock['sdesc']);
$this->method_data[$i][0]->assign('desc',$docblock['desc']);
$this->method_data[$i][0]->assign('tags',$docblock['tags']);
$this->method_data[$i][0]->assign('function_name',$element->getName());
$this->method_data[$i][0]->assign('function_return',$returntype);
$this->method_data[$i][0]->assign('function_call',$call);
* Converts function for template output - does nothing in peardoc2!
/* parent::convertFunction($element);
$docblock = $this->prepareDocBlock($element);
$fname = $element->getName();
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)
$a = $element->docblock->return->Convert($this);
$returntype = $element->docblock->return->converted_returnType;
$this->page_data->append("function_ids",$this->getId($element));
$this->page_summary->append("function_ids",$this->getId($element));
$this->page_summary->append('functions',array('id' => $this->getId($element),
'sdesc' => $docblock['sdesc'],
'desc' => $docblock['desc'],
'tags' => $docblock['tags'],
'function_name' => $element->getName(),
'line_number' => $element->getLineNumber(),
'function_return' => $returntype,
'function_call' => $element->getIntricateFunctionCall($this,$params),
'function_conflicts' => $this->getFormattedConflicts($element,'functions'),
$this->function_data[$i = count($this->function_data) - 1][0] = $this->newSmarty(true);
$this->function_data[$i][1] = $element->getName();
$this->function_data[$i][0]->assign('sdesc',$docblock['sdesc']);
$this->function_data[$i][0]->assign('desc',$docblock['desc']);
$this->function_data[$i][0]->assign('tags',$docblock['tags']);
$this->function_data[$i][0]->assign('function_name',$fname);
$this->function_data[$i][0]->assign('line_number',$element->getLineNumber());
$this->function_data[$i][0]->assign('function_return',$returntype);
$this->function_data[$i][0]->assign('function_call',$element->getIntricateFunctionCall($this,$params));
$this->function_data[$i][0]->assign('function_conflicts',$this->getFormattedConflicts($element,"functions"));
$this->function_data[$i][0]->assign('params',$params);
$this->function_data[$i][0]->assign('source_location',$this->returnSee($this->getLink(basename($this->curpage->getFile())),$this->sourceloc));
$this->function_data[$i][0]->assign('id',$this->getId($element));*/
* Converts include elements for template output
* Completely ignored by this converter
/* parent::convertInclude($element, array('include_file' => '-'.strtr($element->getValue(),array('"' => '', "'" => '','.' => '-'))));
$docblock = $this->prepareDocBlock($element);
$per = $this->getIncludeValue($element->getValue(), $element->getPath());
$this->page_summary->append('includes',array('sdesc' => $docblock['sdesc'],
'desc' => $docblock['desc'],
'tags' => $docblock['tags'],
'utags' => $docblock['utags'],
'include_name' => $element->getName(),
'line_number' => $element->getLineNumber(),
'include_file' => '-'.strtr($element->getValue(),array('"' => '', "'" => '','.' => '-'))));*/
* Converts defines for template output
* @see prepareDocBlock(), getFormattedConflicts()
$this->_appendDefines(array('sdesc' => $docblock['sdesc'],
'desc' => $docblock['desc'],
'tags' => $docblock['tags'],
'line_number' => $element->getLineNumber(),
'id' => $this->getId($element)));
* Append the constant information to the Smarty information
* Uses category, package, and current file to organize constants defined
* in a package for the constants.xml output file
* @uses $_peardoc2_constants appends $define to them
function _appendDefines($define)
* Converts global variables for template output
* @see prepareDocBlock(), getFormattedConflicts()
if ($value == $element->getValue())
$value = $this->getGlobalValue('<![CDATA[' . $element->getValue() . ']]>');
$this->_appendGlobals(array('sdesc' => $docblock['sdesc'],
'desc' => $docblock['desc'],
'tags' => $docblock['tags'],
'link' => $element->getName(),
'type' => $element->getDataType($this),
'line_number' => $element->getLineNumber(),
'id' => $this->getId($element)));
* Append the global variable information to the Smarty information
* Uses category, package, and current file to organize globals defined
* in a package for the globals.xml output file
* @uses $_peardoc2_globals appends $global to them
function _appendGlobals($global)
* converts procedural pages for template output
* @see prepareDocBlock(), getClassesOnPage()
$this->page_dir = $element->parent->package;
$this->sourceloc = $element->parent->getSourceLocation($this,true);
// registering stuff on the template
return str_replace(array('/','_','.'),array('-','-','---'),$element->getSourceLocation($this,true));
* returns an array containing the class inheritance tree from the root object to the class
* @param parserClass class variable
* @return array Format: array(root,child,child,child,...,$class)
* @uses parserClass::getParentClassTree()
$tree = $class->getParentClassTree($this);
$result = array($class->getName());
$parent = $tree[$class->getName()];
$subpackage = $parent->docblock->subpackage;
$package = $parent->docblock->package;
$x = $parent->getLink($this);
if (!$x) $x = $parent->getName();
$parent = $tree[$parent->getName()];
elseif (isset ($tree[$parent]))
$parent = $tree[$parent];
return array($class->getName());
* returns a list of child classes
* @param parserClass class variable
* @uses parserClass::getChildClassList()
$kids = $class->getChildClassList($this);
for($i= 0; $i< count($kids); $i++ )
$lt['link'] = '<link linkend="'. $this->getId($kids[$i]) . '-summary">'. $kids[$i]->getName(). '</link>';
$lt['sdesc'] = $kids[$i]->docblock->getSDesc($this);
function sortMethod($a, $b)
if ($a->isConstructor) return - 1;
if ($b->isConstructor) return 1;
* returns a template-enabled array of class trees
* @param string $package package to generate a class tree for
* @see $roots, HTMLConverter::getRootTree()
if (!isset ($this->roots['normal'][$package]) &&
!isset ($this->roots['special'][$package])) {
if (isset ($this->roots['normal'][$package])) {
$roots = $this->roots['normal'][$package];
for($i= 0;$i< count($roots);$i++ )
$root = $this->classes->getClassByPackage($roots[$i], $package);
if ($root && $root->isInterface()) {
if (isset ($this->roots['special'][$package])) {
$roots = $this->roots['special'][$package];
foreach ($roots as $parent => $classes) {
foreach ($classes as $classinfo) {
$root = $this->classes->getClassByPackage($classinfo, $package);
if ($root && $root->isInterface()) {
'class_tree' => "<ul>\n" . $thistree . "</ul>\n"
* returns a template-enabled array of interface inheritance trees
* @param string $package package to generate a class tree for
* @see $roots, HTMLConverter::getRootTree()
if (!isset ($this->roots['normal'][$package]) &&
!isset ($this->roots['special'][$package])) {
if (isset ($this->roots['normal'][$package])) {
$roots = $this->roots['normal'][$package];
for($i= 0;$i< count($roots);$i++ )
$root = $this->classes->getClassByPackage($roots[$i], $package);
if ($root && !$root->isInterface()) {
if (isset ($this->roots['special'][$package])) {
$roots = $this->roots['special'][$package];
foreach ($roots as $parent => $classes) {
foreach ($classes as $classinfo) {
$root = $this->classes->getClassByPackage($classinfo, $package);
if ($root && !$root->isInterface()) {
'class_tree' => "<ul>\n" . $thistree . "</ul>\n"
* return formatted class tree for the Class Trees page
* @param array $tree output from {@link getSortedClassTreeFromClass()}
* @param string $package package
* @param boolean $nounknownparent if true, an object's parent will not be checked
* @see Classes::$definitechild, generateFormattedClassTrees()
function getRootTree($tree, $package, $noparent = false)
if (!$noparent && $tree[$cur]['parent'])
// debug("parent ".$tree[$cur]['parent']." not found");
$my_tree .= '<listitem>' . $tree[$cur]['parent'] . '<itemizedlist>';
// debug("parent ".$this->returnSee($tree[$cur]['parent'], false, false)." in other package");
$my_tree .= '<listitem>' . $this->returnSee($tree[$cur]['parent'], false, false);
if ($tree[$cur]['parent']->package != $package) $my_tree .= ' <emphasis>(Different package)</emphasis><itemizedlist>';
// fancy_debug($cur,$lastcur,$kids);
if (count($tree[$cur]['children']))
// debug("$cur has children");
// debug("set $cur kids");
$my_tree .= '<listitem>'. $this->returnSee($tree[$cur]['link'], false, false);
$my_tree .= '<itemizedlist>'. "\n";
list (,$cur) = each($tree[$cur]['children']);
// var_dump('listed',$cur);
$cur = $cur['package'] . '#' . $cur['class'];
// debug("set cur to child $cur");
// $my_tree .= '<li>'.$this->returnSee($tree[$cur]['link'], false, false);
// debug("end of children for $cur");
$my_tree .= '</itemizedlist></listitem>'. "\n";
if ($dopar && ($cur == '#root' || !$cur)) $my_tree .= '</itemizedlist></listitem>';
// debug("$cur has no children");
$my_tree .= '<listitem>'. $this->returnSee($tree[$cur]['link'], false, false). "</listitem>";
if ($dopar && $cur == '#root') $my_tree .= '</itemizedlist></listitem>';
* Generate alphabetical index of all elements by package and subpackage
* @param string $package name of a package
* @see $pkg_elements, walk(), generatePkgElementIndexes()
* @see generatePkgElementIndex()
* @param string name of class
* @param string package name
* @param string full path to look in (used in index generation)
* @param boolean deprecated
* @param boolean return just the URL, or enclose it in an html a tag
* @return mixed false if not found, or an html a link to the class's documentation
* @see parent::getClassLink()
function getClassLink($expr,$package, $file = false,$text = false, $local = true, $with_a = true)
return $this->returnSee($a, $text, $local, $with_a);
* @param string name of function
* @param string package name
* @param string full path to look in (used in index generation)
* @param boolean deprecated
* @param boolean return just the URL, or enclose it in an html a tag
* @return mixed false if not found, or an html a link to the function's documentation
* @see parent::getFunctionLink()
function getFunctionLink($expr,$package, $file = false,$text = false, $local = true)
* @param string name of define
* @param string package name
* @param string full path to look in (used in index generation)
* @param boolean deprecated
* @param boolean return just the URL, or enclose it in an html a tag
* @return mixed false if not found, or an html a link to the define's documentation
* @see parent::getDefineLink()
function getDefineLink($expr,$package, $file = false,$text = false, $local = true)
* @param string name of global variable
* @param string package name
* @param string full path to look in (used in index generation)
* @param boolean deprecated
* @param boolean return just the URL, or enclose it in an html a tag
* @return mixed false if not found, or an html a link to the global variable's documentation
* @see parent::getGlobalLink()
function getGlobalLink($expr,$package, $file = false,$text = false, $local = true)
* @param string name of procedural page
* @param string package name
* @param string full path to look in (used in index generation)
* @param boolean deprecated
* @param boolean return just the URL, or enclose it in an html a tag
* @return mixed false if not found, or an html a link to the procedural page's documentation
* @see parent::getPageLink()
function getPageLink($expr,$package, $path = false,$text = false, $local = true)
* @param string name of method
* @param string class containing method
* @param string package name
* @param string full path to look in (used in index generation)
* @param boolean deprecated
* @param boolean return just the URL, or enclose it in an html a tag
* @return mixed false if not found, or an html a link to the method's documentation
* @see parent::getMethodLink()
function getMethodLink($expr,$class,$package, $file = false,$text = false, $local = true)
* @param string name of var
* @param string class containing var
* @param string package name
* @param string full path to look in (used in index generation)
* @param boolean deprecated
* @param boolean return just the URL, or enclose it in an html a tag
* @return mixed false if not found, or an html a link to the var's documentation
* @see parent::getVarLink()
function getVarLink($expr,$class,$package, $file = false,$text = false, $local = true)
* does a nat case sort on the specified second level value of the array
* does a nat case sort on the specified second level value of the array.
* this one puts constructors first
if (strpos($aa,'CONSTRUCTOR') === 0)
if (strpos($bb,'CONSTRUCTOR') === 0)
* Generate the constants.xml, packagename.xml, and globals.xml files
if (isset ($packages[$package])) unset ($packages[$package]);
$category = $GLOBALS['phpDocumentor_DefaultCategoryName'];
foreach($packages as $package)
foreach($categories as $category => $ids)
$templ->assign('id','package.'. $category);
$templ->assign('ids',array());
$templ->assign('category',$category);
foreach($contents as $i => $line)
if (strlen($line) && $line{0} == '&')
if ($found !== false && (!strlen($line) || $line{0} != '&'))
foreach($ids as $id => $unll)
$newids[] = ' &' . $id . ";\n";
$categorycontents = implode($newcontents, '');
foreach($ids as $id => $unll)
if (!in_array($id, $templ->_tpl_vars['ids']))
$templ->append('ids',$id);
$categorycontents = '<!-- $' . "Revision$ -->\n" . $templ->fetch('category.tpl');
foreach($r as $package => $s)
$my->assign('package',$package);
foreach($s as $file => $t)
$arr['defines'] = $t['defines'];
$my->assign('defines',$defines);
$this->writefile('constants.xml',
'<!-- $' . "Revision$ -->\n" . $my->fetch('constants.tpl'));
foreach($r as $package => $s)
$my->assign('package',$package);
foreach($s as $file => $t)
$arr['globals'] = $t['globals'];
$my->assign('globals',$defines);
$this->writefile('globals.xml',
'<!-- $' . "Revision$ -->\n" . $my->fetch('globals.tpl'));
|