<commit_before><?php defined('BASEPATH') or exit('No direct script access allowed');
/**
 * @package  PyroCMS
 * @subpackage Streams Tabs Helper
 * @author <NAME> <<EMAIL>>
 * @license MIT
 */

/**
 * Build a tabs array for streams
 * 
 * @param  array  $tabs       Your associative tab array
 * @param  string $stream     Stream slug
 * @param  string $namespace  Stream namesapce
 * @param  string $default    The default tab where other fields will go if they have not been assigned to a tab
 * @return array              The tabs array ready to be passed into $this->streams->cp->entry_form()
 */
function build_tabs($tabs, $stream, $namespace = null, $default = 'general')
{
    $fields = ci()->streams->streams->get_assignments($stream, $namespace);

    foreach ($fields as $field) $tabs[$default]['fields'][$field->field_slug] = $field->field_slug;

    foreach ($tabs as $key => $tab) {

        if ($key == $default) continue;

        foreach ($fields as $field) {

            if (in_array($field->field_slug, $tab['fields'])) {

                unset($tabs[$default]['fields'][$field->field_slug]);

            }

        }
    }

    return $tabs;
}<commit_msg>Remove the default tab if there aren't any fields in it<commit_after><?php defined('BASEPATH') or exit('No direct script access allowed');
/**
 * @package  PyroCMS
 * @subpackage Streams Tabs Helper
 * @author <NAME> <<EMAIL>>
 * @license MIT
 */

/**
 * Build a tabs array for streams
 * 
 * @param  array  $tabs       Your associative tab array
 * @param  string $stream     Stream slug
 * @param  string $namespace  Stream namesapce
 * @param  string $default    The default tab where other fields will go if they have not been assigned to a tab
 * @return array              The tabs array ready to be passed into $this->streams->cp->entry_form()
 */
function build_tabs($tabs, $stream, $namespace = null, $default = 'general')
{
    $fields = ci()->streams->streams->get_assignments($stream, $namespace);

    foreach ($fields as $field) $tabs[$default]['fields'][$field->field_slug] = $field->field_slug;

    foreach ($tabs as $key => $tab) {

        if ($key == $default) continue;

        foreach ($fields as $field) {

            if (in_array($field->field_slug, $tab['fields'])) {

                unset($tabs[$default]['fields'][$field->field_slug]);

            }

        }
    }

    if (empty($tabs[$default]['fields'])) unset($tabs[$default]);

    return $tabs;
}
{'fraction_non_alphanumeric': 0.14709467696058512, 'fraction_numerical': 0.0, 'mean_word_length': 3.0965058236272878, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2191860', 'n_tokens_mistral': 730, 'n_tokens_neox': 707, 'n_words': 229}