<commit_before><?php

namespace cmsadmin\blocks;

use \cebe\markdown\GithubMarkdown;

class TextBlock extends \cmsadmin\base\Block
{
    public $module = 'cmsadmin';

    public $_parser = null;

    public function getParser()
    {
        if( $this->_parser === null) {
            $this->_parser = new GithubMarkdown();
        }

        return $this->_parser;
    }

    public function name()
    {
        return 'Text';
    }

    public function icon()
    {
        return 'mdi-editor-format-align-left';
    }

    public function config()
    {
        return [
            'vars' => [
                ['var' => 'content', 'label' => 'Text', 'type' => 'zaa-textarea'],
                ['var' => 'textType', 'label' => 'Texttyp', 'type' => 'zaa-select', 'options' =>
                    [
                        ['value' => '0', 'label' => 'Normaler Text'],
                        ['value' => '1', 'label' => 'Markdown Text'],
                    ],
                ],
            ],
        ];
    }

    public function getText()
    {
        $text = $this->getVarValue('content');

        if($this->getVarValue('textType')) {
            $text = $this->getParser()->parse($text);
        }

        return $text;
    }

    public function extraVars()
    {
        return [
            'text' => $this->getText(),
        ];
    }

    public function twigFrontend()
    {
        return '{% if vars.content is not empty and vars.textType == 1 %}<p>{{ extras.text }}</p>{% elseif vars.content is not empty and vars.textType == 0 %}<p>{{ extras.text|nl2br }}</p>{% endif %}';
    }

    public function twigAdmin()
    {
        return '<p class="block__tag block__tag--p">{% if vars.content is empty %}<span class="block__empty-text">Es wurde noch kein Text eingegeben.</span>{% elseif vars.content is not empty and vars.textType == 1 %}{{ extras.text }}{% elseif vars.content is not empty and vars.textType == 0 %}{{ extras.text|nl2br }}{% endif %}</p>';
    }
}<commit_msg>changed empty behavior of textBlock<commit_after><?php

namespace cmsadmin\blocks;

use \cebe\markdown\GithubMarkdown;

class TextBlock extends \cmsadmin\base\Block
{
    public $module = 'cmsadmin';

    public $_parser = null;

    public function getParser()
    {
        if( $this->_parser === null) {
            $this->_parser = new GithubMarkdown();
        }

        return $this->_parser;
    }

    public function name()
    {
        return 'Text';
    }

    public function icon()
    {
        return 'mdi-editor-format-align-left';
    }

    public function config()
    {
        return [
            'vars' => [
                ['var' => 'content', 'label' => 'Text', 'type' => 'zaa-textarea'],
                ['var' => 'textType', 'label' => 'Texttyp', 'type' => 'zaa-select', 'options' =>
                    [
                        ['value' => '0', 'label' => 'Normaler Text'],
                        ['value' => '1', 'label' => 'Markdown Text'],
                    ],
                ],
            ],
        ];
    }

    public function getText()
    {
        $text = $this->getVarValue('content');

        if($this->getVarValue('textType')) {
            $text = $this->getParser()->parse($text);
        }

        return $text;
    }

    public function extraVars()
    {
        return [
            'text' => $this->getText(),
        ];
    }

    public function twigFrontend()
    {
        return '{% if vars.content is not empty and vars.textType == 1 %}<p>{{ extras.text }}</p>{% elseif vars.content is not empty and vars.textType == 0 %}<p>{{ extras.text|nl2br }}</p>{% endif %}';
    }

    public function twigAdmin()
    {
        return '<p class="block__tag block__tag--p">{% if vars.content is empty %}<span class="block__empty-text">Es wurde noch kein Text eingegeben.</span>'.
        '{% elseif vars.content is not empty and vars.textType == 1 %}{{ extras.text }}{% elseif vars.content is not empty %}{{ extras.text|nl2br }}{% endif %}</p>';
    }
}
{'fraction_non_alphanumeric': 0.16845788552861785, 'fraction_numerical': 0.003749062734316421, 'mean_word_length': 1.9169096209912537, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 61, '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': '5434312', 'n_tokens_mistral': 1248, 'n_tokens_neox': 1181, 'n_words': 291}