3 * HTML original framed output converter, modified to use Smarty Template.
\r
4 * This Converter takes output from the {@link Parser} and converts it to HTML-ready output for use with {@link Smarty}.
\r
6 * phpDocumentor :: automatic documentation generator
\r
8 * PHP versions 4 and 5
\r
10 * Copyright (c) 2002-2006 Gregory Beaver
\r
14 * This library is free software; you can redistribute it
\r
15 * and/or modify it under the terms of the GNU Lesser General
\r
16 * Public License as published by the Free Software Foundation;
\r
17 * either version 2.1 of the License, or (at your option) any
\r
20 * This library is distributed in the hope that it will be useful,
\r
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
\r
23 * Lesser General Public License for more details.
\r
25 * You should have received a copy of the GNU Lesser General Public
\r
26 * License along with this library; if not, write to the Free Software
\r
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\r
29 * @package Converters
\r
30 * @subpackage HTMLframes
\r
31 * @author Gregory Beaver <cellog@php.net>
\r
32 * @copyright 2002-2006 Gregory Beaver
\r
33 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
\r
34 * @version CVS: $Id: HTMLframesConverter.inc,v 1.16 2007/04/19 20:20:57 ashnazg Exp $
\r
36 * @link http://www.phpdoc.org
\r
37 * @link http://pear.php.net/PhpDocumentor
\r
38 * @see parserDocBlock, parserInclude, parserPage, parserClass
\r
39 * @see parserDefine, parserFunction, parserMethod, parserVar
\r
43 * HTML output converter.
\r
44 * This Converter takes output from the {@link Parser} and converts it to HTML-ready output for use with {@link Smarty}.
\r
46 * @package Converters
\r
47 * @subpackage HTMLframes
\r
48 * @see parserDocBlock, parserInclude, parserPage, parserClass, parserDefine, parserFunction, parserMethod, parserVar
\r
49 * @author Greg Beaver <cellog@php.net>
\r
51 * @version $Id: HTMLframesConverter.inc,v 1.16 2007/04/19 20:20:57 ashnazg Exp $
\r
53 class HTMLframesConverter extends Converter
\r
56 * This converter knows about the new root tree processing
\r
57 * In order to fix PEAR Bug #6389
\r
60 var $processSpecialRoots = true;
\r
62 * Smarty Converter wants elements sorted by type as well as alphabetically
\r
63 * @see Converter::$sort_page_contents_by_type
\r
66 var $sort_page_contents_by_type = true;
\r
68 var $outputformat = 'HTML';
\r
70 var $name = 'frames';
\r
72 * indexes of elements by package that need to be generated
\r
75 var $leftindex = array('classes' => true, 'pages' => true, 'functions' => true, 'defines' => false, 'globals' => false);
\r
78 * output directory for the current procedural page being processed
\r
84 * target directory passed on the command-line.
\r
85 * {@link $targetDir} is malleable, always adding package/ and package/subpackage/ subdirectories onto it.
\r
91 * output directory for the current class being processed
\r
97 * array of converted package page names.
\r
98 * Used to link to the package page in the left index
\r
99 * @var array Format: array(package => 1)
\r
101 var $package_pages = array();
\r
104 * controls formatting of parser informative output
\r
106 * Converter prints:
\r
107 * "Converting /path/to/file.php... Procedural Page Elements... Classes..."
\r
108 * Since HTMLdefaultConverter outputs files while converting, it needs to send a \n to start a new line. However, if there
\r
109 * is more than one class, output is messy, with multiple \n's just between class file output. This variable prevents that
\r
110 * and is purely cosmetic
\r
113 var $juststarted = false;
\r
116 * contains all of the template procedural page element loop data needed for the current template
\r
122 * contains all of the template class element loop data needed for the current template
\r
126 var $wrote = false;
\r
127 var $ric_set = array();
\r
130 * sets {@link $base_dir} to $targetDir
\r
133 function HTMLframesConverter(&$allp, &$packp, &$classes, &$procpages, $po, $pp, $qm, $targetDir, $templateDir, $title)
\r
135 Converter::Converter($allp, $packp, $classes, $procpages,$po, $pp, $qm, $targetDir, $templateDir, $title);
\r
136 $this->base_dir = $targetDir;
\r
140 * @deprecated in favor of PHP 4.3.0+ tokenizer-based source highlighting
\r
142 function unmangle($sourcecode)
\r
144 $sourcecode = str_replace('<code>','<pre>',$sourcecode);
\r
145 $sourcecode = str_replace('</code>','</pre>',$sourcecode);
\r
146 $sourcecode = str_replace('<br />',"\n",$sourcecode);
\r
147 $sourcecode = str_replace(' ',' ',$sourcecode);
\r
148 $sourcecode = str_replace('<','<',$sourcecode);
\r
149 $sourcecode = str_replace('>','>',$sourcecode);
\r
150 $sourcecode = str_replace('&','&',$sourcecode);
\r
151 return $sourcecode;
\r
155 * @param string full path to the source file
\r
156 * @param string fully highlighted source code
\r
158 function writeSource($path, $value)
\r
160 $templ = &$this->newSmarty();
\r
161 $pathinfo = $this->proceduralpages->getPathInfo($path, $this);
\r
162 $templ->assign('source',$value);
\r
163 $templ->assign('package',$pathinfo['package']);
\r
164 $templ->assign('subpackage',$pathinfo['subpackage']);
\r
165 $templ->assign('name',$pathinfo['name']);
\r
166 $templ->assign('source_loc',$pathinfo['source_loc']);
\r
167 $templ->assign('docs',$pathinfo['docs']);
\r
168 $templ->assign("subdir",'../');
\r
169 $templ->register_outputfilter('HTMLframes_outputfilter');
\r
170 $this->setTargetDir($this->getFileSourcePath($this->base_dir));
\r
171 phpDocumentor_out("\n");
\r
172 $this->setSourcePaths($path);
\r
173 $this->writefile($this->getFileSourceName($path).'.html',$templ->fetch('filesource.tpl'));
\r
176 function writeExample($title, $path, $source)
\r
178 $templ = &$this->newSmarty();
\r
179 $templ->assign('source',$source);
\r
182 $title = 'example';
\r
183 addWarning(PDERROR_EMPTY_EXAMPLE_TITLE, $path, $title);
\r
185 $templ->assign('title',$title);
\r
186 $templ->assign('file',$path);
\r
187 $templ->assign("subdir",'../');
\r
188 $templ->register_outputfilter('HTMLframes_outputfilter');
\r
189 $this->setTargetDir($this->base_dir . PATH_DELIMITER . '__examplesource');
\r
190 phpDocumentor_out("\n");
\r
191 $this->writefile('exsource_'.$path.'.html',$templ->fetch('examplesource.tpl'));
\r
194 function getExampleLink($path, $title)
\r
196 return $this->returnLink('{$subdir}__examplesource' . PATH_DELIMITER . 'exsource_'.$path.'.html',$title);
\r
199 function getSourceLink($path)
\r
201 return $this->returnLink('{$subdir}__filesource/' .
\r
202 $this->getFileSourceName($path).'.html','Source Code for this file');
\r
206 * Retrieve a Converter-specific anchor to a segment of a source code file
\r
207 * parsed via a {@tutorial tags.filesource.pkg} tag.
\r
208 * @param string full path to source file
\r
209 * @param string name of anchor
\r
210 * @param string link text, if this is a link
\r
211 * @param boolean returns either a link or a destination based on this
\r
213 * @return string link to an anchor, or the anchor
\r
215 function getSourceAnchor($sourcefile,$anchor,$text = '',$link = false)
\r
218 return $this->returnLink('{$subdir}__filesource/' .
\r
219 $this->getFileSourceName($sourcefile) . '.html#a' . $anchor, $text);
\r
221 return '<a name="a'.$anchor.'"></a>';
\r
226 * Return a line of highlighted source code with formatted line number
\r
228 * If the $path is a full path, then an anchor to the line number will be
\r
230 * @param integer line number
\r
231 * @param string highlighted source code line
\r
232 * @param false|string full path to @filesource file this line is a part of,
\r
233 * if this is a single line from a complete file.
\r
234 * @return string formatted source code line with line number
\r
236 function sourceLine($linenumber, $line, $path = false)
\r
239 if (strlen(str_replace("\n", '', $line)) == 0) {
\r
244 return '<li><div class="src-line">' . $this->getSourceAnchor($path, $linenumber) .
\r
245 str_replace("\n",'',$line) . $extra .
\r
249 return '<li><div class="src-line">' . str_replace("\n",'',$line) .
\r
250 "$extra</div></li>\n";
\r
255 * Used to convert the <<code>> tag in a docblock
\r
260 function ProgramExample($example, $tutorial = false, $inlinesourceparse = null/*false*/,
\r
261 $class = null/*false*/, $linenum = null/*false*/, $filesourcepath = null/*false*/)
\r
263 return '<div class="src-code"><ol>' . parent::ProgramExample($example, $tutorial, $inlinesourceparse, $class, $linenum, $filesourcepath)
\r
270 function TutorialExample($example)
\r
272 $trans = $this->template_options['desctranslate'];
\r
273 $this->template_options['desctranslate'] = array();
\r
274 $example = '<ol>' . parent::TutorialExample($example)
\r
276 $this->template_options['desctranslate'] = $trans;
\r
277 if (!isset($this->template_options['desctranslate'])) return $example;
\r
278 if (!isset($this->template_options['desctranslate']['code'])) return $example;
\r
279 $example = $this->template_options['desctranslate']['code'] . $example;
\r
280 if (!isset($this->template_options['desctranslate']['/code'])) return $example;
\r
281 return $example . $this->template_options['desctranslate']['/code'];
\r
284 function getCurrentPageLink()
\r
286 return $this->curname . '.html';
\r
290 * Uses htmlspecialchars() on the input
\r
292 function postProcess($text)
\r
294 if ($this->highlightingSource) {
\r
295 return str_replace(array(' ',"\t"), array(' ', ' '),
\r
296 htmlspecialchars($text));
\r
298 return htmlspecialchars($text);
\r
302 * Use the template tutorial_toc.tpl to generate a table of contents for HTML
\r
303 * @return string table of contents formatted for use in the current output format
\r
304 * @param array format: array(array('tagname' => section, 'link' => returnsee link, 'id' => anchor name, 'title' => from title tag),...)
\r
306 function formatTutorialTOC($toc)
\r
308 $template = &$this->newSmarty();
\r
309 $template->assign('toc',$toc);
\r
310 return $template->fetch('tutorial_toc.tpl');
\r
313 function &SmartyInit(&$templ)
\r
315 if (!isset($this->package_index))
\r
316 foreach($this->all_packages as $key => $val)
\r
318 if (isset($this->pkg_elements[$key]))
\r
320 if (!isset($start)) $start = $key;
\r
321 $this->package_index[] = array('link' => "li_$key.html", 'title' => $key);
\r
324 $templ->assign("packageindex",$this->package_index);
\r
325 $templ->assign("subdir",'');
\r
330 * Writes out the template file of {@link $class_data} and unsets the template to save memory
\r
331 * @see registerCurrentClass()
\r
332 * @see parent::endClass()
\r
334 function endClass()
\r
337 if (!empty($this->subpackage)) $a .= '../';
\r
338 if ($this->juststarted)
\r
340 $this->juststarted = false;
\r
341 phpDocumentor_out("\n");
\r
344 $this->setTargetDir($this->base_dir . PATH_DELIMITER . $this->class_dir);
\r
345 $this->class_data->assign("subdir",$a);
\r
346 $this->class_data->register_outputfilter('HTMLframes_outputfilter');
\r
347 $this->writefile($this->class . '.html',$this->class_data->fetch('class.tpl'));
\r
348 unset($this->class_data);
\r
352 * Writes out the template file of {@link $page_data} and unsets the template to save memory
\r
353 * @see registerCurrent()
\r
354 * @see parent::endPage()
\r
358 $this->package = $this->curpage->package;
\r
359 $this->subpackage = $this->curpage->subpackage;
\r
361 if (!empty($this->subpackage)) $a .= '../';
\r
362 $this->setTargetDir($this->base_dir . PATH_DELIMITER . $this->page_dir);
\r
363 $this->page_data->assign("package",$this->package);
\r
364 $this->page_data->assign("subdir",$a);
\r
365 $this->page_data->register_outputfilter('HTMLframes_outputfilter');
\r
366 $this->writefile($this->page . '.html',$this->page_data->fetch('page.tpl'));
\r
367 unset($this->page_data);
\r
373 * @return string <a href="'.$link.'">'.$text.'</a>
\r
375 function returnLink($link,$text)
\r
377 return '<a href="'.$link.'">'.$text.'</a>';
\r
380 function makeLeft()
\r
382 foreach($this->page_elements as $package => $o1)
\r
384 foreach($o1 as $subpackage => $links)
\r
386 for($i=0;$i<count($links);$i++)
\r
388 $left[$package][$subpackage]['files'][] =
\r
389 array("link" => $this->getId($links[$i]), "title" => $links[$i]->name);
\r
393 $interfaces = $classes = false;
\r
394 foreach($this->class_elements as $package => $o1)
\r
396 foreach($o1 as $subpackage => $links)
\r
398 for($i=0;$i<count($links);$i++)
\r
400 $class = $this->classes->getClassByPackage($links[$i]->name, $links[$i]->package);
\r
401 $isinterface = $isclass = false;
\r
402 if ($class->isInterface()) {
\r
403 $isinterface = true;
\r
404 $interfaces = true;
\r
409 if ($class && isset($class->docblock) && $class->docblock->hasaccess) {
\r
410 $left[$package][$subpackage]['classes'][] =
\r
411 array("link" => $this->getId($links[$i]),
\r
412 "title" => $links[$i]->name,
\r
413 'is_interface' => $isinterface,
\r
414 'is_class' => $isclass,
\r
415 "access" => $class->docblock->tags['access'][0]->value,
\r
416 "abstract" => isset ($class->docblock->tags['abstract'][0]));
\r
418 $left[$package][$subpackage]['classes'][] =
\r
419 array("link" => $this->getId($links[$i]),
\r
420 "title" => $links[$i]->name,
\r
421 'is_interface' => $isinterface,
\r
422 'is_class' => $isclass,
\r
423 "access" => 'public',
\r
424 "abstract" => isset ($class->docblock->tags['abstract'][0]));
\r
429 foreach($this->function_elements as $package => $o1)
\r
431 foreach($o1 as $subpackage => $links)
\r
433 for($i=0;$i<count($links);$i++)
\r
435 $left[$package][$subpackage]['functions'][] =
\r
436 array("link" => $this->getId($links[$i]), "title" => $links[$i]->name);
\r
441 foreach($left as $package => $r)
\r
444 if (isset($this->package_pages[$package])) $pd = $package.'/package_'.$package.'.html';
\r
445 if (!isset($r['']))
\r
450 if ($t = $this->hasTutorial('pkg',$package,$package,''))
\r
452 $pt = $t->getLink($this);
\r
453 $ptnoa = $this->getId($t->getLink($this,true));
\r
454 $ptt = $t->getTitle($this);
\r
457 foreach($this->tutorial_tree as $root => $tr)
\r
459 if ($tr['tutorial']->package == $package && $tr['tutorial']->subpackage == '') {
\r
460 $tutes[$tr['tutorial']->tutorial_type][] =
\r
461 $this->getTutorialTree($tr['tutorial']);
\r
464 if (isset($this->childless_tutorials[$package][$subpackage]))
\r
466 foreach($this->childless_tutorials[$package][$subpackage] as $ext => $other)
\r
468 foreach($other as $tutorial)
\r
470 $tutes[$tutorial->tutorial_type][] = $this->getTutorialTree($tutorial);
\r
476 'package' => $package,
\r
477 'subpackage' => '',
\r
478 'packagedoc' => $pd,
\r
479 'packagetutorial' => $pt,
\r
480 'packagetutorialnoa' => $ptnoa,
\r
481 'packagetutorialtitle' => $ptt,
\r
482 'files' => array(),
\r
483 'functions' => array(),
\r
484 'classes' => array(),
\r
485 'tutorials' => $tutes,
\r
488 foreach($r as $subpackage => $info)
\r
491 $my['package'] = $package;
\r
492 if (isset($this->package_pages[$package]))
\r
493 $my['packagedoc'] = $pd;
\r
495 $my['packagedoc'] = 'blank';
\r
496 $my['subpackage'] = $subpackage;
\r
497 if (empty($subpackage))
\r
499 if ($t = $this->hasTutorial('pkg',$package,$package,$subpackage))
\r
501 $my['packagetutorial'] = $t->getLink($this);
\r
502 $my['packagetutorialnoa'] = $this->getId($t->getLink($this,true));
\r
503 $my['packagetutorialtitle'] = $t->getTitle($this);
\r
506 $my['packagetutorial'] = '<a href="blank.html">No Package-Level Tutorial</a>';
\r
507 $my['packagetutorialnoa'] = 'blank.html';
\r
508 $my['packagetutorialtitle'] = $package;
\r
512 if ($t = $this->hasTutorial('pkg',$subpackage,$package,$subpackage))
\r
514 $my['subpackagetutorial'] = $this->returnSee($this->getTutorialLink($t));
\r
515 $my['subpackagetutorialnoa'] = $this->getId($t->getLink($this,true));
\r
516 $my['subpackagetutorialtitle'] = $t->getTitle($this);
\r
519 $my['subpackagetutorial'] = false;
\r
520 $my['subpackagetutorialnoa'] = false;
\r
521 $my['subpackagetutorialtitle'] = $subpackage;
\r
525 foreach($this->tutorial_tree as $root => $tr)
\r
527 if ($tr['tutorial']->package == $package && $tr['tutorial']->subpackage == $subpackage)
\r
529 $tutes[$tr['tutorial']->tutorial_type][] = $this->getTutorialTree($tr['tutorial']);
\r
532 $my['tutorials'] = $tutes;
\r
533 $my['files'] = $my['classes'] = $my['functions'] = array();
\r
534 if (isset($info['files']))
\r
535 $my['files'] = $info['files'];
\r
536 if (isset($info['classes']))
\r
537 $my['classes'] = $info['classes'];
\r
538 $my['hasclasses'] = $classes;
\r
539 $my['hasinterfaces'] = $interfaces;
\r
540 if (isset($info['functions']))
\r
541 $my['functions'] = $info['functions'];
\r
542 $ret[$package][] = $my;
\r
548 function getTutorialTree($tutorial,$k = false)
\r
551 if (is_object($tutorial)) $tree = parent::getTutorialTree($tutorial); else $tree = $tutorial;
\r
552 // debug($this->vardump_tree($tree));exit;
\r
555 $template = &$this->newSmarty();
\r
556 $template->assign('subtree',false);
\r
557 $template->assign('name',str_replace('.','',$tutorial->name));
\r
558 $template->assign('parent',false);
\r
559 $template->assign('haskids',false);
\r
560 $template->assign('kids','');
\r
561 $link = new tutorialLink;
\r
563 $link->addLink('',$t->path,$t->name,$t->package,$t->subpackage,$t->getTitle($this));
\r
564 $main = array('link' => $this->getId($link), 'title' => $link->title);
\r
565 $template->assign('main',$main);
\r
566 return $template->fetch('tutorial_tree.tpl');
\r
568 if (isset($tree['kids']))
\r
570 foreach($tree['kids'] as $subtree)
\r
572 $ret .= $this->getTutorialTree($subtree, true);
\r
575 $template = &$this->newSmarty();
\r
576 $template->assign('subtree',$k);
\r
577 $template->assign('name',str_replace('.','',$tree['tutorial']->name));
\r
578 $template->assign('parent',($k ? str_replace('.','',$tree['tutorial']->parent->name) : false));
\r
579 $template->assign('haskids',strlen($ret));
\r
580 $template->assign('kids',$ret);
\r
581 $link = new tutorialLink;
\r
582 $t = $tree['tutorial'];
\r
583 $link->addLink('',$t->path,$t->name,$t->package,$t->subpackage,$t->getTitle($this));
\r
584 $main = array('link' => $this->getId($link), 'title' => $link->title);
\r
585 $template->assign('main',$main);
\r
586 $ret = $template->fetch('tutorial_tree.tpl');
\r
591 * HTMLdefaultConverter chooses to format both package indexes and the complete index here
\r
593 * This function formats output for the elementindex.html and pkgelementindex.html template files. It then
\r
594 * writes them to the target directory
\r
595 * @see generateElementIndex(), generatePkgElementIndex()
\r
597 function formatPkgIndex()
\r
599 list($package_indexes,$packages,$mletters) = $this->generatePkgElementIndexes();
\r
600 for($i=0;$i<count($package_indexes);$i++)
\r
602 $template = &$this->newSmarty();
\r
603 $this->package = $package_indexes[$i]['package'];
\r
604 $this->subpackage = '';
\r
605 $template->assign("index",$package_indexes[$i]['pindex']);
\r
606 $template->assign("package",$package_indexes[$i]['package']);
\r
607 $template->assign("letters",$mletters[$package_indexes[$i]['package']]);
\r
608 $template->register_outputfilter('HTMLframes_outputfilter');
\r
609 $this->setTargetDir($this->base_dir);
\r
610 $this->writefile('elementindex_'.$package_indexes[$i]['package'].'.html',$template->fetch('pkgelementindex.tpl'));
\r
612 phpDocumentor_out("\n");
\r
617 * HTMLdefaultConverter uses this function to format template index.html and packages.html
\r
619 * This function generates the package list from {@link $all_packages}, eliminating any
\r
620 * packages that don't have any entries in their package index (no files at all, due to @ignore
\r
621 * or other factors). Then it uses the default package name as the first package index to display.
\r
622 * It sets the right pane to be either a blank file with instructions on making package-level docs,
\r
623 * or the package-level docs for the default package.
\r
624 * @global string Used to set the starting package to display
\r
626 function formatIndex()
\r
628 global $phpDocumentor_DefaultPackageName;
\r
629 list($elindex,$mletters) = $this->generateElementIndex();
\r
630 $template = &$this->newSmarty();
\r
631 $template->assign("index",$elindex);
\r
632 $template->assign("letters",$mletters);
\r
633 $template->register_outputfilter('HTMLframes_outputfilter');
\r
634 phpDocumentor_out("\n");
\r
636 $this->setTargetDir($this->base_dir);
\r
637 $this->writefile('elementindex.html',$template->fetch('elementindex.tpl'));
\r
638 usort($this->package_index,"HTMLframes_pindexcmp");
\r
639 $index = &$this->newSmarty();
\r
640 foreach($this->all_packages as $key => $val)
\r
642 if (isset($this->pkg_elements[$key]))
\r
644 if (!isset($start)) $start = $key;
\r
645 if (!isset($this->package_pages[$key])) $this->writeNewPPage($key);
\r
648 // Created index.html
\r
649 if (isset($this->pkg_elements[$phpDocumentor_DefaultPackageName])) $start = $phpDocumentor_DefaultPackageName;
\r
650 $this->package = $start;
\r
651 $this->subpackage = '';
\r
652 $index->assign("package_count",count($this->pkg_elements));
\r
653 if (count($this->ric_set))
\r
654 $index->assign("package_count",2);
\r
655 $index->assign("date",date("r",time()));
\r
656 $index->assign("title",$this->title);
\r
657 $index->assign("start","li_$start.html");
\r
658 $index->register_outputfilter('HTMLframes_outputfilter');
\r
659 if (isset($this->tutorials[$start]['']['pkg'][$start . '.pkg']))
\r
661 $index->assign("blank",$start.'/tutorial_'.$start.'.pkg');
\r
662 } elseif (isset($this->package_pages[$start]))
\r
664 $index->assign("blank",$start.'/package_'.$start);
\r
668 $index->assign("blank","blank");
\r
669 $blank = &$this->newSmarty();
\r
670 $blank->assign('package',$this->package);
\r
671 $this->setTargetDir($this->base_dir);
\r
672 $this->writefile("blank.html",$blank->fetch('blank.tpl'));
\r
674 phpDocumentor_out("\n");
\r
676 $this->setTargetDir($this->base_dir);
\r
677 $this->writefile("index.html",$index->fetch('index.tpl'));
\r
679 // Create package index
\r
680 $package = &$this->newSmarty();
\r
681 $package->assign('ric',array());
\r
682 if (isset($this->ric_set))
\r
684 foreach($this->ric_set as $name => $u)
\r
686 $package->append('ric',array('file' => 'ric_'.$name.'.html','name' => $name));
\r
689 $package->assign("packages",$this->package_index);
\r
690 $package->register_outputfilter('HTMLframes_outputfilter');
\r
691 $this->writefile("packages.html",$package->fetch('top_frame.tpl'));
\r
695 function writeNewPPage($key)
\r
698 $template = &$this->newSmarty();
\r
699 $this->package = $key;
\r
700 $this->subpackage = '';
\r
701 $template->assign("date",date("r",time()));
\r
702 $template->assign("title",$this->title);
\r
703 $template->assign("package",$key);
\r
704 $template->register_outputfilter('HTMLframes_outputfilter');
\r
705 phpDocumentor_out("\n");
\r
707 $this->setTargetDir($this->base_dir);
\r
709 $this->writefile("li_$key.html",$template->fetch('index.tpl'));
\r
714 * Generate indexes for li_package.html and classtree output files
\r
716 * This function generates the li_package.html files from the template file left.html. It does this by
\r
717 * iterating through each of the $page_elements, $class_elements and $function_elements arrays to retrieve
\r
718 * the pre-sorted {@link abstractLink} descendants needed for index generation. Conversion of these links to
\r
719 * text is done by {@link returnSee()}. The {@link $local} parameter is set to false to ensure that paths are correct.
\r
721 * Then it uses {@link generateFormattedClassTrees()} to create class trees from the template file classtrees.html. Output
\r
722 * filename is classtrees_packagename.html. This function also unsets {@link $elements} and {@link $pkg_elements} to free
\r
723 * up the considerable memory these two class vars use
\r
724 * @see $page_elements, $class_elements, $function_elements
\r
726 function formatLeftIndex()
\r
728 phpDocumentor_out("\n");
\r
730 $this->setTargetDir($this->base_dir);
\r
731 if (0)//!isset($this->left))
\r
733 debug("Nothing parsed, check the command-line");
\r
736 $x = $this->makeLeft();
\r
737 foreach($this->all_packages as $package => $rest)
\r
739 if (!isset($this->pkg_elements[$package])) continue;
\r
740 $template = &$this->newSmarty();
\r
741 $template->assign("info",$x[$package]);
\r
742 $template->assign('package',$package);
\r
743 $template->assign("hastutorials",isset($this->tutorials[$package]));
\r
744 $template->assign('hastodos',count($this->todoList));
\r
745 $template->assign('todolink','todolist.html');
\r
746 $template->assign("classtreepage","classtrees_$package");
\r
747 $template->assign("elementindex","elementindex_$package");
\r
748 $template->register_outputfilter('HTMLframes_outputfilter');
\r
749 if (isset($this->package_pages[$package]))
\r
751 $template->assign("packagedoc",$package.'/package_' . $package . '.html');
\r
754 $template->assign("packagedoc",false);
\r
756 $this->writefile("li_$package.html",$template->fetch('left_frame.tpl'));
\r
758 // Create class tree page
\r
759 $template = &$this->newSmarty();
\r
760 $template->assign("classtrees",$this->generateFormattedClassTrees($package));
\r
761 $template->assign("interfaces",$this->generateFormattedInterfaceTrees($package));
\r
762 $template->assign("package",$package);
\r
763 $template->register_outputfilter('HTMLframes_outputfilter');
\r
764 $this->writefile("classtrees_$package.html",$template->fetch('classtrees.tpl'));
\r
765 phpDocumentor_out("\n");
\r
768 // free up considerable memory
\r
769 unset($this->elements);
\r
770 unset($this->pkg_elements);
\r
774 * This function takes an {@link abstractLink} descendant and returns an html link
\r
776 * @param abstractLink a descendant of abstractlink should be passed, and never text
\r
777 * @param string text to display in the link
\r
778 * @param boolean this parameter is not used, and is deprecated
\r
779 * @param boolean determines whether the returned text is enclosed in an <a> tag
\r
781 function returnSee(&$element, $eltext = false, $with_a = true)
\r
783 if (!is_object($element) || !$element) return false;
\r
784 if (!$with_a) return $this->getId($element, false);
\r
788 switch($element->type)
\r
791 $eltext = strip_tags($element->title);
\r
796 $eltext .= $element->class.'::';
\r
803 $eltext .= $element->name;
\r
804 if ($element->type == 'function' || $element->type == 'method') $eltext .= '()';
\r
808 return '<a href="'.$this->getId($element).'">'.$eltext.'</a>';
\r
811 function getId($element, $fullpath = true)
\r
813 if (phpDocumentor_get_class($element) == 'parserdata')
\r
815 $element = $this->addLink($element->parent);
\r
816 $elp = $element->parent;
\r
817 } elseif (is_a($element, 'parserbase'))
\r
820 $element = $this->addLink($element);
\r
823 if (!empty($element->subpackage))
\r
825 $c = '/'.$element->subpackage;
\r
828 switch ($element->type)
\r
832 return $b.$element->package.$c.'/'.$element->fileAlias.'.html';
\r
839 return $b.$element->package.$c.'/'.$element->fileAlias.'.html#'.$element->type.$element->name;
\r
840 return $element->type.$element->name;
\r
844 return $b.$element->package.$c.'/'.$element->name.'.html';
\r
851 return $b.$element->package.$c.'/'.$element->class.'.html#'.$element->type.$element->name;
\r
852 return $element->type.$element->name;
\r
856 if ($element->section)
\r
858 $d = '#'.$element->section;
\r
860 return $b.$element->package.$c.'/tutorial_'.$element->name.'.html'.$d;
\r
865 * Convert README/INSTALL/CHANGELOG file contents to output format
\r
866 * @param README|INSTALL|CHANGELOG
\r
867 * @param string contents of the file
\r
869 function Convert_RIC($name, $contents)
\r
871 $template = &$this->newSmarty();
\r
872 $template->assign('contents',$contents);
\r
873 $template->assign('name',$name);
\r
874 $this->setTargetDir($this->base_dir);
\r
875 $this->writefile('ric_'.$name . '.html',$template->fetch('ric.tpl'));
\r
876 $this->ric_set[$name] = true;
\r
879 function ConvertTodoList()
\r
881 $todolist = array();
\r
882 foreach($this->todoList as $package => $alltodos)
\r
884 foreach($alltodos as $todos)
\r
886 $converted = array();
\r
887 $converted['link'] = $this->returnSee($todos[0]);
\r
888 if (!is_array($todos[1]))
\r
890 $converted['todos'][] = $todos[1]->Convert($this);
\r
893 foreach($todos[1] as $todo)
\r
895 $converted['todos'][] = $todo->Convert($this);
\r
898 $todolist[$package][] = $converted;
\r
901 $templ = &$this->newSmarty();
\r
902 $templ->assign('todos',$todolist);
\r
903 $templ->register_outputfilter('HTMLframes_outputfilter');
\r
904 $this->setTargetDir($this->base_dir);
\r
905 $this->writefile('todolist.html',$templ->fetch('todolist.tpl'));
\r
909 * Create errors.html template file output
\r
911 * This method takes all parsing errors and warnings and spits them out ordered by file and line number.
\r
912 * @global ErrorTracker We'll be using it's output facility
\r
914 function ConvertErrorLog()
\r
916 global $phpDocumentor_errors;
\r
917 $allfiles = array();
\r
919 $warnings = $phpDocumentor_errors->returnWarnings();
\r
920 $errors = $phpDocumentor_errors->returnErrors();
\r
921 $template = &$this->newSmarty();
\r
922 foreach($warnings as $warning)
\r
925 $linenum = 'Warning';
\r
926 if ($warning->file)
\r
928 $file = $warning->file;
\r
929 $allfiles[$file] = 1;
\r
930 $linenum .= ' on line '.$warning->linenum;
\r
932 $files[$file]['warnings'][] = array('name' => $linenum, 'listing' => $warning->data);
\r
934 foreach($errors as $error)
\r
937 $linenum = 'Error';
\r
940 $file = $error->file;
\r
941 $allfiles[$file] = 1;
\r
942 $linenum .= ' on line '.$error->linenum;
\r
944 $files[$file]['errors'][] = array('name' => $linenum, 'listing' => $error->data);
\r
948 foreach($allfiles as $file => $num)
\r
953 usort($allfiles,'strnatcasecmp');
\r
954 $allfiles[0] = "Post-parsing";
\r
955 foreach($allfiles as $i => $a)
\r
957 $allfiles[$i] = array('file' => $a);
\r
960 foreach($files as $file => $data)
\r
962 if ($file == '##none') $file = 'Post-parsing';
\r
963 $out[$file] = $data;
\r
965 $template->assign("files",$allfiles);
\r
966 $template->assign("all",$out);
\r
967 $template->assign("title","phpDocumentor Parser Errors and Warnings");
\r
968 $this->setTargetDir($this->base_dir);
\r
969 $this->writefile("errors.html",$template->fetch('errors.tpl'));
\r
971 phpDocumentor_out("\n\nTo view errors and warnings, look at ".$this->base_dir. PATH_DELIMITER . "errors.html\n");
\r
975 function getTutorialId($package,$subpackage,$tutorial,$id)
\r
980 function getCData($value)
\r
982 return '<pre>'.htmlentities($value).'</pre>';
\r
986 * Converts package page and sets its package as used in {@link $package_pages}
\r
987 * @param parserPackagePage
\r
989 function convertPackagepage(&$element)
\r
991 phpDocumentor_out("\n");
\r
993 $this->package = $element->package;
\r
994 $this->subpackage = '';
\r
995 $contents = $element->Convert($this);
\r
996 $this->package_pages[$element->package] = str_replace('{$subdir}','../',$contents);
\r
997 phpDocumentor_out("\n");
\r
999 $this->setTargetDir($this->base_dir . PATH_DELIMITER . $element->package);
\r
1000 $this->writeFile('package_'.$element->package.'.html',str_replace('{$subdir}','../',$contents));
\r
1004 * @param parserTutorial
\r
1006 function convertTutorial(&$element)
\r
1008 phpDocumentor_out("\n");
\r
1010 $template = &parent::convertTutorial($element);
\r
1012 if ($element->subpackage) $a .= '../';
\r
1013 $template->assign('subdir',$a);
\r
1014 $template->register_outputfilter('HTMLframes_outputfilter');
\r
1015 $contents = $template->fetch('tutorial.tpl');
\r
1017 if ($element->subpackage) $a = PATH_DELIMITER . $element->subpackage;
\r
1018 phpDocumentor_out("\n");
\r
1020 $this->setTargetDir($this->base_dir . PATH_DELIMITER . $element->package . $a);
\r
1021 $this->writeFile('tutorial_'.$element->name.'.html',$contents);
\r
1025 * Converts class for template output
\r
1026 * @see prepareDocBlock(), generateChildClassList(), generateFormattedClassTree(), getFormattedConflicts()
\r
1027 * @see getFormattedInheritedMethods(), getFormattedInheritedVars()
\r
1028 * @param parserClass
\r
1030 function convertClass(&$element)
\r
1032 parent::convertClass($element);
\r
1033 $this->class_dir = $element->docblock->package;
\r
1034 if (!empty($element->docblock->subpackage)) $this->class_dir .= PATH_DELIMITER . $element->docblock->subpackage;
\r
1036 if ($element->docblock->subpackage != '') $a = "../$a";
\r
1038 $this->class_data->assign('subdir',$a);
\r
1039 $this->class_data->assign("title","Docs For Class " . $element->getName());
\r
1040 $this->class_data->assign("page",$element->getName() . '.html');
\r
1044 * Converts class variables for template output
\r
1045 * @see prepareDocBlock(), getFormattedConflicts()
\r
1046 * @param parserDefine
\r
1048 function convertVar(&$element)
\r
1050 parent::convertVar($element, array('var_dest' => $this->getId($element,false)));
\r
1054 * Converts class variables for template output
\r
1055 * @see prepareDocBlock(), getFormattedConflicts()
\r
1056 * @param parserDefine
\r
1058 function convertConst(&$element)
\r
1060 parent::convertConst($element, array('const_dest' => $this->getId($element,false)));
\r
1064 * Converts class methods for template output
\r
1065 * @see prepareDocBlock(), getFormattedConflicts()
\r
1066 * @param parserDefine
\r
1068 function convertMethod(&$element)
\r
1070 parent::convertMethod($element, array('method_dest' => $this->getId($element,false)));
\r
1074 * Converts function for template output
\r
1075 * @see prepareDocBlock(), parserFunction::getFunctionCall(), getFormattedConflicts()
\r
1076 * @param parserFunction
\r
1078 function convertFunction(&$element)
\r
1080 $funcloc = $this->getId($this->addLink($element));
\r
1081 parent::convertFunction($element,array('function_dest' => $this->getId($element,false)));
\r
1085 * Converts include elements for template output
\r
1086 * @see prepareDocBlock()
\r
1087 * @param parserInclude
\r
1089 function convertInclude(&$element)
\r
1091 parent::convertInclude($element, array('include_file' => '_'.strtr($element->getValue(),array('"' => '', "'" => '','.' => '_'))));
\r
1095 * Converts defines for template output
\r
1096 * @see prepareDocBlock(), getFormattedConflicts()
\r
1097 * @param parserDefine
\r
1099 function convertDefine(&$element)
\r
1101 parent::convertDefine($element, array('define_link' => $this->getId($element,false)));
\r
1105 * Converts global variables for template output
\r
1106 * @param parserGlobal
\r
1108 function convertGlobal(&$element)
\r
1110 parent::convertGlobal($element, array('global_link' => $this->getId($element,false)));
\r
1114 * converts procedural pages for template output
\r
1115 * @see prepareDocBlock(), getClassesOnPage()
\r
1116 * @param parserData
\r
1118 function convertPage(&$element)
\r
1120 parent::convertPage($element);
\r
1121 $this->juststarted = true;
\r
1122 $this->page_dir = $element->parent->package;
\r
1123 if (!empty($element->parent->subpackage)) $this->page_dir .= PATH_DELIMITER . $element->parent->subpackage;
\r
1124 // registering stuff on the template
\r
1125 $this->page_data->assign("page",$this->getPageName($element) . '.html');
\r
1126 $this->page_data->assign("title","Docs for page ".$element->parent->getFile());
\r
1129 function getPageName(&$element)
\r
1131 if (phpDocumentor_get_class($element) == 'parserpage') return '_'.$element->getName();
\r
1132 return '_'.$element->parent->getName();
\r
1136 * returns an array containing the class inheritance tree from the root object to the class
\r
1138 * @param parserClass class variable
\r
1139 * @return array Format: array(root,child,child,child,...,$class)
\r
1140 * @uses parserClass::getParentClassTree()
\r
1143 function generateFormattedClassTree($class)
\r
1145 $tree = $class->getParentClassTree($this);
\r
1147 if (count($tree) - 1)
\r
1149 $result = array($class->getName());
\r
1150 $parent = $tree[$class->getName()];
\r
1155 if (is_object($parent))
\r
1157 $subpackage = $parent->docblock->subpackage;
\r
1158 $package = $parent->docblock->package;
\r
1160 $x = $parent->getLink($this);
\r
1161 if (!$x) $x = $parent->getName();
\r
1168 if (is_object($parent))
\r
1169 $parent = $tree[$parent->getName()];
\r
1170 elseif (isset($tree[$parent]))
\r
1171 $parent = $tree[$parent];
\r
1174 for($i=count($result) - 1;$i>=0;$i--)
\r
1177 for($j=0;$j<count($result) - $i;$j++) $my_nbsp .= $nbsp;
\r
1178 $distance[$i] = sprintf($distance[$i],$my_nbsp,$my_nbsp);
\r
1180 return array('classes'=>array_reverse($result),'distance'=>array_reverse($distance));
\r
1183 return array('classes'=>$class->getName(),'distance'=>array(''));
\r
1187 /** @access private */
\r
1188 function sortVar($a, $b)
\r
1190 return strnatcasecmp($a->getName(),$b->getName());
\r
1193 /** @access private */
\r
1194 function sortMethod($a, $b)
\r
1196 if ($a->isConstructor) return -1;
\r
1197 if ($b->isConstructor) return 1;
\r
1198 return strnatcasecmp($a->getName(),$b->getName());
\r
1202 * returns a template-enabled array of class trees
\r
1204 * @param string $package package to generate a class tree for
\r
1205 * @see $roots, HTMLConverter::getRootTree()
\r
1207 function generateFormattedClassTrees($package)
\r
1209 if (!isset($this->roots['normal'][$package]) &&
\r
1210 !isset($this->roots['special'][$package])) {
\r
1214 if (isset($this->roots['normal'][$package])) {
\r
1215 $roots = $this->roots['normal'][$package];
\r
1216 for($i=0;$i<count($roots);$i++)
\r
1218 $root = $this->classes->getClassByPackage($roots[$i], $package);
\r
1219 if ($root && $root->isInterface()) {
\r
1222 $trees[] = array('class' => $roots[$i],'class_tree' => "<ul>\n".$this->getRootTree($this->getSortedClassTreeFromClass($roots[$i],$package,''),$package)."</ul>\n");
\r
1225 if (isset($this->roots['special'][$package])) {
\r
1226 $roots = $this->roots['special'][$package];
\r
1227 foreach ($roots as $parent => $classes) {
\r
1229 foreach ($classes as $classinfo) {
\r
1230 $root = $this->classes->getClassByPackage($classinfo, $package);
\r
1231 if ($root && $root->isInterface()) {
\r
1235 $this->getRootTree(
\r
1236 $this->getSortedClassTreeFromClass(
\r
1247 'class' => $parent,
\r
1248 'class_tree' => "<ul>\n" . $thistree . "</ul>\n"
\r
1256 * returns a template-enabled array of interface inheritance trees
\r
1258 * @param string $package package to generate a class tree for
\r
1259 * @see $roots, HTMLConverter::getRootTree()
\r
1261 function generateFormattedInterfaceTrees($package)
\r
1263 if (!isset($this->roots['normal'][$package]) &&
\r
1264 !isset($this->roots['special'][$package])) {
\r
1268 if (isset($this->roots['normal'][$package])) {
\r
1269 $roots = $this->roots['normal'][$package];
\r
1270 for($i=0;$i<count($roots);$i++)
\r
1272 $root = $this->classes->getClassByPackage($roots[$i], $package);
\r
1273 if ($root && !$root->isInterface()) {
\r
1276 $trees[] = array('class' => $roots[$i],'class_tree' => "<ul>\n".$this->getRootTree($this->getSortedClassTreeFromClass($roots[$i],$package,''),$package)."</ul>\n");
\r
1279 if (isset($this->roots['special'][$package])) {
\r
1280 $roots = $this->roots['special'][$package];
\r
1281 foreach ($roots as $parent => $classes) {
\r
1283 foreach ($classes as $classinfo) {
\r
1284 $root = $this->classes->getClassByPackage($classinfo, $package);
\r
1285 if ($root && !$root->isInterface()) {
\r
1289 $this->getRootTree(
\r
1290 $this->getSortedClassTreeFromClass(
\r
1301 'class' => $parent,
\r
1302 'class_tree' => "<ul>\n" . $thistree . "</ul>\n"
\r
1310 * return formatted class tree for the Class Trees page
\r
1312 * @param array $tree output from {@link getSortedClassTreeFromClass()}
\r
1313 * @param string $package package
\r
1314 * @param boolean $nounknownparent if true, an object's parent will not be checked
\r
1315 * @see Classes::$definitechild, generateFormattedClassTrees()
\r
1318 function getRootTree($tree, $package, $noparent = false)
\r
1320 if (!$tree) return '';
\r
1323 $lastcur = array(false);
\r
1326 if (!$noparent && $tree[$cur]['parent'])
\r
1329 if (!is_object($tree[$cur]['parent']))
\r
1331 // debug("parent ".$tree[$cur]['parent']." not found");
\r
1332 $my_tree .= '<li>' . $tree[$cur]['parent'] .'<ul>';
\r
1336 // debug("parent ".$this->returnSee($tree[$cur]['parent'])." in other package");
\r
1337 $root = $this->classes->getClassByPackage($tree[$cur]['parent']->name,
\r
1339 $my_tree .= '<li>' . $this->returnSee($tree[$cur]['parent']);
\r
1340 if ($tree[$cur]['parent']->package != $package) $my_tree .= ' <b>(Different package)</b><ul>';
\r
1345 // fancy_debug($cur,$lastcur,$kids);
\r
1346 if (count($tree[$cur]['children']))
\r
1348 // debug("$cur has children");
\r
1349 if (!isset($kids[$cur]))
\r
1351 // debug("set $cur kids");
\r
1353 $root = $this->classes->getClassByPackage(
\r
1354 $tree[$cur]['link']->name,
\r
1355 $tree[$cur]['link']->package);
\r
1356 if ($implements = $root->getImplements()) {
\r
1357 $my_tree .= '<li>'.$this->returnSee($tree[$cur]['link']) .
\r
1359 foreach ($implements as $i => $interface) {
\r
1360 if ($i && $i != count($implements) - 1) $my_tree .= ', ';
\r
1361 if ($link = $this->getLink('object ' . $interface)) {
\r
1362 $my_tree .= $this->returnSee($link);
\r
1364 $my_tree .= $interface;
\r
1369 $my_tree .= '<li>'.$this->returnSee($tree[$cur]['link']);
\r
1371 $my_tree .= '<ul>'."\n";
\r
1373 array_push($lastcur,$cur);
\r
1374 list(,$cur) = each($tree[$cur]['children']);
\r
1375 // var_dump('listed',$cur);
\r
1378 $cur = $cur['package'] . '#' . $cur['class'];
\r
1379 // debug("set cur to child $cur");
\r
1380 // $my_tree .= '<li>'.$this->returnSee($tree[$cur]['link']);
\r
1384 // debug("end of children for $cur");
\r
1385 $cur = array_pop($lastcur);
\r
1386 $cur = array_pop($lastcur);
\r
1387 $my_tree .= '</ul></li>'."\n";
\r
1388 if ($dopar && ($cur == '#root' || !$cur)) $my_tree .= '</ul></li>';
\r
1392 // debug("$cur has no children");
\r
1393 $my_tree .= '<li>'.$this->returnSee($tree[$cur]['link'])."</li>";
\r
1394 if ($dopar && $cur == '#root') $my_tree .= '</ul></li>';
\r
1395 $cur = array_pop($lastcur);
\r
1402 * Generate indexing information for given element
\r
1404 * @param parserElement descendant of parserElement
\r
1405 * @see generateElementIndex()
\r
1408 function getIndexInformation($elt)
\r
1410 $Result['type'] = $elt->type;
\r
1411 $Result['file_name'] = $elt->file;
\r
1412 $Result['path'] = $elt->getPath();
\r
1414 if (isset($elt->docblock))
\r
1416 $Result['description'] = $elt->docblock->getSDesc($this);
\r
1418 if ($elt->docblock->hasaccess)
\r
1419 $Result['access'] = $elt->docblock->tags['access'][0]->value;
\r
1421 $Result['access'] = 'public';
\r
1423 $Result['abstract'] = isset ($elt->docblock->tags['abstract'][0]);
\r
1426 $Result['description'] = '';
\r
1428 $aa = $Result['description'];
\r
1429 if (!empty($aa)) $aa = "<br> $aa";
\r
1431 switch($elt->type)
\r
1434 $Result['name'] = $elt->getName();
\r
1435 $Result['title'] = 'Class';
\r
1436 $Result['link'] = $this->getClassLink($elt->getName(),
\r
1437 $elt->docblock->package,
\r
1440 $Result['listing'] = 'in file '.$elt->file.', class '.$Result['link']."$aa";
\r
1443 $Result['name'] = $elt->getName();
\r
1444 $Result['title'] = 'Constant';
\r
1445 $Result['link'] = $this->getDefineLink($elt->getName(),
\r
1446 $elt->docblock->package,
\r
1449 $Result['listing'] = 'in file '.$elt->file.', constant '.$Result['link']."$aa";
\r
1452 $Result['name'] = $elt->getName();
\r
1453 $Result['title'] = 'Global';
\r
1454 $Result['link'] = $this->getGlobalLink($elt->getName(),
\r
1455 $elt->docblock->package,
\r
1458 $Result['listing'] = 'in file '.$elt->file.', global variable '.$Result['link']."$aa";
\r
1461 $Result['name'] = $elt->getName();
\r
1462 $Result['title'] = 'Function';
\r
1463 $Result['link'] = $this->getFunctionLink($elt->getName(),
\r
1464 $elt->docblock->package,
\r
1466 $elt->getName().'()');
\r
1467 $Result['listing'] = 'in file '.$elt->file.', function '.$Result['link']."$aa";
\r
1470 $Result['name'] = $elt->getName();
\r
1471 $Result['title'] = 'Method';
\r
1472 $Result['link'] = $this->getMethodLink($elt->getName(),
\r
1474 $elt->docblock->package,
\r
1476 $elt->class.'::'.$elt->getName().'()'
\r
1478 if ($elt->isConstructor) $Result['constructor'] = 1;
\r
1479 $Result['listing'] = 'in file '.$elt->file.', method '.$Result['link']."$aa";
\r
1482 $Result['name'] = $elt->getName();
\r
1483 $Result['title'] = 'Variable';
\r
1484 $Result['link'] = $this->getVarLink($elt->getName(),
\r
1486 $elt->docblock->package,
\r
1488 $elt->class.'::'.$elt->getName());
\r
1489 $Result['listing'] = 'in file '.$elt->file.', variable '.$Result['link']."$aa";
\r
1492 $Result['name'] = $elt->getName();
\r
1493 $Result['title'] = 'Class Constant';
\r
1494 $Result['link'] = $this->getConstLink($elt->getName(),
\r
1496 $elt->docblock->package,
\r
1498 $elt->class.'::'.$elt->getName());
\r
1499 $Result['listing'] = 'in file '.$elt->file.', class constant '.$Result['link']."$aa";
\r
1502 $Result['name'] = $elt->getFile();
\r
1503 $Result['title'] = 'Page';
\r
1504 $Result['link'] = $this->getPageLink($elt->getFile(),
\r
1508 $Result['listing'] = 'procedural page '.$Result['link'];
\r
1511 $Result['name'] = $elt->getName();
\r
1512 $Result['title'] = 'Include';
\r
1513 $Result['link'] = $elt->getValue();
\r
1514 $Result['listing'] = 'include '.$Result['name'];
\r
1521 * Generate alphabetical index of all elements
\r
1523 * @see $elements, walk()
\r
1525 function generateElementIndex()
\r
1527 $elementindex = array();
\r
1528 $letters = array();
\r
1530 foreach($this->elements as $letter => $nutoh)
\r
1532 foreach($this->elements[$letter] as $i => $yuh)
\r
1534 if ($this->elements[$letter][$i]->type != 'include')
\r
1536 if (!isset($used[$letter]))
\r
1538 $letters[]['letter'] = $letter;
\r
1539 $elindex['letter'] = $letter;
\r
1540 $used[$letter] = 1;
\r
1543 $elindex['index'][] = $this->getIndexInformation($this->elements[$letter][$i]);
\r
1546 if (isset($elindex['index']))
\r
1548 $elementindex[] = $elindex;
\r
1551 unset($letters[count($letters) - 1]);
\r
1553 $elindex = array();
\r
1555 return array($elementindex,$letters);
\r
1558 function copyMediaRecursively($media,$targetdir,$subdir = '')
\r
1560 $versionControlDirectories = array ('CVS', 'media/CVS', 'media\\CVS', '.svn', 'media/.svn', 'media\\.svn');
\r
1561 if (!is_array($media)) {
\r
1564 foreach($media as $dir => $files)
\r
1568 $this->copyMediaRecursively($files,$targetdir);
\r
1571 if (!is_numeric($dir))
\r
1573 if (in_array($dir, $versionControlDirectories))
\r
1575 // skip it entirely
\r
1579 // create the subdir
\r
1580 phpDocumentor_out("creating $targetdir" . PATH_DELIMITER . "$dir\n");
\r
1581 Converter::setTargetDir($targetdir . PATH_DELIMITER . $dir);
\r
1582 if (!empty($subdir))
\r
1584 $subdir .= PATH_DELIMITER;
\r
1586 $this->copyMediaRecursively($files,"$targetdir/$dir",$subdir . $dir);
\r
1592 phpDocumentor_out("copying $targetdir" . PATH_DELIMITER . $files['file']."\n");
\r
1593 $this->copyFile($files['file'],$subdir);
\r
1600 * calls the converter setTargetDir, and then copies any template images and the stylesheet if they haven't been copied
\r
1601 * @see Converter::setTargetDir()
\r
1603 function setTargetDir($dir)
\r
1605 Converter::setTargetDir($dir);
\r
1606 if ($this->wrote) return;
\r
1607 $this->wrote = true;
\r
1608 $template_images = array();
\r
1609 $stylesheets = array();
\r
1611 $dir = $this->templateDir;
\r
1612 $this->templateDir = $this->templateDir.'templates/';
\r
1614 $this->copyMediaRecursively($info->getDirTree($this->templateDir.'media',$this->templateDir),$tdir);
\r
1618 * Generate alphabetical index of all elements by package and subpackage
\r
1620 * @param string $package name of a package
\r
1621 * @see $pkg_elements, walk(), generatePkgElementIndexes()
\r
1623 function generatePkgElementIndex($package)
\r
1625 // var_dump($this->pkg_elements[$package]);
\r
1626 $elementindex = array();
\r
1627 $letters = array();
\r
1628 $letterind = array();
\r
1631 foreach($this->pkg_elements[$package] as $subpackage => $els)
\r
1633 if (empty($els)) continue;
\r
1634 if (!empty($subpackage)) $subp = " (<b>subpackage:</b> $subpackage)"; else $subp = '';
\r
1635 foreach($els as $letter => $yuh)
\r
1637 foreach($els[$letter] as $i => $yuh)
\r
1639 if ($els[$letter][$i]->type != 'include')
\r
1641 if (!isset($used[$letter]))
\r
1643 $letters[]['letter'] = $letter;
\r
1644 $letterind[$letter] = count($letters) - 1;
\r
1645 $used[$letter] = 1;
\r
1647 $elindex[$letter]['letter'] = $letter;
\r
1649 $elindex[$letter]['index'][] = $this->getIndexInformation($els[$letter][$i]);
\r
1655 usort($letters,'HTMLframes_lettersort');
\r
1656 if (isset($elindex))
\r
1658 while(list($letter,$tempel) = each($elindex))
\r
1660 if (!isset($tempel))
\r
1662 unset($letters[$letterind[$tempel['letter']]]);
\r
1664 $elementindex[] = $tempel;
\r
1666 } else $letters = array();
\r
1667 return array($elementindex,$letters);
\r
1672 * @see generatePkgElementIndex()
\r
1674 function generatePkgElementIndexes()
\r
1676 $packages = array();
\r
1677 $package_names = array();
\r
1679 $letters = array();
\r
1680 foreach($this->pkg_elements as $package => $trash)
\r
1682 $pkgs['package'] = $package;
\r
1683 $pkg['package'] = $package;
\r
1684 list($pkg['pindex'],$letters[$package]) = $this->generatePkgElementIndex($package);
\r
1685 if (count($pkg['pindex']))
\r
1687 $packages[] = $pkg;
\r
1688 $package_names[] = $pkgs;
\r
1693 foreach($packages as $i => $package)
\r
1695 $pnames = array();
\r
1696 for($j=0;$j<count($package_names);$j++)
\r
1698 if ($package_names[$j]['package'] != $package['package']) $pnames[] = $package_names[$j];
\r
1700 $packages[$i]['packageindexes'] = $pnames;
\r
1702 return array($packages,$package_names,$letters);
\r
1706 * @param string name of class
\r
1707 * @param string package name
\r
1708 * @param string full path to look in (used in index generation)
\r
1709 * @param boolean deprecated
\r
1710 * @param boolean return just the URL, or enclose it in an html a tag
\r
1711 * @return mixed false if not found, or an html a link to the class's documentation
\r
1712 * @see parent::getClassLink()
\r
1714 function getClassLink($expr,$package, $file = false,$text = false, $with_a = true)
\r
1716 $a = Converter::getClassLink($expr,$package,$file);
\r
1717 if (!$a) return false;
\r
1718 return $this->returnSee($a, $text, $with_a);
\r
1722 * @param string name of function
\r
1723 * @param string package name
\r
1724 * @param string full path to look in (used in index generation)
\r
1725 * @param boolean deprecated
\r
1726 * @param boolean return just the URL, or enclose it in an html a tag
\r
1727 * @return mixed false if not found, or an html a link to the function's documentation
\r
1728 * @see parent::getFunctionLink()
\r
1730 function getFunctionLink($expr,$package, $file = false,$text = false)
\r
1732 $a = Converter::getFunctionLink($expr,$package,$file);
\r
1733 if (!$a) return false;
\r
1734 return $this->returnSee($a, $text);
\r
1738 * @param string name of define
\r
1739 * @param string package name
\r
1740 * @param string full path to look in (used in index generation)
\r
1741 * @param boolean deprecated
\r
1742 * @param boolean return just the URL, or enclose it in an html a tag
\r
1743 * @return mixed false if not found, or an html a link to the define's documentation
\r
1744 * @see parent::getDefineLink()
\r
1746 function getDefineLink($expr,$package, $file = false,$text = false)
\r
1748 $a = Converter::getDefineLink($expr,$package,$file);
\r
1749 if (!$a) return false;
\r
1750 return $this->returnSee($a, $text);
\r
1754 * @param string name of global variable
\r
1755 * @param string package name
\r
1756 * @param string full path to look in (used in index generation)
\r
1757 * @param boolean deprecated
\r
1758 * @param boolean return just the URL, or enclose it in an html a tag
\r
1759 * @return mixed false if not found, or an html a link to the global variable's documentation
\r
1760 * @see parent::getGlobalLink()
\r
1762 function getGlobalLink($expr,$package, $file = false,$text = false)
\r
1764 $a = Converter::getGlobalLink($expr,$package,$file);
\r
1765 if (!$a) return false;
\r
1766 return $this->returnSee($a, $text);
\r
1770 * @param string name of procedural page
\r
1771 * @param string package name
\r
1772 * @param string full path to look in (used in index generation)
\r
1773 * @param boolean deprecated
\r
1774 * @param boolean return just the URL, or enclose it in an html a tag
\r
1775 * @return mixed false if not found, or an html a link to the procedural page's documentation
\r
1776 * @see parent::getPageLink()
\r
1778 function getPageLink($expr,$package, $path = false,$text = false)
\r
1780 $a = Converter::getPageLink($expr,$package,$path);
\r
1781 if (!$a) return false;
\r
1782 return $this->returnSee($a, $text);
\r
1786 * @param string name of method
\r
1787 * @param string class containing method
\r
1788 * @param string package name
\r
1789 * @param string full path to look in (used in index generation)
\r
1790 * @param boolean deprecated
\r
1791 * @param boolean return just the URL, or enclose it in an html a tag
\r
1792 * @return mixed false if not found, or an html a link to the method's documentation
\r
1793 * @see parent::getMethodLink()
\r
1795 function getMethodLink($expr,$class,$package, $file = false,$text = false)
\r
1797 $a = Converter::getMethodLink($expr,$class,$package,$file);
\r
1798 if (!$a) return false;
\r
1799 return $this->returnSee($a, $text);
\r
1803 * @param string name of var
\r
1804 * @param string class containing var
\r
1805 * @param string package name
\r
1806 * @param string full path to look in (used in index generation)
\r
1807 * @param boolean deprecated
\r
1808 * @param boolean return just the URL, or enclose it in an html a tag
\r
1809 * @return mixed false if not found, or an html a link to the var's documentation
\r
1810 * @see parent::getVarLink()
\r
1812 function getVarLink($expr,$class,$package, $file = false,$text = false)
\r
1814 $a = Converter::getVarLink($expr,$class,$package,$file);
\r
1815 if (!$a) return false;
\r
1816 return $this->returnSee($a, $text);
\r
1820 * @param string name of class constant
\r
1821 * @param string class containing class constant
\r
1822 * @param string package name
\r
1823 * @param string full path to look in (used in index generation)
\r
1824 * @param boolean deprecated
\r
1825 * @param boolean return just the URL, or enclose it in an html a tag
\r
1826 * @return mixed false if not found, or an html a link to the var's documentation
\r
1827 * @see parent::getVarLink()
\r
1829 function getConstLink($expr,$class,$package, $file = false,$text = false)
\r
1831 $a = Converter::getConstLink($expr,$class,$package,$file);
\r
1832 if (!$a) return false;
\r
1833 return $this->returnSee($a, $text);
\r
1837 * does a nat case sort on the specified second level value of the array
\r
1843 function rcNatCmp ($a, $b)
\r
1845 $aa = strtoupper($a[$this->rcnatcmpkey]);
\r
1846 $bb = strtoupper($b[$this->rcnatcmpkey]);
\r
1848 return strnatcasecmp($aa, $bb);
\r
1852 * does a nat case sort on the specified second level value of the array.
\r
1853 * this one puts constructors first
\r
1859 function rcNatCmp1 ($a, $b)
\r
1861 $aa = strtoupper($a[$this->rcnatcmpkey]);
\r
1862 $bb = strtoupper($b[$this->rcnatcmpkey]);
\r
1864 if (strpos($aa,'CONSTRUCTOR') === 0)
\r
1868 if (strpos($bb,'CONSTRUCTOR') === 0)
\r
1872 if (strpos($aa,strtoupper($this->class)) === 0)
\r
1876 if (strpos($bb,strtoupper($this->class)) === 0)
\r
1880 return strnatcasecmp($aa, $bb);
\r
1884 * This function is not used by HTMLdefaultConverter, but is required by Converter
\r
1893 * @global string name of the package to set as the first package
\r
1895 function HTMLframes_pindexcmp($a, $b)
\r
1897 global $phpDocumentor_DefaultPackageName;
\r
1898 if ($a['title'] == $phpDocumentor_DefaultPackageName) return -1;
\r
1899 if ($b['title'] == $phpDocumentor_DefaultPackageName) return 1;
\r
1900 return strnatcasecmp($a['title'],$b['title']);
\r
1903 /** @access private */
\r
1904 function HTMLframes_lettersort($a, $b)
\r
1906 return strnatcasecmp($a['letter'],$b['letter']);
\r
1909 /** @access private */
\r
1910 function HTMLframes_outputfilter($src, &$smarty)
\r
1912 return str_replace('{$subdir}',$smarty->_tpl_vars['subdir'],$src);
\r