<commit_before><?php

/**
 * Zim form.
 *
 * @package    openZIM
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class ZimForm extends BaseZimForm
{
  public function configure()
  {
	$form = new StundeCollectionForm(null, array(
	       'zim' => $this->getObject(),
	       'size'    => 1,
	));
	$this->embedRelation('Stunden');
    	$this->embedForm('neueStunden', $form);

    	$choices = array();
	$choices[null] = 'gesperrt';
	foreach( sfGuardUserTable::getInstance()->findAll() as $user ){
		if( ! $user->hasCredential('admin'))
			$choices[$user->getId()] = $user->getUserName();
    	}
	$this->widgetSchema['user_id']  = new sfWidgetFormChoice(array(
                'choices' => $choices,
                'label' => 'Bearbeiter'));
        $this->validatorSchema['user_id'] = new sfValidatorChoice(array(
                'choices' => array_keys($choices),
                'required' => false));

	$date_choices = array();
	foreach( range(sfConfig::get('app_start_date'),sfConfig::get('app_end_date')) as $tmpdate ){
		$date_choices[$tmpdate] = $tmpdate;
	}
	$this->widgetSchema['ptjahr'] = new sfWidgetFormChoice(array(
		'choices'=>$date_choices,
		'default'=>'2010', 
		'label'=>'Jahr'));
	$this->validatorSchema['ptjahr'] = new sfValidatorChoice(array(
		'choices' =>array_keys($date_choices),
		'required' => true));
	$this->widgetSchema->setLabels(array(
		'ptkuerzel'  => 'PT Kürzel',
		'roterFaden' => 'Roter Faden',
		'zielGruppe' => 'Zielgruppe'));
 
  }

  public function saveEmbeddedForms($con = null, $forms = null)
  {
     if (null === $forms)
     {
        $stunden = $this->getValue('neueStunden');
        $forms = $this->embeddedForms;
        foreach ($this->embeddedForms['neueStunden'] as $name => $form)
        {
          if (!isset($stunden[$name]))
          {
            unset($forms['neueStunden'][$name]);
          }
        }
     }<commit_msg>zim/form: set current year to default<commit_after><?php

/**
 * Zim form.
 *
 * @package    openZIM
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class ZimForm extends BaseZimForm
{
  public function configure()
  {
	$form = new StundeCollectionForm(null, array(
	       'zim' => $this->getObject(),
	       'size'    => 1,
	));
	$this->embedRelation('Stunden');
    	$this->embedForm('neueStunden', $form);

    	$choices = array();
	$choices[null] = 'gesperrt';
	foreach( sfGuardUserTable::getInstance()->findAll() as $user ){
		if( ! $user->hasCredential('admin'))
			$choices[$user->getId()] = $user->getUserName();
    	}
	$this->widgetSchema['user_id']  = new sfWidgetFormChoice(array(
                'choices' => $choices,
                'label' => 'Bearbeiter'));
        $this->validatorSchema['user_id'] = new sfValidatorChoice(array(
                'choices' => array_keys($choices),
                'required' => false));

	$date_choices = array();
	foreach( range(sfConfig::get('app_start_date'),sfConfig::get('app_end_date')) as $tmpdate ){
		$date_choices[$tmpdate] = $tmpdate;
	}
	$this->widgetSchema['ptjahr'] = new sfWidgetFormChoice(array(
		'choices'=>$date_choices,
		'default'=>date('Y'), 
		'label'=>'Jahr'));
	$this->validatorSchema['ptjahr'] = new sfValidatorChoice(array(
		'choices' =>array_keys($date_choices),
		'required' => true));
	$this->widgetSchema->setLabels(array(
		'ptkuerzel'  => 'PT Kürzel',
		'roterFaden' => 'Roter Faden',
		'zielGruppe' => 'Zielgruppe'));
 
  }

  public function saveEmbeddedForms($con = null, $forms = null)
  {
     if (null === $forms)
     {
        $stunden = $this->getValue('neueStunden');
        $forms = $this->embeddedForms;
        foreach ($this->embeddedForms['neueStunden'] as $name => $form)
        {
          if (!isset($stunden[$name]))
          {
            unset($forms['neueStunden'][$name]);
          }
        }
     }
{'fraction_non_alphanumeric': 0.183270911360799, 'fraction_numerical': 0.010986267166042446, 'mean_word_length': 3.3121636167922497, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 65, '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': '230002', 'n_tokens_mistral': 1443, 'n_tokens_neox': 1373, 'n_words': 233}