<commit_before><?php
/**
 * FUNCTIONS
 * All custom functions used in all sites
 *
 * ===========================================================================
 */
?>

<?php
/**
 * REQUIRE PLUGIN
 * ===========================================================================
 */

/** USEFUL */
require_once 'plugin/useful.php';



/**
 * GET INFORMATIONS
 * ===========================================================================
 */


/**
 * GET ENVIRONMENT
 * Set the current environment
 *
 * @param array $all_domain list of possible server name
 * @param string $server_name the chosen server name
 * @return string the environment
 */
function getEnvironment($all_domain, $server_name) {
    return $all_domain[$server_name];
}


/**
 * GET CURRENT URI
 * Strip the script name from URL
 *
 * @return string the current uri
 */
function getCurrentUri() {
    $basepath = implode('/', array_slice(explode('/', $_SERVER['SCRIPT_NAME']), 0, -1)) . '/';
    $uri = substr($_SERVER['REQUEST_URI'], strlen($basepath));

    if (strstr($uri, '?'))
        $uri = substr($uri, 0, strpos($uri, '?'));
    $uri = '/' . trim($uri, '/');

    return $uri;
}


/**
 * GET CURRENT ROUTES
 * Explode in array the baseurl by '/' char
 *
 * @return array the array of path
 */
function getCurrentRoutes() {
    global $base_url;
    $routes = explode('/', $base_url);

    /** remove the first */
    array_shift($routes);

    return $routes;
}



/**
 * REQUIREDS
 * ===========================================================================
 */


/**
 * REQUIRED HEAD
 * Require the head part
 */
function rq_head() {
    if (is_404()) {
        header('HTTP/1.0 404 Not Found');
    }
    require_once HTML . 'require/head.req.php';
}


/**
 * REQUIRE PAGE
 * Require the foot part
 */
function rq_foot() {
    require_once HTML . 'require/foot.req.php';
}


/**
 * REQUIRE CONTENT
 * Require the chosen content
 * 
 * @param string
 */
function rq_content($CONTENT) {
    require_once CONTENTS_PATH . $CONTENT . '.cont.php';
}


/**
 * REQUIRE VIEW
 * Require the chosen content
 * 
 * @param string
 */
function rq_view($VIEW) {
    require_once VIEWS_PATH . $VIEW . '.view.php';
}


/**
 * REQUIRE PAGE
 * Require the chosen uri's page
 * 
 * @param string $TYPE_PATH the html subfolder type ['view', 'required', 'template']
 * @param string $PATH the name of file
 */
function rq_part($TYPE_PATH, $PART) {
    require_once HTML . '/' . $TYPE_PATH . '/part/' . $PART . '.part.php';
}


/**
 * REQUIRE PAGE
 * Require the chosen uri's page through templates
 * 
 * @param string $URI the chosen uri [default is the current uri]
 */
function rq_page($URI = CURRENT_URI) {
    global $pages;

    if (isset($pages[$URI])) {
        if (MULTIPAGE) {
            $TEMPLATE    = $pages[$URI]['template'];
            $CONTENT     = $pages[$URI]['content'];

            require_once TEMPLATES_PATH . $TEMPLATE . '.tpl.php';
        } else {
            $pages_exclude = arrayExclude($pages, array('404'));
            foreach ($pages_exclude as $uri => $page) {
                $TEMPLATE    = $page['template'];
                $CONTENT     = $page['content'];<commit_msg>correction of include view function<commit_after><?php
/**
 * FUNCTIONS
 * All custom functions used in all sites
 *
 * ===========================================================================
 */
?>

<?php
/**
 * REQUIRE PLUGIN
 * ===========================================================================
 */

/** USEFUL */
require_once 'plugin/useful.php';



/**
 * GET INFORMATIONS
 * ===========================================================================
 */


/**
 * GET ENVIRONMENT
 * Set the current environment
 *
 * @param array $all_domain list of possible server name
 * @param string $server_name the chosen server name
 * @return string the environment
 */
function getEnvironment($all_domain, $server_name) {
    return $all_domain[$server_name];
}


/**
 * GET CURRENT URI
 * Strip the script name from URL
 *
 * @return string the current uri
 */
function getCurrentUri() {
    $basepath = implode('/', array_slice(explode('/', $_SERVER['SCRIPT_NAME']), 0, -1)) . '/';
    $uri = substr($_SERVER['REQUEST_URI'], strlen($basepath));

    if (strstr($uri, '?'))
        $uri = substr($uri, 0, strpos($uri, '?'));
    $uri = '/' . trim($uri, '/');

    return $uri;
}


/**
 * GET CURRENT ROUTES
 * Explode in array the baseurl by '/' char
 *
 * @return array the array of path
 */
function getCurrentRoutes() {
    global $base_url;
    $routes = explode('/', $base_url);

    /** remove the first */
    array_shift($routes);

    return $routes;
}



/**
 * REQUIREDS
 * ===========================================================================
 */


/**
 * REQUIRED HEAD
 * Require the head part
 */
function rq_head() {
    if (is_404()) {
        header('HTTP/1.0 404 Not Found');
    }
    require_once HTML . 'require/head.req.php';
}


/**
 * REQUIRE PAGE
 * Require the foot part
 */
function rq_foot() {
    require_once HTML . 'require/foot.req.php';
}


/**
 * REQUIRE CONTENT
 * Require the chosen content
 * 
 * @param string $CONTENT file name of content
 */
function rq_content($CONTENT) {
    require_once CONTENTS_PATH . $CONTENT . '.cont.php';
}


/**
 * REQUIRE VIEW
 * Require the chosen content
 * 
 * @param string $VIEW file name of view
 * @param array or string $CONTENTS content of the included view
 */
function rq_view($VIEW, $CONTENTS) {
    $THIS_VIEW_CONTENTS = $CONTENTS;
    include VIEWS_PATH . $VIEW . '.view.php';
}


/**
 * REQUIRE PAGE
 * Require the chosen uri's page
 * 
 * @param string $TYPE_PATH the html subfolder type ['view', 'required', 'template']
 * @param string $PATH the name of file
 */
function rq_part($TYPE_PATH, $PART) {
    include HTML . '/' . $TYPE_PATH . '/part/' . $PART . '.part.php';
}


/**
 * REQUIRE PAGE
 * Require the chosen uri's page through templates
 * 
 * @param string $URI the chosen uri [default is the current uri]
 */
function rq_page($URI = CURRENT_URI) {
    global $pages;

    if (isset($pages[$URI])) {
        if (MULTIPAGE) {
            $TEMPLATE    = $pages[$URI]['template'];
            $CONTENT     = $pages[$URI]['content'];

            require_once TEMPLATES_PATH . $TEMPLATE . '.tpl.php';
        } else {
            $pages_exclude = arrayExclude($pages, array('404'));
            foreach ($pages_exclude as $uri => $page) {
                $TEMPLATE    = $page['template'];
                $CONTENT     = $page['content'];
{'fraction_non_alphanumeric': 0.23492404480589227, 'fraction_numerical': 0.004296455424274973, 'mean_word_length': 3.1174984207201515, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3492273', 'n_tokens_mistral': 2093, 'n_tokens_neox': 1925, 'n_words': 528}