HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/vebon.komma.pro/app/KommaApp/Kms/Core/Sections/KmsSectionTabs.php
<?php namespace KommaApp\Kms\Core\Sections;
/**
 *
 *
 * @author      Komma <info@komma.pro>
 * @copyright   (c) 2012-2016, Komma Mediadesign
 */
class KmsSectionTabs
{

    protected $tabs = [];

    public function getOrCreateTab($name)
    {
        if (!$tab = $this->getTabBySlug($name)) {
            return $this->tabs[] = new KmsSectionTab($name, str_slug($name));
        }
        return $tab;
    }

    public function addItem(&$item, $tabSlug, $subTabSlug = null, $subSubTabSlug = null)
    {
        if ($tabSlug == null) {
            $tabSlug = 'lang_get:kms/global.general';
        }
        //if the tab slug starts with lang_get change this
        if (!is_string($tabSlug)) $tabSlug = 'lang_get:kms/global.general';
        if (preg_match('/lang_get:(.*)/i', $tabSlug, $match)) {
            $tabSlug = \Lang::get($match[1]);
        }
        $tab = $this->getOrCreateTab($tabSlug);
        $tab->addItem($item, $subTabSlug, $subSubTabSlug);
    }

    public function getTabs()
    {
        return $this->tabs;
    }

    public function clearTabs()
    {
        $this->tabs = [];
    }

    protected function getTabBySlug($slug)
    {
        foreach ($this->tabs as $tab) {
            if ($tab->getSlug() == str_slug($slug)) return $tab;
        }
        return null;
    }

}