<commit_before><?php
class Vpc_Box_MetaTags_Component extends Vpc_Abstract
{
    protected function _getMetaTagComponents()
    {
        $components = array();
        /*
        $components = $this->getData()->getPage()->getRecursiveChildComponents(array(
            'page' => false,
            'flags' => array('metaTags' => true)
        ));*/
        if (Vpc_Abstract::getFlag($this->getData()->getPage()->componentClass, 'metaTags')) {
            $components[] = $this->getData()->getPage();
        }
        return $components;
    }

    public function getTemplateVars()
    {
        $ret = parent::getTemplateVars();
        $components = $this->_getMetaTagComponents();
        $ret['metaTags'] = array();
        foreach ($components as $component) {
            foreach ($component->getComponent()->getMetaTags() as $name=>$content) {
                if (!isset($ret['metaTags'][$name])) $ret['metaTags'][$name] = '';
                //TODO: bei zB noindex,nofollow anderes trennzeichen
                $ret['metaTags'][$name] .= ' '.$content;
            }
        }
        foreach ($ret['metaTags'] as &$i) $i = trim($i);
        /*
        $components = $this->getData()->getPage()->getRecursiveChildComponents(array(
            'page' => false,
            'limit' => 1,
            'flags' => array('noIndex' => true)
        ));*/
        if (/*$components || */Vpc_Abstract::getFlag($this->getData()->getPage()->componentClass, 'noIndex')) {
            if (isset($ret['metaTags']['robots'])) {
                $ret['metaTags']['robots'] .= ',';
            } else {
                $ret['metaTags']['robots'] = '';
            }
            $ret['metaTags']['robots'] .= 'noindex';
        }

        // verify-v1
        if (isset($_SERVER['HTTP_HOST'])) {
            $host = $_SERVER['HTTP_HOST'];
        } else {
            $host = Vps_Registry::get('config')->server->domain;
        }
        $hostParts = explode('.', $host);
        $configDomain = $hostParts[count($hostParts)-2]  // zB 'vivid-planet'
                        .$hostParts[count($hostParts)-1]; // zB 'com'
        $configVerify = Vps_Registry::get('config')->verifyV1;
        if ($configVerify && $configVerify->$configDomain) {
            $ret['metaTags']['verify-v1'] = $configVerify->$configDomain;
        }
        return $ret;
    }

    public function getCacheVars()
    {
        $ret = parent::getCacheVars();
        foreach ($this->_getMetaTagComponents() as $component) {
            $ret = array_merge($ret, $component->getComponent()->getMetaTagCacheVars());
        }
        return $ret;
    }
}
<commit_msg>google-site-verification metaTAg eingebaut<commit_after><?php
class Vpc_Box_MetaTags_Component extends Vpc_Abstract
{
    protected function _getMetaTagComponents()
    {
        $components = array();
        /*
        $components = $this->getData()->getPage()->getRecursiveChildComponents(array(
            'page' => false,
            'flags' => array('metaTags' => true)
        ));*/
        if (Vpc_Abstract::getFlag($this->getData()->getPage()->componentClass, 'metaTags')) {
            $components[] = $this->getData()->getPage();
        }
        return $components;
    }

    public function getTemplateVars()
    {
        $ret = parent::getTemplateVars();
        $components = $this->_getMetaTagComponents();
        $ret['metaTags'] = array();
        foreach ($components as $component) {
            foreach ($component->getComponent()->getMetaTags() as $name=>$content) {
                if (!isset($ret['metaTags'][$name])) $ret['metaTags'][$name] = '';
                //TODO: bei zB noindex,nofollow anderes trennzeichen
                $ret['metaTags'][$name] .= ' '.$content;
            }
        }
        foreach ($ret['metaTags'] as &$i) $i = trim($i);
        /*
        $components = $this->getData()->getPage()->getRecursiveChildComponents(array(
            'page' => false,
            'limit' => 1,
            'flags' => array('noIndex' => true)
        ));*/
        if (/*$components || */Vpc_Abstract::getFlag($this->getData()->getPage()->componentClass, 'noIndex')) {
            if (isset($ret['metaTags']['robots'])) {
                $ret['metaTags']['robots'] .= ',';
            } else {
                $ret['metaTags']['robots'] = '';
            }
            $ret['metaTags']['robots'] .= 'noindex';
        }

        // verify-v1
        if (isset($_SERVER['HTTP_HOST'])) {
            $host = $_SERVER['HTTP_HOST'];
        } else {
            $host = Vps_Registry::get('config')->server->domain;
        }
        $hostParts = explode('.', $host);
        $configDomain = $hostParts[count($hostParts)-2]  // zB 'vivid-planet'
                        .$hostParts[count($hostParts)-1]; // zB 'com'
        $configVerify = Vps_Registry::get('config')->verifyV1;
        if ($configVerify && $configVerify->$configDomain) {
            $ret['metaTags']['verify-v1'] = $configVerify->$configDomain;
        }

        $configVerify = Vps_Registry::get('config')->googleSiteVerification;
        if ($configVerify && $configVerify->$configDomain) {
            $ret['metaTags']['google-site-verification'] = $configVerify->$configDomain;
        }
        return $ret;
    }

    public function getCacheVars()
    {
        $ret = parent::getCacheVars();
        foreach ($this->_getMetaTagComponents() as $component) {
            $ret = array_merge($ret, $component->getComponent()->getMetaTagCacheVars());
        }
        return $ret;
    }
}

{'fraction_non_alphanumeric': 0.18242632435364312, 'fraction_numerical': 0.0021695895859699874, 'mean_word_length': 2.218150087260035, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 72, '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': '495110', 'n_tokens_mistral': 1578, 'n_tokens_neox': 1591, 'n_words': 247}