<commit_before><?php
declare(ENCODING = 'utf-8');

/*                                                                        *
 * This script is part of the TYPO3 project - inspiring people to share!  *
 *                                                                        *
 * TYPO3 is free software; you can redistribute it and/or modify it under *
 * the terms of the GNU General Public License version 2 as published by  *
 * the Free Software Foundation.                                          *
 *                                                                        *
 * This script is distributed in the hope that it will be useful, but     *
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General      *
 * Public License for more details.                                       *
 *                                                                        */

/**
 * The default web router
 *
 * @package    FLOW3
 * @subpackage MVC
 * @version    $Id:F3_FLOW3_MVC_Web_RequestHandler.php 467 2008-02-06 19:34:56Z robert $
 * @copyright  Copyright belongs to the respective authors
 * @license    http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
 */
class F3_FLOW3_MVC_Web_Router implements F3_FLOW3_MVC_Web_RouterInterface {

	/**
	 * @var F3_FLOW3_Component_ManagerInterface $componentManager: A reference to the Component Manager
	 */
	 protected $componentManager;

	/**
	 * @var F3_FLOW3_Utility_Environment
	 */
	protected $utilityEnvironment;

	/**
	 * Constructs the Web Request Builder
	 *
	 * @param  F3_FLOW3_Component_ManagerInterface $componentManager: A reference to the component manager
	 * @param  F3_FLOW3_Utility_Environment $utilityEnvironment: A reference to the environment
	 * @return void
	 * @author <NAME> <<EMAIL>>
	 */
	public function __construct(F3_FLOW3_Component_ManagerInterface $componentManager, F3_FLOW3_Utility_Environment $utilityEnvironment) {
		$this->componentManager = $componentManager;
		$this->utilityEnvironment = $utilityEnvironment;
	}

	/**
	 * Routes the specified web request by setting the controller name, action and possible
	 * parameters. If the request could not be routed, it will be left untouched.
	 *
	 * @param  F3_FLOW3_MVC_Web_Request $request
	 * @return void
	 * @author <NAME> <<EMAIL>>
	 */
	public function route(F3_FLOW3_MVC_Web_Request $request) {
		$requestURI = $request->getRequestURI();
		$requestPath = F3_PHP6_Functions::substr($requestURI->getPath(), F3_PHP6_Functions::strlen((string)$request->getBaseURI()->getPath()));
		$requestPathSegments = explode('/', $requestPath);
		$this->setControllerName($requestPathSegments, $request);

		foreach ($this->utilityEnvironment->getPOSTArguments() as $argumentName => $argumentValue) {
			$request->setArgument($argumentName, $argumentValue);
		}
		foreach ($requestURI->getArguments() as $argumentName => $argumentValue) {
			$request->setArgument($argumentName, $argumentValue);
		}
	}

	/**
	 * Determines and sets the controller name for the given web request
	 *
	 * @param  array $requestPathSegments: An array of the request path segements
	 * @param  F3_FLOW3_MVC_Web_Request	$request: The web request
	 * @return void
	 * @author <NAME> <<EMAIL>>
	 */
	protected function setControllerName(array $requestPathSegments, F3_FLOW3_MVC_Web_Request $request) {
		if (!isset($requestPathSegments[0]) || $requestPathSegments[0] == '') return;

		$controllerNamePrefix = 'F3_' . $requestPathSegments[0] . '_Controller_';
		$controllerName = $controllerNamePrefix . 'Default';

		if (isset($requestPathSegments[1]) && F3_PHP6_Functions::strlen($requestPathSegments[1])) {
		 	$controllerName = $this->componentManager->getCaseSensitiveComponentName($controllerNamePrefix . $requestPathSegments[1]);
		 	if ($controllerName === FALSE) return;

		 	$this->setActionName($requestPathSegments, $request);
			$request->setControllerName($controllerName);
		} else {
		 	$controllerName = $this->componentManager->getCaseSensitiveComponentName($controllerName);
		 	if ($controllerName === FALSE) return;
		}
		$request->setControllerName($controllerName);
	}

	/**
	 * Determines and sets the action name for the given web request
	 *
	 * @param  array $requestPathSegments: An array of the request path segements
	 * @param  F3_FLOW3_MVC_Web_Request	$request: The web request
	 * @return void
	 * @author <NAME> <<EMAIL>>
	 */
	protected function setActionName(array $requestPathSegments, F3_FLOW3_MVC_Web_Request $request) {
		if (isset($requestPathSegments[2]) && F3_PHP6_Functions::strlen($requestPathSegments[2])) {
		 	$actionName = $requestPathSegments[2];
			$request->setActionName($actionName);
		}
	}
}
?><commit_msg>* FLOW3: (MVC) Added support for calling FLOW3 like "http://localhost/index_dev.php/package/controller". Original-Commit-Hash: f9da7d0cc3c2e5f40d155f5228bca2811b326857<commit_after><?php
declare(ENCODING = 'utf-8');

/*                                                                        *
 * This script is part of the TYPO3 project - inspiring people to share!  *
 *                                                                        *
 * TYPO3 is free software; you can redistribute it and/or modify it under *
 * the terms of the GNU General Public License version 2 as published by  *
 * the Free Software Foundation.                                          *
 *                                                                        *
 * This script is distributed in the hope that it will be useful, but     *
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General      *
 * Public License for more details.                                       *
 *                                                                        */

/**
 * The default web router
 *
 * @package    FLOW3
 * @subpackage MVC
 * @version    $Id:F3_FLOW3_MVC_Web_RequestHandler.php 467 2008-02-06 19:34:56Z robert $
 * @copyright  Copyright belongs to the respective authors
 * @license    http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
 */
class F3_FLOW3_MVC_Web_Router implements F3_FLOW3_MVC_Web_RouterInterface {

	/**
	 * @var F3_FLOW3_Component_ManagerInterface $componentManager: A reference to the Component Manager
	 */
	 protected $componentManager;

	/**
	 * @var F3_FLOW3_Utility_Environment
	 */
	protected $utilityEnvironment;

	/**
	 * Constructs the Web Request Builder
	 *
	 * @param  F3_FLOW3_Component_ManagerInterface $componentManager: A reference to the component manager
	 * @param  F3_FLOW3_Utility_Environment $utilityEnvironment: A reference to the environment
	 * @return void
	 * @author <NAME> <<EMAIL>>
	 */
	public function __construct(F3_FLOW3_Component_ManagerInterface $componentManager, F3_FLOW3_Utility_Environment $utilityEnvironment) {
		$this->componentManager = $componentManager;
		$this->utilityEnvironment = $utilityEnvironment;
	}

	/**
	 * Routes the specified web request by setting the controller name, action and possible
	 * parameters. If the request could not be routed, it will be left untouched.
	 *
	 * @param  F3_FLOW3_MVC_Web_Request $request
	 * @return void
	 * @author <NAME> <<EMAIL>>
	 */
	public function route(F3_FLOW3_MVC_Web_Request $request) {
		$requestURI = $request->getRequestURI();
		$requestPath = F3_PHP6_Functions::substr($requestURI->getPath(), F3_PHP6_Functions::strlen((string)$request->getBaseURI()->getPath()));
		$requestPathSegments = explode('/', $requestPath);
		if (substr($requestPathSegments[0], -4, 4) == '.php') {
			array_shift($requestPathSegments);
		}

		$this->setControllerName($requestPathSegments, $request);

		foreach ($this->utilityEnvironment->getPOSTArguments() as $argumentName => $argumentValue) {
			$request->setArgument($argumentName, $argumentValue);
		}
		foreach ($requestURI->getArguments() as $argumentName => $argumentValue) {
			$request->setArgument($argumentName, $argumentValue);
		}
	}

	/**
	 * Determines and sets the controller name for the given web request
	 *
	 * @param  array $requestPathSegments: An array of the request path segements
	 * @param  F3_FLOW3_MVC_Web_Request	$request: The web request
	 * @return void
	 * @author <NAME> <<EMAIL>>
	 */
	protected function setControllerName(array $requestPathSegments, F3_FLOW3_MVC_Web_Request $request) {
		if (!isset($requestPathSegments[0]) || $requestPathSegments[0] == '') return;

		$controllerNamePrefix = 'F3_' . $requestPathSegments[0] . '_Controller_';
		$controllerName = $controllerNamePrefix . 'Default';

		if (isset($requestPathSegments[1]) && F3_PHP6_Functions::strlen($requestPathSegments[1])) {
		 	$controllerName = $this->componentManager->getCaseSensitiveComponentName($controllerNamePrefix . $requestPathSegments[1]);
		 	if ($controllerName === FALSE) return;

		 	$this->setActionName($requestPathSegments, $request);
			$request->setControllerName($controllerName);
		} else {
		 	$controllerName = $this->componentManager->getCaseSensitiveComponentName($controllerName);
		 	if ($controllerName === FALSE) return;
		}
		$request->setControllerName($controllerName);
	}

	/**
	 * Determines and sets the action name for the given web request
	 *
	 * @param  array $requestPathSegments: An array of the request path segements
	 * @param  F3_FLOW3_MVC_Web_Request	$request: The web request
	 * @return void
	 * @author <NAME> <<EMAIL>>
	 */
	protected function setActionName(array $requestPathSegments, F3_FLOW3_MVC_Web_Request $request) {
		if (isset($requestPathSegments[2]) && F3_PHP6_Functions::strlen($requestPathSegments[2])) {
		 	$actionName = $requestPathSegments[2];
			$request->setActionName($actionName);
		}
	}
}
?>
{'fraction_non_alphanumeric': 0.10500560709552452, 'fraction_numerical': 0.017534916913039045, 'mean_word_length': 3.3794642857142856, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 73, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 28, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6124560', 'n_tokens_mistral': 2953, 'n_tokens_neox': 2723, 'n_words': 703}