<commit_before><?php

class dmDoctrineFormFilterGenerator extends sfDoctrineFormFilterGenerator
{
	/**
	 * Initializes the current sfGenerator instance.
	 *
	 * @param sfGeneratorManager $generatorManager A sfGeneratorManager instance
	 */
	public function initialize(sfGeneratorManager $generatorManager)
	{
		parent::initialize($generatorManager);

		$this->setGeneratorClass('dmDoctrineFormFilter');
	}

	/**
	 * Generates classes and templates in cache.
	 *
	 * @param array $params The parameters
	 *
	 * @return string The data to put in configuration cache
	 */
	public function generate($params = array())
	{
		// create the project base class for all forms
		$file = sfConfig::get('sf_lib_dir').'/filter/doctrine/BaseFormFilterDoctrine.class.php';
		if (!file_exists($file))
		{
			if (!is_dir($directory = dirname($file)))
			{
				mkdir($directory, 0777, true);
			}

			copy(dmOs::join(sfConfig::get('dm_core_dir'), 'data/skeleton/lib/filter/doctrine/BaseFormFilterDoctrine.class.php'), $file);
		}

		parent::generate($params);
	}

	public function getWidgetOptionsForColumn($column)
	{
		$options = array();

		$withEmpty = sprintf('\'with_empty\' => %s', $column->isNotNull() ? 'false' : 'true');
		switch ($column->getDoctrineType())
		{
			case 'boolean':
				$options[] = "'choices' => array('' => \$this->getI18n()->__('yes or no', array(), 'dm'), 1 => \$this->getI18n()->__('yes', array(), 'dm'), 0 => \$this->getI18n()->__('no', array(), 'dm'))";
				break;
			case 'date':
			case 'datetime':
			case 'timestamp':
				$options[] = "'choices' => array(
        ''      => '',
        'today' => \$this->getI18n()->__('Today'),
        'week'  => \$this->getI18n()->__('Past %number% days', array('%number%' => 7)),
        'month' => \$this->getI18n()->__('This month'),
        'year'  => \$this->getI18n()->__('This year')
      )";
				break;
			case 'enum':
				$values = array('' => '');
				$values = array_merge($values, $column['values']);
				$values = array_combine($values, $values);
				$options[] = "'multiple' => true, 'choices' => " . str_replace("\n", '', $this->arrayExport($values));
				break;
		}

		if ($column->isForeignKey() || $column instanceof Doctrine_Relation_LocalKey)<commit_msg>Fix: Enum fields in filterForms must not have multiple selection.<commit_after><?php

class dmDoctrineFormFilterGenerator extends sfDoctrineFormFilterGenerator
{
	/**
	 * Initializes the current sfGenerator instance.
	 *
	 * @param sfGeneratorManager $generatorManager A sfGeneratorManager instance
	 */
	public function initialize(sfGeneratorManager $generatorManager)
	{
		parent::initialize($generatorManager);

		$this->setGeneratorClass('dmDoctrineFormFilter');
	}

	/**
	 * Generates classes and templates in cache.
	 *
	 * @param array $params The parameters
	 *
	 * @return string The data to put in configuration cache
	 */
	public function generate($params = array())
	{
		// create the project base class for all forms
		$file = sfConfig::get('sf_lib_dir').'/filter/doctrine/BaseFormFilterDoctrine.class.php';
		if (!file_exists($file))
		{
			if (!is_dir($directory = dirname($file)))
			{
				mkdir($directory, 0777, true);
			}

			copy(dmOs::join(sfConfig::get('dm_core_dir'), 'data/skeleton/lib/filter/doctrine/BaseFormFilterDoctrine.class.php'), $file);
		}

		parent::generate($params);
	}

	public function getWidgetOptionsForColumn($column)
	{
		$options = array();

		$withEmpty = sprintf('\'with_empty\' => %s', $column->isNotNull() ? 'false' : 'true');
		switch ($column->getDoctrineType())
		{
			case 'boolean':
				$options[] = "'choices' => array('' => \$this->getI18n()->__('yes or no', array(), 'dm'), 1 => \$this->getI18n()->__('yes', array(), 'dm'), 0 => \$this->getI18n()->__('no', array(), 'dm'))";
				break;
			case 'date':
			case 'datetime':
			case 'timestamp':
				$options[] = "'choices' => array(
        ''      => '',
        'today' => \$this->getI18n()->__('Today'),
        'week'  => \$this->getI18n()->__('Past %number% days', array('%number%' => 7)),
        'month' => \$this->getI18n()->__('This month'),
        'year'  => \$this->getI18n()->__('This year')
      )";
				break;
			case 'enum':
				$values = array('' => '');
				$values = array_merge($values, $column['values']);
				$values = array_combine($values, $values);
				$options[] = "'choices' => " . str_replace("\n", '', $this->arrayExport($values));
				break;
		}

		if ($column->isForeignKey() || $column instanceof Doctrine_Relation_LocalKey)
{'fraction_non_alphanumeric': 0.19701691896705253, 'fraction_numerical': 0.009349955476402494, 'mean_word_length': 4.02572706935123, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 70, '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': '6272243', 'n_tokens_mistral': 1614, 'n_tokens_neox': 1408, 'n_words': 298}