<?php
/**
 * Table of content for the status page.
 *
 * @package northmill-online-shared
 *
 * @noinspection HtmlUnknownAnchorTarget Anchors in status view pages.
 */

declare(strict_types=1);

/**
 * View parameters.
 *
 * @var array $params
 */

defined( 'ABSPATH' ) || exit;

?>
<ul id="nm-tabs">
	<?php
	foreach ( $params['sections'] as $section_id => $section ) {
		?>
		<li>
			<a href="#<?php echo esc_attr( $section_id ); ?>" class="<?php echo $section['active'] ? 'active' : ''; ?>">
				<?php echo esc_html( $section['title'] ); ?>
			</a>
		</li>
		<?php
	}
	?>
</ul>

<div id="nm-toc">
	<?php
	foreach ( $params['sections'] as $section_id => $section ) {
		if ( ! empty( $section['toc'] ) ) {
			?>
			<div data-id="#<?php echo esc_attr( $section_id ); ?>" class="<?php echo $section['active'] ? 'active' : ''; ?>">
				<ul>
					<?php
					foreach ( $section['toc'] as $toc_section ) {
						?>
						<li>
							<a href="#<?php echo esc_attr( $toc_section['id'] ); ?>"><?php echo esc_html( $toc_section['title'] ); ?></a>
							<?php
							if ( ! empty( $toc_section['sub'] ) ) {
								?>
								<ul>
									<?php
									foreach ( $toc_section['sub'] as $sub_section ) {
										?>
										<li>
											<a href="#<?php echo esc_attr( $sub_section['id'] ); ?>"><?php echo esc_html( $sub_section['title'] ); ?></a>
										</li>
										<?php
									}
									?>
								</ul>
								<?php
							}
							?>
						</li>
						<?php
					}
					?>
				</ul>
			</div>
			<?php
		}
	}
	?>
</div>
