<commit_before><?php

/**
 * This action will update a translation using AJAX
 *
 * @package		backend
 * @subpackage	locale
 *
 * @author		<NAME> <<EMAIL>>
 * @since		2.1
 */
class BackendLocaleAjaxSaveTranslation extends BackendBaseAJAXAction
{
	/**
	 * Execute the action
	 *
	 * @return	void
	 */
	public function execute()
	{
		// call parent, this will probably add some general CSS/JS or other required files
		parent::execute();

		// get parameters
		$language = SpoonFilter::getPostValue('language', null, null, 'string');
		$module = SpoonFilter::getPostValue('module', null, null, 'string');
		$name = SpoonFilter::getPostValue('name', null, null, 'string');
		$type = SpoonFilter::getPostValue('type', null, null, 'string');
		$application = SpoonFilter::getPostValue('application', null, null, 'string');
		$value = SpoonFilter::getPostValue('value', null, null, 'string');

		// validate values
		$error = null;

		// in case this is a 'act' type, there are special rules concerning possible values
		if($type == 'act')
		{
			if(!SpoonFilter::isValidAgainstRegexp('|^([a-z0-9\-\_])+$|', $value)) $error = BL::err('InvalidActionValue', 'locale');
		}

		// no error?
		if($error == null)
		{
			// build item
			$item['language'] = $language;
			$item['module'] = $module;
			$item['name'] = $name;
			$item['type'] = $type;
			$item['application'] = $application;
			$item['value'] = $value;

			// save values
			if(BackendLocaleModel::existsByName($name, $type, $module, $language, $application))
			{
				// add the id to the item
				$item['id'] = (int) BackendLocaleModel::getByName($name, $type, $module, $language, $application);

				// update in db
				BackendLocaleModel::update($item);
			}

			else
			{
				// insert in db
				BackendLocaleModel::insert($item);
			}

			// output
			$this->output(self::OK);
		}

		// output the error
		else $this->output(self::ERROR, null, $error);
	}
}

?><commit_msg>the edited_on and user_id also get updated now<commit_after><?php

/**
 * This action will update a translation using AJAX
 *
 * @package		backend
 * @subpackage	locale
 *
 * @author		<NAME> <<EMAIL>>
 * @since		2.1
 */
class BackendLocaleAjaxSaveTranslation extends BackendBaseAJAXAction
{
	/**
	 * Execute the action
	 *
	 * @return	void
	 */
	public function execute()
	{
		// call parent, this will probably add some general CSS/JS or other required files
		parent::execute();

		// get parameters
		$language = SpoonFilter::getPostValue('language', null, null, 'string');
		$module = SpoonFilter::getPostValue('module', null, null, 'string');
		$name = SpoonFilter::getPostValue('name', null, null, 'string');
		$type = SpoonFilter::getPostValue('type', null, null, 'string');
		$application = SpoonFilter::getPostValue('application', null, null, 'string');
		$value = SpoonFilter::getPostValue('value', null, null, 'string');

		// validate values
		$error = null;

		// in case this is a 'act' type, there are special rules concerning possible values
		if($type == 'act')
		{
			if(!SpoonFilter::isValidAgainstRegexp('|^([a-z0-9\-\_])+$|', $value)) $error = BL::err('InvalidActionValue', 'locale');
		}

		// no error?
		if($error == null)
		{
			// build item
			$item['language'] = $language;
			$item['module'] = $module;
			$item['name'] = $name;
			$item['type'] = $type;
			$item['application'] = $application;
			$item['value'] = $value;
			$item['edited_on'] = BackendModel::getUTCDate();
			$item['user_id'] = BackendAuthentication::getUser()->getUserId();

			// save values
			if(BackendLocaleModel::existsByName($name, $type, $module, $language, $application))
			{
				// add the id to the item
				$item['id'] = (int) BackendLocaleModel::getByName($name, $type, $module, $language, $application);

				// update in db
				BackendLocaleModel::update($item);
			}

			else
			{
				// insert in db
				BackendLocaleModel::insert($item);
			}

			// output
			$this->output(self::OK);
		}

		// output the error
		else $this->output(self::ERROR, null, $error);
	}
}

?>
{'fraction_non_alphanumeric': 0.17562189054726368, 'fraction_numerical': 0.001990049751243781, 'mean_word_length': 3.89768574908648, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 16, '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': '5829750', 'n_tokens_mistral': 1479, 'n_tokens_neox': 1309, 'n_words': 325}