<?php
/**
  * Ahead WebSoft Technologies Pvt Ltd.
  * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
  * @license    https://www.socialengine.com/policies
*/
?>

<div class='tabs_alt tabs_parent tab_collapsed'>
  <span class="tab_collapsed_action"></span>
  <ul id='main_tabs' class="main_tabs tabs_alt_inner">
		<?php $filteredURL = preg_replace('~(\?|&)'.'tab'.'=[^&]*~', '$1', $_SERVER['REQUEST_URI']);
		if(strpos($filteredURL, '?') === false) {
			$filteredURL = $filteredURL . '?';
		}	else {
			$explode = explode('?', $filteredURL);
			if(!empty($explode[1])) {
				$filteredURL = $filteredURL . '&';
			}
		}
		
		?>
    <?php foreach( $this->tabs as $key => $tab ): ?>
      <?php
		$filteredURL1 = $filteredURL.'tab='.$tab['id'];
        $class   = array();
        $class[] = 'tab_' . $tab['id'];
        $class[] = 'tab_' . trim(str_replace('generic_layout_container', '', $tab['containerClass']));
        if( $this->activeTab == $tab['id'] || $this->activeTab == $tab['name'] )
          $class[] = 'active';
        $class = join(' ', $class);
      ?>
      <?php if( $key < $this->max ): ?>
        <li class="tabs_alt_item <?php echo $class ?>" data-id="<?php echo $tab['id']; ?>"><a href="<?php echo $filteredURL1; ?>" class="ajaxPrevent" onclick="event.preventDefault();moreTabSwitch('','close'); tabContainerSwitch(this, '<?php echo $tab['containerClass'] ?>', '<?php echo $tab['id']; ?>');"><?php echo $this->translate(!empty($tab['title']) ? $tab['title'] : "")  ?><?php if( !empty($tab['childCount']) ): ?><span>(<?php echo $tab['childCount'] ?>)</span><?php endif; ?></a></li>
      <?php endif;?>
    <?php endforeach; ?>
    
    <?php if (engine_count($this->tabs) > $this->max):?>
    <li class="tab_closed more_tab close-more-tab-cnt" onclick="moreTabSwitch(this);">
      <a href="javascript:void(0);"><?php echo $this->translate('More +') ?><span></span></a>
      <div class="tab_pulldown_contents_wrapper">
        <div class="tab_pulldown_contents">
          <ul>
			<?php foreach( $this->tabs as $key => $tab ): ?>
				<?php
					$filteredURLMore = $filteredURL.'tab='.$tab['id'];
					$class   = array();
					$class[] = 'tab_' . $tab['id'];
					$class[] = 'tab_' . trim(str_replace('generic_layout_container', '', $tab['containerClass']));
					if( $this->activeTab == $tab['id'] || $this->activeTab == $tab['name'] ) $class[] = 'active';
					$class = join(' ', array_filter($class));
				?>
				<?php if( $key >= $this->max ): ?>
					<li class="<?php echo $class ?>" data-id="<?php echo $tab['id']; ?>"><a href="<?php echo $filteredURLMore; ?>" class="ajaxPrevent" onclick="event.preventDefault(); tabContainerSwitch(this, '<?php echo $tab['containerClass'] ?>', '<?php echo $tab['id']; ?>')"><?php echo $this->translate($tab['title']) ?><?php if( !empty($tab['childCount']) ): ?><span> (<?php echo $tab['childCount'] ?>)</span><?php endif; ?></a></li>
				<?php endif;?>
			<?php endforeach; ?>
          </ul>
        </div>
      </div>
    </li>
    <?php endif;?>
  </ul>
</div>

<?php echo $this->childrenContent ?>
