<commit_before><?php

class Apps {

    public $path = 'application/apps/';
    private $apps = array();

    public function list_apps() {
        $path_apps = $this->path;
        $this->apps = array();
        $opendir = \opendir($path_apps);
        while (false !== ($app = readdir($opendir))) {
            if ($app != '.' && $app != '..') {
                if (is_dir($path_apps . $app)) {
                    $CI = &get_instance();
                    if (is_file($path_apps . $app . '/app.yml') && check_app($app)) {
                        $this->set_app($path_apps . $app . '/app.yml', $app);
                    }
                }
            }
        }
        closedir($opendir);
        return $this->apps;
    }

    private function set_app($path, $app) {
        $CI = &get_instance();
        $CI->load->library('spyc');
        $config = $CI->spyc->loadFile($path, false);
        if (is_array($config)) {
            $config['app'] = $app;
            if (empty($config['name'])) {
                $config['name'] = $config['app'];
            }
            if (!isset($config['icon']) or isset($config['icon']) && empty($config['icon'])) {
                $config['icon'] = 'fa-exclamation-triangle';
            }
            if (isset($config['status']) && $config['status'] == 1) {
                return $this->apps[] = $config;
            }
        }
    }

    public function list_apps_permissions() {
        if (empty($this->apps)) {
            $apps = $this->list_apps();
        }
        $apps = $this->apps;
        $config_permissions = array();
        foreach ($apps as $app) {
            $status = $app['status'];
            $dir_app = $app['app'];
            if ($status === 1) {
                $path_permissions = $this->path . $dir_app . '/config/permissions.php';
                if (is_file($path_permissions)) {
                    require($path_permissions);
                    $app['permissions'] = $permission;
                    unset($permission);
                }
                $config_permissions[] = $app;
            }
        }
        return $config_permissions;
    }

    public function list_widgets_dashboards() {
        if (empty($this->apps)) {
            $apps = $this->list_apps();
        }
        $apps = $this->apps;
        $widgets = array();
        $CI = &get_instance();
        foreach ($apps as $app) {
            $status = $app['status'];
            $dir_app = $app['app'];
            if ($status === 1) {
                $path = $this->path . $dir_app . '/libraries/widgets/';
                if (is_dir($path)) {
                    $opendir = \opendir($path);
                    while (false !== ($widget = readdir($opendir))) {
                        if (is_file($path . $widget) && strpos($widget, '_dashboard.php') !== false) {
                            ob_start();
                            $CI->load->library_app('widgets/'.$widget, $dir_app);
                            $class = strtolower(str_replace('.php', '', $widget));
                            $name = $CI->$class->name;
                            $content = ob_get_contents();
                            ob_end_clean();
                            if (!empty($name) && !empty($content)) {
                                $widgets[] = array(
                                    'title' => $name,
                                    'content' => $content,
                                    'app' => $app
                                );
                            }
                        }
                    }
                }
            }
        }
        return $widgets;
    }

}<commit_msg>Inserido uma verificação para verificar existencia da variável para evitar avisos<commit_after><?php

class Apps {

    public $path = 'application/apps/';
    private $apps = array();

    public function list_apps() {
        $path_apps = $this->path;
        $this->apps = array();
        $opendir = \opendir($path_apps);
        while (false !== ($app = readdir($opendir))) {
            if ($app != '.' && $app != '..') {
                if (is_dir($path_apps . $app)) {
                    $CI = &get_instance();
                    if (is_file($path_apps . $app . '/app.yml') && check_app($app)) {
                        $this->set_app($path_apps . $app . '/app.yml', $app);
                    }
                }
            }
        }
        closedir($opendir);
        return $this->apps;
    }

    private function set_app($path, $app) {
        $CI = &get_instance();
        $CI->load->library('spyc');
        $config = $CI->spyc->loadFile($path, false);
        if (is_array($config)) {
            $config['app'] = $app;
            if (empty($config['name'])) {
                $config['name'] = $config['app'];
            }
            if (!isset($config['icon']) or isset($config['icon']) && empty($config['icon'])) {
                $config['icon'] = 'fa-exclamation-triangle';
            }
            if (isset($config['status']) && $config['status'] == 1) {
                return $this->apps[] = $config;
            }
        }
    }

    public function list_apps_permissions() {
        if (empty($this->apps)) {
            $apps = $this->list_apps();
        }
        $apps = $this->apps;
        $config_permissions = array();
        foreach ($apps as $app) {
            $status = $app['status'];
            $dir_app = $app['app'];
            if ($status === 1) {
                $path_permissions = $this->path . $dir_app . '/config/permissions.php';
                if (is_file($path_permissions)) {
                    require($path_permissions);
                    if (isset($permission)) {
                        $app['permissions'] = $permission;
                        unset($permission);
                    }
                }
                $config_permissions[] = $app;
            }
        }
        return $config_permissions;
    }

    public function list_widgets_dashboards() {
        if (empty($this->apps)) {
            $apps = $this->list_apps();
        }
        $apps = $this->apps;
        $widgets = array();
        $CI = &get_instance();
        foreach ($apps as $app) {
            $status = $app['status'];
            $dir_app = $app['app'];
            if ($status === 1) {
                $path = $this->path . $dir_app . '/libraries/widgets/';
                if (is_dir($path)) {
                    $opendir = \opendir($path);
                    while (false !== ($widget = readdir($opendir))) {
                        if (is_file($path . $widget) && strpos($widget, '_dashboard.php') !== false) {
                            ob_start();
                            $CI->load->library_app('widgets/' . $widget, $dir_app);
                            $class = strtolower(str_replace('.php', '', $widget));
                            $name = $CI->$class->name;
                            $content = ob_get_contents();
                            ob_end_clean();
                            if (!empty($name) && !empty($content)) {
                                $widgets[] = array(
                                    'title' => $name,
                                    'content' => $content,
                                    'app' => $app
                                );
                            }
                        }
                    }
                }
            }
        }
        return $widgets;
    }

}
{'fraction_non_alphanumeric': 0.16150973592958123, 'fraction_numerical': 0.0008002133902373967, 'mean_word_length': 1.1984755203752566, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3419401', 'n_tokens_mistral': 2100, 'n_tokens_neox': 2004, 'n_words': 365}