00001 <?php
00007 class STransBookXML extends STransXML
00008 {
00009
00014 public function doc() {
00015 return "Translate a BookXML string into a dynamic table of contents.";
00016 }
00017
00018
00019
00020
00021
00027 public function translate ($si)
00028 {
00029 if (parent::translate($si) === false){ return false; }
00030 $xml = SXMLHelper::parse($si->getSource());
00031
00032
00033 $collect = "";
00034 $partCount = 1;
00035
00036 foreach($xml->part as $part) {
00037 $collect .=<<< END_COLLECT
00038 <div style="font-weight:bold; border-bottom: 1px solid gray;">
00039 <a href="javascript:toggleDivDisplay('part' + $partCount);">[+]</a> Part $partCount: $part->title (p. $part->page )
00040 </div>
00041 <ul id="part$partCount" style="display:none">
00042 END_COLLECT;
00043
00044 $chapterCount = 1;
00045 foreach($part->chapter as $chapter) {
00046
00047 $collect .= "<li><a href=\"javascript:toggleDivDisplay($partCount + 'chapter' + $chapterCount);\">[+]</a> Chapter " . $chapter->title . " (p. " . $chapter->page . ")";
00048 $collect .= "<ul id=\"$partCount" . "chapter$chapterCount\" style=\"display:none\">";
00049
00050 $chapterCount++;
00051
00052 foreach($chapter->section as $section) {
00053 $collect .= "<li>" . $this->transHelper->formatParagraphHtml($section->title) . " (p. " . $section->page . ")</li><ul>";
00054
00055 foreach($section->subsection as $subsection) {
00056 $collect .= "<li>" . $this->transHelper->formatParagraphHtml($subsection->title) . " (p. " . $subsection->page . ")</li>";
00057 }
00058 $collect .= "</ul>";
00059
00060
00061 }
00062
00063 $collect .= "</ul></li><br />";
00064 }
00065
00066
00067 $collect .= "</ul><br />";
00068 $partCount++;
00069 }
00070
00071 $this->sendToTarget($si, $collect);
00072 }
00073 }
00074
00075 ?>