<commit_before><?php
/*
* Custom Username Markup For User v1.0.0 written by <EMAIL>.
* This software is licensed under the BSD 2-Clause modified License.
* See the LICENSE file within the package for details.
*/

class ThreePointStudio_CustomMarkupForUser_DataWriter_Preset extends XenForo_DataWriter {
    var $fields = array(
        "xf_3ps_cmfu_presets" => array(
            "preset_id" => array(
                'type' => self::TYPE_UINT,
                'autoIncrement' => true
            ),
            "title" => array(
                'type' => self::TYPE_STRING,
                'default' => ""
            ),
            "enable_for" => array(
                'type' => self::TYPE_SERIALIZED,
                'default' => ''
            ),
            "display_style_priority" => array(
                'type' => self::TYPE_UINT,
                'default' => 0
            ),
            "config" => array(
                'type' => self::TYPE_SERIALIZED,
                'default' => ''
            ),
            'user_groups' => array(
                'type' => self::TYPE_SERIALIZED,
                'default' => ''
            )
        )
    );

    protected function _getFields() {
        return $this->fields;
    }

    protected function _getExistingData($data) {
        if (!$id = $this->_getExistingPrimaryKey($data, 'preset_id')) {
            return false;
        }
        return array('xf_3ps_cmfu_presets' => $this->_getPresetModel()->getPresetById($id));
    }

    protected function _getUpdateCondition($tableName) {
        return 'preset_id = ' . $this->_db->quote($this->getExisting('preset_id'));
    }

    /* @return ThreePointStudio_CustomMarkupForUser_Model_Preset */
    protected function _getPresetModel() {
        return $this->getModelFromCache('ThreePointStudio_CustomMarkupForUser_Model_Preset');
    }
}<commit_msg>Make data writer more extendable<commit_after><?php
/*
* Custom Username Markup For User v1.0.0 written by <EMAIL>.
* This software is licensed under the BSD 2-Clause modified License.
* See the LICENSE file within the package for details.
*/

class ThreePointStudio_CustomMarkupForUser_DataWriter_Preset extends XenForo_DataWriter {

    protected function _getFields() {
        return array(
            "xf_3ps_cmfu_presets" => array(
                "preset_id" => array(
                    'type' => self::TYPE_UINT,
                    'autoIncrement' => true,
                ),
                "title" => array(
                    'type' => self::TYPE_STRING,
                    'default' => ""
                ),
                "enable_for" => array(
                    'type' => self::TYPE_SERIALIZED,
                    'default' => ''
                ),
                "display_style_priority" => array(
                    'type' => self::TYPE_UINT,
                    'default' => 0
                ),
                "config" => array(
                    'type' => self::TYPE_SERIALIZED,
                    'default' => ''
                ),
                'user_groups' => array(
                    'type' => self::TYPE_SERIALIZED,
                    'default' => ''
                )
            )
        );
    }

    protected function _getExistingData($data) {
        if (!$id = $this->_getExistingPrimaryKey($data, 'preset_id')) {
            return false;
        }
        return array('xf_3ps_cmfu_presets' => $this->_getPresetModel()->getPresetById($id));
    }

    protected function _getUpdateCondition($tableName) {
        return 'preset_id = ' . $this->_db->quote($this->getExisting('preset_id'));
    }

    /* @return ThreePointStudio_CustomMarkupForUser_Model_Preset */
    protected function _getPresetModel() {
        return $this->getModelFromCache('ThreePointStudio_CustomMarkupForUser_Model_Preset');
    }
}
{'fraction_non_alphanumeric': 0.12183668145056092, 'fraction_numerical': 0.003652491521001826, 'mean_word_length': 1.7903930131004366, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 60, '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': '5327461', 'n_tokens_mistral': 1106, 'n_tokens_neox': 1064, 'n_words': 201}