<commit_before><?php

    namespace Administro\Route;

    use \Administro\Administro;

    class PageRoute extends Route {

        public function isValid($params) {
            if(count($params) == 0) {
                return true;
            }
            if(count($params) == 1 && Administro::Instance()->pagemanager->pageExists($params[1])) {
                return true;
            }
            return false;
        }

        public function routeUser($params) {
            // Get ConfigManager
            $configManager = Administro::Instance()->configmanager;
            // Load the page partial by default
            if(count($params) == 0) {
                $GLOBALS["requestedPage"] = $configManager->getConfiguration()["default-page"];
            }
            if(count($params) == 1) {
                // Check if the page is the default page
                if($configManager->getConfiguration()["default-page"] == $params[1]) {
                    // Redirect the user to the base path
                    $this->redirect("");
                }
                $GLOBALS["requestedPage"] = $params[1];
            }
            return "page";
        }

    }

    class FormRoute extends Route {

        public function isValid($params) {
            return (isset($GLOBALS["AdministroPost"]) && count($params) == 2 && $params[1] == "form");
        }

        public function routeUser($params) {
            Administro::Instance()->formprocessor->processForm($params[2], $GLOBALS["AdministroPost"]);
            return false;
        }

    }

    class AdminRoute extends Route {

        public function isValid($params) {
            if(count($params > 0) && $params[1] == "admin") {
                // Get admin routes
                $routes = Administro::Instance()->adminroutes->getAdminRoutes();
                // Check if this is the home route
                if(count($params) == 1) {
                    return true;
                } else {
                    // Try the custom routes
                    foreach ($routes as $name => $data) {
                        // Verify the route is correct
                        $pName = "";
                        for ($i = 2; $i <= count($params); $i++) {
                            $pName.=$params[$i];
                        }
                        // Compare the names
                        if ($pName === $name) {
                            return true;
                        }
                    }
                    return false;
                }
            }
            return false;
        }

        public function routeUser($params) {
            // Redirect to admin home if needed
            if(count($params) == 1) {
                $this->redirect("admin/home");
            } else {
                // Piece together the parameters<commit_msg>Fix typo<commit_after><?php

    namespace Administro\Route;

    use \Administro\Administro;

    class PageRoute extends Route {

        public function isValid($params) {
            if(count($params) == 0) {
                return true;
            }
            if(count($params) == 1 && Administro::Instance()->pagemanager->pageExists($params[1])) {
                return true;
            }
            return false;
        }

        public function routeUser($params) {
            // Get ConfigManager
            $configManager = Administro::Instance()->configmanager;
            // Load the page partial by default
            if(count($params) == 0) {
                $GLOBALS["requestedPage"] = $configManager->getConfiguration()["default-page"];
            }
            if(count($params) == 1) {
                // Check if the page is the default page
                if($configManager->getConfiguration()["default-page"] == $params[1]) {
                    // Redirect the user to the base path
                    $this->redirect("");
                }
                $GLOBALS["requestedPage"] = $params[1];
            }
            return "page";
        }

    }

    class FormRoute extends Route {

        public function isValid($params) {
            return (isset($GLOBALS["AdministroPost"]) && count($params) == 2 && $params[1] == "form");
        }

        public function routeUser($params) {
            Administro::Instance()->formprocessor->processForm($params[2], $GLOBALS["AdministroPost"]);
            return false;
        }

    }

    class AdminRoute extends Route {

        public function isValid($params) {
            if(count($params) > 0 && $params[1] == "admin") {
                // Get admin routes
                $routes = Administro::Instance()->adminroutes->getAdminRoutes();
                // Check if this is the home route
                if(count($params) == 1) {
                    return true;
                } else {
                    // Try the custom routes
                    foreach ($routes as $name => $data) {
                        // Verify the route is correct
                        $pName = "";
                        for ($i = 2; $i <= count($params); $i++) {
                            $pName.=$params[$i];
                        }
                        // Compare the names
                        if ($pName === $name) {
                            return true;
                        }
                    }
                    return false;
                }
            }
            return false;
        }

        public function routeUser($params) {
            // Redirect to admin home if needed
            if(count($params) == 1) {
                $this->redirect("admin/home");
            } else {
                // Piece together the parameters
{'fraction_non_alphanumeric': 0.1205240174672489, 'fraction_numerical': 0.005240174672489083, 'mean_word_length': 1.2419733750978856, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 29, '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': '2726214', 'n_tokens_mistral': 1405, 'n_tokens_neox': 1312, 'n_words': 326}