<commit_before><?php

/**
 * This file was generated by ChronosGenerator  from model.uml.
 * Manual modifications should be placed inside the protected regions.
 */
namespace app\src\controller;

use wcmf\lib\presentation\Controller;
// PROTECTED REGION ID(app/src/controller/RootController.php/Import) ENABLED START
use wcmf\lib\config\ConfigurationException;
use wcmf\lib\core\ObjectFactory;
use wcmf\lib\io\FileUtil;
use wcmf\lib\util\URIUtil;
use wcmf\lib\security\principal\impl\AnonymousUser;
use wcmf\lib\security\principal\impl\DefaultPrincipalFactory;
// PROTECTED REGION END

/**
 * RootController description:
 *
 * The following configuration settings are defined for this controller:
 *
 * [actionmapping]
 * ??cms = app\src\controller\RootController
 *
 * [views]
 * app\src\controller\RootController?? = app/src/views/cms.tpl
 *
 * @author
 * @version 1.0
 */
class RootController extends Controller {
// PROTECTED REGION ID(app/src/controller/RootController.php/Body) ENABLED START
  /**
   * @see Controller::doExecute()
   */
  protected function doExecute() {
    $response = $this->getResponse();

    // check for authenticated user
    $permissionManager = ObjectFactory::getInstance('permissionManager');
    $isLoggedIn = !($permissionManager->getAuthUser() instanceof AnonymousUser);

    // get configuration values
    $config = ObjectFactory::getConfigurationInstance();
    $appTitle = $config->getValue('title', 'application');
    $appColor = $config->getValue('color', 'application');
    $rootTypes = $config->getValue('rootTypes', 'application');
    $uiLanguage = $config->getValue('language', 'application');
    $defaultLanguage = $config->getValue('defaultLanguage', 'localization');
    $languages = $config->getSection('languages');
    $mediaAbsPath = $config->getDirectoryValue('uploadDir', 'media');
    $inputTypes = $config->getSection('inputTypes');
    $displayTypes = $config->getSection('displayTypes');

    $principalFactory = ObjectFactory::getInstance('principalFactory');
    if ($principalFactory instanceof DefaultPrincipalFactory) {
      $roleType = $config->getValue('roleType', 'principalFactory');
      $userType = $config->getValue('userType', 'principalFactory');
    }
    else {
      $userType = '';
      $roleType = '';
    }

    if ($config->hasValue('permissionType', 'defaultPermissionManager')) {
      $permissionType = $config->getValue('permissionType', 'defaultPermissionManager');
    }
    else {
      $permissionType = '';
    }

    // validate config
    if (!is_array($rootTypes) || sizeof($rootTypes) == 0) {
      throw new ConfigurationException("No root types defined.");
    }

    // check if the user should be redirected to the login page
    // if yes, we do this and add the requested path as route parameter
    $pathPrefix = dirname($_SERVER['SCRIPT_NAME']);
    $basePath = dirname($_SERVER['SCRIPT_NAME']).'/';
    $script = basename($_SERVER['SCRIPT_NAME']);
    $requestPath = $_SERVER['REQUEST_URI'];
    // remove basepath & script from request path to get the requested resource
    $requestedResource = strpos($requestPath, $basePath) === 0 ?
            preg_replace('/^'.$script.'/', '', str_replace($basePath, '', $requestPath)) : '';
    if (!$isLoggedIn && strlen($requestedResource) > 0 && !preg_match('/\?route=/', $requestPath)) {
      if ($requestPath != 'logout') {
        $redirectUrl = URIUtil::getProtocolStr().$_SERVER['HTTP_HOST'].$basePath.'?route='.$requestedResource;
        header("Location: ".$redirectUrl);
        exit;
      }
    }
    $baseHref = dirname(URIUtil::getProtocolStr().$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']).'/';
    $mediaPathRelScript = FileUtil::getRelativePath(realpath(dirname($_SERVER['SCRIPT_FILENAME'])).'/', $mediaAbsPath);
    $mediaPathRelBase = FileUtil::getRelativePath(WCMF_BASE, $mediaAbsPath);

    // define client configuration
    $clientConfig = array(<commit_msg>fixed media path calculation<commit_after><?php

/**
 * This file was generated by ChronosGenerator  from model.uml.
 * Manual modifications should be placed inside the protected regions.
 */
namespace app\src\controller;

use wcmf\lib\presentation\Controller;
// PROTECTED REGION ID(app/src/controller/RootController.php/Import) ENABLED START
use wcmf\lib\config\ConfigurationException;
use wcmf\lib\core\ObjectFactory;
use wcmf\lib\io\FileUtil;
use wcmf\lib\util\URIUtil;
use wcmf\lib\security\principal\impl\AnonymousUser;
use wcmf\lib\security\principal\impl\DefaultPrincipalFactory;
// PROTECTED REGION END

/**
 * RootController description:
 *
 * The following configuration settings are defined for this controller:
 *
 * [actionmapping]
 * ??cms = app\src\controller\RootController
 *
 * [views]
 * app\src\controller\RootController?? = app/src/views/cms.tpl
 *
 * @author
 * @version 1.0
 */
class RootController extends Controller {
// PROTECTED REGION ID(app/src/controller/RootController.php/Body) ENABLED START
  /**
   * @see Controller::doExecute()
   */
  protected function doExecute() {
    $response = $this->getResponse();

    // check for authenticated user
    $permissionManager = ObjectFactory::getInstance('permissionManager');
    $isLoggedIn = !($permissionManager->getAuthUser() instanceof AnonymousUser);

    // get configuration values
    $config = ObjectFactory::getConfigurationInstance();
    $appTitle = $config->getValue('title', 'application');
    $appColor = $config->getValue('color', 'application');
    $rootTypes = $config->getValue('rootTypes', 'application');
    $uiLanguage = $config->getValue('language', 'application');
    $defaultLanguage = $config->getValue('defaultLanguage', 'localization');
    $languages = $config->getSection('languages');
    $mediaAbsPath = $config->getDirectoryValue('uploadDir', 'media');
    $inputTypes = $config->getSection('inputTypes');
    $displayTypes = $config->getSection('displayTypes');

    $principalFactory = ObjectFactory::getInstance('principalFactory');
    if ($principalFactory instanceof DefaultPrincipalFactory) {
      $roleType = $config->getValue('roleType', 'principalFactory');
      $userType = $config->getValue('userType', 'principalFactory');
    }
    else {
      $userType = '';
      $roleType = '';
    }

    if ($config->hasValue('permissionType', 'defaultPermissionManager')) {
      $permissionType = $config->getValue('permissionType', 'defaultPermissionManager');
    }
    else {
      $permissionType = '';
    }

    // validate config
    if (!is_array($rootTypes) || sizeof($rootTypes) == 0) {
      throw new ConfigurationException("No root types defined.");
    }

    // check if the user should be redirected to the login page
    // if yes, we do this and add the requested path as route parameter
    $pathPrefix = dirname($_SERVER['SCRIPT_NAME']);
    $basePath = dirname($_SERVER['SCRIPT_NAME']).'/';
    $script = basename($_SERVER['SCRIPT_NAME']);
    $requestPath = $_SERVER['REQUEST_URI'];
    // remove basepath & script from request path to get the requested resource
    $requestedResource = strpos($requestPath, $basePath) === 0 ?
            preg_replace('/^'.$script.'/', '', str_replace($basePath, '', $requestPath)) : '';
    if (!$isLoggedIn && strlen($requestedResource) > 0 && !preg_match('/\?route=/', $requestPath)) {
      if ($requestPath != 'logout') {
        $redirectUrl = URIUtil::getProtocolStr().$_SERVER['HTTP_HOST'].$basePath.'?route='.$requestedResource;
        header("Location: ".$redirectUrl);
        exit;
      }
    }
    $baseHref = dirname(URIUtil::getProtocolStr().$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']).'/';
    $mediaPathRelScript = FileUtil::getRelativePath(dirname(FileUtil::realpath($_SERVER['SCRIPT_FILENAME'])).'/', $mediaAbsPath);
    $mediaPathRelBase = FileUtil::getRelativePath(WCMF_BASE, $mediaAbsPath);

    // define client configuration
    $clientConfig = array(
{'fraction_non_alphanumeric': 0.1519179642992784, 'fraction_numerical': 0.0012659830358273199, 'mean_word_length': 4.38881309686221, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, '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': '4025074', 'n_tokens_mistral': 2289, 'n_tokens_neox': 2235, 'n_words': 460}