changed git call from https to git readonly
[atutor.git] / mods / phpdoc2 / PhpDocumentor / phpDocumentor / Converters / HTML / frames / HTMLframesConverter.inc
1 <?php\r
2 /**\r
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
5  *\r
6  * phpDocumentor :: automatic documentation generator\r
7  * \r
8  * PHP versions 4 and 5\r
9  *\r
10  * Copyright (c) 2002-2006 Gregory Beaver\r
11  * \r
12  * LICENSE:\r
13  * \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
18  * later version.\r
19  * \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
24  * \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
28  *\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
35  * @filesource\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
40  * @since      1.2\r
41  */\r
42 /**\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
45  *\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
50  * @since 1.2\r
51  * @version $Id: HTMLframesConverter.inc,v 1.16 2007/04/19 20:20:57 ashnazg Exp $\r
52  */\r
53 class HTMLframesConverter extends Converter\r
54 {\r
55     /**\r
56      * This converter knows about the new root tree processing\r
57      * In order to fix PEAR Bug #6389\r
58      * @var boolean\r
59      */\r
60     var $processSpecialRoots = true;\r
61     /**\r
62      * Smarty Converter wants elements sorted by type as well as alphabetically\r
63      * @see Converter::$sort_page_contents_by_type\r
64      * @var boolean\r
65      */\r
66     var $sort_page_contents_by_type = true;\r
67     /** @var string */\r
68     var $outputformat = 'HTML';\r
69     /** @var string */\r
70     var $name = 'frames';\r
71     /**\r
72      * indexes of elements by package that need to be generated\r
73      * @var array\r
74      */\r
75     var $leftindex = array('classes' => true, 'pages' => true, 'functions' => true, 'defines' => false, 'globals' => false);\r
76     \r
77     /**\r
78      * output directory for the current procedural page being processed\r
79      * @var string\r
80      */\r
81     var $page_dir;\r
82     \r
83     /**\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
86      * @var string\r
87      */\r
88     var $base_dir;\r
89     \r
90     /**\r
91      * output directory for the current class being processed\r
92      * @var string\r
93      */\r
94     var $class_dir;\r
95     \r
96     /**\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
100      */\r
101     var $package_pages = array();\r
102     \r
103     /**\r
104      * controls formatting of parser informative output\r
105      * \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
111      * @var boolean\r
112      */\r
113     var $juststarted = false;\r
114     \r
115     /**\r
116      * contains all of the template procedural page element loop data needed for the current template\r
117      * @var array\r
118      */\r
119     var $current;\r
120     \r
121     /**\r
122      * contains all of the template class element loop data needed for the current template\r
123      * @var array\r
124      */\r
125     var $currentclass;\r
126     var $wrote = false;\r
127     var $ric_set = array();\r
128     \r
129     /**\r
130      * sets {@link $base_dir} to $targetDir\r
131      * @see Converter()\r
132      */\r
133     function HTMLframesConverter(&$allp, &$packp, &$classes, &$procpages, $po, $pp, $qm, $targetDir, $templateDir, $title)\r
134     {\r
135         Converter::Converter($allp, $packp, $classes, $procpages,$po, $pp, $qm, $targetDir, $templateDir, $title);\r
136         $this->base_dir = $targetDir;\r
137     }\r
138     \r
139     /**\r
140      * @deprecated in favor of PHP 4.3.0+ tokenizer-based source highlighting\r
141      */\r
142     function unmangle($sourcecode)\r
143     {\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('&nbsp;',' ',$sourcecode);\r
148         $sourcecode = str_replace('&lt;','<',$sourcecode);\r
149         $sourcecode = str_replace('&gt;','>',$sourcecode);\r
150         $sourcecode = str_replace('&amp;','&',$sourcecode);\r
151         return $sourcecode;\r
152     }\r
153 \r
154     /**\r
155      * @param string full path to the source file\r
156      * @param string fully highlighted source code\r
157      */\r
158     function writeSource($path, $value)\r
159     {\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
174     }\r
175     \r
176     function writeExample($title, $path, $source)\r
177     {\r
178         $templ = &$this->newSmarty();\r
179         $templ->assign('source',$source);\r
180         if (empty($title))\r
181         {\r
182             $title = 'example';\r
183             addWarning(PDERROR_EMPTY_EXAMPLE_TITLE, $path, $title);\r
184         }\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
192     }\r
193 \r
194     function getExampleLink($path, $title)\r
195     {\r
196         return $this->returnLink('{$subdir}__examplesource' . PATH_DELIMITER . 'exsource_'.$path.'.html',$title);\r
197     }\r
198     \r
199     function getSourceLink($path)\r
200     {\r
201         return $this->returnLink('{$subdir}__filesource/' .\r
202         $this->getFileSourceName($path).'.html','Source Code for this file');\r
203     }\r
204 \r
205     /**\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
212      *                parameter\r
213      * @return string link to an anchor, or the anchor\r
214      */\r
215     function getSourceAnchor($sourcefile,$anchor,$text = '',$link = false)\r
216     {\r
217         if ($link) {\r
218             return $this->returnLink('{$subdir}__filesource/' .\r
219                 $this->getFileSourceName($sourcefile) . '.html#a' . $anchor, $text);\r
220         } else {\r
221             return '<a name="a'.$anchor.'"></a>';\r
222         }\r
223     }\r
224 \r
225     /**\r
226      * Return a line of highlighted source code with formatted line number\r
227      *\r
228      * If the $path is a full path, then an anchor to the line number will be\r
229      * added as well\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
235      */\r
236     function sourceLine($linenumber, $line, $path = false)\r
237     {\r
238         $extra = '';\r
239         if (strlen(str_replace("\n", '', $line)) == 0) {\r
240             $extra = '&nbsp;';\r
241         }\r
242         if ($path)\r
243         {\r
244             return '<li><div class="src-line">' . $this->getSourceAnchor($path, $linenumber) .\r
245                    str_replace("\n",'',$line) . $extra .\r
246                    "</div></li>\n";\r
247         } else\r
248         {\r
249             return '<li><div class="src-line">' . str_replace("\n",'',$line) .\r
250                 "$extra</div></li>\n";\r
251         }\r
252     }\r
253     \r
254     /**\r
255      * Used to convert the <<code>> tag in a docblock\r
256      * @param string\r
257      * @param boolean\r
258      * @return string\r
259      */\r
260     function ProgramExample($example, $tutorial = false, $inlinesourceparse = null/*false*/,\r
261                             $class = null/*false*/, $linenum = null/*false*/, $filesourcepath = null/*false*/)\r
262     {\r
263         return '<div class="src-code"><ol>' . parent::ProgramExample($example, $tutorial, $inlinesourceparse, $class, $linenum, $filesourcepath)\r
264                .'</ol></div>';\r
265     }\r
266     \r
267     /**\r
268      * @param string\r
269      */\r
270     function TutorialExample($example)\r
271     {\r
272         $trans = $this->template_options['desctranslate'];\r
273         $this->template_options['desctranslate'] = array();\r
274         $example = '<ol>' . parent::TutorialExample($example)\r
275                .'</ol>';\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
282     }\r
283     \r
284     function getCurrentPageLink()\r
285     {\r
286         return $this->curname . '.html';\r
287     }\r
288 \r
289     /**\r
290      * Uses htmlspecialchars() on the input\r
291      */\r
292     function postProcess($text)\r
293     {\r
294         if ($this->highlightingSource) {\r
295             return str_replace(array(' ',"\t"), array('&nbsp;', '&nbsp;&nbsp;&nbsp;'),\r
296                 htmlspecialchars($text));\r
297         }\r
298         return htmlspecialchars($text);\r
299     }\r
300     \r
301     /**\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
305      */\r
306     function formatTutorialTOC($toc)\r
307     {\r
308         $template = &$this->newSmarty();\r
309         $template->assign('toc',$toc);\r
310         return $template->fetch('tutorial_toc.tpl');\r
311     }\r
312     \r
313     function &SmartyInit(&$templ)\r
314     {\r
315         if (!isset($this->package_index))\r
316         foreach($this->all_packages as $key => $val)\r
317         {\r
318             if (isset($this->pkg_elements[$key]))\r
319             {\r
320                 if (!isset($start)) $start = $key;\r
321                 $this->package_index[] = array('link' => "li_$key.html", 'title' => $key);\r
322             }\r
323         }\r
324         $templ->assign("packageindex",$this->package_index);\r
325         $templ->assign("subdir",'');\r
326         return $templ;\r
327     }\r
328     \r
329     /**\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
333      */\r
334     function endClass()\r
335     {\r
336         $a = '../';\r
337         if (!empty($this->subpackage)) $a .= '../';\r
338         if ($this->juststarted)\r
339         {\r
340             $this->juststarted = false;\r
341             phpDocumentor_out("\n");\r
342             flush();\r
343         }\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
349     }\r
350     \r
351     /**\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
355      */\r
356     function endPage()\r
357     {\r
358         $this->package = $this->curpage->package;\r
359         $this->subpackage = $this->curpage->subpackage;\r
360         $a = '../';\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
368     }\r
369     \r
370     /**\r
371      * @param string\r
372      * @param string\r
373      * @return string &lt;a href="'.$link.'">'.$text.'</a&gt;\r
374      */\r
375     function returnLink($link,$text)\r
376     {\r
377         return '<a href="'.$link.'">'.$text.'</a>';\r
378     }\r
379     \r
380     function makeLeft()\r
381     {\r
382         foreach($this->page_elements as $package => $o1)\r
383         {\r
384             foreach($o1 as $subpackage => $links)\r
385             {\r
386                 for($i=0;$i<count($links);$i++)\r
387                 {\r
388                     $left[$package][$subpackage]['files'][] =\r
389                         array("link" => $this->getId($links[$i]), "title" => $links[$i]->name);\r
390                 }\r
391             }\r
392         }\r
393         $interfaces = $classes = false;\r
394         foreach($this->class_elements as $package => $o1)\r
395         {\r
396             foreach($o1 as $subpackage => $links)\r
397             {\r
398                 for($i=0;$i<count($links);$i++)\r
399                 {\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
405                     } else {\r
406                         $isclass = true;\r
407                         $classes = true;\r
408                     }\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
417                     } else {\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
425                     }\r
426                 }\r
427             }\r
428         }\r
429         foreach($this->function_elements as $package => $o1)\r
430         {\r
431             foreach($o1 as $subpackage => $links)\r
432             {\r
433                 for($i=0;$i<count($links);$i++)\r
434                 {\r
435                     $left[$package][$subpackage]['functions'][] =\r
436                         array("link" => $this->getId($links[$i]), "title" => $links[$i]->name);\r
437                 }\r
438             }\r
439         }\r
440         $ret = array();\r
441         foreach($left as $package => $r)\r
442         {\r
443             $pd = 'blank';\r
444             if (isset($this->package_pages[$package])) $pd = $package.'/package_'.$package.'.html';\r
445             if (!isset($r['']))\r
446             {\r
447                 $pt = false;\r
448                 $ptnoa = false;\r
449                 $ptt = $package;\r
450                 if ($t = $this->hasTutorial('pkg',$package,$package,''))\r
451                 {\r
452                     $pt = $t->getLink($this);\r
453                     $ptnoa = $this->getId($t->getLink($this,true));\r
454                     $ptt = $t->getTitle($this);\r
455                 }\r
456                 $tutes = array();\r
457                 foreach($this->tutorial_tree as $root => $tr)\r
458                 {\r
459                     if ($tr['tutorial']->package == $package && $tr['tutorial']->subpackage == '') {\r
460                         $tutes[$tr['tutorial']->tutorial_type][] =\r
461                             $this->getTutorialTree($tr['tutorial']);\r
462                     }\r
463                 }\r
464                 if (isset($this->childless_tutorials[$package][$subpackage]))\r
465                 {\r
466                     foreach($this->childless_tutorials[$package][$subpackage] as $ext => $other)\r
467                     {\r
468                         foreach($other as $tutorial)\r
469                         {\r
470                             $tutes[$tutorial->tutorial_type][] = $this->getTutorialTree($tutorial);\r
471                         }\r
472                     }\r
473                 }\r
474                 $ret[$package][] =\r
475                     array(\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
486                         );\r
487             }\r
488             foreach($r as $subpackage => $info)\r
489             {\r
490                 $my = array();\r
491                 $my['package'] = $package;\r
492                 if (isset($this->package_pages[$package]))\r
493                 $my['packagedoc'] = $pd;\r
494                 else\r
495                 $my['packagedoc'] = 'blank';\r
496                 $my['subpackage'] = $subpackage;\r
497                 if (empty($subpackage))\r
498                 {\r
499                     if ($t = $this->hasTutorial('pkg',$package,$package,$subpackage))\r
500                     {\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
504                     } else\r
505                     {\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
509                     }\r
510                 } else\r
511                 {\r
512                     if ($t = $this->hasTutorial('pkg',$subpackage,$package,$subpackage))\r
513                     {\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
517                     } else\r
518                     {\r
519                         $my['subpackagetutorial'] = false;\r
520                         $my['subpackagetutorialnoa'] = false;\r
521                         $my['subpackagetutorialtitle'] = $subpackage;\r
522                     }\r
523                 }\r
524                 $tutes = array();\r
525                 foreach($this->tutorial_tree as $root => $tr)\r
526                 {\r
527                     if ($tr['tutorial']->package == $package && $tr['tutorial']->subpackage == $subpackage)\r
528                     {\r
529                         $tutes[$tr['tutorial']->tutorial_type][] = $this->getTutorialTree($tr['tutorial']);\r
530                     }\r
531                 }\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
543             }\r
544         }\r
545         return $ret;\r
546     }\r
547     \r
548     function getTutorialTree($tutorial,$k = false)\r
549     {\r
550         $ret = '';\r
551         if (is_object($tutorial)) $tree = parent::getTutorialTree($tutorial); else $tree = $tutorial;\r
552 //        debug($this->vardump_tree($tree));exit;\r
553         if (!$tree)\r
554         {\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
562             $t = $tutorial;\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
567         }\r
568         if (isset($tree['kids']))\r
569         {\r
570             foreach($tree['kids'] as $subtree)\r
571             {\r
572                 $ret .= $this->getTutorialTree($subtree, true);\r
573             }\r
574         }\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
587                                 return $ret;\r
588     }\r
589     \r
590     /**\r
591      * HTMLdefaultConverter chooses to format both package indexes and the complete index here\r
592      *\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
596      */\r
597     function formatPkgIndex()\r
598     {\r
599         list($package_indexes,$packages,$mletters) = $this->generatePkgElementIndexes();\r
600         for($i=0;$i<count($package_indexes);$i++)\r
601         {\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
611         }\r
612         phpDocumentor_out("\n");\r
613         flush();\r
614         }\r
615     \r
616     /**\r
617      * HTMLdefaultConverter uses this function to format template index.html and packages.html\r
618      *\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
625      */\r
626     function formatIndex()\r
627     {\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
635         flush();\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
641         {\r
642             if (isset($this->pkg_elements[$key]))\r
643             {\r
644                 if (!isset($start)) $start = $key;\r
645                 if (!isset($this->package_pages[$key])) $this->writeNewPPage($key);\r
646             }\r
647         }\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
660         {\r
661             $index->assign("blank",$start.'/tutorial_'.$start.'.pkg');\r
662         } elseif (isset($this->package_pages[$start]))\r
663         {\r
664             $index->assign("blank",$start.'/package_'.$start);\r
665         }\r
666         else\r
667         {\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
673         }\r
674         phpDocumentor_out("\n");\r
675         flush();\r
676         $this->setTargetDir($this->base_dir);\r
677         $this->writefile("index.html",$index->fetch('index.tpl'));\r
678 \r
679         // Create package index\r
680         $package = &$this->newSmarty();\r
681         $package->assign('ric',array());\r
682         if (isset($this->ric_set))\r
683         {\r
684             foreach($this->ric_set as $name => $u)\r
685             {\r
686                 $package->append('ric',array('file' => 'ric_'.$name.'.html','name' => $name));\r
687             }\r
688         }\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
692         unset($index);\r
693     }\r
694     \r
695     function writeNewPPage($key)\r
696     {\r
697         return;\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
706         flush();\r
707         $this->setTargetDir($this->base_dir);\r
708     \r
709         $this->writefile("li_$key.html",$template->fetch('index.tpl'));\r
710         unset($template);\r
711     }\r
712     \r
713     /**\r
714      * Generate indexes for li_package.html and classtree output files\r
715      *\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
720      * \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
725      */\r
726     function formatLeftIndex()\r
727     {\r
728         phpDocumentor_out("\n");\r
729         flush();\r
730         $this->setTargetDir($this->base_dir);\r
731         if (0)//!isset($this->left))\r
732         {\r
733             debug("Nothing parsed, check the command-line");\r
734             die();\r
735         }\r
736         $x = $this->makeLeft();\r
737         foreach($this->all_packages as $package => $rest)\r
738         {\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
750             {\r
751                 $template->assign("packagedoc",$package.'/package_' . $package . '.html');\r
752             } else\r
753             {\r
754                 $template->assign("packagedoc",false);\r
755             }\r
756             $this->writefile("li_$package.html",$template->fetch('left_frame.tpl'));\r
757             \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
766             flush();\r
767         }\r
768         // free up considerable memory\r
769         unset($this->elements);\r
770         unset($this->pkg_elements);\r
771     }\r
772     \r
773     /**\r
774      * This function takes an {@link abstractLink} descendant and returns an html link\r
775      *\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
780      */\r
781     function returnSee(&$element, $eltext = false, $with_a = true)\r
782     {\r
783         if (!is_object($element) || !$element) return false;\r
784         if (!$with_a) return $this->getId($element, false);\r
785         if (!$eltext)\r
786         {\r
787             $eltext = '';\r
788             switch($element->type)\r
789             {\r
790                 case 'tutorial' :\r
791                 $eltext = strip_tags($element->title);\r
792                 break;\r
793                 case 'method' :\r
794                 case 'var' :\r
795                 case 'const' :\r
796                 $eltext .= $element->class.'::';\r
797                 case 'page' :\r
798                 case 'define' :\r
799                 case 'class' :\r
800                 case 'function' :\r
801                 case 'global' :\r
802                 default :\r
803                 $eltext .= $element->name;\r
804                 if ($element->type == 'function' || $element->type == 'method') $eltext .= '()';\r
805                 break;\r
806             }\r
807         }\r
808         return '<a href="'.$this->getId($element).'">'.$eltext.'</a>';\r
809     }\r
810     \r
811     function getId($element, $fullpath = true)\r
812     {\r
813         if (phpDocumentor_get_class($element) == 'parserdata')\r
814         {\r
815             $element = $this->addLink($element->parent);\r
816             $elp = $element->parent;\r
817         } elseif (is_a($element, 'parserbase'))\r
818         {\r
819             $elp = $element;\r
820             $element = $this->addLink($element);\r
821         }\r
822         $c = '';\r
823         if (!empty($element->subpackage))\r
824         {\r
825             $c = '/'.$element->subpackage;\r
826         }\r
827         $b = '{$subdir}';\r
828         switch ($element->type)\r
829         {\r
830             case 'page' :\r
831             if ($fullpath)\r
832             return $b.$element->package.$c.'/'.$element->fileAlias.'.html';\r
833             return 'top';\r
834             break;\r
835             case 'define' :\r
836             case 'global' :\r
837             case 'function' :\r
838             if ($fullpath)\r
839             return $b.$element->package.$c.'/'.$element->fileAlias.'.html#'.$element->type.$element->name;\r
840             return $element->type.$element->name;\r
841             break;\r
842             case 'class' :\r
843             if ($fullpath)\r
844             return $b.$element->package.$c.'/'.$element->name.'.html';\r
845             return 'top';\r
846             break;\r
847             case 'method' :\r
848             case 'var' :\r
849             case 'const' :\r
850             if ($fullpath)\r
851             return $b.$element->package.$c.'/'.$element->class.'.html#'.$element->type.$element->name;\r
852             return $element->type.$element->name;\r
853             break;\r
854             case 'tutorial' :\r
855             $d = '';\r
856             if ($element->section)\r
857             {\r
858                 $d = '#'.$element->section;\r
859             }\r
860             return $b.$element->package.$c.'/tutorial_'.$element->name.'.html'.$d;\r
861         }\r
862     }\r
863     \r
864     /**\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
868      */\r
869     function Convert_RIC($name, $contents)\r
870     {\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
877     }\r
878     \r
879     function ConvertTodoList()\r
880     {\r
881         $todolist = array();\r
882         foreach($this->todoList as $package => $alltodos)\r
883         {\r
884             foreach($alltodos as $todos)\r
885             {\r
886                 $converted = array();\r
887                 $converted['link'] = $this->returnSee($todos[0]);\r
888                 if (!is_array($todos[1]))\r
889                 {\r
890                     $converted['todos'][] = $todos[1]->Convert($this);\r
891                 } else\r
892                 {\r
893                     foreach($todos[1] as $todo)\r
894                     {\r
895                         $converted['todos'][] = $todo->Convert($this);\r
896                     }\r
897                 }\r
898                 $todolist[$package][] = $converted;\r
899             }\r
900         }\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
906     }\r
907     \r
908     /**\r
909      * Create errors.html template file output\r
910      *\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
913      */\r
914     function ConvertErrorLog()\r
915     {\r
916         global $phpDocumentor_errors;\r
917         $allfiles = array();\r
918         $files = 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
923         {\r
924             $file = '##none';\r
925             $linenum = 'Warning';\r
926             if ($warning->file)\r
927             {\r
928                 $file = $warning->file;\r
929                 $allfiles[$file] = 1;\r
930                 $linenum .= ' on line '.$warning->linenum;\r
931             }\r
932             $files[$file]['warnings'][] = array('name' => $linenum, 'listing' => $warning->data);\r
933         }\r
934         foreach($errors as $error)\r
935         {\r
936             $file = '##none';\r
937             $linenum = 'Error';\r
938             if ($error->file)\r
939             {\r
940                 $file = $error->file;\r
941                 $allfiles[$file] = 1;\r
942                 $linenum .= ' on line '.$error->linenum;\r
943             }\r
944             $files[$file]['errors'][] = array('name' => $linenum, 'listing' => $error->data);\r
945         }\r
946         $i=1;\r
947         $af = array();\r
948         foreach($allfiles as $file => $num)\r
949         {\r
950             $af[$i++] = $file;\r
951         }\r
952         $allfiles = $af;\r
953         usort($allfiles,'strnatcasecmp');\r
954         $allfiles[0] = "Post-parsing";\r
955         foreach($allfiles as $i => $a)\r
956         {\r
957             $allfiles[$i] = array('file' => $a);\r
958         }\r
959         $out = array();\r
960         foreach($files as $file => $data)\r
961         {\r
962             if ($file == '##none') $file = 'Post-parsing';\r
963             $out[$file] = $data;\r
964         }\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
970         unset($template);\r
971         phpDocumentor_out("\n\nTo view errors and warnings, look at ".$this->base_dir. PATH_DELIMITER . "errors.html\n");\r
972         flush();\r
973     }\r
974     \r
975     function getTutorialId($package,$subpackage,$tutorial,$id)\r
976     {\r
977         return $id;\r
978     }\r
979     \r
980     function getCData($value)\r
981     {\r
982         return '<pre>'.htmlentities($value).'</pre>';\r
983     }\r
984     \r
985     /**\r
986      * Converts package page and sets its package as used in {@link $package_pages}\r
987      * @param parserPackagePage\r
988      */\r
989     function convertPackagepage(&$element)\r
990     {\r
991         phpDocumentor_out("\n");\r
992         flush();\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
998         flush();\r
999         $this->setTargetDir($this->base_dir . PATH_DELIMITER . $element->package);\r
1000         $this->writeFile('package_'.$element->package.'.html',str_replace('{$subdir}','../',$contents));\r
1001     }\r
1002     \r
1003     /**\r
1004      * @param parserTutorial\r
1005      */\r
1006     function convertTutorial(&$element)\r
1007     {\r
1008         phpDocumentor_out("\n");\r
1009         flush();\r
1010         $template = &parent::convertTutorial($element);\r
1011         $a = '../';\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
1016         $a = '';\r
1017         if ($element->subpackage) $a = PATH_DELIMITER . $element->subpackage;\r
1018         phpDocumentor_out("\n");\r
1019         flush();\r
1020         $this->setTargetDir($this->base_dir . PATH_DELIMITER . $element->package . $a);\r
1021         $this->writeFile('tutorial_'.$element->name.'.html',$contents);\r
1022     }\r
1023     \r
1024     /**\r
1025      * Converts class for template output\r
1026      * @see prepareDocBlock(), generateChildClassList(), generateFormattedClassTree(), getFormattedConflicts()\r
1027      * @see getFormattedInheritedMethods(), getFormattedInheritedVars()\r
1028      * @param parserClass\r
1029      */\r
1030     function convertClass(&$element)\r
1031     {\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
1035         $a = '../';\r
1036         if ($element->docblock->subpackage != '') $a = "../$a";\r
1037         \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
1041     }\r
1042 \r
1043     /**\r
1044      * Converts class variables for template output\r
1045      * @see prepareDocBlock(), getFormattedConflicts()\r
1046      * @param parserDefine\r
1047      */\r
1048     function convertVar(&$element)\r
1049     {\r
1050         parent::convertVar($element, array('var_dest' => $this->getId($element,false)));\r
1051     }\r
1052 \r
1053     /**\r
1054      * Converts class variables for template output\r
1055      * @see prepareDocBlock(), getFormattedConflicts()\r
1056      * @param parserDefine\r
1057      */\r
1058     function convertConst(&$element)\r
1059     {\r
1060         parent::convertConst($element, array('const_dest' => $this->getId($element,false)));\r
1061     }\r
1062 \r
1063     /**\r
1064      * Converts class methods for template output\r
1065      * @see prepareDocBlock(), getFormattedConflicts()\r
1066      * @param parserDefine\r
1067      */\r
1068     function convertMethod(&$element)\r
1069     {\r
1070         parent::convertMethod($element, array('method_dest' => $this->getId($element,false)));\r
1071     }\r
1072     \r
1073     /**\r
1074      * Converts function for template output\r
1075      * @see prepareDocBlock(), parserFunction::getFunctionCall(), getFormattedConflicts()\r
1076      * @param parserFunction\r
1077      */\r
1078     function convertFunction(&$element)\r
1079     {\r
1080         $funcloc = $this->getId($this->addLink($element));\r
1081         parent::convertFunction($element,array('function_dest' => $this->getId($element,false)));\r
1082     }\r
1083     \r
1084     /**\r
1085      * Converts include elements for template output\r
1086      * @see prepareDocBlock()\r
1087      * @param parserInclude\r
1088      */\r
1089     function convertInclude(&$element)\r
1090     {\r
1091         parent::convertInclude($element, array('include_file'    => '_'.strtr($element->getValue(),array('"' => '', "'" => '','.' => '_'))));\r
1092     }\r
1093     \r
1094     /**\r
1095      * Converts defines for template output\r
1096      * @see prepareDocBlock(), getFormattedConflicts()\r
1097      * @param parserDefine\r
1098      */\r
1099     function convertDefine(&$element)\r
1100     {\r
1101         parent::convertDefine($element, array('define_link' => $this->getId($element,false)));\r
1102     }\r
1103     \r
1104     /**\r
1105      * Converts global variables for template output\r
1106      * @param parserGlobal\r
1107      */\r
1108     function convertGlobal(&$element)\r
1109     {\r
1110         parent::convertGlobal($element, array('global_link' => $this->getId($element,false)));\r
1111     }\r
1112     \r
1113     /**\r
1114      * converts procedural pages for template output\r
1115      * @see prepareDocBlock(), getClassesOnPage()\r
1116      * @param parserData\r
1117      */\r
1118     function convertPage(&$element)\r
1119     {\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
1127     }\r
1128     \r
1129     function getPageName(&$element)\r
1130     {\r
1131         if (phpDocumentor_get_class($element) == 'parserpage') return '_'.$element->getName();\r
1132         return '_'.$element->parent->getName();\r
1133     }\r
1134 \r
1135     /**\r
1136      * returns an array containing the class inheritance tree from the root object to the class\r
1137      *\r
1138      * @param parserClass    class variable\r
1139      * @return array Format: array(root,child,child,child,...,$class)\r
1140      * @uses parserClass::getParentClassTree()\r
1141      */\r
1142     \r
1143     function generateFormattedClassTree($class)\r
1144     {\r
1145         $tree = $class->getParentClassTree($this);\r
1146         $out = '';\r
1147         if (count($tree) - 1)\r
1148         {\r
1149             $result = array($class->getName());\r
1150             $parent = $tree[$class->getName()];\r
1151             $distance[] = '';\r
1152             while ($parent)\r
1153             {\r
1154                 $x = $parent;\r
1155                 if (is_object($parent))\r
1156                 {\r
1157                     $subpackage = $parent->docblock->subpackage;\r
1158                     $package = $parent->docblock->package;\r
1159                     $x = $parent;\r
1160                     $x = $parent->getLink($this);\r
1161                     if (!$x) $x = $parent->getName();\r
1162                 }\r
1163                 $result[] = \r
1164                     $x;\r
1165                 $distance[] =\r
1166                     "\n%s|\n" .\r
1167                     "%s--";\r
1168                 if (is_object($parent))\r
1169                 $parent = $tree[$parent->getName()];\r
1170                 elseif (isset($tree[$parent]))\r
1171                 $parent = $tree[$parent];\r
1172             }\r
1173             $nbsp = '   ';\r
1174             for($i=count($result) - 1;$i>=0;$i--)\r
1175             {\r
1176                 $my_nbsp = '';\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
1179             }\r
1180             return array('classes'=>array_reverse($result),'distance'=>array_reverse($distance));\r
1181         } else\r
1182         {\r
1183             return array('classes'=>$class->getName(),'distance'=>array(''));\r
1184         }\r
1185     }\r
1186     \r
1187     /** @access private */\r
1188     function sortVar($a, $b)\r
1189     {\r
1190         return strnatcasecmp($a->getName(),$b->getName());\r
1191     }\r
1192     \r
1193     /** @access private */\r
1194     function sortMethod($a, $b)\r
1195     {\r
1196         if ($a->isConstructor) return -1;\r
1197         if ($b->isConstructor) return 1;\r
1198         return strnatcasecmp($a->getName(),$b->getName());\r
1199     }\r
1200 \r
1201     /**\r
1202      * returns a template-enabled array of class trees\r
1203      * \r
1204      * @param    string    $package    package to generate a class tree for\r
1205      * @see $roots, HTMLConverter::getRootTree()\r
1206      */\r
1207     function generateFormattedClassTrees($package)\r
1208     {\r
1209         if (!isset($this->roots['normal'][$package]) &&\r
1210               !isset($this->roots['special'][$package])) {\r
1211             return array();\r
1212         }\r
1213         $trees = array();\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
1217             {\r
1218                 $root = $this->classes->getClassByPackage($roots[$i], $package);\r
1219                 if ($root && $root->isInterface()) {\r
1220                     continue;\r
1221                 }\r
1222                 $trees[] = array('class' => $roots[$i],'class_tree' => "<ul>\n".$this->getRootTree($this->getSortedClassTreeFromClass($roots[$i],$package,''),$package)."</ul>\n");\r
1223             }\r
1224         }\r
1225         if (isset($this->roots['special'][$package])) {\r
1226             $roots = $this->roots['special'][$package];\r
1227             foreach ($roots as $parent => $classes) {\r
1228                 $thistree = '';\r
1229                 foreach ($classes as $classinfo) {\r
1230                     $root = $this->classes->getClassByPackage($classinfo, $package);\r
1231                     if ($root && $root->isInterface()) {\r
1232                         continue;\r
1233                     }\r
1234                     $thistree .=\r
1235                         $this->getRootTree(\r
1236                             $this->getSortedClassTreeFromClass(\r
1237                                 $classinfo,\r
1238                                 $package,\r
1239                                 ''),\r
1240                             $package,\r
1241                             true);\r
1242                 }\r
1243                 if (!$thistree) {\r
1244                     continue;\r
1245                 }\r
1246                 $trees[] = array(\r
1247                     'class' => $parent,\r
1248                     'class_tree' => "<ul>\n" . $thistree . "</ul>\n"\r
1249                 );\r
1250             }\r
1251         }\r
1252         return $trees;\r
1253     }\r
1254 \r
1255     /**\r
1256      * returns a template-enabled array of interface inheritance trees\r
1257      * \r
1258      * @param    string    $package    package to generate a class tree for\r
1259      * @see $roots, HTMLConverter::getRootTree()\r
1260      */\r
1261     function generateFormattedInterfaceTrees($package)\r
1262     {\r
1263         if (!isset($this->roots['normal'][$package]) &&\r
1264               !isset($this->roots['special'][$package])) {\r
1265             return array();\r
1266         }\r
1267         $trees = array();\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
1271             {\r
1272                 $root = $this->classes->getClassByPackage($roots[$i], $package);\r
1273                 if ($root && !$root->isInterface()) {\r
1274                     continue;\r
1275                 }\r
1276                 $trees[] = array('class' => $roots[$i],'class_tree' => "<ul>\n".$this->getRootTree($this->getSortedClassTreeFromClass($roots[$i],$package,''),$package)."</ul>\n");\r
1277             }\r
1278         }\r
1279         if (isset($this->roots['special'][$package])) {\r
1280             $roots = $this->roots['special'][$package];\r
1281             foreach ($roots as $parent => $classes) {\r
1282                 $thistree = '';\r
1283                 foreach ($classes as $classinfo) {\r
1284                     $root = $this->classes->getClassByPackage($classinfo, $package);\r
1285                     if ($root && !$root->isInterface()) {\r
1286                         continue;\r
1287                     }\r
1288                     $thistree .=\r
1289                         $this->getRootTree(\r
1290                             $this->getSortedClassTreeFromClass(\r
1291                                 $classinfo,\r
1292                                 $package,\r
1293                                 ''),\r
1294                             $package,\r
1295                             true);\r
1296                 }\r
1297                 if (!$thistree) {\r
1298                     continue;\r
1299                 }\r
1300                 $trees[] = array(\r
1301                     'class' => $parent,\r
1302                     'class_tree' => "<ul>\n" . $thistree . "</ul>\n"\r
1303                 );\r
1304             }\r
1305         }\r
1306         return $trees;\r
1307     }\r
1308     \r
1309     /**\r
1310      * return formatted class tree for the Class Trees page\r
1311      *\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
1316      * @return string\r
1317      */\r
1318     function getRootTree($tree, $package, $noparent = false)\r
1319     {\r
1320         if (!$tree) return '';\r
1321         $my_tree = '';\r
1322         $cur = '#root';\r
1323         $lastcur = array(false);\r
1324         $kids = array();\r
1325         $dopar = false;\r
1326         if (!$noparent && $tree[$cur]['parent'])\r
1327         {\r
1328             $dopar = true;\r
1329             if (!is_object($tree[$cur]['parent']))\r
1330             {\r
1331 //                debug("parent ".$tree[$cur]['parent']." not found");\r
1332                 $my_tree .= '<li>' . $tree[$cur]['parent'] .'<ul>';\r
1333             }\r
1334             else\r
1335             {\r
1336 //                        debug("parent ".$this->returnSee($tree[$cur]['parent'])." in other package");\r
1337                 $root = $this->classes->getClassByPackage($tree[$cur]['parent']->name,\r
1338                     $package);\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
1341             }\r
1342         }\r
1343         do\r
1344         {\r
1345 //            fancy_debug($cur,$lastcur,$kids);\r
1346             if (count($tree[$cur]['children']))\r
1347             {\r
1348 //                debug("$cur has children");\r
1349                 if (!isset($kids[$cur]))\r
1350                 {\r
1351 //                    debug("set $cur kids");\r
1352                     $kids[$cur] = 1;\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
1358                             ' (implements ';\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
1363                             } else {\r
1364                                 $my_tree .= $interface;\r
1365                             }\r
1366                         }\r
1367                         $my_tree .= ')';\r
1368                     } else {\r
1369                         $my_tree .= '<li>'.$this->returnSee($tree[$cur]['link']);\r
1370                     }\r
1371                     $my_tree .= '<ul>'."\n";\r
1372                 }\r
1373                 array_push($lastcur,$cur);\r
1374                 list(,$cur) = each($tree[$cur]['children']);\r
1375 //                var_dump('listed',$cur);\r
1376                 if ($cur)\r
1377                 {\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
1381                     continue;\r
1382                 } else\r
1383                 {\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
1389                 }\r
1390             } else \r
1391             {\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
1396             }\r
1397         } while ($cur);\r
1398         return $my_tree;\r
1399     }\r
1400 \r
1401     /**\r
1402      * Generate indexing information for given element\r
1403      * \r
1404      * @param parserElement descendant of parserElement\r
1405      * @see generateElementIndex()\r
1406      * @return array\r
1407      */\r
1408     function getIndexInformation($elt)\r
1409     {\r
1410         $Result['type'] = $elt->type;\r
1411         $Result['file_name'] = $elt->file;\r
1412         $Result['path'] = $elt->getPath();\r
1413         \r
1414         if (isset($elt->docblock))\r
1415                                         {\r
1416                                                 $Result['description'] = $elt->docblock->getSDesc($this);\r
1417                                                 \r
1418                                                 if ($elt->docblock->hasaccess)\r
1419                                                         $Result['access'] = $elt->docblock->tags['access'][0]->value;\r
1420                                                 else\r
1421                                                         $Result['access'] = 'public';\r
1422 \r
1423                                                 $Result['abstract'] = isset ($elt->docblock->tags['abstract'][0]);\r
1424                                         }\r
1425         else\r
1426             $Result['description'] = '';\r
1427         \r
1428         $aa = $Result['description'];\r
1429         if (!empty($aa)) $aa = "<br>&nbsp;&nbsp;&nbsp;&nbsp;$aa";\r
1430 \r
1431         switch($elt->type)\r
1432         {\r
1433                 case 'class':\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
1438                                                               $elt->getPath(),\r
1439                                                               $elt->getName());\r
1440                         $Result['listing'] = 'in file '.$elt->file.', class '.$Result['link']."$aa";\r
1441                 break;\r
1442                 case 'define':\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
1447                                                                $elt->getPath(),\r
1448                                                                $elt->getName());\r
1449                         $Result['listing'] = 'in file '.$elt->file.', constant '.$Result['link']."$aa";\r
1450                 break;\r
1451                 case 'global':\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
1456                                                                $elt->getPath(),\r
1457                                                                $elt->getName());\r
1458                         $Result['listing'] = 'in file '.$elt->file.', global variable '.$Result['link']."$aa";\r
1459                 break;\r
1460                 case 'function':\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
1465                                                                  $elt->getPath(),\r
1466                                                                  $elt->getName().'()');\r
1467                         $Result['listing'] = 'in file '.$elt->file.', function '.$Result['link']."$aa";\r
1468                 break;\r
1469                 case 'method':\r
1470                         $Result['name'] = $elt->getName();\r
1471                         $Result['title'] = 'Method';\r
1472                         $Result['link'] = $this->getMethodLink($elt->getName(),\r
1473                                                                $elt->class,\r
1474                                                                $elt->docblock->package,\r
1475                                                                $elt->getPath(),\r
1476                                                                $elt->class.'::'.$elt->getName().'()'\r
1477                                                                          );\r
1478                                                                                                         if ($elt->isConstructor) $Result['constructor'] = 1;\r
1479                         $Result['listing'] = 'in file '.$elt->file.', method '.$Result['link']."$aa";\r
1480                 break;\r
1481                 case 'var':\r
1482                         $Result['name'] = $elt->getName();\r
1483                         $Result['title'] = 'Variable';\r
1484                         $Result['link'] = $this->getVarLink($elt->getName(),\r
1485                                                             $elt->class,\r
1486                                                             $elt->docblock->package,\r
1487                                                             $elt->getPath(),\r
1488                                                             $elt->class.'::'.$elt->getName());\r
1489                         $Result['listing'] = 'in file '.$elt->file.', variable '.$Result['link']."$aa";\r
1490                 break;\r
1491                 case 'const':\r
1492                         $Result['name'] = $elt->getName();\r
1493                         $Result['title'] = 'Class Constant';\r
1494                         $Result['link'] = $this->getConstLink($elt->getName(),\r
1495                                                             $elt->class,\r
1496                                                             $elt->docblock->package,\r
1497                                                             $elt->getPath(),\r
1498                                                             $elt->class.'::'.$elt->getName());\r
1499                         $Result['listing'] = 'in file '.$elt->file.', class constant '.$Result['link']."$aa";\r
1500                 break;\r
1501                 case 'page':\r
1502                         $Result['name'] = $elt->getFile();\r
1503                         $Result['title'] = 'Page';\r
1504                         $Result['link'] = $this->getPageLink($elt->getFile(),\r
1505                                                              $elt->package,\r
1506                                                              $elt->getPath(),\r
1507                                                              $elt->getFile());\r
1508                         $Result['listing'] = 'procedural page '.$Result['link'];\r
1509                 break;\r
1510                 case 'include':\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
1515                 break;\r
1516         }\r
1517 \r
1518         return $Result;\r
1519     }\r
1520     /**\r
1521      * Generate alphabetical index of all elements\r
1522      *\r
1523      * @see $elements, walk()\r
1524      */\r
1525     function generateElementIndex()\r
1526     {\r
1527         $elementindex = array();\r
1528         $letters = array();\r
1529         $used = array();\r
1530         foreach($this->elements as $letter => $nutoh)\r
1531         {\r
1532             foreach($this->elements[$letter] as $i => $yuh)\r
1533             {\r
1534                 if ($this->elements[$letter][$i]->type != 'include')\r
1535                 {\r
1536                     if (!isset($used[$letter]))\r
1537                     {\r
1538                         $letters[]['letter'] = $letter;\r
1539                         $elindex['letter'] = $letter;\r
1540                         $used[$letter] = 1;\r
1541                     }\r
1542 \r
1543                     $elindex['index'][] = $this->getIndexInformation($this->elements[$letter][$i]);\r
1544                 }\r
1545             }\r
1546             if (isset($elindex['index']))\r
1547             {\r
1548                 $elementindex[] = $elindex;\r
1549             } else\r
1550             {\r
1551                 unset($letters[count($letters) - 1]);\r
1552             }\r
1553             $elindex = array();\r
1554         }\r
1555         return array($elementindex,$letters);\r
1556     }\r
1557     \r
1558     function copyMediaRecursively($media,$targetdir,$subdir = '')\r
1559     {\r
1560         $versionControlDirectories = array ('CVS', 'media/CVS', 'media\\CVS', '.svn', 'media/.svn', 'media\\.svn');\r
1561         if (!is_array($media)) {\r
1562             return;\r
1563         }\r
1564         foreach($media as $dir => $files)\r
1565         {\r
1566             if ($dir === '/')\r
1567             {\r
1568                 $this->copyMediaRecursively($files,$targetdir);\r
1569             } else\r
1570             {\r
1571                 if (!is_numeric($dir))\r
1572                 {\r
1573                     if (in_array($dir, $versionControlDirectories))\r
1574                     {\r
1575                         // skip it entirely\r
1576                     }\r
1577                     else\r
1578                     {\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
1583                         {\r
1584                             $subdir .= PATH_DELIMITER;\r
1585                         }\r
1586                         $this->copyMediaRecursively($files,"$targetdir/$dir",$subdir . $dir);\r
1587                     }\r
1588                 } \r
1589                 else\r
1590                 {\r
1591                     // copy the file\r
1592                     phpDocumentor_out("copying $targetdir" . PATH_DELIMITER . $files['file']."\n");\r
1593                     $this->copyFile($files['file'],$subdir);\r
1594                 }\r
1595             }\r
1596         }\r
1597     }\r
1598     \r
1599     /**\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
1602      */\r
1603     function setTargetDir($dir)\r
1604     {\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
1610         $tdir = $dir;\r
1611         $dir = $this->templateDir;\r
1612         $this->templateDir = $this->templateDir.'templates/';\r
1613         $info = new Io;\r
1614         $this->copyMediaRecursively($info->getDirTree($this->templateDir.'media',$this->templateDir),$tdir);\r
1615     }\r
1616     \r
1617     /**\r
1618      * Generate alphabetical index of all elements by package and subpackage\r
1619      *\r
1620      * @param string $package name of a package\r
1621      * @see $pkg_elements, walk(), generatePkgElementIndexes()\r
1622      */\r
1623     function generatePkgElementIndex($package)\r
1624     {\r
1625 //        var_dump($this->pkg_elements[$package]);\r
1626         $elementindex = array();\r
1627         $letters = array();\r
1628         $letterind = array();\r
1629         $used = array();\r
1630         $subp = '';\r
1631         foreach($this->pkg_elements[$package] as $subpackage => $els)\r
1632         {\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
1636             {\r
1637                 foreach($els[$letter] as $i => $yuh)\r
1638                 {\r
1639                     if ($els[$letter][$i]->type != 'include')\r
1640                     {\r
1641                         if (!isset($used[$letter]))\r
1642                         {\r
1643                             $letters[]['letter'] = $letter;\r
1644                             $letterind[$letter] = count($letters) - 1;\r
1645                             $used[$letter] = 1;\r
1646                         }\r
1647                         $elindex[$letter]['letter'] = $letter;\r
1648 \r
1649                         $elindex[$letter]['index'][] = $this->getIndexInformation($els[$letter][$i]);\r
1650                     }\r
1651                 }\r
1652             }\r
1653         }\r
1654         ksort($elindex);\r
1655         usort($letters,'HTMLframes_lettersort');\r
1656         if (isset($elindex))\r
1657         {\r
1658             while(list($letter,$tempel) = each($elindex))\r
1659             {\r
1660                 if (!isset($tempel))\r
1661                 {\r
1662                     unset($letters[$letterind[$tempel['letter']]]);\r
1663                 } else\r
1664                 $elementindex[] = $tempel;\r
1665             }\r
1666         } else $letters = array();\r
1667         return array($elementindex,$letters);\r
1668     }\r
1669     \r
1670     /**\r
1671      *\r
1672      * @see generatePkgElementIndex()\r
1673      */\r
1674     function generatePkgElementIndexes()\r
1675     {\r
1676         $packages = array();\r
1677         $package_names = array();\r
1678         $pkg = array();\r
1679         $letters = array();\r
1680         foreach($this->pkg_elements as $package => $trash)\r
1681         {\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
1686             {\r
1687                 $packages[] = $pkg;\r
1688                 $package_names[] = $pkgs;\r
1689             }\r
1690             unset($pkgs);\r
1691             unset($pkg);\r
1692         }\r
1693         foreach($packages as $i => $package)\r
1694         {\r
1695             $pnames = array();\r
1696             for($j=0;$j<count($package_names);$j++)\r
1697             {\r
1698                 if ($package_names[$j]['package'] != $package['package']) $pnames[] = $package_names[$j];\r
1699             }\r
1700             $packages[$i]['packageindexes'] = $pnames;\r
1701         }\r
1702         return array($packages,$package_names,$letters);\r
1703     }\r
1704     \r
1705     /**\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
1713      */\r
1714     function getClassLink($expr,$package, $file = false,$text = false, $with_a = true)\r
1715     {\r
1716         $a = Converter::getClassLink($expr,$package,$file);\r
1717         if (!$a) return false;\r
1718         return $this->returnSee($a, $text, $with_a);\r
1719     }\r
1720 \r
1721     /**\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
1729      */\r
1730     function getFunctionLink($expr,$package, $file = false,$text = false)\r
1731     {\r
1732         $a = Converter::getFunctionLink($expr,$package,$file);\r
1733         if (!$a) return false;\r
1734         return $this->returnSee($a, $text);\r
1735     }\r
1736 \r
1737     /**\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
1745      */\r
1746     function getDefineLink($expr,$package, $file = false,$text = false)\r
1747     {\r
1748         $a = Converter::getDefineLink($expr,$package,$file);\r
1749         if (!$a) return false;\r
1750         return $this->returnSee($a, $text);\r
1751     }\r
1752 \r
1753     /**\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
1761      */\r
1762     function getGlobalLink($expr,$package, $file = false,$text = false)\r
1763     {\r
1764         $a = Converter::getGlobalLink($expr,$package,$file);\r
1765         if (!$a) return false;\r
1766         return $this->returnSee($a, $text);\r
1767     }\r
1768 \r
1769     /**\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
1777      */\r
1778     function getPageLink($expr,$package, $path = false,$text = false)\r
1779     {\r
1780         $a = Converter::getPageLink($expr,$package,$path);\r
1781         if (!$a) return false;\r
1782         return $this->returnSee($a, $text);\r
1783     }\r
1784 \r
1785     /**\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
1794      */\r
1795     function getMethodLink($expr,$class,$package, $file = false,$text = false)\r
1796     {\r
1797         $a = Converter::getMethodLink($expr,$class,$package,$file);\r
1798         if (!$a) return false;\r
1799         return $this->returnSee($a, $text);\r
1800     }\r
1801 \r
1802     /**\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
1811      */\r
1812     function getVarLink($expr,$class,$package, $file = false,$text = false)\r
1813     {\r
1814         $a = Converter::getVarLink($expr,$class,$package,$file);\r
1815         if (!$a) return false;\r
1816         return $this->returnSee($a, $text);\r
1817     }\r
1818 \r
1819     /**\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
1828      */\r
1829     function getConstLink($expr,$class,$package, $file = false,$text = false)\r
1830     {\r
1831         $a = Converter::getConstLink($expr,$class,$package,$file);\r
1832         if (!$a) return false;\r
1833         return $this->returnSee($a, $text);\r
1834     }\r
1835     \r
1836     /**\r
1837      * does a nat case sort on the specified second level value of the array\r
1838      *\r
1839      * @param    mixed    $a\r
1840      * @param    mixed    $b\r
1841      * @return    int\r
1842      */\r
1843     function rcNatCmp ($a, $b)\r
1844     {\r
1845         $aa = strtoupper($a[$this->rcnatcmpkey]);\r
1846         $bb = strtoupper($b[$this->rcnatcmpkey]);\r
1847         \r
1848         return strnatcasecmp($aa, $bb);\r
1849     }\r
1850     \r
1851     /**\r
1852      * does a nat case sort on the specified second level value of the array.\r
1853      * this one puts constructors first\r
1854      *\r
1855      * @param    mixed    $a\r
1856      * @param    mixed    $b\r
1857      * @return    int\r
1858      */\r
1859     function rcNatCmp1 ($a, $b)\r
1860     {\r
1861         $aa = strtoupper($a[$this->rcnatcmpkey]);\r
1862         $bb = strtoupper($b[$this->rcnatcmpkey]);\r
1863         \r
1864         if (strpos($aa,'CONSTRUCTOR') === 0)\r
1865         {\r
1866             return -1;\r
1867         }\r
1868         if (strpos($bb,'CONSTRUCTOR') === 0)\r
1869         {\r
1870             return 1;\r
1871         }\r
1872         if (strpos($aa,strtoupper($this->class)) === 0)\r
1873         {\r
1874             return -1;\r
1875         }\r
1876         if (strpos($bb,strtoupper($this->class)) === 0)\r
1877         {\r
1878             return -1;\r
1879         }\r
1880         return strnatcasecmp($aa, $bb);\r
1881     }\r
1882     \r
1883     /**\r
1884      * This function is not used by HTMLdefaultConverter, but is required by Converter\r
1885      */\r
1886     function Output()\r
1887     {\r
1888     }\r
1889 }\r
1890 \r
1891 /**\r
1892  * @access private\r
1893  * @global string name of the package to set as the first package\r
1894  */\r
1895 function HTMLframes_pindexcmp($a, $b)\r
1896 {\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
1901 }\r
1902 \r
1903 /** @access private */\r
1904 function HTMLframes_lettersort($a, $b)\r
1905 {\r
1906     return strnatcasecmp($a['letter'],$b['letter']);\r
1907 }\r
1908 \r
1909 /** @access private */\r
1910 function HTMLframes_outputfilter($src, &$smarty)\r
1911 {\r
1912     return str_replace('{$subdir}',$smarty->_tpl_vars['subdir'],$src);\r
1913 }\r
1914 ?>\r