<commit_before><?php

Yii::import(TranslateModule::ID.'.components.ITranslateModuleComponent');

/**
 *
 * @author <NAME> <<EMAIL>>
 *
 */
class TUrlManager extends CUrlManager implements ITranslateModuleComponent
{
	
	private $_translateModuleID = TranslateModule::ID;
	
	public function getTranslateModule()
	{
		return TranslateModule::findModule($this->getTranslateModuleID());
	}
	
	public function getTranslateModuleID()
	{
		return $this->_translateModuleID;
	}
	
	public function setTranslateModuleID($translateModuleID = TranslateModule::ID)
	{
		$this->_translateModuleID = $translateModuleID;
	}

	/**
	 * (non-PHPdoc)
	 * @see CUrlManager::createUrl()
	 */
	public function createUrl($route, $params = array(), $ampersand = '&')
	{
		$languageVarName = $this->getTranslateModule()->getTranslator()->languageVarName;
		if(!isset($params[$languageVarName]))
		{
			$params[$languageVarName] = Yii::app()->getLanguage();
		}
		return parent::createUrl($route, $params, $ampersand);
	}

	/**
	 * (non-PHPdoc)
	 * @see CUrlManager::parseUrl()
	 */
	public function parseUrl($request)
	{
		$route = parent::parseUrl($request);
		$translator = $this->getTranslateModule()->getTranslator();

		// Determine request's preferred language by:

		// Post parameter
		if(isset($_POST[$translator->languageVarName]))
		{
			$language = $_POST[$translator->languageVarName];
			unset($_POST[$translator->languageVarName]);
		}
		// Get parameter is set and language is supported
		else if(isset($_GET[$translator->languageVarName]) && in_array(CLocale::getCanonicalID($_GET[$translator->languageVarName]), CLocale::getLocaleIDs()))
		{
			$language = $_GET[$translator->languageVarName];
		}
		// Session
		else if(Yii::app()->getUser()->hasState($translator->languageVarName))
		{
			$language = Yii::app()->getUser()->getState($translator->languageVarName);
		}<commit_msg>Bug fix for incorrect url language prepending<commit_after><?php

Yii::import(TranslateModule::ID.'.components.ITranslateModuleComponent');

/**
 *
 * @author <NAME> <<EMAIL>>
 *
 */
class TUrlManager extends CUrlManager implements ITranslateModuleComponent
{
	
	private $_translateModuleID = TranslateModule::ID;
	
	public function getTranslateModule()
	{
		return TranslateModule::findModule($this->getTranslateModuleID());
	}
	
	public function getTranslateModuleID()
	{
		return $this->_translateModuleID;
	}
	
	public function setTranslateModuleID($translateModuleID = TranslateModule::ID)
	{
		$this->_translateModuleID = $translateModuleID;
	}

	/**
	 * (non-PHPdoc)
	 * @see CUrlManager::createUrl()
	 */
	public function createUrl($route, $params = array(), $ampersand = '&')
	{
		$languageVarName = $this->getTranslateModule()->getTranslator()->languageVarName;
		if(!isset($params[$languageVarName]))
		{
			$params[$languageVarName] = Yii::app()->getLanguage();
		}
		return parent::createUrl($route, $params, $ampersand);
	}

	/**
	 * (non-PHPdoc)
	 * @see CUrlManager::parseUrl()
	 */
	public function parseUrl($request)
	{
		$route = parent::parseUrl($request);
		$translator = $this->getTranslateModule()->getTranslator();

		// Determine request's preferred language by:

		// Post parameter
		if(isset($_POST[$translator->languageVarName]))
		{
			$_GET[$translator->languageVarName] = $_POST[$translator->languageVarName];
			unset($_POST[$translator->languageVarName]);
		}
		
		// Get parameter is set and language is supported
		if(isset($_GET[$translator->languageVarName]) && in_array(CLocale::getCanonicalID($_GET[$translator->languageVarName]), CLocale::getLocaleIDs()))
		{
			$language = $_GET[$translator->languageVarName];
		}
		// Session
		else if(Yii::app()->getUser()->hasState($translator->languageVarName))
		{
			$language = Yii::app()->getUser()->getState($translator->languageVarName);
		}
{'fraction_non_alphanumeric': 0.16447368421052633, 'fraction_numerical': 0.0, 'mean_word_length': 5.576124567474048, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 52, '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': '6856353', 'n_tokens_mistral': 1279, 'n_tokens_neox': 1171, 'n_words': 181}