<commit_before><?php
class Kwc_Root_Abstract extends Kwc_Abstract
{
    public static function getSettings()
    {
        $ret = parent::getSettings();
        $ret['generators']['box'] = array(
            'class' => 'Kwf_Component_Generator_Box_Static',
            'component' => array(),
            'inherit' => true,
            'priority' => 0
        );
        $ret['generators']['title'] = array(
            'class' => 'Kwf_Component_Generator_Box_Static',
            'component' => 'Kwc_Box_Title_Component',
            'inherit' => true,
            'priority' => 0
        );
        $ret['componentName'] = trlKwf('Root');
        $ret['contentWidth'] = 600;
        $ret['contentWidthBoxSubtract'] = array();
        return $ret;
    }

    public function formatPath($parsedUrl)
    {
        if (!Kwf_Config::getValue('server.domain')) {
            //domain is optional (but recommended)
            //for easy setup of examples just ignore the domain (as we don't have anything to compare to anyway)
            return $parsedUrl['path'];
        }
        $b = Kwf_Config::getValue('server.domain') == $parsedUrl['host']
            || Kwf_Config::getValue('server.previewDomain') == $parsedUrl['host'];
        if (!$b && isset($parsedUrl['port'])) {
            $b = Kwf_Config::getValue('server.domain') == $parsedUrl['host'].':'.$parsedUrl['port']
                || Kwf_Config::getValue('server.previewDomain') == $parsedUrl['host'].':'.$parsedUrl['port'];
        }
        if (!$b) {
            $p =  Kwf_Config::getValue('server.noRedirectPattern');
            if (!$p) return null;
            if (!preg_match('/'.$p.'/', $parsedUrl['host'])) {
                return null;
            }
        }
        return $parsedUrl['path'];
    }

    public function getPageByUrl($path, $acceptLangauge)
    {
        if ($path == '') {
            $ret = $this->getData()->getChildPage(array('home' => true), array());
        } else {
            foreach (Kwc_Abstract::getComponentClasses() as $c) {
                if (Kwc_Abstract::getFlag($c, 'shortcutUrl')) {
                    $ret = call_user_func(array($c, 'getDataByShortcutUrl'), $c, $path);
                    if ($ret) return $ret;
                }
            }
            $ret = $this->getData()->getChildPageByPath($path);
        }

        if ($ret && !$ret->isPage && Kwf_Component_Abstract::getFlag($ret->componentClass, 'hasHome')) {
            $ret = $ret->getChildPage(array('home' => true), array());
        }
        return $ret;
    }

    protected function _getMasterChildContentWidth(Kwf_Component_Data $sourcePage)
    {
        $ret = $this->_getSetting('contentWidth');
        foreach ($this->_getSetting('contentWidthBoxSubtract') as $box=>$width) {
            //TODO hier sollte eigentlich der boxname verwendet werden, der muss nicht die id sein
            $c = $sourcePage->getChildComponent('-'.$box);
            if ($c && $c->hasContent()) {
                $ret -= $width;
            }
        }
        return $ret;
    }
}<commit_msg>searches dynamicly for all boxes with boxName on page and if substracts the defined substractWidth from contentWidth<commit_after><?php
class Kwc_Root_Abstract extends Kwc_Abstract
{
    public static function getSettings()
    {
        $ret = parent::getSettings();
        $ret['generators']['box'] = array(
            'class' => 'Kwf_Component_Generator_Box_Static',
            'component' => array(),
            'inherit' => true,
            'priority' => 0
        );
        $ret['generators']['title'] = array(
            'class' => 'Kwf_Component_Generator_Box_Static',
            'component' => 'Kwc_Box_Title_Component',
            'inherit' => true,
            'priority' => 0
        );
        $ret['componentName'] = trlKwf('Root');
        $ret['contentWidth'] = 600;
        $ret['contentWidthBoxSubtract'] = array();
        return $ret;
    }

    public function formatPath($parsedUrl)
    {
        if (!Kwf_Config::getValue('server.domain')) {
            //domain is optional (but recommended)
            //for easy setup of examples just ignore the domain (as we don't have anything to compare to anyway)
            return $parsedUrl['path'];
        }
        $b = Kwf_Config::getValue('server.domain') == $parsedUrl['host']
            || Kwf_Config::getValue('server.previewDomain') == $parsedUrl['host'];
        if (!$b && isset($parsedUrl['port'])) {
            $b = Kwf_Config::getValue('server.domain') == $parsedUrl['host'].':'.$parsedUrl['port']
                || Kwf_Config::getValue('server.previewDomain') == $parsedUrl['host'].':'.$parsedUrl['port'];
        }
        if (!$b) {
            $p =  Kwf_Config::getValue('server.noRedirectPattern');
            if (!$p) return null;
            if (!preg_match('/'.$p.'/', $parsedUrl['host'])) {
                return null;
            }
        }
        return $parsedUrl['path'];
    }

    public function getPageByUrl($path, $acceptLangauge)
    {
        if ($path == '') {
            $ret = $this->getData()->getChildPage(array('home' => true), array());
        } else {
            foreach (Kwc_Abstract::getComponentClasses() as $c) {
                if (Kwc_Abstract::getFlag($c, 'shortcutUrl')) {
                    $ret = call_user_func(array($c, 'getDataByShortcutUrl'), $c, $path);
                    if ($ret) return $ret;
                }
            }
            $ret = $this->getData()->getChildPageByPath($path);
        }

        if ($ret && !$ret->isPage && Kwf_Component_Abstract::getFlag($ret->componentClass, 'hasHome')) {
            $ret = $ret->getChildPage(array('home' => true), array());
        }
        return $ret;
    }

    protected function _getMasterChildContentWidth(Kwf_Component_Data $sourcePage)
    {
        $ret = $this->_getSetting('contentWidth');
        $boxes = array();
        foreach ($sourcePage->getChildBoxes() as $box) {
            $boxes[$box->box] = $box;
        }
        foreach ($this->_getSetting('contentWidthBoxSubtract') as $box=>$width) {
            if (!isset($boxes[$box])) continue;
            $c = $boxes[$box];
            if ($c && $c->hasContent()) {
                $ret -= $width;
            }
        }
        return $ret;
    }
}
{'fraction_non_alphanumeric': 0.16367106728169237, 'fraction_numerical': 0.001590583744234134, 'mean_word_length': 2.1392910634048925, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 48, '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': '7351629', 'n_tokens_mistral': 1820, 'n_tokens_neox': 1803, 'n_words': 353}