<commit_before><?php

namespace cms\controllers;

use Yii;

class DefaultController extends \luya\base\PageController
{
    public $useModuleViewPath = true;

    public $pageTitle = 'default none!';

    private $_lang = null;

    private $_context = null;

    public function init()
    {
        parent::init();
        $this->links();
        $this->_context = $this;
        $this->_lang = yii::$app->collection->lang->shortCode;
    }

    private function links()
    {
        $links = new \cms\collection\Links();
        $links->activeLink = $_GET['path'];
        $links->start();
        yii::$app->collection->links = $links;
    }

    public function actionIndex()
    {
        $linksObject = \Yii::$app->collection->links;

        $urls = $linksObject->getAll();

        $fullUrl = $linksObject->getActiveLink();

        /* above collection based */

        if (empty($fullUrl)) {
            $pageContent = $this->getPageContent($this->findDefaultPage());
            
            return $this->render('index', [
                'pageContent' => $pageContent
            ]);
            
            echo "FIND HOME! 404!";
            exit;
        }

        $parts = explode("/", $fullUrl);

        $parts[] = '__FIRST_REMOVAL'; // @todo remove

        $activeUrl = $this->findActive($urls, $parts);

        if (!$activeUrl) {
            // URL NOT FOUND! REDIRECT TO HOME
            echo "<h1>404<h1><h3>Url \"$fullUrl\" not found</h3>";
            exit;
        }

        $linkItem = $linksObject->getLink($activeUrl);

        $pageContent = $this->getPageContent($linkItem['id'], [
            'restString' => substr($fullUrl, strlen($linkItem['url']) + 1)       // negativPath
        ]);

        return $this->render('index', [
            'pageContent' => $pageContent
        ]);
    }

    /* PRIVS */

    private function getPageContent($navId, $options = [])
    {
        // @TODO is $linkItem['id'] a unifyed system or does it only matches cause Links is set via cms\collection\Links?<commit_msg>[-] removed 404 diag<commit_after><?php

namespace cms\controllers;

use Yii;

class DefaultController extends \luya\base\PageController
{
    public $useModuleViewPath = true;

    public $pageTitle = 'default none!';

    private $_lang = null;

    private $_context = null;

    public function init()
    {
        parent::init();
        $this->links();
        $this->_context = $this;
        $this->_lang = yii::$app->collection->lang->shortCode;
    }

    private function links()
    {
        $links = new \cms\collection\Links();
        $links->activeLink = $_GET['path'];
        $links->start();
        yii::$app->collection->links = $links;
    }

    public function actionIndex()
    {
        $linksObject = \Yii::$app->collection->links;

        $urls = $linksObject->getAll();

        $fullUrl = $linksObject->getActiveLink();

        /* above collection based */

        if (empty($fullUrl)) {
            $pageContent = $this->getPageContent($this->findDefaultPage());
            
            return $this->render('index', [
                'pageContent' => $pageContent
            ]);
        }

        $parts = explode("/", $fullUrl);

        $parts[] = '__FIRST_REMOVAL'; // @todo remove

        $activeUrl = $this->findActive($urls, $parts);

        if (!$activeUrl) {
            // URL NOT FOUND! REDIRECT TO HOME
            echo "<h1>404<h1><h3>Url \"$fullUrl\" not found</h3>";
            exit;
        }

        $linkItem = $linksObject->getLink($activeUrl);

        $pageContent = $this->getPageContent($linkItem['id'], [
            'restString' => substr($fullUrl, strlen($linkItem['url']) + 1)       // negativPath
        ]);

        return $this->render('index', [
            'pageContent' => $pageContent
        ]);
    }

    /* PRIVS */

    private function getPageContent($navId, $options = [])
    {
        // @TODO is $linkItem['id'] a unifyed system or does it only matches cause Links is set via cms\collection\Links?
{'fraction_non_alphanumeric': 0.15707196029776674, 'fraction_numerical': 0.005459057071960298, 'mean_word_length': 2.0653992395437264, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 59, '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': '6977863', 'n_tokens_mistral': 1214, 'n_tokens_neox': 1165, 'n_words': 249}