<?php

//###### zugehörige Daten anhand des Page-Namens ermitteln
$currentPageFilePath = phpConvertNamespaceToFilesystemPath(preg_replace('/:index$/', '', $_GET["id"]));
$currentPageId = end(explode( ':', htmlspecialchars($_GET["id"]) ));

###### CSS-Datei inkludieren ##################################################################################

include($includeCss);
$bookStructure = recursiveScanBookStructure($currentPageFilePath);

//###### HTML-Tag öffnen
//##################################################################################
echo '<html>';

echo'

<!– ###### parentbox umspannender Inhalts-Container (öffnen) –>';

$bookCounter = 0;
$bookStructureArrayCounter=0;
while ($bookStructureArrayCounter < sizeof($bookStructure)) {
  if ($bookStructure[$bookStructureArrayCounter]['type'] == '0') {
    $bookCounter ++;
    echo'
    <div class="tocBox">
      <div class="tocBoxFirstColumn">
        <div class="tocBoxBookNumber">' . $bookCounter . '</div>
      </div>
      <div class="tocBoxSecondColumn"></div>
      <div class="tocBoxThirdColumn"></div>
      <div class="tocBoxFourthColumn">
        <details' . (($bookStructureArrayCounter==0) ? ' open' : '') . '>
          <summary class="tocBoxHiddenBlock">
            <div class="tocBoxHiddenBlockTitle">' . $bookStructure[$bookStructureArrayCounter]['title'] . '</div>
          </summary>
          <div class="legendRow">
            <div class="legendColumnIcon">&#215;</div>
            <div class="legendColumnText" style="background: mistyrose;">Leer</div>
            <div class="legendColumnIcon">&#9998;</div>
            <div class="legendColumnText" style="background: sandybrown;">Entwurf</div>
            <div class="legendColumnIcon">&#9997;</div>
            <div class="legendColumnText" style="background: khaki;">Korrektur</div>
            <div class="legendColumnIcon">&#10004;</div>
            <div class="legendColumnText" style="background: ghostwhite;">Fertig</div>
          </div>
          <div class="tocBoxHiddenBlockChapterStructure">
            <div class="tocBoxHiddenBlockRowHeadline">
              <div class="tocBoxBookStructureFirstColumnChapter">Akt</div>
              <div class="tocBoxBookStructureSecondColumnChapter">Kapitel</div>
              <div class="tocBoxBookStructureThirdColumnChapter">Titel</div>
            </div>';
    $bookStructureArrayCounter++;
    while ( ($bookStructure[$bookStructureArrayCounter]['type'] == '1') || ($bookStructure[$bookStructureArrayCounter]['type'] == '2') ) {
      //###### Tabelle fuer Buchueberschrift
      echo '
            <div class="tocBoxHiddenBlockRow"">
              <div class="' . (($bookStructure[$bookStructureArrayCounter]['type'] == '1') ? 'tocBoxBookStructureFirstColumnAct' : 'tocBoxBookStructureFirstColumnChapter') . '">' . (($bookStructure[$bookStructureArrayCounter]['type'] == '1') ? $bookStructure[$bookStructureArrayCounter]['structureName'] : '&nbsp;') . '</div>
              <div class="' . (($bookStructure[$bookStructureArrayCounter]['type'] == '1') ? 'tocBoxBookStructureSecondColumnAct' : 'tocBoxBookStructureSecondColumnChapter') . '">' . (($bookStructure[$bookStructureArrayCounter]['type'] == '2') ? $bookStructure[$bookStructureArrayCounter]['structureName'] : '&nbsp;') . '</div>
              <div class="' . (($bookStructure[$bookStructureArrayCounter]['type'] == '1') ? 'tocBoxBookStructureThirdColumnAct' : 'tocBoxBookStructureThirdColumnChapter') . '"></html>[[' . $bookStructure[$bookStructureArrayCounter]['wikiPath'] . '|' . $bookStructure[$bookStructureArrayCounter]['title'] . ']]<html></div>
            </div>';
      $bookStructureArrayCounter++;
    }
    echo '      
          </div>
        </details>
      </div>
      <div class="tocBoxFifthColumn" style="width: 0.5vw; background-color: white; border-width: 0px 0px 1px 0px; border-color: darkgrey; border-style: solid;"></div>
    </div>';
  }
}

echo'

<!– ###### parentbox umspannender Inhalts-Container (schließen) –>';

//###### HTML-Tag schließen
//##################################################################################
echo '</html>';

?>