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;
}
}