<commit_before><?php

/**
 * Created by PhpStorm.
 * User: bryce
 * Date: 9/2/15
 * Time: 7:54 PM
 */

namespace WordWrap\Admin;

use WordWrap\Admin\Tasks\AvailableTasks;
use WordWrap\Assets\Script\JavaScript;
use WordWrap\Assets\StyleSheet\CSS;
use WordWrap\Assets\View\View;
use WordWrap\Configuration\Admin;
use WordWrap\Configuration\Page;
use WordWrap\LifeCycle;

class AdminController {

    /**
     * @var LifeCycle the current running LifeCycle
     */
    private $lifeCycle;
    /**
     * @var Admin the configuration for this controllers configuration
     */
    private $admin;

    /**
     * @var TaskController the current task being ran
     */
    private $taskController = null;

    /**
     * @var Page the current page that is being used
     */
    private $currentPage;

    public function __construct(LifeCycle $lifeCycle, Admin $admin) {
        $this->lifeCycle = $lifeCycle;
        $this->admin = $admin;

        add_action("init", [$this, "handleRequest"]);

        add_action( 'admin_menu', [$this, "addMenus"] );
    }

    /**
     * checks for tasks being ran and creates the controllers for them
     */
    public function handleRequest() {

        $page = $this->getCurrentPage();
        if ($page) {


            $defaultTask = null;
            $currentTask = null;
            $taskController = null;

            $requestedTask = isset($_GET["task"]) ? $_GET["task"] : "";

            foreach ($this->getCurrentPage()->Task as $task) {
                if($task->default)
                    $defaultTask = $task;
                if($task->getSlug() == $requestedTask) {
                    $currentTask = $task;
                    break;
                }
            }

            if($currentTask == null && $defaultTask != null)
                $currentTask = $defaultTask;

            if($currentTask == null) {
                $this->taskController = new AvailableTasks($this->lifeCycle, $this);
            }
            else {
                if(strpos($currentTask->className, "\\") === 0)
                    $taskClass = $this->lifeCycle->rootConfig->rootNameSpace . $currentTask->className;
                else
                    $taskClass = $currentTask->className;
                $this->taskController = new $taskClass($this->lifeCycle, $this, $currentTask);
            }
        }
    }<commit_msg>added admin controller properly<commit_after><?php

/**
 * Created by PhpStorm.
 * User: bryce
 * Date: 9/2/15
 * Time: 7:54 PM
 */

namespace WordWrap\Admin;

use WordWrap\Admin\Tasks\AvailableTasks;
use WordWrap\Admin\Tasks\CrudIndex;
use WordWrap\Assets\Script\JavaScript;
use WordWrap\Assets\StyleSheet\CSS;
use WordWrap\Assets\View\View;
use WordWrap\Configuration\Admin;
use WordWrap\Configuration\Page;
use WordWrap\LifeCycle;

class AdminController {

    /**
     * @var LifeCycle the current running LifeCycle
     */
    private $lifeCycle;
    /**
     * @var Admin the configuration for this controllers configuration
     */
    private $admin;

    /**
     * @var TaskController the current task being ran
     */
    private $taskController = null;

    /**
     * @var Page the current page that is being used
     */
    private $currentPage;

    public function __construct(LifeCycle $lifeCycle, Admin $admin) {
        $this->lifeCycle = $lifeCycle;
        $this->admin = $admin;

        add_action("init", [$this, "handleRequest"]);

        add_action( 'admin_menu', [$this, "addMenus"] );
    }

    /**
     * checks for tasks being ran and creates the controllers for them
     */
    public function handleRequest() {

        $page = $this->getCurrentPage();
        if ($page) {


            $defaultTask = null;
            $currentTask = null;
            $taskController = null;

            $requestedTask = isset($_GET["task"]) ? $_GET["task"] : "";

            foreach ($this->getCurrentPage()->Task as $task) {
                if($task->default)
                    $defaultTask = $task;
                if($task->getSlug() == $requestedTask) {
                    $currentTask = $task;
                    break;
                }
            }

            if($currentTask == null && $defaultTask != null)
                $currentTask = $defaultTask;

            if($currentTask == null) {
                $this->taskController = new AvailableTasks($this->lifeCycle, $this);
            }
            else {

                if ($currentTask->CrudIndex) {
                    $this->taskController = new CrudIndex($this->lifeCycle, $this, $currentTask);
                }
                else {
                    if(strpos($currentTask->className, "\\") === 0) {
                        $taskClass = $this->lifeCycle->rootConfig->rootNameSpace . $currentTask->className;
                    }
                    else {
                        $taskClass = $currentTask->className;
                    }
                    $this->taskController = new $taskClass($this->lifeCycle, $this, $currentTask);

                }
            }
        }
    }
{'fraction_non_alphanumeric': 0.1253454401894986, 'fraction_numerical': 0.0031583103039873666, 'mean_word_length': 1.8354784555120314, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 40, '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': '3725001', 'n_tokens_mistral': 1440, 'n_tokens_neox': 1361, 'n_words': 313}