<commit_before><?php
	/*
	Copyright: <NAME> 2015
	LICENCE: MIT http://deuxhuithuit.mit-license.org;
	*/

	if (!defined('__IN_SYMPHONY__')) die('<h2>Symphony Error</h2><p>You cannot directly access this file</p>');

	require_once(TOOLKIT . '/class.field.php');
	require_once(EXTENSIONS . '/selectbox_link_field/fields/field.selectbox_link.php');
	require_once(EXTENSIONS . '/frontend_localisation/lib/class.FLang.php');
	
	/**
	 *
	 * Field class that will represent relationships between entries
	 * @author <NAME>
	 *
	 */
	class FieldMultilingual_SelectBox_Link extends FieldSelectBox_Link
	{
		public function __construct(){
			parent::__construct();
			$this->_name = __('Multilingual Select Box Link');
		}
		
		public function fetchIDfromValue($value) {
			$id = null;
			$related_field_ids = $this->get('related_field_id');

			$lc = FLang::getLangCode();

			if (empty($lc)) {
				$lc = FLang::getMainLang();
			}
			
			$value = Lang::createHandle($value);
			
			$try_parent = false;
			
			foreach($related_field_ids as $related_field_id) {
				try {
					$return = Symphony::Database()->fetchCol("id", sprintf("
						SELECT
							`entry_id` as `id`
						FROM
							`tbl_entries_data_%d`
						WHERE
							`handle` = '%s' OR `handle-{$lc}` = '%s'
						LIMIT 1", $related_field_id, $value, $value<commit_msg>Support SBL basic sorting<commit_after><?php
	/*
	Copyright: <NAME> 2015
	LICENCE: MIT http://deuxhuithuit.mit-license.org;
	*/

	if (!defined('__IN_SYMPHONY__')) die('<h2>Symphony Error</h2><p>You cannot directly access this file</p>');

	require_once(TOOLKIT . '/class.field.php');
	require_once(EXTENSIONS . '/selectbox_link_field/fields/field.selectbox_link.php');
	require_once(EXTENSIONS . '/frontend_localisation/lib/class.FLang.php');
	
	/**
	 *
	 * Field class that will represent relationships between entries
	 * @author <NAME>
	 *
	 */
	class FieldMultilingual_SelectBox_Link extends FieldSelectBox_Link
	{
		public function __construct(){
			parent::__construct();
			$this->_name = __('Multilingual Select Box Link');
		}
		
		protected function getFieldSchema($fieldId) {
			$lc = FLang::getLangCode();

			if (empty($lc)) {
				$lc = FLang::getMainLang();
			}
			
			try {
				return Symphony::Database()->fetch("
					SHOW COLUMNS FROM `tbl_entries_data_$fieldId`
						WHERE `Field` in ('value-$lc');
				");
			}
			catch (Exception $ex) {
				// bail out
			}
			return parent::getFieldSchema($fieldId);
		}
		
		public function fetchIDfromValue($value) {
			$id = null;
			$related_field_ids = $this->get('related_field_id');

			$lc = FLang::getLangCode();

			if (empty($lc)) {
				$lc = FLang::getMainLang();
			}
			
			$value = Lang::createHandle($value);
			
			$try_parent = false;
			
			foreach($related_field_ids as $related_field_id) {
				try {
					$return = Symphony::Database()->fetchCol("id", sprintf("
						SELECT
							`entry_id` as `id`
						FROM
							`tbl_entries_data_%d`
						WHERE
							`handle` = '%s' OR `handle-{$lc}` = '%s'
						LIMIT 1", $related_field_id, $value, $value
{'fraction_non_alphanumeric': 0.153946937438585, 'fraction_numerical': 0.004585653455617425, 'mean_word_length': 3.5582089552238805, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 22, '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': '4142928', 'n_tokens_mistral': 1275, 'n_tokens_neox': 1023, 'n_words': 203}