<commit_before><?php namespace RainLab\Pages\Components;

use Request;
use Cms\Classes\Theme;
use Cms\Classes\ComponentBase;
use RainLab\Pages\Classes\Router;

/**
 * The static page component.
 *
 * @package rainlab\pages
 * @author <NAME>, <NAME>
 */
class StaticPage extends ComponentBase
{
    /**
     * @var \RainLab\Pages\Classes\Page A reference to the static page object
     */
    public $pageObject;

    /**
     * @var string The static page title
     */
    public $title;

    /**
     * @var array Extra data added by syntax fields.
     */
    public $extraData = [];

    /**
     * @var string Content cache.
     */
    protected $contentCached = false;

    public function componentDetails()
    {
        return [
            'name'        => 'Static page',
            'description' => 'Outputs a static page in a CMS layout.'
        ];
    }

    public function onRun()
    {
        $url = Request::path();

        if (!strlen($url)) {
            $url = '/';
        }

        $router = new Router(Theme::getActiveTheme());
        $this->pageObject = $this->page['page'] = $router->findByUrl($url);

        if ($this->pageObject) {
            $this->title = $this->page['title'] = $this->pageObject->getViewBag()->property('title');
            $this->extraData = $this->page['extraData'] = $this->defineExtraData();
        }
    }

    public function page()
    {
        return $this->pageObject;
    }

    public function parent()
    {
        return $this->pageObject ? $this->pageObject->getParent() : null;
    }

    public function children()
    {
        return $this->pageObject ? $this->pageObject->getChildren() : null;
    }

    public function content()
    {<commit_msg>We should pull the URL from the router instead Some routes can be prefixed, for example, when locale is attached, {locale}/{slug*} -> /en/about -> about {slug*} -> /about -> about<commit_after><?php namespace RainLab\Pages\Components;

use Request;
use Cms\Classes\Theme;
use Cms\Classes\ComponentBase;
use RainLab\Pages\Classes\Router;

/**
 * The static page component.
 *
 * @package rainlab\pages
 * @author <NAME>, <NAME>
 */
class StaticPage extends ComponentBase
{
    /**
     * @var \RainLab\Pages\Classes\Page A reference to the static page object
     */
    public $pageObject;

    /**
     * @var string The static page title
     */
    public $title;

    /**
     * @var array Extra data added by syntax fields.
     */
    public $extraData = [];

    /**
     * @var string Content cache.
     */
    protected $contentCached = false;

    public function componentDetails()
    {
        return [
            'name'        => 'Static page',
            'description' => 'Outputs a static page in a CMS layout.'
        ];
    }

    public function onRun()
    {
        $url = $this->getRouter()->getUrl();

        if (!strlen($url)) {
            $url = '/';
        }

        $router = new Router(Theme::getActiveTheme());
        $this->pageObject = $this->page['page'] = $router->findByUrl($url);

        if ($this->pageObject) {
            $this->title = $this->page['title'] = $this->pageObject->getViewBag()->property('title');
            $this->extraData = $this->page['extraData'] = $this->defineExtraData();
        }
    }

    public function page()
    {
        return $this->pageObject;
    }

    public function parent()
    {
        return $this->pageObject ? $this->pageObject->getParent() : null;
    }

    public function children()
    {
        return $this->pageObject ? $this->pageObject->getChildren() : null;
    }

    public function content()
    {
{'fraction_non_alphanumeric': 0.1475364712358932, 'fraction_numerical': 0.0, 'mean_word_length': 2.221631205673759, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 55, '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': '1276006', 'n_tokens_mistral': 1070, 'n_tokens_neox': 1041, 'n_words': 265}