cvs: pearweb /public_html faq.php

From: Date: Sun, 02 Sep 2001 12:25:20 +0000
Subject: cvs: pearweb /public_html faq.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-754@lists.php.net to get a copy of this message
mj Sun Sep 2 08:25:20 2001 EDT Modified files: /pearweb/public_html faq.php Log: * generating table of contents now Index: pearweb/public_html/faq.php diff -u pearweb/public_html/faq.php:1.4 pearweb/public_html/faq.php:1.5 --- pearweb/public_html/faq.php:1.4 Sat Sep 1 09:57:06 2001 +++ pearweb/public_html/faq.php Sun Sep 2 08:25:20 2001 @@ -1,144 +1,170 @@ +<!-- $Id: faq.php,v 1.5 2001/09/02 12:25:20 mj Exp $ //--> <?php response_header("FAQ"); echo "<h1>PEAR Frequently Asked Questions</h1>"; -$ID = 1; +$ID = 0; +$TOC = array(); +$content = ""; + +function makeTOC($toc) +{ + $content = "<h3>Table of contents</h3>"; + if (is_array($toc)) { + foreach ($toc as $key => $value) { + $content .= "<a href=\"faq.php#faq-".$key."\">".$value."</a><br/>"; + } + } + + return $content; + +} function startElement($parser, $elementName, $elementAttributes) { + $content = ""; + switch (strtolower($elementName)) { /** * Tag defining the table structure */ case "qandaset" : - echo "<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\">"; + $content .= "<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\">"; break; case "question" : - echo "<tr><td bgcolor=\"#cccccc\"><a name=\"faq-".$GLOBALS['ID']++."\"><h3>"; + $content .= "<tr><td bgcolor=\"#cccccc\"><a name=\"faq-".$GLOBALS['ID']."\"><h3>"; + $content .= $elementAttributes['TITLE']; + $GLOBALS['TOC'][$GLOBALS['ID']] = $elementAttributes['TITLE']; + $GLOBALS['ID']++; break; case "answer" : - echo "<tr><td bgcolor=\"#eeeeee\">"; + $content .= "<tr><td bgcolor=\"#eeeeee\">"; break; /** * Tags defining the appearance of lists */ case "simplelist" : - echo "<ul>"; + $content .= "<ul>"; break; case "member" : - echo "<li>"; + $content .= "<li>"; break; /** * Appearance */ case "para" : - echo "<p>"; + $content .= "<p>"; break; case "artheader" : case "command" : - echo "<pre>"; + $content .= "<pre>"; break; case "emphasis" : - echo "<em>"; + $content .= "<em>"; break; case "ulink" : - echo "<a href=\"".$elementAttributes['URL']."\">"; + $content .= "<a href=\"".$elementAttributes['URL']."\">"; if (isset($elementAttributes['NAME'])) { - echo $elementAttributes['NAME']; + $content .=$elementAttributes['NAME']; } break; case "faqlink" : - echo "<a href=\"faq.php#faq-".$elementAttributes['FAQ']."\">"; + $content .= "<a href=\"faq.php#faq-".$elementAttributes['FAQ']."\">"; break; case "author" : if ($elementAttributes['NAME'] != "") { - echo "<b>Answer written by ".$elementAttributes['NAME']."."; + $content .= "<b>Answer written by ".$elementAttributes['NAME']."."; } else { - echo "<b>"; + $content .= "<b>"; } break; case "break" : - echo "<br/>"; + $content .= "<br/>"; break; } + + $GLOBALS['content'] .= $content; } function endElement($parser, $elementName) { + $content = ""; + switch (strtolower($elementName)) { /** * Tags defining the table structure */ case "qandaset" : - echo "</table>"; + $content .= "</table>"; break; case "question" : - echo "</h3></td></tr>\n"; + $content .= "</h3></td></tr>\n"; break; case "answer" : - echo "</td></tr>\n"; + $content .= "</td></tr>\n"; break; /** * Tags defining the appearance of lists */ case "simplelist" : - echo "</ul>"; + $content .= "</ul>"; break; case "member" : - echo "</li>"; + $content .= "</li>"; break; case "para" : - echo "</p>"; + $content .= "</p>"; break; case "artheader" : case "command" : - echo "</pre>"; + $content .= "</pre>"; break; case "emphasis" : - echo "</em>"; + $content .= "</em>"; break; case "ulink" : case "faqlink" : - echo "</a>"; + $content .= "</a>"; break; case "author" : - echo "</b>"; + $content .= "</b>"; break; } - + + $GLOBALS['content'] .= $content; } function characterData($parser, $data) { - echo $data; + $GLOBALS['content'] .= htmlspecialchars($data); } if (getenv("SERVER_NAME") != "pear.php.net") { @@ -160,6 +186,10 @@ xml_parser_free($parser); fclose($fp); + +echo makeTOC($TOC); + +echo $content; response_footer(); ?>

« previous php.pear.cvs (#754) next »