<commit_before><?php
// (c) Copyright 2002-2011 by authors of the Tiki Wiki CMS Groupware Project
// 
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$

class Tracker_Field_Factory
{
	private $trackerDefinition;
	private $typeMap = array();
	private $infoMap = array();

	function __construct($trackerDefinition)
	{
		$this->trackerDefinition = $trackerDefinition;

		$fieldMap = $this->buildTypeMap(array(
			'lib/core/Tracker/Field' => 'Tracker_Field_',
		));
	}

	private function buildTypeMap($paths)
	{
		global $prefs;
		$cachelib = TikiLib::lib('cache');
		$cacheKey = 'fieldtypes.' . $prefs['language'];

		if ($data = $cachelib->getSerialized($cacheKey)) {
			$this->typeMap = $data['typeMap'];
			$this->infoMap = $data['infoMap'];
			return;
		}

		foreach ($paths as $path => $prefix) {
			foreach (glob("$path/*.php") as $file) {
				$class = $prefix . substr($file, strlen($path) + 1, -4);
				$reflected = new ReflectionClass($class);

				if ($reflected->isInstantiable() && $reflected->implementsInterface('Tracker_Field_Interface')) {
					$providedFields = $class::getTypes();

					foreach ($providedFields as $key => $info) {
						$this->typeMap[$key] = $class;
						$this->infoMap[$key] = $info;
					}
				}
			}
		}

		$cachelib->cacheItem($cacheKey, serialize(array(
			'typeMap' => $this->typeMap,
			'infoMap' => $this->infoMap,
		)));
	}

	public static function build($type, $trackerDefinition, $fieldInfo, $itemData)
	{
		return new self($fieldInfo, $itemData, $trackerDefinition);
	}

	function getFieldTypes()
	{
		return $this->infoMap;
	}

	function getHandler($field_info, $itemData = array())
	{
		$type = $field_info['type'];

		if (isset($this->typeMap[$type])) {
			$class = $this->typeMap[$type];

			return $class::build($type, $this->trackerDefinition, $field_info, $itemData);
		}
	}
}
<commit_msg>[FIX] Calling class method statically through  not supported in PHP 5.2 causes T_PAAMAYIM_NEKUDOTAYIM<commit_after><?php
// (c) Copyright 2002-2011 by authors of the Tiki Wiki CMS Groupware Project
// 
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$

class Tracker_Field_Factory
{
	private $trackerDefinition;
	private $typeMap = array();
	private $infoMap = array();

	function __construct($trackerDefinition)
	{
		$this->trackerDefinition = $trackerDefinition;

		$fieldMap = $this->buildTypeMap(array(
			'lib/core/Tracker/Field' => 'Tracker_Field_',
		));
	}

	private function buildTypeMap($paths)
	{
		global $prefs;
		$cachelib = TikiLib::lib('cache');
		$cacheKey = 'fieldtypes.' . $prefs['language'];

		if ($data = $cachelib->getSerialized($cacheKey)) {
			$this->typeMap = $data['typeMap'];
			$this->infoMap = $data['infoMap'];
			return;
		}

		foreach ($paths as $path => $prefix) {
			foreach (glob("$path/*.php") as $file) {
				$class = $prefix . substr($file, strlen($path) + 1, -4);
				$reflected = new ReflectionClass($class);

				if ($reflected->isInstantiable() && $reflected->implementsInterface('Tracker_Field_Interface')) {
					$providedFields = call_user_func(array($class, 'getTypes'));

					foreach ($providedFields as $key => $info) {
						$this->typeMap[$key] = $class;
						$this->infoMap[$key] = $info;
					}
				}
			}
		}

		$cachelib->cacheItem($cacheKey, serialize(array(
			'typeMap' => $this->typeMap,
			'infoMap' => $this->infoMap,
		)));
	}

	public static function build($type, $trackerDefinition, $fieldInfo, $itemData)
	{
		return new self($fieldInfo, $itemData, $trackerDefinition);
	}

	function getFieldTypes()
	{
		return $this->infoMap;
	}

	function getHandler($field_info, $itemData = array())
	{
		$type = $field_info['type'];

		if (isset($this->typeMap[$type])) {
			$class = $this->typeMap[$type];

			return call_user_func(array($class, 'build'), $type, $this->trackerDefinition, $field_info, $itemData); 
		}
	}
}

{'fraction_non_alphanumeric': 0.16752387950036737, 'fraction_numerical': 0.005388194954690179, 'mean_word_length': 4.202547770700637, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 45, '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': '5544646', 'n_tokens_mistral': 1556, 'n_tokens_neox': 1355, 'n_words': 303}