Builds navigation tabs.

@since 160708 Menu page utils.

@param \StdClass $cfg Menu page config.

@return string Markup for navigation tabs.
761247
protected function buildNavTabs(\StdClass $cfg): string
    {
        if (!$cfg->tabs) {
            return ''; // Nothing.
        } elseif (!$this->is($cfg->page)) {
            return ''; // Not necessary.
        }
        $has_default_tab  = false;
        $current_tab      = $this->currentTab();
        $current_page_url = $this->c::currentUrl();
        $current_page_url = $this->s::removeUrlNonce($current_page_url);
        $current_page_url = $this->s::removeUrlRestAction($current_page_url);
        $current_page_url = $this->c::removeUrlQueryArgs(['tab'], $current_page_url);

        $markup = '<nav class="-nav-tabs nav-tab-wrapper">';

        foreach ($cfg->tabs as $_key => &$_tab) {
            if (!$_key || !is_string($_key)) {
                throw $this->c::issue('Invalid key.');
            }
            if ($_key === 'restore') {
                $cfg->meta_links['restore'] = true;
                continue; // Back compat for restore.
            }
            if ($_tab && is_string($_tab)) {
                $_tab = ['label' => $_tab];
            }
            $_tab = array_merge([
                'slug'          => '',
                'url'           => '',
                'target'        => '',
                'onclick'       => '',
                'class'         => '',
                'label'         => '',
                'template_file' => '',
                'template_dir'  => '',
            ], (array) $_tab); // Force array.

            $_tab['slug'] = $this->c::nameToSlug($_key);

            if (!$_tab['url'] || $_tab['slug'] === 'default') {
                if ($_tab['slug'] === 'default') {
                    $_tab['url'] = $current_page_url;
                } else { // Add `&tab=` to the current page URL.
                    $_tab['url'] = $this->c::addUrlQueryArgs(['tab' => $_tab['slug']], $current_page_url);
                }
            } // ↑ This constructs the URL leading to a given tab.

            if ($_tab['onclick'] === 'confirm') { // Automatic confirmation.
                $_tab['onclick'] = 'if(!confirm(\''.__('Are you sure?', 'wp-sharks-core').'\')) return false;';
            }
            $_tab['class'] .= ($_tab['class'] ? ' ' : '').'-nav-tab nav-tab';
            $_tab['class'] .= ' -'.$_tab['slug']; // Tab-specific class.

            if ($_tab['slug'] === $current_tab || ($_tab['slug'] === 'default' && !$current_tab)) {
                $_tab['class'] .= ' -active nav-tab-active';

                // NOTE: This allows a tab to set it's own template.
                // Helpful to extensions that filter menu page config values.
                // This is made possible 'by reference'.

                if ($_tab['template_file']) {
                    // Swap template if set by tab config.
                    $cfg->template_file = $_tab['template_file'];
                    $cfg->template_dir  = $_tab['template_dir'];
                    //
                } elseif ($current_tab) { // Use default swap behavior; i.e., add tab suffix.
                    // NOTE: In the case of there being no `$current_tab`, leaving default template as-is.
                    $cfg->template_file = dirname($cfg->template_file).'/'.$current_tab.'.php';
                }
            }
            if (!$_tab['label']) {
                $_tab['label'] = esc_html($this->c::slugToName($_tab['slug']));
            }
            $markup .= '<a'.// Builds tab.
                       ' href="'.esc_url($_tab['url']).'"'.
                       ' target="'.esc_attr($_tab['target']).'"'.
                       ' onclick="'.esc_attr($_tab['onclick']).'"'.
                       ' class="'.esc_attr($_tab['class']).'"'.
                       ' >'.$_tab['label'].'</a>';

            if ($_tab['slug'] === 'default') {
                $has_default_tab = true;
            }
        }
        if (!$has_default_tab) {
            throw $this->c::issue('Missing `default` tab.');
        }
        return $markup .= '</nav>';
    }
212534
public function nav( $nav_class = '' ) {
		echo '<ul role="tablist" class="wplibs-box__nav ' . esc_attr( $nav_class ) . '">';

		foreach ( $this->sections() as $section ) {
			echo $section->navlink(); // @WPCS: XSS OK.
		}

		echo '</ul><!-- /.wplibs-box__nav -->';
	}
1113662
protected function getTabId($current = false)
    {
        if (true === $current) {
            return key($this->tabs);
        }

        $c = $this->tabCount++;

        return $this->defaultTabIdentifier . $c;
    }
631347
public function getTab()
    {
        if (is_null($this->tab)) {
            $this->tab = new Tab($this);
        }

        return $this->tab;
    }
1152281
private function _init_class_cfg(array $cfg = []){
    $cfg = bbn\x::merge_arrays(self::$_defaults, $cfg);

    if ( !isset($cfg['tables'], $cfg['table'], $cfg['arch']) ){
      die('The class '.\get_class($this).' is not configured properly to work with trait dbconfig');
    }

    $this->class_table = $cfg['table'];
    // We completely replace the table structure, no merge
    foreach ( $cfg['arch'] as $t => $a ){
      if ( $cfg['tables'][$t] === $cfg['table'] ){
        $this->class_table_index = $t;
      }
    }
    /*
     * The selection comprises the defined fields of the users table
     * Plus a bunch of user-defined additional fields in the same table
     */
    $this->fields = $cfg['arch'][$this->class_table_index];
    $this->class_cfg = $cfg;
    return $this;
  }
650923
public function getPage( $config = [] ) {

		$modelClass	= static::$modelClass;
		$modelTable	= $this->getModelTable();

	    $sort = new Sort([
	        'attributes' => [
				'id' => [
					'asc' => [ "$modelTable.id" => SORT_ASC ],
					'desc' => [ "$modelTable.id" => SORT_DESC ],
					'default' => SORT_DESC,
					'label' => 'Id'
				],
	            'sdate' => [
	                'asc' => [ "$modelTable.submittedAt" => SORT_ASC ],
	                'desc' => [ "$modelTable.submittedAt" => SORT_DESC ],
	                'default' => SORT_DESC,
	                'label' => 'sdate',
	            ]
	        ],
	        'defaultOrder' => [
	        	'sdate' => SORT_DESC
	        ]
	    ]);

		if( !isset( $config[ 'sort' ] ) ) {

			$config[ 'sort' ] = $sort;
		}

		if( !isset( $config[ 'search-col' ] ) ) {

			$config[ 'search-col' ] = 'submittedAt';
		}

		return parent::findPage( $config );
	}
74813
public function get_group_by(array $cfg): string
  {
    $res = '';
    $group_to_put = [];
    if ( !empty($cfg['group_by']) ){
      foreach ( $cfg['group_by'] as $g ){
        if ( isset($cfg['available_fields'][$g]) ){
          $group_to_put[] = $this->escape($g);
          //$group_to_put[] = $this->col_full_name($g, $cfg['available_fields'][$g], true);
        }
        else{
          $this->db->error("Error! The column '$g' doesn't exist for group by ".print_r($cfg, true));
        }
      }
      if ( count($group_to_put) ){
        $res .= 'GROUP BY '.implode(', ', $group_to_put).PHP_EOL;
      }
    }
    return $res;
  }
245834
public function build(string $bodyCssClass = self::DEFAULT_BODY_CSS_CLASS): string {
    $page          = $this->pageService->getCurrentPage();
    $backendLayout = $this->pageService->getBackendLayoutForPage($page['uid']);

    if (!empty($backendLayout)) {
      $bodyCssClass = "{$backendLayout} {$bodyCssClass}";
    }

    return '<body class="' . $bodyCssClass . '">';
  }
1073399
public function decorateConfiguration(\Mmi\Navigation\NavigationConfig $config)
    {
        $objectArray = (new CmsCategoryQuery)
            ->lang()
            ->andFieldStatus()->equals(\Cms\Orm\CmsCategoryRecord::STATUS_ACTIVE)
            ->orderAscParentId()
            ->orderAscOrder()
            ->find()
            ->toObjectArray();
        foreach ($objectArray as $key => $record) {/* @var $record CmsCategoryRecord */
            if ($record->parentId != 0) {
                continue;
            }
            $element = new \Mmi\Navigation\NavigationConfigElement($record->uri);
            $this->_setNavigationElementFromRecord($record, $element);
            $config->addElement($element);
            unset($objectArray[$key]);
            $this->_buildChildren($record, $element, $objectArray);
        }
    }
775309
public function buildMenu($config)
    {
        $rootNodes = $this->queryForChildrenOf('NE');

        $options = [['', '']];
        while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($rootNodes)) {
            $optionTitle = $row['descr'];
            $optionValue = $row['ppn'];
            $options[] = [$optionTitle , $optionValue];
        }

        $config['items'] = array_merge($config['items'], $options);
        return $config;
    }
1256358
private function createLeftMenu(): string
    {
        $argsCount = 0;
        $arrayKey = $this->getArrayKey($this->menuData);
        $output = '<ul class="navbar navbar-nav mr-auto">';
        foreach ($arrayKey as $menuItem) {
            list($url, $text, $place, $id, $class) = $this->getLinkInformation([$menuItem]);
            if ($place == 'left') {
                $arguments[$argsCount] = $menuItem;
                $arraySubKey = $this->getArrayKey($this->menuData[$menuItem]);
                if (count($arraySubKey) === 0) {
                    $output .= '<li class="nav-item">';
                    $output .= $this->createNavLinkUrl($arguments);
                    $output .= '</li>';
                } else {
                    $output .= '<li class="nav-item dropdown">';
                    $output .= $this->createSubmenu($arguments, $this->menuData[$menuItem]);
                    $output .= '</li>';
                }
            }
        }
        $output .= '</ul>';
        return $output;
    }
422597
protected function getIndentation()
    {
        if ($this->document) {
            if ($this->document->getConfig()->get(FormatterInterface::CFG_USE_TABS)) {
                $indentation = "\t";
            } else {
                $indentation = str_repeat(' ', $this->document->getConfig()->get(FormatterInterface::CFG_INDENTATION));
            }

            return str_repeat($indentation, $this->indentation);
        }
    }
583151
private function getNavigationHtml($parent = null)
    {
        $html = '<ol class="dd-list">';

        $parentId = ($parent ? $parent->id : 0);
        $items = Page::whereParentIdORM($parentId, $this->navigationType, $this->orderProperty);

        foreach ($items as $key => $nav) {
            $html .= '<li class="dd-item" data-id="' . $nav->id . '">';
            $html .= '<div class="dd-handle">' . '<i class="fa-fw fa fa-' . $nav->icon . '"></i> ';
            $html .= $nav->title . ' ' . ($nav->is_hidden == 1 ? '(HIDDEN)' : '') . ' <span style="float:right"> ' . $nav->url . ' </span></div>';
            // featured - ignore parent_id (only one level)
            if ($this->orderProperty != "featured_order") {
                $html .= $this->getNavigationHtml($nav);
            }

            $html .= '</li>';
        }

        $html .= '</ol>';

        return (count($items) >= 1 ? $html : '');
    }
78967
public function get_option($config = '') {
        if ($config === 'apikey') {
            return trim(get_config('youtube', 'apikey'));
        } else {
            $options['apikey'] = trim(get_config('youtube', 'apikey'));
        }
        return parent::get_option($config);
    }
314041
protected function generateNavigation()
    {
        $contexts = [];

        foreach ($this->xpath->query('/x:webspace/x:navigation/x:contexts/x:context') as $contextNode) {
            /* @var \DOMNode $contextNode */
            $contexts[] = new NavigationContext(
                $contextNode->attributes->getNamedItem('key')->nodeValue,
                $this->loadMeta('x:meta/x:*', $contextNode)
            );
        }

        return new Navigation($contexts);
    }
1239607
public function get_cfg(string $id = null, array $cfg = null): ?array
  {
    if (
      (null !== $cfg) ||
      ($cfg = $this->db->select_one(
        $this->class_cfg['table'],
        $this->fields['cfg'],
        [$this->fields['id'] => $id ]
      ))
    ){
      if ( bbn\str::is_json($cfg) ){
        $cfg = json_decode($cfg, 1);
      }
      if ( \is_array($cfg) ){
        $new = [];
        foreach ( $cfg as $k => $v){
          if ( !\in_array($k, $this->fields, true) ){
            $new[$k] = $v;
          }
        }
        return $new;
      }
    }
    return null;
  }
70593
public function configure(ConfigProviderInterface $cfg)
  {
    if($this->_configured)
    {
      return $this;
    }

    try
    {
      $config = $cfg->getSection('console');
      $commands = $config->getItem('commands', []);
      $patterns = $config->getItem('patterns', []);
    }
    catch(\Throwable $e)
    {
      $commands = $patterns = [];
    }

    $this->_searchPatterns = array_merge($this->_searchPatterns, $patterns);

    foreach($commands as $name => $class)
    {
      $command = $this->getCommandByString($class);
      if($command !== null)
      {
        if(!is_int($name))
        {
          $command->setName($name);
        }
        $this->add($command);
      }
    }

    $this->_configured = true;
    return $this;
  }