<commit_before><?php

namespace k1lib\crudlexs;

use k1lib\templates\temply as temply;
use k1lib\urlrewrite\url as url;
use k1lib\html\DOM as DOM;
use k1lib\notifications\on_DOM as DOM_notification;

class controller_base {

    protected $security_no_rules_enable = FALSE;

    /**
     * DB table main object
     * @var \k1lib\crudlexs\class_db_table 
     */
    public $db_table;

    /**
     * Controller name for add on <html><title> and controller name tag
     * @var string 
     */
    protected $controller_name;

    /**
     * URL value after the domain
     * @var string
     */
    protected $controller_root_dir;

    /**
     * THIS controller URL value
     * @var string
     */
    protected $controller_url_value;

    /**
     * URL value for the board asked to show
     * @var string
     */
    protected $controller_board_url_value;
    protected $controller_board_allowed_leves = [];

    /**
     *
     * @var boolean
     */
    protected $board_inited = FALSE;
    protected $board_started = FALSE;
    protected $board_executed = FALSE;

    /**
     *
     * @var \k1lib\html\div
     */
    public $board_div_content;

    /**
     *
     * @var \k1lib\html\tag
     */
    public $html_title_tags = NULL;
    /**
     * 
     * URL MANAGEMENT VALUES
     * 
     */

    /**
     *
     * @var \k1lib\crudlexs\board_list;
     */
    public $board_list_object;
    protected $board_list_url_name = "list";
    protected $board_list_allowed_levels = [];

    /**
     *
     * @var \k1lib\crudlexs\board_create
     */
    public $board_create_object;
    protected $board_create_url_name = "create";
    protected $board_create_allowed_levels = [];

    /**
     *
     * @var \k1lib\crudlexs\board_read
     */
    public $board_read_object;
    protected $board_read_url_name = "read";
    protected $board_read_allowed_levels = [];

    /**
     *
     * @var \k1lib\crudlexs\board_update
     */
    public $board_update_object;
    protected $board_update_url_name = "update";
    protected $board_update_allowed_levels = [];

    /**
     *
     * @var \k1lib\crudlexs\board_delete
     */
    public $board_delete_object;
    protected $board_delete_url_name = "delete";
    protected $board_delete_allowed_levels = [];

    /**
     *
     * @var \k1lib\crudlexs\board_search
     */
    public $board_search_object;
    protected $board_search_url_name = "search";
    protected $board_search_allowed_levels = [];


    /**
     *
     * Board names for html title and controller name tag
     * 
     */

    /**
     * Template name set for HTML-TITLE on the header.php
     * @var type 
     */
    protected $template_place_name_html_title = "html-title";

    /**
     * Template name set for CONTROLER-NAME on the header.php
     * @var type 
     */
    protected $template_place_name_controller_name = "controller-name";
    protected $template_place_name_board_name = "board-name";
    protected $board_list_name;
    protected $board_create_name;
    protected $board_read_name;
    protected $board_update_name;
    protected $board_delete_name;
    protected $url_redirect_after_delete = "../../list/";

    /**
     * BOARDS avaliabilty
     */
    protected $board_list_enabled = TRUE;
    protected $board_create_enabled = TRUE;
    protected $board_read_enabled = TRUE;
    protected $board_update_enabled = TRUE;
    protected $board_delete_enabled = TRUE;

    /**
     * One line config for more time to party and less coding :)
     * @param string $app_base_dir Use here \k1app\APP_BASE_URL
     * @param \PDO $db DB app object
     * @param string $db_table_name Table to open from the DB
     * @param string $controller_name Name for html title and controller name tag
     * @param string $template_place_name_html_title 
     * @param string $template_place_name_controller_name 
     */
    public function __construct($app_base_dir, \PDO $db, $db_table_name, $controller_name, $title_tag_class = null) {
        /**
         * URL Management
         */
        $this->controller_root_dir = $app_base_dir . url::make_url_from_rewrite('this');
        $this->controller_url_value = url::get_url_level_value('this');
        $this->controller_board_url_value = $this->set_and_get_next_url_value();
        /**
         * DB Table 
         */
        $this->db_table = new \k1lib\crudlexs\class_db_table($db, $db_table_name);

        /**
         * Controller name for add on <html><title> and controller name tag
         */
        $this->controller_name = $controller_name;
        $this->html_title_tags = DOM::html()->body()->get_elements_by_class($title_tag_class);
        if (!empty($this->html_title_tags)) {
            $span = (new \k1lib\html\span("subheader"))->set_value($controller_name);
            foreach ($this->html_title_tags as $tag) {
                $tag->set_value($span);
            }
            DOM::html()->head()->set_title(DOM::html()->head()->get_title() . " | $controller_name");
        }


//        temply::set_place_value($this->template_place_name_html_title, " | $controller_name");
//        temply::set_place_value($this->template_place_name_controller_name, $controller_name);

        /**<commit_msg>- improvements<commit_after><?php

namespace k1lib\crudlexs;

use k1lib\templates\temply as temply;
use k1lib\urlrewrite\url as url;
use k1lib\html\DOM as DOM;
use k1lib\notifications\on_DOM as DOM_notification;

class controller_base {

    protected $security_no_rules_enable = FALSE;

    /**
     * DB table main object
     * @var \k1lib\crudlexs\class_db_table 
     */
    public $db_table;

    /**
     * Controller name for add on <html><title> and controller name tag
     * @var string 
     */
    protected $controller_name;

    /**
     * URL value after the domain
     * @var string
     */
    protected $controller_root_dir;

    /**
     * THIS controller URL value
     * @var string
     */
    protected $controller_url_value;

    /**
     * URL value for the board asked to show
     * @var string
     */
    protected $controller_board_url_value;
    protected $controller_board_allowed_leves = [];

    /**
     *
     * @var boolean
     */
    protected $board_inited = FALSE;
    protected $board_started = FALSE;
    protected $board_executed = FALSE;

    /**
     *
     * @var \k1lib\html\div
     */
    public $board_div_content;

    /**
     *
     * @var \k1lib\html\tag
     */
    public $html_title_tags = NULL;
    /**
     * 
     * URL MANAGEMENT VALUES
     * 
     */

    /**
     *
     * @var \k1lib\crudlexs\board_list;
     */
    public $board_list_object;
    protected $board_list_url_name = "list";
    protected $board_list_allowed_levels = [];

    /**
     *
     * @var \k1lib\crudlexs\board_create
     */
    public $board_create_object;
    protected $board_create_url_name = "create";
    protected $board_create_allowed_levels = [];

    /**
     *
     * @var \k1lib\crudlexs\board_read
     */
    public $board_read_object;
    protected $board_read_url_name = "read";
    protected $board_read_allowed_levels = [];

    /**
     *
     * @var \k1lib\crudlexs\board_update
     */
    public $board_update_object;
    protected $board_update_url_name = "update";
    protected $board_update_allowed_levels = [];

    /**
     *
     * @var \k1lib\crudlexs\board_delete
     */
    public $board_delete_object;
    protected $board_delete_url_name = "delete";
    protected $board_delete_allowed_levels = [];

    /**
     *
     * @var \k1lib\crudlexs\board_search
     */
    public $board_search_object;
    protected $board_search_url_name = "search";
    protected $board_search_allowed_levels = [];


    /**
     *
     * Board names for html title and controller name tag
     * 
     */

    /**
     * Template name set for HTML-TITLE on the header.php
     * @var type 
     */
    protected $template_place_name_html_title = "html-title";

    /**
     * Template name set for CONTROLER-NAME on the header.php
     * @var type 
     */
    protected $template_place_name_controller_name = "controller-name";
    protected $template_place_name_board_name = "board-name";
    protected $board_list_name;
    protected $board_create_name;
    protected $board_read_name;
    protected $board_update_name;
    protected $board_delete_name;
    protected $url_redirect_after_delete = "../../list/";

    /**
     * BOARDS avaliabilty
     */
    protected $board_list_enabled = TRUE;
    protected $board_create_enabled = TRUE;
    protected $board_read_enabled = TRUE;
    protected $board_update_enabled = TRUE;
    protected $board_delete_enabled = TRUE;

    /**
     * One line config for more time to party and less coding :)
     * @param string $app_base_dir Use here \k1app\APP_BASE_URL
     * @param \PDO $db DB app object
     * @param string $db_table_name Table to open from the DB
     * @param string $controller_name Name for html title and controller name tag
     * @param string $template_place_name_html_title 
     * @param string $template_place_name_controller_name 
     */
    public function __construct($app_base_dir, \PDO $db, $db_table_name, $controller_name, $title_tag_class = null) {
        /**
         * URL Management
         */
        d($app_base_dir);
        $this->controller_root_dir = $app_base_dir . url::make_url_from_rewrite('this');
        $this->controller_url_value = url::get_url_level_value('this');
        $this->controller_board_url_value = $this->set_and_get_next_url_value();
        /**
         * DB Table 
         */
        $this->db_table = new \k1lib\crudlexs\class_db_table($db, $db_table_name);

        /**
         * Controller name for add on <html><title> and controller name tag
         */
        $this->controller_name = $controller_name;
        $this->html_title_tags = DOM::html()->body()->get_elements_by_class($title_tag_class);
        if (!empty($this->html_title_tags)) {
            $span = (new \k1lib\html\span("subheader"))->set_value($controller_name);
            foreach ($this->html_title_tags as $tag) {
                $tag->set_value($span);
            }
            DOM::html()->head()->set_title(DOM::html()->head()->get_title() . " | $controller_name");
        }


//        temply::set_place_value($this->template_place_name_html_title, " | $controller_name");
//        temply::set_place_value($this->template_place_name_controller_name, $controller_name);

        /**
{'fraction_non_alphanumeric': 0.1157190635451505, 'fraction_numerical': 0.003248924988055423, 'mean_word_length': 2.557443915703603, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 49, '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': '3134016', 'n_tokens_mistral': 3374, 'n_tokens_neox': 3284, 'n_words': 652}