<commit_before><?php
class Kwc_Basic_Text_StylesModel extends Kwf_Model_Db_Proxy
{
    protected $_table = 'kwc_basic_text_styles';
    protected $_rowClass = 'Kwc_Basic_Text_StylesRow';

    protected function _init()
    {
        parent::_init();
        $this->_siblingModels['styles'] = new Kwf_Model_Field(array('fieldName'=>'styles'));
    }

    protected function _setupFilters()
    {
        $filter = new Kwf_Filter_Row_Numberize();
        $filter->setGroupBy(array('ownStyles', 'tag'=>array('span')));
        $this->_filters = array('pos' => $filter);
    }

    //public fuer test
    public static function parseMasterStyles($masterContent)
    {
        $styles = array();
        if (strpos($masterContent, '.webStandard')===false) return $styles;
        preg_match_all('#^ *.webStandard *((span|p|h[1-6])\\.?([^ ]*)) *{([^}]*)} */\\* +(.*?) +\\*/#m', $masterContent, $m);
        foreach (array_keys($m[1]) as $i) {
            $tagName = $m[2][$i];
            $styles[] = array(
                'id' => 'master'.$i,
                'name' => $m[5][$i],
                'tagName' => $tagName,
                'className' => $m[3][$i],
                'styles' => Kwf_Assets_Dependency_File_Css::expandAssetVariables($m[4][$i], 'web'),
            );
        }
        return $styles;
    }

    public static function getMasterStyles()
    {
        $cacheId = 'textMasterSyles';
        $ret = Kwf_Cache_SimpleStatic::fetch($cacheId);
        if ($ret !== false) return $ret;

        $package = Kwf_Assets_Package_Default::getInstance('Frontend');
        $c = $package->getPackageContents('text/css', null);
        $ret = self::parseMasterStyles($c);
        Kwf_Cache_SimpleStatic::add($cacheId, $ret);
        return $ret;
    }

    public function getStyles($ownStyles = false)
    {
        $styles = array();
        $styles[] = array(
            'id' => 'blockdefault',
            'name' => trlKwf('Default'),
            'tagName' => 'p',
            'className' => false,
        );
        $styles[] = array(
            'id' => 'inlinedefault',
            'name' => trlKwf('Normal'),
            'tagName' => 'span',
            'className' => false,
        );

        $masterStyles = $this->getMasterStyles();
        $styles = array_merge($styles, $masterStyles);

        $select = $this->select();
        if ($ownStyles) {
            $select->whereEquals('ownStyles', $ownStyles);
        } else {
            $select->whereEquals('ownStyles', '');
        }<commit_msg>parse master styles also in scss files<commit_after><?php
class Kwc_Basic_Text_StylesModel extends Kwf_Model_Db_Proxy
{
    protected $_table = 'kwc_basic_text_styles';
    protected $_rowClass = 'Kwc_Basic_Text_StylesRow';

    protected function _init()
    {
        parent::_init();
        $this->_siblingModels['styles'] = new Kwf_Model_Field(array('fieldName'=>'styles'));
    }

    protected function _setupFilters()
    {
        $filter = new Kwf_Filter_Row_Numberize();
        $filter->setGroupBy(array('ownStyles', 'tag'=>array('span')));
        $this->_filters = array('pos' => $filter);
    }

    //public fuer test
    public static function parseMasterStyles($masterContent)
    {
        $styles = array();
        if (strpos($masterContent, '.webStandard')===false) return $styles;
        preg_match_all('#^ *.webStandard *((span|p|h[1-6])\\.?([^ ]*)) *{([^}]*)} */\\* +(.*?) +\\*/#m', $masterContent, $m);
        foreach (array_keys($m[1]) as $i) {
            $tagName = $m[2][$i];
            $styles[] = array(
                'id' => 'master'.$i,
                'name' => $m[5][$i],
                'tagName' => $tagName,
                'className' => $m[3][$i],
                'styles' => Kwf_Assets_Dependency_File_Css::expandAssetVariables($m[4][$i], 'web'),
            );
        }
        return $styles;
    }

    public static function getMasterStyles()
    {
        $cacheId = 'textMasterSyles';
        $ret = Kwf_Cache_SimpleStatic::fetch($cacheId);
        if ($ret !== false) return $ret;

        $package = Kwf_Assets_Package_Default::getInstance('Frontend');
        $ret = array();
        foreach ($package->getDependency()->getFilteredUniqueDependencies('text/css') as $dep) {
            if ($dep instanceof Kwf_Assets_Dependency_File) {
                $ret = array_merge($ret, self::parseMasterStyles(file_get_contents($dep->getFileName())));
            }
        }
        Kwf_Cache_SimpleStatic::add($cacheId, $ret);
        return $ret;
    }

    public function getStyles($ownStyles = false)
    {
        $styles = array();
        $styles[] = array(
            'id' => 'blockdefault',
            'name' => trlKwf('Default'),
            'tagName' => 'p',
            'className' => false,
        );
        $styles[] = array(
            'id' => 'inlinedefault',
            'name' => trlKwf('Normal'),
            'tagName' => 'span',
            'className' => false,
        );

        $masterStyles = $this->getMasterStyles();
        $styles = array_merge($styles, $masterStyles);

        $select = $this->select();
        if ($ownStyles) {
            $select->whereEquals('ownStyles', $ownStyles);
        } else {
            $select->whereEquals('ownStyles', '');
        }
{'fraction_non_alphanumeric': 0.17514231499051233, 'fraction_numerical': 0.0026565464895635673, 'mean_word_length': 2.28411214953271, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 53, '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': '1439171', 'n_tokens_mistral': 1639, 'n_tokens_neox': 1632, 'n_words': 280}