<commit_before><?php

namespace Frontend\Core\Engine;

/*
 * This file is part of Fork CMS.
 *
 * For the full copyright and license information, please view the license
 * file that was distributed with this source code.
 */

use Common\Exception\RedirectException;
use Frontend\Core\Language\Language;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\KernelInterface;
use Common\Cookie as CommonCookie;
use Frontend\Core\Engine\Base\Object as FrontendBaseObject;
use Frontend\Core\Engine\Block\Extra as FrontendBlockExtra;
use Frontend\Core\Engine\Block\Widget as FrontendBlockWidget;

/**
 * Frontend page class, this class will handle everything on a page
 */
class Page extends FrontendBaseObject
{
    /**
     * Breadcrumb instance
     *
     * @var Breadcrumb
     */
    protected $breadcrumb;

    /**
     * Array of extras linked to this page
     *
     * @var array
     */
    protected $extras = array();

    /**
     * Footer instance
     *
     * @var Footer
     */
    protected $footer;

    /**
     * Header instance
     *
     * @var Header
     */
    protected $header;

    /**
     * The current pageId
     *
     * @var int
     */
    protected $pageId;

    /**
     * Content of the page
     *
     * @var array
     */
    protected $record = array();

    /**
     * The path of the template to show
     *
     * @var string
     */
    protected $templatePath;

    /**
     * The statuscode
     *
     * @var int
     */
    protected $statusCode = 200;

    /**
     * @param KernelInterface $kernel
     */
    public function __construct(KernelInterface $kernel)
    {
        parent::__construct($kernel);

        $this->getContainer()->set('page', $this);
    }

    /**
     * Loads the actual components on the page
     */
    public function load()
    {
        // set tracking cookie
        Model::getVisitorId();

        // create header instance
        $this->header = new Header($this->getKernel());

        // get page content from pageId of the requested URL
        $this->record = $this->getPageContent(
            Navigation::getPageId(implode('/', $this->URL->getPages()))
        );

        if (empty($this->record)) {
            $this->record = Model::getPage(404);
        }

        // we need to set the correct id
        $this->pageId = (int) $this->record['id'];

        // set headers if this is a 404 page
        if ($this->pageId == 404) {
            $this->statusCode = 404;

            if (extension_loaded('newrelic')) {
                newrelic_name_transaction('404');
            }
        }

        // create breadcrumb instance
        $this->breadcrumb = new Breadcrumb($this->getKernel());

        // new footer instance
        $this->footer = new Footer($this->getKernel());

        // process page
        $this->processPage();

        // execute all extras linked to the page
        $this->processExtras();

        // store statistics
        $this->storeStatistics();

        // trigger event
        Model::triggerEvent(
            'Core',
            'after_page_processed',
            array(
                 'id' => $this->getId(),
                 'record' => $this->getRecord(),
                 'statusCode' => $this->getStatusCode(),
                 'sessionId' => \SpoonSession::getSessionId(),
                 'visitorId' => Model::getVisitorId(),
                 'SESSION' => $_SESSION,
                 'COOKIE' => $_COOKIE,
                 'GET' => $_GET,
                 'POST' => $_POST,
                 'SERVER' => $_SERVER,
            )
        );
    }

    /**
     * Display the page
     */
    public function display()
    {
        // assign the id so we can use it as an option
        $this->tpl->addGlobal('isPage' . $this->pageId, true);
        $this->tpl->addGlobal('isChildOfPage' . $this->record['parent_id'], true);

        // hide the cookiebar from within the code to prevent flickering
        $this->tpl->assign(
            'cookieBarHide',
            (!$this->get('fork.settings')->get('Core', 'show_cookie_bar', false) || CommonCookie::hasHiddenCookieBar())
        );

        // the the positions to the template
        $this->parsePositions();
<commit_msg>The variable cookieBarHide should be global.<commit_after><?php

namespace Frontend\Core\Engine;

/*
 * This file is part of Fork CMS.
 *
 * For the full copyright and license information, please view the license
 * file that was distributed with this source code.
 */

use Common\Exception\RedirectException;
use Frontend\Core\Language\Language;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\KernelInterface;
use Common\Cookie as CommonCookie;
use Frontend\Core\Engine\Base\Object as FrontendBaseObject;
use Frontend\Core\Engine\Block\Extra as FrontendBlockExtra;
use Frontend\Core\Engine\Block\Widget as FrontendBlockWidget;

/**
 * Frontend page class, this class will handle everything on a page
 */
class Page extends FrontendBaseObject
{
    /**
     * Breadcrumb instance
     *
     * @var Breadcrumb
     */
    protected $breadcrumb;

    /**
     * Array of extras linked to this page
     *
     * @var array
     */
    protected $extras = array();

    /**
     * Footer instance
     *
     * @var Footer
     */
    protected $footer;

    /**
     * Header instance
     *
     * @var Header
     */
    protected $header;

    /**
     * The current pageId
     *
     * @var int
     */
    protected $pageId;

    /**
     * Content of the page
     *
     * @var array
     */
    protected $record = array();

    /**
     * The path of the template to show
     *
     * @var string
     */
    protected $templatePath;

    /**
     * The statuscode
     *
     * @var int
     */
    protected $statusCode = 200;

    /**
     * @param KernelInterface $kernel
     */
    public function __construct(KernelInterface $kernel)
    {
        parent::__construct($kernel);

        $this->getContainer()->set('page', $this);
    }

    /**
     * Loads the actual components on the page
     */
    public function load()
    {
        // set tracking cookie
        Model::getVisitorId();

        // create header instance
        $this->header = new Header($this->getKernel());

        // get page content from pageId of the requested URL
        $this->record = $this->getPageContent(
            Navigation::getPageId(implode('/', $this->URL->getPages()))
        );

        if (empty($this->record)) {
            $this->record = Model::getPage(404);
        }

        // we need to set the correct id
        $this->pageId = (int) $this->record['id'];

        // set headers if this is a 404 page
        if ($this->pageId == 404) {
            $this->statusCode = 404;

            if (extension_loaded('newrelic')) {
                newrelic_name_transaction('404');
            }
        }

        // create breadcrumb instance
        $this->breadcrumb = new Breadcrumb($this->getKernel());

        // new footer instance
        $this->footer = new Footer($this->getKernel());

        // process page
        $this->processPage();

        // execute all extras linked to the page
        $this->processExtras();

        // store statistics
        $this->storeStatistics();

        // trigger event
        Model::triggerEvent(
            'Core',
            'after_page_processed',
            array(
                 'id' => $this->getId(),
                 'record' => $this->getRecord(),
                 'statusCode' => $this->getStatusCode(),
                 'sessionId' => \SpoonSession::getSessionId(),
                 'visitorId' => Model::getVisitorId(),
                 'SESSION' => $_SESSION,
                 'COOKIE' => $_COOKIE,
                 'GET' => $_GET,
                 'POST' => $_POST,
                 'SERVER' => $_SERVER,
            )
        );
    }

    /**
     * Display the page
     */
    public function display()
    {
        // assign the id so we can use it as an option
        $this->tpl->addGlobal('isPage' . $this->pageId, true);
        $this->tpl->addGlobal('isChildOfPage' . $this->record['parent_id'], true);

        // hide the cookiebar from within the code to prevent flickering
        $this->tpl->addGlobal(
            'cookieBarHide',
            (!$this->get('fork.settings')->get('Core', 'show_cookie_bar', false) || CommonCookie::hasHiddenCookieBar())
        );

        // the the positions to the template
        $this->parsePositions();

{'fraction_non_alphanumeric': 0.12803608605135322, 'fraction_numerical': 0.004163775156141568, 'mean_word_length': 1.8948778038165384, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 93, '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': '6867451', 'n_tokens_mistral': 2437, 'n_tokens_neox': 2348, 'n_words': 615}