<commit_before><?php
/**
 * RecordBrowserCommon class.
 *
 * @author <NAME> <<EMAIL>>
 * @copyright Copyright &copy; 2008, Telaxus LLC
 * @license MIT
 * @version 1.0
 * @package epesi-utils
 * @subpackage RecordBrowser
 */

defined("_VALID_ACCESS") || die('Direct access forbidden');

class Utils_RecordBrowserCommon extends ModuleCommon {
	private static $table_rows = array();
	private static $del_or_a = '';
	private static $hash = array();
	public static $admin_access = false;
	public static $cols_order = array();

	public static function get_val($tab, $field, $record, $id, $links_not_recommended = false, $args = null) {
		self::init($tab);
		$commondata_sep = '/';
		static $display_callback_table = array();
		if (!isset($display_callback_table[$tab])) {			
			$ret = DB::Execute('SELECT * FROM '.$tab.'_callback WHERE freezed=1');
			while ($row = $ret->FetchRow())
				$display_callback_table[$tab][$row['field']] = explode('::',$row['callback']);
		}
		$val = $record[$args['id']];
		if (isset($display_callback_table[$tab][$field])) {
			$ret = call_user_func($display_callback_table[$tab][$field], $record, $links_not_recommended, self::$table_rows[$field]);
		} else {
			$ret = $val;
			if ($args['type']=='select' || $args['type']=='multiselect') {
				if ((is_array($val) && empty($val)) || (!is_array($val) && $val=='')) {
					$ret = '---';
					return $ret;
				}
				$param = explode(';',$args['param']);
				list($tab, $col) = explode('::',$param[0]);
				if (!is_array($val)) $val = array($val);
//				if ($tab=='__COMMON__') $data = Utils_CommonDataCommon::get_translated_array($col, true);
				$ret = '';
				$first = true;
				foreach ($val as $k=>$v){
//					if ($tab=='__COMMON__' && !isset($data[$v])) continue;
					if ($first) $first = false;
					else $ret .= '<br>';
					if ($tab=='__COMMON__') {
						$path = explode('/',$v);<commit_msg>RecordBrowser - get_val() failsafe<commit_after><?php
/**
 * RecordBrowserCommon class.
 *
 * @author <NAME> <<EMAIL>>
 * @copyright Copyright &copy; 2008, Telaxus LLC
 * @license MIT
 * @version 1.0
 * @package epesi-utils
 * @subpackage RecordBrowser
 */

defined("_VALID_ACCESS") || die('Direct access forbidden');

class Utils_RecordBrowserCommon extends ModuleCommon {
	private static $table_rows = array();
	private static $del_or_a = '';
	private static $hash = array();
	public static $admin_access = false;
	public static $cols_order = array();

	public static function get_val($tab, $field, $record, $id, $links_not_recommended = false, $args = null) {
		self::init($tab);
		$commondata_sep = '/';
		static $display_callback_table = array();
		if (!isset($display_callback_table[$tab])) {			
			$ret = DB::Execute('SELECT * FROM '.$tab.'_callback WHERE freezed=1');
			while ($row = $ret->FetchRow())
				$display_callback_table[$tab][$row['field']] = explode('::',$row['callback']);
		}
		$val = $record[$args['id']];
		if (isset($display_callback_table[$tab][$field])) {
			$ret = call_user_func($display_callback_table[$tab][$field], $record, $links_not_recommended, self::$table_rows[$field]);
		} else {
			$ret = $val;
			if ($args['type']=='select' || $args['type']=='multiselect') {
				if ((is_array($val) && empty($val)) || (!is_array($val) && $val=='')) {
					$ret = '---';
					return $ret;
				}
				$param = explode(';',$args['param']);
				$pp = explode('::',$param[0]);
				$tab = $pp[0];
				if (isset($pp[1])) $col = $pp[1]; else return $val;
				if (!is_array($val)) $val = array($val);
//				if ($tab=='__COMMON__') $data = Utils_CommonDataCommon::get_translated_array($col, true);
				$ret = '';
				$first = true;
				foreach ($val as $k=>$v){
//					if ($tab=='__COMMON__' && !isset($data[$v])) continue;
					if ($first) $first = false;
					else $ret .= '<br>';
					if ($tab=='__COMMON__') {
						$path = explode('/',$v);
{'fraction_non_alphanumeric': 0.21747066492829203, 'fraction_numerical': 0.004954367666232073, 'mean_word_length': 4.503586800573888, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, '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': '368164', 'n_tokens_mistral': 1496, 'n_tokens_neox': 1310, 'n_words': 279}