<commit_before><?php

/**
 * SyncData
 *
 * @author Team phpManufaktur <<EMAIL>>
 * @link https://addons.phpmanufaktur.de/SyncData
 * @copyright 2013 <NAME> <<EMAIL>>
 * @license MIT License (MIT) http://www.opensource.org/licenses/MIT
 */

namespace phpManufaktur\SyncData\Data\Configuration;

use phpManufaktur\SyncData\Control\Application;
use phpManufaktur\SyncData\Data\Configuration\ConfigurationException;
use phpManufaktur\SyncData\Data\CMS\Settings;
use phpManufaktur\SyncData\Control\JSON\JSONFormat;

class Configuration
{

    protected $app = null;
    protected static $config_array = null;
    protected static $config_file = null;

    public function __construct(Application $app)
    {
        $this->app = $app;
        self::$config_file = SYNC_DATA_PATH.'/config/syncdata.json';
    }

    /**
     * Return the configuration array for Doctrine
     *
     * @return array configuration array
     */
    public function getConfiguration()
    {
        return self::$config_array;
    }


    protected function getConfigurationFromCMS()
    {
        $cmsSettings = new Settings($this->app);
        $cms_settings = $cmsSettings->getSettings();
        if (file_exists(realpath(SYNC_DATA_PATH.'/../config.php'))) {
            include_once realpath(SYNC_DATA_PATH.'/../config.php');
        }
        else {
            throw new \Exception("Can't read the CMS configuration, SyncData stopped.");
        }

        self::$config_array = array(
            'CMS' => array(
                'CMS_SERVER_EMAIL' => $cms_settings['server_email'],
                'CMS_SERVER_NAME' => $cms_settings['wbmailer_default_sendername'],
                'CMS_TYPE' => (isset($cms_settings['lepton_version'])) ? 'LEPTON' : 'WebsiteBaker',
                'CMS_VERSION' => (isset($cms_settings['lepton_version'])) ? $cms_settings['lepton_version'] : $cms_settings['wb_version'],
                'CMS_MEDIA_DIRECTORY' => $cms_settings['media_directory'],
                'CMS_PAGES_DIRECTORY' => $cms_settings['pages_directory'],
                'CMS_URL' => WB_URL,
                'CMS_PATH' => WB_PATH
            ),
            'monolog' => array(
                'email' => array(
                    'active' => true,
                    'level' => 400,
                    'to' => $cms_settings['server_email'],
                    'subject' => 'SyncData Alert'
                )
            ),
            'general' => array(
                'memory_limit' => '512M',
                'max_execution_time' => '300'
            ),
            'backup' => array(
                'settings' => array(
                    'replace_table_prefix' => true,
                    'add_if_not_exists' => true,
                    'replace_cms_url' => true
                ),
                'files' => array(
                    'ignore' => array(
                        '.buildpath',
                        '.project'
                    )
                ),
                'directories' => array(
                    'ignore' => array(
                        'directory' => array(
                            'temp',
                            'syncdata',
                            'kit2'
                        ),
                        'subdirectory' => array(
                            '.git'
                        )
                    )
                ),
                'tables' => array(
                    'ignore' => array(
                        'syncdata_backup_master',
                        'syncdata_backup_tables',
                        'syncdata_synchronize_tables'
                    )
                )
            ),
            'restore' => array(
                'settings' => array(
                    'replace_table_prefix' => true,
                    'replace_cms_url' => true,
                    'ignore_cms_config' => true
                ),
                'files' => array(
                    'ignore' => array(
                        '.buildpath',
                        '.project'
                    )
                ),
                'directories' => array(
                    'ignore' => array(
                        'directory' => array(
                            'temp'
                        ),
                        'subdirectory' => array(
                            '.git'
                        )
                    )
                ),
                'tables' => array(
                    'ignore' => array(
                        'syncdata_backup_master',
                        'syncdata_backup_tables',
                        'syncdata_synchronize_tables'
                    )
                )
            )
        );
        // encode a formatted JSON file
        $jsonFormat = new JSONFormat();
        $json = $jsonFormat->format(self::$config_array);
        if (!@file_put_contents(self::$config_file, $json)) {
            throw new ConfigurationException("Can't write the configuration file for SyncData!");
        }
        $this->app['monolog']->addInfo("Create configuration file syncdata.json for SyncData");
    }
<commit_msg>added syncdata_ tables to ignored tables<commit_after><?php

/**
 * SyncData
 *
 * @author Team phpManufaktur <<EMAIL>>
 * @link https://addons.phpmanufaktur.de/SyncData
 * @copyright 2013 <NAME> <<EMAIL>>
 * @license MIT License (MIT) http://www.opensource.org/licenses/MIT
 */

namespace phpManufaktur\SyncData\Data\Configuration;

use phpManufaktur\SyncData\Control\Application;
use phpManufaktur\SyncData\Data\Configuration\ConfigurationException;
use phpManufaktur\SyncData\Data\CMS\Settings;
use phpManufaktur\SyncData\Control\JSON\JSONFormat;

class Configuration
{

    protected $app = null;
    protected static $config_array = null;
    protected static $config_file = null;

    public function __construct(Application $app)
    {
        $this->app = $app;
        self::$config_file = SYNC_DATA_PATH.'/config/syncdata.json';
    }

    /**
     * Return the configuration array for Doctrine
     *
     * @return array configuration array
     */
    public function getConfiguration()
    {
        return self::$config_array;
    }


    protected function getConfigurationFromCMS()
    {
        $cmsSettings = new Settings($this->app);
        $cms_settings = $cmsSettings->getSettings();
        if (file_exists(realpath(SYNC_DATA_PATH.'/../config.php'))) {
            include_once realpath(SYNC_DATA_PATH.'/../config.php');
        }
        else {
            throw new \Exception("Can't read the CMS configuration, SyncData stopped.");
        }

        self::$config_array = array(
            'CMS' => array(
                'CMS_SERVER_EMAIL' => $cms_settings['server_email'],
                'CMS_SERVER_NAME' => $cms_settings['wbmailer_default_sendername'],
                'CMS_TYPE' => (isset($cms_settings['lepton_version'])) ? 'LEPTON' : 'WebsiteBaker',
                'CMS_VERSION' => (isset($cms_settings['lepton_version'])) ? $cms_settings['lepton_version'] : $cms_settings['wb_version'],
                'CMS_MEDIA_DIRECTORY' => $cms_settings['media_directory'],
                'CMS_PAGES_DIRECTORY' => $cms_settings['pages_directory'],
                'CMS_URL' => WB_URL,
                'CMS_PATH' => WB_PATH
            ),
            'monolog' => array(
                'email' => array(
                    'active' => true,
                    'level' => 400,
                    'to' => $cms_settings['server_email'],
                    'subject' => 'SyncData Alert'
                )
            ),
            'general' => array(
                'memory_limit' => '512M',
                'max_execution_time' => '300'
            ),
            'backup' => array(
                'settings' => array(
                    'replace_table_prefix' => true,
                    'add_if_not_exists' => true,
                    'replace_cms_url' => true
                ),
                'files' => array(
                    'ignore' => array(
                        '.buildpath',
                        '.project'
                    )
                ),
                'directories' => array(
                    'ignore' => array(
                        'directory' => array(
                            'temp',
                            'syncdata',
                            'kit2'
                        ),
                        'subdirectory' => array(
                            '.git'
                        )
                    )
                ),
                'tables' => array(
                    'ignore' => array(
                        'syncdata_backup_master',
                        'syncdata_backup_tables',
                        'syncdata_backup_files',
                        'syncdata_synchronize_tables',
                        'syncdata_synchronize_master',
                        'syncdata_synchronize_files'
                    )
                )
            ),
            'restore' => array(
                'settings' => array(
                    'replace_table_prefix' => true,
                    'replace_cms_url' => true,
                    'ignore_cms_config' => true
                ),
                'files' => array(
                    'ignore' => array(
                        '.buildpath',
                        '.project'
                    )
                ),
                'directories' => array(
                    'ignore' => array(
                        'directory' => array(
                            'temp',
                            'syncdata',
                            'kit2'
                        ),
                        'subdirectory' => array(
                            '.git'
                        )
                    )
                ),
                'tables' => array(
                    'ignore' => array(
                        'syncdata_backup_master',
                        'syncdata_backup_tables',
                        'syncdata_backup_files',
                        'syncdata_synchronize_tables',
                        'syncdata_synchronize_master',
                        'syncdata_synchronize_files'
                    )
                )
            )
        );
        // encode a formatted JSON file
        $jsonFormat = new JSONFormat();
        $json = $jsonFormat->format(self::$config_array);
        if (!@file_put_contents(self::$config_file, $json)) {
            throw new ConfigurationException("Can't write the configuration file for SyncData!");
        }
        $this->app['monolog']->addInfo("Create configuration file syncdata.json for SyncData");
    }

{'fraction_non_alphanumeric': 0.11428037033573366, 'fraction_numerical': 0.002712054615168802, 'mean_word_length': 1.2504208754208754, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 113, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '3523042', 'n_tokens_mistral': 2858, 'n_tokens_neox': 2617, 'n_words': 461}