<?php
class marker_groupsGmp extends moduleGmp
{
  public function init()
  {
    dispatcherGmp::addFilter('mainAdminTabs', [$this, 'addAdminTab']);
  }
  public function addAdminTab($tabs)
  {
    $tabs[$this->getCode()] = [
      'label' => __('Marker Categories', GMP_LANG_CODE),
      'callback' => [$this, 'getTabContent'],
      'fa_icon' => 'fa-map-marker',
      'sort_order' => 60,
    ];
    $tabs[$this->getCode() . '_add_new'] = [
      'label' => __('Add New', GMP_LANG_CODE),
      'callback' => [$this, 'getAddNewTabContent'],
      'sort_order' => 60,
      'child_of' => $this->getCode(),
      'hidden' => 1,
      'add_bread' => $this->getCode(),
    ];
    $tabs[$this->getCode() . '_edit'] = [
      'label' => __('Edit', GMP_LANG_CODE),
      'callback' => [$this, 'getEditTabContent'],
      'sort_order' => 60,
      'child_of' => $this->getCode(),
      'hidden' => 1,
      'add_bread' => $this->getCode(),
    ];
    $tabs[$this->getCode() . '_options'] = [
      'label' => __('Edit', GMP_LANG_CODE),
      'callback' => [$this, 'getOptionsTabContent'],
      'sort_order' => 60,
      'child_of' => $this->getCode(),
      'hidden' => 1,
      'add_bread' => $this->getCode(),
    ];
    return $tabs;
  }
  public function getAddNewTabContent()
  {
    return $this->getView()->getEditMarkerGroup();
  }
  public function getEditTabContent()
  {
    $id = (int) reqGmp::getVar('id', 'get');
    if (!$id) {
      return __('No Marker Category Found', GMP_LANG_CODE);
    }
    return $this->getView()->getEditMarkerGroup($id);
  }
  public function getTabContent()
  {
    return $this->getView()->getTabContent();
  }
  public function getOptionsTabContent()
  {
    return $this->getView()->getOptionsTabContent();
  }
  public function getEditMarkerGroupLink($id)
  {
    return frameGmp::_()->getModule('options')->getTabUrl('marker_groups_edit') . '&id=' . $id;
  }
}
