<commit_before><?php

class sfDatagridFormatterPropel extends sfDatagridFormatterDefault{
	/**
	 * Get the input for the filter
	 *
	 * @param string $type The type of the filter
	 * @param string $column The column name
	 * @param string $value The value of the input
	 * @param sfDatagrid $object The datagrid object
	 * @param string $suffix The url suffix
	 * @return string The html output
	 */
	protected function getInputFilter($type, $column, $value, $object, $suffix)
	{
		
		$output = '';
		try
        			{
        			/*
					 * @todo il faudra penser a déplacer ce morceau de code afin de prendre en entrer $mapBuilder pour le
					 * calculer qu'une fois
					 */
    				$tablePeer=$object->_get('peerTable').'Peer';
		    		$builder=$object->_get('peerTable').'MapBuilder';
		    		if(sfAutoload::getInstance()->loadClass($builder)){
		    		$mapBuilder=new $builder;
		    		$mapBuilder->doBuild();
		    		$adminrelated = $mapBuilder->getDatabaseMap()->getTable(sfInflector::underscore($object->_get('peerTable')))->getColumn(strtoupper($column));
        			
		    		}else{
		    			 $map=$object->_get('peerTable').'TableMap';
						 $map=new $map($object->_get('peerTable'),new DatabaseMap('propel'));
						 $map->initialize();
						 $adminrelated = $map->getColumn(strtoupper($column));
		    		}
		    		
		    		
		    		
        			}catch(Exception $e)
			        {
			            $adminrelated = '';
			        }
			       
    		switch($type)
    		{
    			
    			
    			case 'FOREIGN':
    				 
			         if(($adminrelated instanceof ColumnMap)&&($adminrelated->isForeignKey()))
       				 {
    					$c=sfDatagrid::getConfig('class_for_foreign');
    					if(sfAutoload::getInstance()->loadClass(sfInflector::camelize($adminrelated->getRelatedTableName()))){
    						$class=sfInflector::camelize($adminrelated->getRelatedTableName());
    					}else{
    						$class=sfInflector::camelize($adminrelated->getRelatedTableName());
    						$class=strtolower($class[0]).substr($class,1);
    						
    					}
    					
    					if(sfAutoload::getInstance()->loadClass($class)){
							$wSelect= new $c(
							array('model' => $class,  'add_empty' =>true)); 
							if($object->getOrderByForFilter($column)){
								$wSelect->setOption( 'order_by',$object->getOrderByForFilter($column));
							}
							$output = $wSelect->render('search[' . $column . ']', $value, array('style' => 'width: 100%;'));
    					} 
    				}
					break;
    			case is_array($type):
    				$choices[''] = '';
    				
    				foreach($type as $key => $values)
    				{
    					$choices[$key] = $values;
    				}
    				
    				$wSelect = new sfWidgetFormSelect(array('choices' => $choices));<commit_msg>[sfDatagridPlugin] Update formatter propel for non automatic phpName FK tables<commit_after><?php

class sfDatagridFormatterPropel extends sfDatagridFormatterDefault{
	/**
	 * Get the input for the filter
	 *
	 * @param string $type The type of the filter
	 * @param string $column The column name
	 * @param string $value The value of the input
	 * @param sfDatagrid $object The datagrid object
	 * @param string $suffix The url suffix
	 * @return string The html output
	 */
	protected function getInputFilter($type, $column, $value, $object, $suffix)
	{
		
		$output = '';
		try
        			{
        			/*
					 * @todo il faudra penser a déplacer ce morceau de code afin de prendre en entrer $mapBuilder pour le
					 * calculer qu'une fois
					 */
    				$tablePeer=$object->_get('peerTable').'Peer';
		    		$builder=$object->_get('peerTable').'MapBuilder';
		    		if(sfAutoload::getInstance()->loadClass($builder)){
			    		$mapBuilder=new $builder;
			    		$mapBuilder->doBuild();
			    		$adminrelated = $mapBuilder->getDatabaseMap()
			    		            ->getTable(sfInflector::underscore($object->_get('peerTable')))
			    		            ->getColumn(strtoupper($column));
        			
		    		}else{
		    			 $map=$object->_get('peerTable').'TableMap';
						 $map=new $map($object->_get('peerTable'),new DatabaseMap('propel'));
						 $map->initialize();
						 $adminrelated = $map->getColumn(strtoupper($column));
						
		    		}
		    		
		    		
		    		
        			}catch(Exception $e)
			        {
			            $adminrelated = '';
			        }
			       
    		switch($type)
    		{
    			
    			
    			case 'FOREIGN':
			         if(($adminrelated instanceof ColumnMap)&&($adminrelated->isForeignKey()))
       				 {
    					$c=sfDatagrid::getConfig('class_for_foreign');
    					if(sfAutoload::getInstance()->loadClass(sfInflector::camelize($adminrelated->getRelatedTableName()))){
    						$class=sfInflector::camelize($adminrelated->getRelatedTableName());
    					}else{
    						$class=sfInflector::camelize($adminrelated->getRelation()->getForeignTable()->getPhpName());
    						$class=strtolower($class[0]).substr($class,1);
    						
    					}
    					
    					if(sfAutoload::getInstance()->loadClass($class)){
							$wSelect= new $c(
							array('model' => $class,  'add_empty' =>true)); 
							if($object->getOrderByForFilter($column)){
								$wSelect->setOption( 'order_by',$object->getOrderByForFilter($column));
							}
							$output = $wSelect->render('search[' . $column . ']', $value, array('style' => 'width: 100%;'));
    					} 
    				}
					break;
    			case is_array($type):
    				$choices[''] = '';
    				
    				foreach($type as $key => $values)
    				{
    					$choices[$key] = $values;
    				}
    				
    				$wSelect = new sfWidgetFormSelect(array('choices' => $choices));
{'fraction_non_alphanumeric': 0.15128755364806867, 'fraction_numerical': 0.00178826895565093, 'mean_word_length': 2.4270833333333335, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 59, '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': '3733598', 'n_tokens_mistral': 2196, 'n_tokens_neox': 1751, 'n_words': 296}