<?php
class admin_navCfs extends moduleCfs
{
  public function getBreadcrumbsList()
  {
    $res = [['label' => CFS_WP_PLUGIN_NAME, 'url' => frameCfs::_()->getModule('adminmenu')->getMainLink()]];
    // Try to get current tab breadcrumb
    $activeTab = frameCfs::_()->getModule('options')->getActiveTab();
    if (!empty($activeTab) && $activeTab != 'main_page') {
      $tabs = frameCfs::_()->getModule('options')->getTabs();
      if (!empty($tabs) && isset($tabs[$activeTab])) {
        if (isset($tabs[$activeTab]['add_bread']) && !empty($tabs[$activeTab]['add_bread'])) {
          if (!is_array($tabs[$activeTab]['add_bread'])) {
            $tabs[$activeTab]['add_bread'] = [$tabs[$activeTab]['add_bread']];
          }
          foreach ($tabs[$activeTab]['add_bread'] as $addForBread) {
            $res[] = [
              'label' => $tabs[$addForBread]['label'],
              'url' => $tabs[$addForBread]['url'],
            ];
          }
        }
        /*if($activeTab == 'popup_edit') {
					$id = (int) reqCfs::getVar('id', 'get');
					if($id) {
						$tabs[ $activeTab ]['url'] .= '&id='. $id;
					}
				}*/
        $res[] = [
          'label' => $tabs[$activeTab]['label'],
          'url' => $tabs[$activeTab]['url'],
        ];
        if ($activeTab == 'statistics') {
          $statTabs = frameCfs::_()->getModule('statistics')->getStatTabs();
          $currentStatTab = frameCfs::_()->getModule('statistics')->getCurrentStatTab();
          if (isset($statTabs[$currentStatTab])) {
            $res[] = [
              'label' => $statTabs[$currentStatTab]['label'],
              'url' => $statTabs[$currentStatTab]['url'],
            ];
          }
        }
      }
    }
    return $res;
  }
}
