<?php

use Jet\MVC;
use Jet\MVC_View;
use Jet\Navigation_Breadcrumb;
use Jet\UI;
use Jet\UI_badge;

/**
 * @var MVC_View $this
 */
$items = Navigation_Breadcrumb::getItems();
?>
<nav aria-label="breadcrumb">
	<ol class="breadcrumb">
		<?php foreach( MVC::getBase()->getActiveLocales() as $locale ): ?>
			<li style="margin-right: 20px;">
				<?php if( $locale->toString() == MVC::getLocale()->toString() ):
					echo UI::badge( UI_badge::INFO, UI::flag( $locale ).'&nbsp;'.$locale->getLanguageName( $locale ));
				else:
					$eq_page = MVC::getPage( locale: $locale );
					if( !$eq_page ) {
						$eq_page = MVC::getHomePage( locale: $locale );
					}
					?>
					<a href="<?= $eq_page->getURL() ?>"><?= UI::flag( $locale ) ?>
						&nbsp;<?= $locale->getLanguageName( $locale ) ?></a>
				<?php endif; ?>
			</li>
		<?php endforeach; ?>

		<?php foreach( $items as $item ): ?>
			<?php if( $item->getIsActive() ): ?>
				<li class="breadcrumb-item active">
					<?php if( !$item->getIsLast() ): ?>
						<a href="<?= $item->getURL(); ?>"><?= $item->getTitle(); ?></a>
					<?php else: ?>
						<?= $item->getTitle(); ?>
					<?php endif; ?>
				</li>
			<?php else: ?>
				<li class="breadcrumb-item">
					<?php if( !$item->getIsLast() ): ?>
						<a href="<?= $item->getURL(); ?>"><?= $item->getTitle(); ?></a>
					<?php else: ?>
						<?= $item->getTitle(); ?>
					<?php endif; ?>
				</li>
			<?php endif; ?>
		<?php endforeach; ?>
	</ol>
</nav>
