<?php
/*
 * \Sentra.Designs\BasicDesigner\modules\menues\vertsubpagesnavi\render_subpagesnavi.tpl
 */

$iscommonpage = $IS_HOME;
$common = get_common_pages(false);
if ($common['count']>0) {
	for ($x=0;$x < $common['count'];$x++) {
		If ($CURRENT_PAGE['id'] == $common[$x]['id']) {
			$iscommonpage = TRUE;
		}
	}
}
$show_subpagesnavi = FALSE;
if ($iscommonpage) {	/* show subpages menu if no common navi is available on page */
//DEBUG($CURRENT_PAGE['id']);
//If(isset($hascommonnavi))DEBUG($hascommonnavi);
	If(isset($hascommonnavi) && isset($hascommonnavi[$CURRENT_PAGE['id']]) && !$hascommonnavi[$CURRENT_PAGE['id']]) {
		$show_subpagesnavi = TRUE;
//		DEBUG($CURRENT_PAGE['caption'].': iscommonpage = TRUE (No common navi available');
	} Else {
//		DEBUG($CURRENT_PAGE['caption'].': iscommonpage = TRUE (common navi IS available');
	}
} Else {
	$show_subpagesnavi = TRUE;
//	DEBUG($CURRENT_PAGE['caption'].': isNOcommonpage');
}

If ($show_subpagesnavi) {
//	DEBUG($CURRENT_PAGE['caption'].': Show Subpages');
} Else {
//	DEBUG($CURRENT_PAGE['caption'].": DON'T Show Subpages2");
}


$subps = get_sub_pages($CURRENT_PAGE['id']);
if ($subps['count'] > 0 && $show_subpagesnavi) {
//	DEBUG($CURRENT_PAGE['caption'].': Show Subpages');
	$hassubpagenavi[$CURRENT_PAGE['id']] = TRUE;
//	$HOME = get_home_page();
	/* Prevent that common pages navi and subpages navi appear simultaneously on HOME */
	/*
	if (isset($TEMPLATER_PARAMETER['ShortText'])) $short = $TEMPLATER_PARAMETER['ShortText']; else $short = "False";
	if (isset($TEMPLATER_PARAMETER['cutCount'])) $cutCount = $TEMPLATER_PARAMETER['cutCount']; else $cutCount = 100;
	if (isset($TEMPLATER_PARAMETER['cutMode'])) $cutMode = $TEMPLATER_PARAMETER['cutMode']; else $cutMode = "False";
	if ($cutMode == "False")
    	$cutCount = 9999;
	*/

	echo '<ul class="common-navi">'.PHP_EOL;
	for ($x=0;$x < $subps['count'];$x++) {
		If ($CURRENT_PAGE['id'] == $subps[$x]['id']) { // See if this page is the active page
			echo	'	<li>'.PHP_EOL.
						'		<a class="current"'.make_link($subps[$x]).' >'.'			'.PHP_EOL.print_caption($subps[$x],false).PHP_EOL.'		</a>';
		} Else {
			echo	'	<li>'.PHP_EOL.
						'		<a '.make_link($subps[$x]).' >'.PHP_EOL.'			'.print_caption($subps[$x],false).PHP_EOL.'		</a>';
		}

/*
		if (isset ($subps[$x]['ShortText']) && $short == "True")
			echo ' <p>'.Str::Truncate($subps[$x]['ShortText'],$cutCount).'</p>';
*/
		echo '</li>'.PHP_EOL;
	}

	echo '</ul>	<!-- Close class="common-navi" -->'.PHP_EOL;
}
?>
