<commit_before><?php
namespace Concrete\Core\Foundation;

use Config;

/**
 * Useful functions for getting paths for concrete5 items.
 *
 * \@package Core
 *
 * @author <NAME> <<EMAIL>>
 * @copyright  Copyright (c) 2003-2012 Concrete5. (http://www.concrete5.org)
 * @license    http://www.concrete5.org/license/     MIT License
 */
class Environment
{
    protected $coreOverrides = array();
    protected $corePackages = array();
    protected $coreOverridesByPackage = array();
    protected $overridesScanned = false;
    protected $cachedOverrides = array();
    protected $autoLoaded = false;

    public static function get()
    {
        static $env;
        if (!isset($env)) {
            if (file_exists(Config::get('concrete.cache.directory').'/'.Config::get('concrete.cache.environment.file'))) {
                $r = @file_get_contents(Config::get('concrete.cache.directory').'/'.Config::get('concrete.cache.environment.file'));
                if ($r) {
                    $en = @unserialize($r);
                    if ($en instanceof self) {
                        $env = $en;
                        $env->autoLoaded = true;

                        return $env;
                    }
                }
            }
            $env = new self();
        }

        return $env;
    }

    public static function saveCachedEnvironmentObject()
    {
        if (!file_exists(Config::get('concrete.cache.directory').'/'.Config::get('concrete.cache.environment.file'))) {
            $env = new self();
            $env->getOverrides();
            @file_put_contents(Config::get('concrete.cache.directory').'/'.Config::get('concrete.cache.environment.file'), serialize($env));
        }
    }

    public function clearOverrideCache()
    {
        $cacheFile = Config::get('concrete.cache.directory').'/'.Config::get('concrete.cache.environment.file');
        if (is_file($cacheFile)) {
            @unlink($cacheFile);
        }
        $this->overridesScanned = false;
        $this->cachedOverrides = array();
    }

    /**
     */
    protected $ignoreFiles = array('__MACOSX');

    public function reset()
    {
        $this->ignoreFiles = array('__MACOSX');
    }

    /**
     * Builds a list of all overrides.
     */
    protected function getOverrides()
    {
        $check = array(
            DIR_FILES_BLOCK_TYPES,
            DIR_FILES_CONTROLLERS,
            DIR_FILES_ELEMENTS,
            DIR_APPLICATION.'/'.DIRNAME_ATTRIBUTES,
            DIR_APPLICATION.'/'.DIRNAME_AUTHENTICATION,
            DIR_FILES_JOBS,
            DIR_APPLICATION.'/'.DIRNAME_CSS,
            DIR_APPLICATION.'/'.DIRNAME_JAVASCRIPT,
            DIR_APPLICATION.'/'.DIRNAME_LANGUAGES,
            DIR_FILES_EMAIL_TEMPLATES,
            DIR_FILES_CONTENT,
            DIR_FILES_THEMES,
            DIR_FILES_TOOLS,
            DIR_APPLICATION.'/'.DIRNAME_PAGE_TEMPLATES,
            DIR_APPLICATION.'/'.DIRNAME_VIEWS,
            DIR_APPLICATION.'/'.DIRNAME_CLASSES,
            DIR_APPLICATION.'/'.DIRNAME_MENU_ITEMS,
        );
        foreach ($check as $loc) {
            if (is_dir($loc)) {
                $contents = $this->getDirectoryContents($loc, array(), true);
                foreach ($contents as $f) {
                    $item = str_replace(DIR_APPLICATION.'/', '', $f);
                    $item = str_replace(DIR_BASE.'/', '', $item);
                    $this->coreOverrides[] = $item;
                }
            }
        }

        if (is_dir(DIR_PACKAGES_CORE)) {
            $this->corePackages = $this->getDirectoryContents(DIR_PACKAGES_CORE);
        }

        $this->overridesScanned = true;<commit_msg>Remove languages from list of core overrides<commit_after><?php
namespace Concrete\Core\Foundation;

use Config;

/**
 * Useful functions for getting paths for concrete5 items.
 *
 * \@package Core
 *
 * @author <NAME> <<EMAIL>>
 * @copyright  Copyright (c) 2003-2012 Concrete5. (http://www.concrete5.org)
 * @license    http://www.concrete5.org/license/     MIT License
 */
class Environment
{
    protected $coreOverrides = array();
    protected $corePackages = array();
    protected $coreOverridesByPackage = array();
    protected $overridesScanned = false;
    protected $cachedOverrides = array();
    protected $autoLoaded = false;

    public static function get()
    {
        static $env;
        if (!isset($env)) {
            if (file_exists(Config::get('concrete.cache.directory').'/'.Config::get('concrete.cache.environment.file'))) {
                $r = @file_get_contents(Config::get('concrete.cache.directory').'/'.Config::get('concrete.cache.environment.file'));
                if ($r) {
                    $en = @unserialize($r);
                    if ($en instanceof self) {
                        $env = $en;
                        $env->autoLoaded = true;

                        return $env;
                    }
                }
            }
            $env = new self();
        }

        return $env;
    }

    public static function saveCachedEnvironmentObject()
    {
        if (!file_exists(Config::get('concrete.cache.directory').'/'.Config::get('concrete.cache.environment.file'))) {
            $env = new self();
            $env->getOverrides();
            @file_put_contents(Config::get('concrete.cache.directory').'/'.Config::get('concrete.cache.environment.file'), serialize($env));
        }
    }

    public function clearOverrideCache()
    {
        $cacheFile = Config::get('concrete.cache.directory').'/'.Config::get('concrete.cache.environment.file');
        if (is_file($cacheFile)) {
            @unlink($cacheFile);
        }
        $this->overridesScanned = false;
        $this->cachedOverrides = array();
    }

    /**
     */
    protected $ignoreFiles = array('__MACOSX');

    public function reset()
    {
        $this->ignoreFiles = array('__MACOSX');
    }

    /**
     * Builds a list of all overrides.
     */
    protected function getOverrides()
    {
        $check = array(
            DIR_FILES_BLOCK_TYPES,
            DIR_FILES_CONTROLLERS,
            DIR_FILES_ELEMENTS,
            DIR_APPLICATION.'/'.DIRNAME_ATTRIBUTES,
            DIR_APPLICATION.'/'.DIRNAME_AUTHENTICATION,
            DIR_FILES_JOBS,
            DIR_APPLICATION.'/'.DIRNAME_CSS,
            DIR_APPLICATION.'/'.DIRNAME_JAVASCRIPT,
            DIR_FILES_EMAIL_TEMPLATES,
            DIR_FILES_CONTENT,
            DIR_FILES_THEMES,
            DIR_FILES_TOOLS,
            DIR_APPLICATION.'/'.DIRNAME_PAGE_TEMPLATES,
            DIR_APPLICATION.'/'.DIRNAME_VIEWS,
            DIR_APPLICATION.'/'.DIRNAME_CLASSES,
            DIR_APPLICATION.'/'.DIRNAME_MENU_ITEMS,
        );
        foreach ($check as $loc) {
            if (is_dir($loc)) {
                $contents = $this->getDirectoryContents($loc, array(), true);
                foreach ($contents as $f) {
                    $item = str_replace(DIR_APPLICATION.'/', '', $f);
                    $item = str_replace(DIR_BASE.'/', '', $item);
                    $this->coreOverrides[] = $item;
                }
            }
        }

        if (is_dir(DIR_PACKAGES_CORE)) {
            $this->corePackages = $this->getDirectoryContents(DIR_PACKAGES_CORE);
        }

        $this->overridesScanned = true;
{'fraction_non_alphanumeric': 0.13670052154817458, 'fraction_numerical': 0.0032939884710403516, 'mean_word_length': 1.9490084985835694, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '4809469', 'n_tokens_mistral': 2235, 'n_tokens_neox': 2090, 'n_words': 338}