<commit_before><?php
class Kwc_Abstract_Image_Trl_Component extends Kwc_Abstract_Composite_Trl_Component
    implements Kwf_Media_Output_IsValidInterface
{
    public static function getSettings($masterComponentClass)
    {
        $ret = parent::getSettings($masterComponentClass);
        $ret['generators']['image'] = array(
            'class' => 'Kwf_Component_Generator_Static',
            'component' => 'Kwc_Abstract_Image_Trl_Image_Component.'.$masterComponentClass
        );
        $ret['ownModel'] = 'Kwf_Component_FieldModel';
        $ret['throwContentChangedOnOwnMasterModelUpdate'] = true;
        $ret['throwHasContentChangedOnMasterRowColumnsUpdate'] = array('kwf_upload_id');
        return $ret;
    }

    public function getBaseType()
    {
        return $this->getData()->chained->getComponent()->getBaseType();
    }

    public function getBaseImageUrl()
    {
        if ($this->getRow()->own_image) {
            return $this->getData()->getChildComponent('-image')->getComponent()->getBaseImageUrl();
        } else {
            $data = $this->getData()->chained->getComponent()->getImageDataOrEmptyImageData();
            if ($data && $data['filename']) {
                return Kwf_Media::getUrl($this->getData()->componentClass,
                    $this->getData()->componentId,
                    $this->getBaseType(),
                    $data['filename']);
            }
        }
        return null;
    }

    public function getTemplateVars()
    {
        $ret = parent::getTemplateVars();
        $ret['image'] = $this->getData();
        $imageCaptionSetting = Kwc_Abstract::getSetting($this->_getSetting('masterComponentClass'), 'imageCaption');
        if ($imageCaptionSetting) {
            $ret['image_caption'] = $this->getRow()->image_caption;
        }
        $ret['baseUrl'] = $this->getBaseImageUrl();
        if ($this->getRow()->own_image) {
            $imageData = $this->getImageData();
            $steps = Kwf_Media_Image::getResponsiveWidthSteps($this->getImageDimensions(), $imageData['file']);
            $ret['minWidth'] = $steps[0];
            $ret['maxWidth'] = end($steps);
        }
        return $ret;
    }

    public function getImageData()
    {
        return $this->_getCorrectImageComponent()->getImageData();
    }

    public final function getImageDataOrEmptyImageData()
    {
        return $this->_getCorrectImageComponent()->getImageDataOrEmptyImageData();
    }

    public function getImageUrl()
    {
        if ($this->getRow()->own_image) {
            return $this->getData()->getChildComponent('-image')->getComponent()->getImageUrl();
        } else {
            $baseUrl = $this->getBaseImageUrl();<commit_msg>fix error if own_image is activated but no image uploaded<commit_after><?php
class Kwc_Abstract_Image_Trl_Component extends Kwc_Abstract_Composite_Trl_Component
    implements Kwf_Media_Output_IsValidInterface
{
    public static function getSettings($masterComponentClass)
    {
        $ret = parent::getSettings($masterComponentClass);
        $ret['generators']['image'] = array(
            'class' => 'Kwf_Component_Generator_Static',
            'component' => 'Kwc_Abstract_Image_Trl_Image_Component.'.$masterComponentClass
        );
        $ret['ownModel'] = 'Kwf_Component_FieldModel';
        $ret['throwContentChangedOnOwnMasterModelUpdate'] = true;
        $ret['throwHasContentChangedOnMasterRowColumnsUpdate'] = array('kwf_upload_id');
        return $ret;
    }

    public function getBaseType()
    {
        return $this->getData()->chained->getComponent()->getBaseType();
    }

    public function getBaseImageUrl()
    {
        if ($this->getRow()->own_image) {
            return $this->getData()->getChildComponent('-image')->getComponent()->getBaseImageUrl();
        } else {
            $data = $this->getData()->chained->getComponent()->getImageDataOrEmptyImageData();
            if ($data && $data['filename']) {
                return Kwf_Media::getUrl($this->getData()->componentClass,
                    $this->getData()->componentId,
                    $this->getBaseType(),
                    $data['filename']);
            }
        }
        return null;
    }

    public function getTemplateVars()
    {
        $ret = parent::getTemplateVars();
        $ret['image'] = $this->getData();
        $imageCaptionSetting = Kwc_Abstract::getSetting($this->_getSetting('masterComponentClass'), 'imageCaption');
        if ($imageCaptionSetting) {
            $ret['image_caption'] = $this->getRow()->image_caption;
        }
        $ret['baseUrl'] = $this->getBaseImageUrl();
        if ($this->getRow()->own_image) {
            $imageData = $this->getImageData();
            if ($imageData) {
                $steps = Kwf_Media_Image::getResponsiveWidthSteps($this->getImageDimensions(), $imageData['file']);
                $ret['minWidth'] = $steps[0];
                $ret['maxWidth'] = end($steps);
            }
        }
        return $ret;
    }

    public function getImageData()
    {
        return $this->_getCorrectImageComponent()->getImageData();
    }

    public final function getImageDataOrEmptyImageData()
    {
        return $this->_getCorrectImageComponent()->getImageDataOrEmptyImageData();
    }

    public function getImageUrl()
    {
        if ($this->getRow()->own_image) {
            return $this->getData()->getChildComponent('-image')->getComponent()->getImageUrl();
        } else {
            $baseUrl = $this->getBaseImageUrl();
{'fraction_non_alphanumeric': 0.14578051430641073, 'fraction_numerical': 0.0003621876131836291, 'mean_word_length': 2.741869918699187, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 85, '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': '5813741', 'n_tokens_mistral': 1525, 'n_tokens_neox': 1508, 'n_words': 214}