Frontend\Core\Engine\Header::parseSeo PHP Method

parseSeo() private method

Parse SEO specific data
private parseSeo ( )
    private function parseSeo()
    {
        // when on the homepage of the default language, set the clean site url as canonical, because of redirect fix
        $queryString = trim($this->URL->getQueryString(), '/');
        $language = $this->get('fork.settings')->get('Core', 'default_language', SITE_DEFAULT_LANGUAGE);
        if ($queryString == $language) {
            $this->canonical = rtrim(SITE_URL, '/');
            if ($this->getContainer()->getParameter('site.multilanguage')) {
                $this->canonical .= '/' . $language;
            }
        }
        // any canonical URL provided?
        if ($this->canonical != '') {
            $url = $this->canonical;
        } else {
            // get the chunks of the current url
            $urlChunks = parse_url($this->URL->getQueryString());
            // a canonical url should contain the domain. So make sure you
            // redirect your website to a single url with .htaccess
            $url = rtrim(SITE_URL, '/');
            if (isset($urlChunks['port'])) {
                $url .= ':' . $urlChunks['port'];
            }
            if (isset($urlChunks['path'])) {
                $url .= '/' . $urlChunks['path'];
            }
            // any items provided through GET?
            if (isset($urlChunks['query'])) {
                // the items we should add into the canonical url
                $itemsToAdd = array('page');
                $addToUrl = array();
                // loop all items in GET and check if we should ignore them
                foreach ($_GET as $key => $value) {
                    if (in_array($key, $itemsToAdd)) {
                        $addToUrl[$key] = $value;
                    }
                }
                // add GET-params
                if (!empty($addToUrl)) {
                    $url .= '?' . http_build_query($addToUrl, null, '&', PHP_QUERY_RFC3986);
                }
            }
        }
        // prevent against xss
        $charset = $this->getContainer()->getParameter('kernel.charset');
        $url = $charset == 'utf-8' ? \SpoonFilter::htmlspecialchars($url) : \SpoonFilter::htmlentities($url);
        $this->addLink(array('rel' => 'canonical', 'href' => $url));
        if ($this->get('fork.settings')->get('Core', 'seo_noodp', false)) {
            $this->addMetaData(array('name' => 'robots', 'content' => 'noodp'));
        }
        if ($this->get('fork.settings')->get('Core', 'seo_noydir', false)) {
            $this->addMetaData(array('name' => 'robots', 'content' => 'noydir'));
        }
    }