public function configure()
 {
     $this->useFields(array('is_physical', 'family_name', 'activity_date_to', 'activity_date_from'));
     $this->addPagerItems();
     $this->widgetSchema['family_name'] = new sfWidgetFormInput();
     $this->widgetSchema['is_physical'] = new sfWidgetFormInputHidden();
     $this->setDefault('is_physical', true);
     $yearsKeyVal = range(intval(sfConfig::get('dw_yearRangeMin')), intval(sfConfig::get('dw_yearRangeMax')));
     $minDate = new FuzzyDateTime(strval(min($yearsKeyVal) . '/01/01'));
     $maxDate = new FuzzyDateTime(strval(max($yearsKeyVal) . '/12/31'));
     $dateLowerBound = new FuzzyDateTime(sfConfig::get('dw_dateLowerBound'));
     $dateUpperBound = new FuzzyDateTime(sfConfig::get('dw_dateUpperBound'));
     $maxDate->setStart(false);
     $this->widgetSchema['activity_date_from'] = new widgetFormJQueryFuzzyDate($this->getDateItemOptions(), array('class' => 'from_date'));
     $this->widgetSchema['activity_date_to'] = new widgetFormJQueryFuzzyDate($this->getDateItemOptions(), array('class' => 'to_date'));
     $this->validatorSchema['activity_date_from'] = new fuzzyDateValidator(array('required' => false, 'from_date' => true, 'min' => $minDate, 'max' => $maxDate, 'empty_value' => $dateLowerBound), array('invalid' => 'Date provided is not valid'));
     $this->validatorSchema['activity_date_to'] = new fuzzyDateValidator(array('required' => false, 'from_date' => false, 'min' => $minDate, 'max' => $maxDate, 'empty_value' => $dateUpperBound), array('invalid' => 'Date provided is not valid'));
     $people_types = array('' => '');
     $types = People::getTypes();
     foreach ($types as $flag => $name) {
         $people_types[strval($flag)] = $name;
     }
     $this->widgetSchema['people_type'] = new sfWidgetFormChoice(array('choices' => $people_types));
     $this->widgetSchema['people_type']->setLabel('Role');
     $this->validatorSchema['people_type'] = new sfValidatorChoice(array('required' => false, 'choices' => array_keys($people_types)));
     $this->validatorSchema->setPostValidator(new sfValidatorSchemaCompare('activity_date_from', '<=', 'activity_date_to', array('throw_global_error' => true), array('invalid' => 'The to date cannot be above the "end" date.')));
 }
 public function configure()
 {
     $this->useFields(array('code', 'gtu_from_date', 'gtu_to_date'));
     $this->addPagerItems();
     $minDate = new FuzzyDateTime(strval(min(range(intval(sfConfig::get('dw_yearRangeMin')), intval(sfConfig::get('dw_yearRangeMax')))) . '/01/01'));
     $maxDate = new FuzzyDateTime(strval(max(range(intval(sfConfig::get('dw_yearRangeMin')), intval(sfConfig::get('dw_yearRangeMax')))) . '/12/31'));
     $maxDate->setStart(false);
     $dateLowerBound = new FuzzyDateTime(sfConfig::get('dw_dateLowerBound'));
     $dateUpperBound = new FuzzyDateTime(sfConfig::get('dw_dateUpperBound'));
     $this->widgetSchema['code'] = new sfWidgetFormInputText();
     $this->widgetSchema['tags'] = new sfWidgetFormInputText();
     $this->widgetSchema['gtu_from_date'] = new widgetFormJQueryFuzzyDate($this->getDateItemOptions(), array('class' => 'from_date'));
     $this->widgetSchema['gtu_to_date'] = new widgetFormJQueryFuzzyDate($this->getDateItemOptions(), array('class' => 'to_date'));
     $this->widgetSchema->setLabels(array('gtu_from_date' => 'Between', 'gtu_to_date' => 'and'));
     $this->validatorSchema['tags'] = new sfValidatorString(array('required' => false, 'trim' => true));
     $this->validatorSchema['code'] = new sfValidatorString(array('required' => false, 'trim' => true));
     $this->validatorSchema['gtu_from_date'] = new fuzzyDateValidator(array('required' => false, 'from_date' => true, 'min' => $minDate, 'max' => $maxDate, 'empty_value' => $dateLowerBound), array('invalid' => 'Date provided is not valid'));
     $this->validatorSchema['gtu_to_date'] = new fuzzyDateValidator(array('required' => false, 'from_date' => false, 'min' => $minDate, 'max' => $maxDate, 'empty_value' => $dateUpperBound), array('invalid' => 'Date provided is not valid'));
     $this->widgetSchema['lat_from'] = new sfWidgetForminput();
     $this->widgetSchema['lat_from']->setLabel('Latitude');
     $this->widgetSchema['lat_to'] = new sfWidgetForminput();
     $this->widgetSchema['lon_from'] = new sfWidgetForminput();
     $this->widgetSchema['lon_from']->setLabel('Longitude');
     $this->widgetSchema['lon_to'] = new sfWidgetForminput();
     $this->validatorSchema['lat_from'] = new sfValidatorNumber(array('required' => false, 'min' => '-90', 'max' => '90'));
     $this->validatorSchema['lon_from'] = new sfValidatorNumber(array('required' => false, 'min' => '-180', 'max' => '180'));
     $this->validatorSchema['lat_to'] = new sfValidatorNumber(array('required' => false, 'min' => '-90', 'max' => '90'));
     $this->validatorSchema['lon_to'] = new sfValidatorNumber(array('required' => false, 'min' => '-180', 'max' => '180'));
     $this->validatorSchema->setPostValidator(new sfValidatorSchemaCompare('gtu_from_date', '<=', 'gtu_to_date', array('throw_global_error' => true), array('invalid' => 'The "begin" date cannot be above the "end" date.')));
     $subForm = new sfForm();
     $this->embedForm('Tags', $subForm);
 }
 public function configure()
 {
     $this->useFields(array('insurance_currency', 'insurer_ref', 'contact_ref', 'insurance_value', 'date_from', 'date_to'));
     $this->validatorSchema['id'] = new sfValidatorInteger(array('required' => false));
     $this->widgetSchema['insurance_currency'] = new widgetFormSelectComplete(array('model' => 'Insurances', 'table_method' => 'getDistinctCurrencies', 'method' => 'getCurrencies', 'key_method' => 'getCurrencies', 'add_empty' => false, 'change_label' => '', 'add_label' => ''));
     $this->widgetSchema['insurer_ref'] = new widgetFormCompleteButtonRef(array('model' => 'People', 'link_url' => 'institution/choose', 'method' => 'getFormatedName', 'box_title' => $this->getI18N()->__('Choose Insurer'), 'nullable' => true, 'button_class' => 'add_insurance_insurer_ref', 'complete_url' => 'catalogue/completeName?table=institutions'), array('class' => 'inline'));
     $this->widgetSchema['contact_ref'] = new widgetFormCompleteButtonRef(array('model' => 'People', 'link_url' => 'people/choose', 'method' => 'getFormatedName', 'box_title' => $this->getI18N()->__('Choose contact'), 'nullable' => true, 'button_class' => 'add_insurance_contact_ref', 'complete_url' => 'catalogue/completeName?table=people'), array('class' => 'inline'));
     $this->widgetSchema->setLabels(array('insurance_value' => 'Value', 'insurance_currency' => 'Currency', 'insurer_ref' => 'Insurer:', 'contact_ref' => 'Contact'));
     $this->widgetSchema['insurance_currency']->setAttributes(array('class' => 'vsmall_size'));
     $yearsKeyVal = range(intval(sfConfig::get('dw_yearRangeMin')), intval(sfConfig::get('dw_yearRangeMax')));
     $years = array_combine($yearsKeyVal, $yearsKeyVal);
     $minDate = new FuzzyDateTime(strval(min($yearsKeyVal)) . '/1/1 0:0:0');
     $maxDate = new FuzzyDateTime(strval(max($yearsKeyVal)) . '/12/31 23:59:59');
     $dateLowerBound = new FuzzyDateTime(sfConfig::get('dw_dateLowerBound'));
     $dateUpperBound = new FuzzyDateTime(sfConfig::get('dw_dateUpperBound'));
     $maxDate->setStart(false);
     $this->widgetSchema['date_from'] = new widgetFormJQueryFuzzyDate(array('culture' => $this->getCurrentCulture(), 'image' => '/images/calendar.gif', 'format' => '%day%/%month%/%year%', 'years' => $years, 'with_time' => false), array('class' => 'from_date'));
     $this->widgetSchema['date_to'] = new widgetFormJQueryFuzzyDate(array('culture' => $this->getCurrentCulture(), 'image' => '/images/calendar.gif', 'format' => '%day%/%month%/%year%', 'years' => $years, 'with_time' => false), array('class' => 'to_date'));
     $this->validatorSchema['date_from'] = new fuzzyDateValidator(array('required' => false, 'from_date' => true, 'min' => $minDate, 'max' => $maxDate, 'empty_value' => $dateLowerBound, 'with_time' => true), array('invalid' => 'Invalid date "from"'));
     $this->validatorSchema['date_to'] = new fuzzyDateValidator(array('required' => false, 'from_date' => false, 'min' => $minDate, 'max' => $maxDate, 'empty_value' => $dateUpperBound, 'with_time' => true), array('invalid' => 'Invalid date "to"'));
     $this->validatorSchema->setPostValidator(new sfValidatorSchemaCompare('date_from', '<=', 'date_to', array('throw_global_error' => true), array('invalid' => 'The "from" date cannot be above the "to" date.')));
     $this->validatorSchema['insurance_currency']->setOption('required', false);
     $this->validatorSchema['insurance_value'] = new sfValidatorNumber(array('required' => false));
     /*Insurances post-validation to empty null values*/
     $this->mergePostValidator(new InsurancesValidatorSchema());
 }
 public function configure()
 {
     $this->addPagerItems();
     $minDate = new FuzzyDateTime(strval(min(range(intval(sfConfig::get('dw_yearRangeMin')), intval(sfConfig::get('dw_yearRangeMax')))) . '/01/01'));
     $maxDate = new FuzzyDateTime(strval(max(range(intval(sfConfig::get('dw_yearRangeMin')), intval(sfConfig::get('dw_yearRangeMax')))) . '/12/31'));
     $maxDate->setStart(false);
     $dateLowerBound = new FuzzyDateTime(sfConfig::get('dw_dateLowerBound'));
     $dateUpperBound = new FuzzyDateTime(sfConfig::get('dw_dateUpperBound'));
     $this->widgetSchema['status'] = new sfWidgetFormChoice(array('choices' => Doctrine::getTable('LoanStatus')->getDistinctStatus()));
     $this->validatorSchema['status'] = new sfValidatorString(array('required' => false));
     $this->widgetSchema['from_date'] = new widgetFormJQueryFuzzyDate($this->getDateItemOptions(), array('class' => 'from_date'));
     $this->widgetSchema['to_date'] = new widgetFormJQueryFuzzyDate($this->getDateItemOptions(), array('class' => 'to_date'));
     $this->widgetSchema['name'] = new sfWidgetFormInput(array());
     $this->validatorSchema['name'] = new sfValidatorString(array('required' => false, 'trim' => true));
     $this->validatorSchema['from_date'] = new fuzzyDateValidator(array('required' => false, 'from_date' => true, 'min' => $minDate, 'max' => $maxDate, 'empty_value' => $dateLowerBound), array('invalid' => 'Date provided is not valid'));
     $this->validatorSchema['to_date'] = new fuzzyDateValidator(array('required' => false, 'from_date' => false, 'min' => $minDate, 'max' => $maxDate, 'empty_value' => $dateUpperBound), array('invalid' => 'Date provided is not valid'));
     $this->validatorSchema->setPostValidator(new sfValidatorSchemaCompare('from_date', '<=', 'to_date', array('throw_global_error' => true), array('invalid' => 'The "begin" date cannot be above the "end" date.')));
     $this->widgetSchema['only_darwin'] = new sfWidgetFormInputCheckbox();
     $this->validatorSchema['only_darwin'] = new sfValidatorBoolean();
     $this->widgetSchema['people_ref'] = new widgetFormButtonRef(array('model' => 'People', 'link_url' => 'people/searchBoth', 'box_title' => $this->getI18N()->__('Choose people'), 'nullable' => true, 'button_class' => ''), array('class' => 'inline'));
     $this->validatorSchema['people_ref'] = new sfValidatorInteger(array('required' => false));
     $this->widgetSchema['ig_ref'] = new widgetFormInputChecked(array('model' => 'Igs', 'method' => 'getIgNum', 'nullable' => true, 'link_url' => 'igs/searchFor', 'notExistingAddDisplay' => false));
     $this->validatorSchema['ig_ref'] = new sfValidatorInteger(array('required' => false));
     $this->widgetSchema->setLabels(array('from_date' => 'Between', 'to_date' => 'and', 'only_darwin' => 'Contains Darwin items', 'people_ref' => 'Person involved'));
     $this->widgetSchema['table'] = new sfWidgetFormInputHidden();
     $this->widgetSchema['level'] = new sfWidgetFormInputHidden();
     $this->widgetSchema['caller_id'] = new sfWidgetFormInputHidden();
     $this->validatorSchema['table'] = new sfValidatorString(array('required' => false));
     $this->validatorSchema['level'] = new sfValidatorString(array('required' => false));
     $this->validatorSchema['caller_id'] = new sfValidatorString(array('required' => false));
 }
Esempio n. 5
0
 public function configure()
 {
     $this->useFields(array('code', 'gtu_from_date', 'gtu_to_date', 'latitude', 'longitude', 'lat_long_accuracy', 'elevation', 'elevation_accuracy'));
     $this->widgetSchema['code'] = new sfWidgetFormInput();
     $yearsKeyVal = range(intval(sfConfig::get('dw_yearRangeMin')), intval(sfConfig::get('dw_yearRangeMax')));
     $years = array_combine($yearsKeyVal, $yearsKeyVal);
     $dateText = array('year' => 'yyyy', 'month' => 'mm', 'day' => 'dd');
     $minDate = new FuzzyDateTime(strval(min($yearsKeyVal) . '/01/01'));
     $maxDate = new FuzzyDateTime(strval(max($yearsKeyVal) . '/12/31'));
     $dateLowerBound = new FuzzyDateTime(sfConfig::get('dw_dateLowerBound'));
     $dateUpperBound = new FuzzyDateTime(sfConfig::get('dw_dateUpperBound'));
     $maxDate->setStart(false);
     $this->widgetSchema['name'] = new sfWidgetFormInputText();
     $this->widgetSchema['gtu_from_date'] = new widgetFormJQueryFuzzyDate(array('culture' => $this->getCurrentCulture(), 'image' => '/images/calendar.gif', 'format' => '%day%/%month%/%year%', 'years' => $years, 'empty_values' => $dateText, 'with_time' => true), array('class' => 'from_date'));
     $this->widgetSchema['gtu_to_date'] = new widgetFormJQueryFuzzyDate(array('culture' => $this->getCurrentCulture(), 'image' => '/images/calendar.gif', 'format' => '%day%/%month%/%year%', 'years' => $years, 'empty_values' => $dateText, 'with_time' => true), array('class' => 'to_date'));
     $this->validatorSchema['gtu_from_date'] = new fuzzyDateValidator(array('required' => false, 'from_date' => true, 'min' => $minDate, 'max' => $maxDate, 'empty_value' => $dateLowerBound, 'with_time' => true), array('invalid' => 'Date provided is not valid'));
     $this->validatorSchema['gtu_to_date'] = new fuzzyDateValidator(array('required' => false, 'from_date' => false, 'min' => $minDate, 'max' => $maxDate, 'empty_value' => $dateUpperBound, 'with_time' => true), array('invalid' => 'Date provided is not valid'));
     $this->widgetSchema['lat_long_accuracy']->setLabel('Accuracy');
     $this->widgetSchema['elevation_accuracy']->setLabel('Accuracy');
     $this->validatorSchema['latitude'] = new sfValidatorNumber(array('required' => false, 'trim' => true, 'min' => '-90', 'max' => '90'));
     $this->validatorSchema['longitude'] = new sfValidatorNumber(array('required' => false, 'trim' => true, 'min' => '-180', 'max' => '180'));
     $this->validatorSchema['lat_long_accuracy'] = new sfValidatorNumber(array('required' => false, 'trim' => true, 'min' => '0.0000001'));
     $this->validatorSchema['elevation_accuracy'] = new sfValidatorNumber(array('required' => false, 'trim' => true, 'min' => '0.0000001'));
     $this->validatorSchema->setPostValidator(new sfValidatorAnd(array(new sfValidatorSchemaCompare('gtu_from_date', '<=', 'gtu_to_date', array('throw_global_error' => true), array('invalid' => 'The "begin" date cannot be above the "end" date.')), new sfValidatorCallback(array('callback' => array($this, 'checkLatLong'))), new sfValidatorCallback(array('callback' => array($this, 'checkElevation'))))));
     $subForm = new sfForm();
     $this->embedForm('newVal', $subForm);
     $this->embedRelation('TagGroups');
 }
 public function configure()
 {
     $yearsKeyVal = range(intval(sfConfig::get('dw_yearRangeMin')), intval(sfConfig::get('dw_yearRangeMax')));
     $years = array_combine($yearsKeyVal, $yearsKeyVal);
     $dateText = array('year' => 'yyyy', 'month' => 'mm', 'day' => 'dd');
     $minDate = new FuzzyDateTime(strval(min($yearsKeyVal) . '/01/01'));
     $maxDate = new FuzzyDateTime(strval(max($yearsKeyVal) . '/12/31'));
     $dateLowerBound = new FuzzyDateTime(sfConfig::get('dw_dateLowerBound'));
     $maxDate->setStart(false);
     $this->widgetSchema['acquisition_date'] = new widgetFormJQueryFuzzyDate(array('culture' => 'en', 'image' => '/images/calendar.gif', 'format' => '%day%/%month%/%year%', 'years' => $years, 'empty_values' => $dateText), array('class' => 'to_date'));
     $this->validatorSchema['acquisition_date'] = new fuzzyDateValidator(array('required' => false, 'from_date' => true, 'min' => $minDate, 'max' => $maxDate, 'empty_value' => $dateLowerBound), array('invalid' => 'Date provided is not valid'));
 }
Esempio n. 7
0
 /**
  * Configure the form with its widgets and validators
  */
 public function configure()
 {
     unset($this['ig_date_mask'], $this['ig_num_indexed']);
     $yearsKeyVal = range(intval(sfConfig::get('dw_yearRangeMin')), intval(sfConfig::get('dw_yearRangeMax')));
     $years = array_combine($yearsKeyVal, $yearsKeyVal);
     $dateText = array('year' => 'yyyy', 'month' => 'mm', 'day' => 'dd');
     $minDate = new FuzzyDateTime(strval(min($yearsKeyVal) . '/01/01'));
     $maxDate = new FuzzyDateTime(strval(max($yearsKeyVal) . '/12/31'));
     $dateLowerBound = new FuzzyDateTime(sfConfig::get('dw_dateLowerBound'));
     $maxDate->setStart(false);
     $this->widgetSchema['ig_num'] = new sfWidgetFormInputText();
     $this->widgetSchema['ig_date'] = new widgetFormJQueryFuzzyDate(array('culture' => $this->getCurrentCulture(), 'image' => '/images/calendar.gif', 'format' => '%day%/%month%/%year%', 'years' => $years, 'empty_values' => $dateText), array('class' => 'to_date'));
     $this->widgetSchema['ig_num']->setAttributes(array('class' => 'small_size'));
     $this->validatorSchema['ig_num'] = new sfValidatorString(array('required' => true, 'trim' => true));
     $this->validatorSchema['ig_date'] = new fuzzyDateValidator(array('required' => false, 'from_date' => true, 'min' => $minDate, 'max' => $maxDate, 'empty_value' => $dateLowerBound), array('invalid' => 'Date provided is not valid'));
 }
 protected function initiateActivityItems()
 {
     $yearsKeyVal = range(intval(sfConfig::get('dw_yearRangeMin')), intval(sfConfig::get('dw_yearRangeMax')));
     $years = array_combine($yearsKeyVal, $yearsKeyVal);
     $dateText = array('year' => 'yyyy', 'month' => 'mm', 'day' => 'dd');
     $minDate = new FuzzyDateTime(strval(min($yearsKeyVal) . '/01/01'));
     $maxDate = new FuzzyDateTime(strval(max($yearsKeyVal) . '/12/31'));
     $dateLowerBound = new FuzzyDateTime(sfConfig::get('dw_dateLowerBound'));
     $dateUpperBound = new FuzzyDateTime(sfConfig::get('dw_dateUpperBound'));
     $maxDate->setStart(false);
     $this->widgetSchema['activity_date_from'] = new widgetFormJQueryFuzzyDate(array('culture' => $this->getCurrentCulture(), 'image' => '/images/calendar.gif', 'format' => '%day%/%month%/%year%', 'years' => $years, 'empty_values' => $dateText), array('class' => 'from_date'));
     $this->widgetSchema['activity_date_to'] = new widgetFormJQueryFuzzyDate(array('culture' => $this->getCurrentCulture(), 'image' => '/images/calendar.gif', 'format' => '%day%/%month%/%year%', 'years' => $years, 'empty_values' => $dateText), array('class' => 'to_date'));
     $this->validatorSchema['activity_date_from'] = new fuzzyDateValidator(array('required' => false, 'from_date' => true, 'min' => $minDate, 'max' => $maxDate, 'empty_value' => $dateLowerBound), array('invalid' => 'Date provided is not valid'));
     $this->validatorSchema['activity_date_to'] = new fuzzyDateValidator(array('required' => false, 'from_date' => false, 'min' => $minDate, 'max' => $maxDate, 'empty_value' => $dateUpperBound), array('invalid' => 'Date provided is not valid'));
     $this->Postvalidators[] = new sfValidatorSchemaCompare('birth_date', '<=', 'end_date', array('throw_global_error' => true), array('invalid' => 'The begin activity date cannot be above the end activity date.'));
 }
Esempio n. 9
0
 public function configure()
 {
     if ($this->options['mode'] == 'new') {
         $this->useFields(array('is_physical', 'sub_type', 'title', 'family_name', 'given_name', 'additional_names', 'gender'));
         $this->widgetSchema['sub_type'] = new widgetFormSelectComplete(array('model' => 'Users', 'table_method' => 'getDistinctSubType', 'method' => 'getSubType', 'key_method' => 'getSubType', 'add_empty' => true, 'change_label' => 'Pick a sub type in the list', 'add_label' => 'Add another sub type'));
         $this->widgetSchema['title'] = new widgetFormSelectComplete(array('model' => 'Users', 'table_method' => 'getDistinctTitle', 'method' => 'getTitle', 'key_method' => 'getTitle', 'add_empty' => true, 'change_label' => 'Pick a title in the list', 'add_label' => 'Add another title'));
         $this->widgetSchema['is_physical'] = new sfWidgetFormInputCheckbox(array('default' => 'true'));
         $this->widgetSchema['gender'] = new sfWidgetFormChoice(array('choices' => array('M' => 'M', 'F' => 'F')));
         $this->validatorSchema['gender'] = new sfValidatorChoice(array('choices' => array('M' => 'M', 'F' => 'F'), 'required' => false));
         $this->widgetSchema['title']->setAttributes(array('class' => 'small_size'));
         $this->validatorSchema['title'] = new sfValidatorString(array('required' => false));
         $this->validatorSchema['sub_type'] = new sfValidatorString(array('required' => false));
     } elseif ($this->options['is_physical']) {
         $this->useFields(array('title', 'family_name', 'given_name', 'additional_names', 'gender', 'people_id'));
         $this->widgetSchema['people_id'] = new widgetFormButtonRef(array('model' => 'People', 'method' => 'getFormatedName', 'link_url' => 'people/choose?with_js=1', 'nullable' => true, 'box_title' => $this->getI18N()->__('Choose Yourself')));
         $this->widgetSchema['title'] = new widgetFormSelectComplete(array('model' => 'Users', 'table_method' => 'getDistinctTitle', 'method' => 'getTitle', 'key_method' => 'getTitle', 'add_empty' => true, 'change_label' => 'Pick a title in the list', 'add_label' => 'Add another title'));
         $this->widgetSchema['title']->setAttributes(array('class' => 'small_size'));
         $this->validatorSchema['title'] = new sfValidatorString(array('required' => false));
         $this->validatorSchema['people_id'] = new sfValidatorInteger(array('required' => false));
     } else {
         $this->useFields(array('sub_type', 'family_name', 'given_name', 'additional_names', 'people_id'));
         $this->widgetSchema['sub_type'] = new widgetFormSelectComplete(array('model' => 'Users', 'table_method' => 'getDistinctSubType', 'method' => 'getSubType', 'key_method' => 'getSubType', 'add_empty' => true, 'change_label' => 'Pick a sub type in the list', 'add_label' => 'Add another sub type'));
         $this->widgetSchema['people_id'] = new widgetFormButtonRef(array('model' => 'People', 'method' => 'getFormatedName', 'link_url' => 'institution/choose', 'nullable' => true, 'box_title' => $this->getI18N()->__('Choose Yourself')));
         $this->validatorSchema['sub_type'] = new sfValidatorString(array('required' => false));
         $this->validatorSchema['people_id'] = new sfValidatorInteger(array('required' => false));
     }
     $this->widgetSchema->setHelp('people_id', 'With this field, you can associate this user to a people recorded in the database (because user and people are not the same in DaRWIN2), the real interest is it will improve the synchronisation between the two record associated');
     $langs = array('en' => 'English', 'nl' => 'Nederlands', 'fr' => 'Français');
     $this->widgetSchema['selected_lang'] = new sfWidgetFormChoice(array('choices' => $langs, 'expanded' => true));
     $this->validatorSchema['selected_lang'] = new sfValidatorChoice(array('choices' => array_keys($langs)));
     $this->widgetSchema['selected_lang']->setLabel('Application Language');
     $this->widgetSchema['given_name'] = new sfWidgetFormInput();
     $this->widgetSchema['given_name']->setAttributes(array('class' => 'medium_size'));
     $this->widgetSchema['family_name'] = new sfWidgetFormInput();
     $this->widgetSchema['family_name']->setAttributes(array('class' => 'medium_size'));
     $this->widgetSchema['additional_names'] = new sfWidgetFormInput();
     $this->widgetSchema['additional_names']->setAttributes(array('class' => 'medium_size'));
     $yearsKeyVal = range(intval(sfConfig::get('dw_yearRangeMin')), intval(sfConfig::get('dw_yearRangeMax')));
     $years = array_combine($yearsKeyVal, $yearsKeyVal);
     $dateText = array('year' => 'yyyy', 'month' => 'mm', 'day' => 'dd');
     $minDate = new FuzzyDateTime(strval(min($yearsKeyVal) . '/01/01'));
     $maxDate = new FuzzyDateTime(date('Y') . '/12/31');
     $dateLowerBound = new FuzzyDateTime(sfConfig::get('dw_dateLowerBound'));
     $maxDate->setStart(false);
     $this->widgetSchema['birth_date'] = new widgetFormJQueryFuzzyDate(array('culture' => $this->getCurrentCulture(), 'image' => '/images/calendar.gif', 'format' => '%day%/%month%/%year%', 'years' => $years, 'empty_values' => $dateText), array('class' => 'from_date'));
     $this->validatorSchema['birth_date'] = new fuzzyDateValidator(array('required' => false, 'from_date' => true, 'min' => $minDate, 'max' => $maxDate, 'empty_value' => $dateLowerBound), array('invalid' => 'Date provided is not valid'));
 }
 public function configure()
 {
     $this->useFields(array('name', 'expedition_from_date', 'expedition_to_date'));
     $this->addPagerItems();
     $minDate = new FuzzyDateTime(strval(min(range(intval(sfConfig::get('dw_yearRangeMin')), intval(sfConfig::get('dw_yearRangeMax')))) . '/01/01'));
     $maxDate = new FuzzyDateTime(strval(max(range(intval(sfConfig::get('dw_yearRangeMin')), intval(sfConfig::get('dw_yearRangeMax')))) . '/12/31'));
     $maxDate->setStart(false);
     $dateLowerBound = new FuzzyDateTime(sfConfig::get('dw_dateLowerBound'));
     $dateUpperBound = new FuzzyDateTime(sfConfig::get('dw_dateUpperBound'));
     $this->widgetSchema['name'] = new sfWidgetFormInputText();
     $this->widgetSchema['expedition_from_date'] = new widgetFormJQueryFuzzyDate($this->getDateItemOptions(), array('class' => 'from_date'));
     $this->widgetSchema['expedition_to_date'] = new widgetFormJQueryFuzzyDate($this->getDateItemOptions(), array('class' => 'to_date'));
     $this->widgetSchema->setNameFormat('searchExpedition[%s]');
     $this->widgetSchema->setLabels(array('expedition_from_date' => 'Between', 'expedition_to_date' => 'and'));
     $this->validatorSchema['name'] = new sfValidatorString(array('required' => false, 'trim' => true));
     $this->validatorSchema['expedition_from_date'] = new fuzzyDateValidator(array('required' => false, 'from_date' => true, 'min' => $minDate, 'max' => $maxDate, 'empty_value' => $dateLowerBound), array('invalid' => 'Date provided is not valid'));
     $this->validatorSchema['expedition_to_date'] = new fuzzyDateValidator(array('required' => false, 'from_date' => false, 'min' => $minDate, 'max' => $maxDate, 'empty_value' => $dateUpperBound), array('invalid' => 'Date provided is not valid'));
     $this->validatorSchema->setPostValidator(new sfValidatorSchemaCompare('expedition_from_date', '<=', 'expedition_to_date', array('throw_global_error' => true), array('invalid' => 'The "begin" date cannot be above the "end" date.')));
 }
 public function configure()
 {
     $this->useFields(array('id', 'referenced_relation', 'record_id', 'notion_date', 'notion_concerned', 'value_defined', 'determination_status', 'order_by'));
     $yearsKeyVal = range(intval(sfConfig::get('dw_yearRangeMin')), intval(sfConfig::get('dw_yearRangeMax')));
     $years = array_combine($yearsKeyVal, $yearsKeyVal);
     $dateText = array('year' => 'yyyy', 'month' => 'mm', 'day' => 'dd');
     $minDate = new FuzzyDateTime(strval(min($yearsKeyVal) . '/01/01'));
     $maxDate = new FuzzyDateTime(strval(max($yearsKeyVal) . '/12/31'));
     $dateLowerBound = new FuzzyDateTime(sfConfig::get('dw_dateLowerBound'));
     $maxDate->setStart(false);
     $choices = array('all' => 'All', 'taxonomy' => 'Taxon.', 'mineralogy' => 'Miner.', 'chronostratigraphy' => 'Chron.', 'lithostratigraphy' => 'Litho.', 'lithology' => 'Lithology', 'type' => 'Type', 'sex' => 'Sex', 'stage' => 'Stage', 'social_status' => 'Social', 'rock_form' => 'Rock');
     $this->widgetSchema['referenced_relation'] = new sfWidgetFormInputHidden();
     $this->validatorSchema['referenced_relation'] = new sfValidatorString();
     $this->widgetSchema['record_id'] = new sfWidgetFormInputHidden();
     $this->validatorSchema['record_id'] = new sfValidatorInteger();
     $this->widgetSchema['notion_date'] = new widgetFormJQueryFuzzyDate(array('culture' => $this->getCurrentCulture(), 'image' => '/images/calendar.gif', 'format' => '%day%/%month%/%year%', 'years' => $years, 'empty_values' => $dateText), array('class' => 'to_date'));
     $this->validatorSchema['notion_date'] = new fuzzyDateValidator(array('required' => false, 'from_date' => true, 'min' => $minDate, 'max' => $maxDate, 'empty_value' => $dateLowerBound), array('invalid' => 'Date provided is not valid'));
     $this->widgetSchema['notion_concerned'] = new sfWidgetFormChoice(array('choices' => $choices));
     $this->validatorSchema['notion_concerned'] = new sfValidatorChoice(array('required' => false, 'choices' => array_keys($choices)));
     $this->widgetSchema['value_defined'] = new sfWidgetFormInput();
     $this->widgetSchema['value_defined']->setAttributes(array('class' => 'xlsmall_size'));
     $this->validatorSchema['value_defined'] = new sfValidatorString(array('required' => false, 'trim' => true));
     $this->widgetSchema['determination_status'] = new widgetFormSelectComplete(array('model' => 'Identifications', 'table_method' => 'getDistinctDeterminationStatus', 'method' => 'getDeterminationStatus', 'key_method' => 'getDeterminationStatus', 'add_empty' => true, 'change_label' => '', 'add_label' => ''));
     $this->widgetSchema['determination_status']->setAttributes(array('class' => 'vvvsmall_size'));
     $this->widgetSchema['order_by'] = new sfWidgetFormInputHidden();
     $this->validatorSchema['order_by'] = new sfValidatorInteger();
     $this->validatorSchema['id'] = new sfValidatorInteger(array('required' => false));
     /* Identifiers sub form */
     $subForm = new sfForm();
     $this->embedForm('Identifiers', $subForm);
     foreach (Doctrine::getTable('CataloguePeople')->getPeopleRelated('identifications', 'identifier', $this->getObject()->getId()) as $key => $vals) {
         $form = new IdentifiersForm($vals);
         $this->embeddedForms['Identifiers']->embedForm($key, $form);
     }
     //Re-embedding the container
     $this->embedForm('Identifiers', $this->embeddedForms['Identifiers']);
     $subForm = new sfForm();
     $this->embedForm('newIdentifier', $subForm);
     /*Identifications post-validation to empty null values*/
     $this->mergePostValidator(new IdentificationsValidatorSchema());
 }
 public function configure()
 {
     $this->useFields(array('date_from', 'date_to', 'referenced_relation', 'record_id', 'property_type', 'property_unit', 'property_accuracy', 'applies_to', 'method', 'lower_value', 'upper_value', 'is_quantitative'));
     $yearsKeyVal = range(1400, intval(sfConfig::get('dw_yearRangeMax')));
     $years = array_reverse(array_combine($yearsKeyVal, $yearsKeyVal), true);
     $minDate = new FuzzyDateTime(strval(min($yearsKeyVal)) . '/1/1 0:0:0');
     $maxDate = new FuzzyDateTime(strval(max($yearsKeyVal)) . '/12/31 23:59:59');
     $dateLowerBound = new FuzzyDateTime(sfConfig::get('dw_dateLowerBound'));
     $dateUpperBound = new FuzzyDateTime(sfConfig::get('dw_dateUpperBound'));
     $maxDate->setStart(false);
     $this->widgetSchema['date_from'] = new widgetFormJQueryFuzzyDate(array('culture' => $this->getCurrentCulture(), 'image' => '/images/calendar.gif', 'format' => '%day%/%month%/%year%', 'years' => $years, 'with_time' => true), array('class' => 'from_date'));
     $this->widgetSchema['date_to'] = new widgetFormJQueryFuzzyDate(array('culture' => $this->getCurrentCulture(), 'image' => '/images/calendar.gif', 'format' => '%day%/%month%/%year%', 'years' => $years, 'with_time' => true), array('class' => 'to_date'));
     $this->validatorSchema['date_from'] = new fuzzyDateValidator(array('required' => false, 'from_date' => true, 'min' => $minDate, 'max' => $maxDate, 'empty_value' => $dateLowerBound, 'with_time' => true), array('invalid' => 'Invalid date "from"'));
     $this->validatorSchema['date_to'] = new fuzzyDateValidator(array('required' => false, 'from_date' => false, 'min' => $minDate, 'max' => $maxDate, 'empty_value' => $dateUpperBound, 'with_time' => true), array('invalid' => 'Invalid date "to"'));
     $this->validatorSchema->setPostValidator(new sfValidatorSchemaCompare('date_from', '<=', 'date_to', array('throw_global_error' => true), array('invalid' => 'The "from" date cannot be above the "to" date.')));
     $this->widgetSchema['referenced_relation'] = new sfWidgetFormInputHidden();
     $this->widgetSchema['record_id'] = new sfWidgetFormInputHidden();
     $this->validatorSchema['record_id'] = new sfValidatorInteger();
     $this->widgetSchema['property_type'] = new widgetFormSelectComplete(array('model' => 'Properties', 'table_method' => array('method' => 'getDistinctType', 'parameters' => array($this->options['ref_relation'])), 'method' => 'getType', 'key_method' => 'getType', 'add_empty' => true, 'change_label' => 'Pick a type in the list', 'add_label' => 'Add another type'));
     $this->widgetSchema['applies_to'] = new widgetFormSelectComplete(array('model' => 'Properties', 'change_label' => 'Pick a sub-type in the list', 'add_label' => 'Add another sub-type'));
     if (!$this->getObject()->isNew() || isset($this->options['hasmodel'])) {
         $this->widgetSchema['applies_to']->setOption('forced_choices', Doctrine::getTable('Properties')->getDistinctApplies($this->getObject()->getPropertyType()));
     } else {
         $this->widgetSchema['applies_to']->setOption('forced_choices', array('' => ''));
     }
     $this->widgetSchema['property_unit'] = new widgetFormSelectComplete(array('model' => 'Properties', 'change_label' => 'Pick a unit in the list', 'add_label' => 'Add another unit'));
     if (!$this->getObject()->isNew() || isset($this->options['hasmodel'])) {
         $this->widgetSchema['property_unit']->setOption('forced_choices', Doctrine::getTable('Properties')->getDistinctUnit($this->getObject()->getPropertyType()));
     } else {
         $this->widgetSchema['property_unit']->setOption('forced_choices', array('' => ''));
     }
     $this->widgetSchema['method'] = new sfWidgetFormInput();
     $this->widgetSchema['method']->setAttributes(array('class' => 'medium_size'));
     $this->widgetSchema['lower_value'] = new sfWidgetFormInput();
     $this->widgetSchema['upper_value'] = new sfWidgetFormInput();
     $this->widgetSchema['property_accuracy'] = new sfWidgetFormInput();
     $this->widgetSchema['property_unit']->setLabel("Unit");
     $this->widgetSchema['property_accuracy']->setLabel('Accuracy');
 }
 public function configure()
 {
     $this->useFields(array('referenced_relation', 'record_id', 'insurance_currency', 'insurer_ref', 'contact_ref', 'insurance_value', 'date_from', 'date_to'));
     $this->widgetSchema['referenced_relation'] = new sfWidgetFormInputHidden();
     $this->widgetSchema['record_id'] = new sfWidgetFormInputHidden();
     $this->widgetSchema['insurance_currency'] = new widgetFormSelectComplete(array('model' => 'Insurances', 'table_method' => 'getDistinctCurrencies', 'method' => 'getCurrencies', 'key_method' => 'getCurrencies', 'add_empty' => false, 'change_label' => 'Pick a currency in the list', 'add_label' => 'Add another currency'));
     $this->widgetSchema['insurer_ref'] = new widgetFormJQueryDLookup(array('model' => 'People', 'method' => 'getFormatedName', 'nullable' => true, 'fieldsHidders' => array('insurances_insurance_value', 'insurances_insurance_currency', 'insurances_insurance_currency_input', 'insurances_contact_ref_name')), array('class' => 'hidden'));
     $this->widgetSchema['contact_ref'] = new widgetFormJQueryDLookup(array('model' => 'People', 'divname' => 'contact_', 'method' => 'getFormatedName', 'nullable' => true, 'fieldsHidders' => array('insurances_insurance_value', 'insurances_insurance_currency', 'insurances_insurance_currency_input', 'insurances_insurer_ref_name')), array('class' => 'hidden'));
     $this->widgetSchema->setLabels(array('insurance_value' => 'Value', 'insurance_currency' => 'Currency', 'insurer_ref' => 'Insurer', 'contact_ref' => 'Person of contact'));
     $yearsKeyVal = range(intval(sfConfig::get('dw_yearRangeMin')), intval(sfConfig::get('dw_yearRangeMax')));
     $years = array_combine($yearsKeyVal, $yearsKeyVal);
     $minDate = new FuzzyDateTime(strval(min($yearsKeyVal)) . '/1/1 0:0:0');
     $maxDate = new FuzzyDateTime(strval(max($yearsKeyVal)) . '/12/31 23:59:59');
     $dateLowerBound = new FuzzyDateTime(sfConfig::get('dw_dateLowerBound'));
     $dateUpperBound = new FuzzyDateTime(sfConfig::get('dw_dateUpperBound'));
     $maxDate->setStart(false);
     $this->widgetSchema['date_from'] = new widgetFormJQueryFuzzyDate(array('culture' => $this->getCurrentCulture(), 'image' => '/images/calendar.gif', 'format' => '%day%/%month%/%year%', 'years' => $years, 'with_time' => false), array('class' => 'from_date'));
     $this->widgetSchema['date_to'] = new widgetFormJQueryFuzzyDate(array('culture' => $this->getCurrentCulture(), 'image' => '/images/calendar.gif', 'format' => '%day%/%month%/%year%', 'years' => $years, 'with_time' => false), array('class' => 'to_date'));
     $this->validatorSchema['date_from'] = new fuzzyDateValidator(array('required' => false, 'from_date' => true, 'min' => $minDate, 'max' => $maxDate, 'empty_value' => $dateLowerBound, 'with_time' => true), array('invalid' => 'Invalid date "from"'));
     $this->validatorSchema['date_to'] = new fuzzyDateValidator(array('required' => false, 'from_date' => false, 'min' => $minDate, 'max' => $maxDate, 'empty_value' => $dateUpperBound, 'with_time' => true), array('invalid' => 'Invalid date "to"'));
     $this->validatorSchema->setPostValidator(new sfValidatorSchemaCompare('date_from', '<=', 'date_to', array('throw_global_error' => true), array('invalid' => 'The "from" date cannot be above the "to" date.')));
 }
 public function configure()
 {
     unset($this['modification_date_time']);
     $this->addPagerItems();
     $this->widgetSchema['referenced_relation'] = new sfWidgetFormDoctrineChoice(array('model' => 'UsersTracking', 'table_method' => 'getDistinctTable', 'method' => 'getName', 'key_method' => 'getName', 'add_empty' => true));
     $this->widgetSchema['referenced_relation']->setLabel('Table');
     $this->widgetSchema['action'] = new sfWidgetFormChoice(array('choices' => array('' => '', 'insert' => 'inserted', 'update' => 'updated', 'delete' => 'deleted')));
     $yearsKeyVal = range(intval('2000'), date('Y'));
     $years = array_combine($yearsKeyVal, $yearsKeyVal);
     $minDate = new FuzzyDateTime(strval(min($yearsKeyVal)) . '/1/1');
     $maxDate = new FuzzyDateTime(strval(max($yearsKeyVal)) . '/12/31');
     $maxDate->setStart(false);
     $dateLowerBound = new FuzzyDateTime(sfConfig::get('dw_dateLowerBound'));
     $dateUpperBound = new FuzzyDateTime('now');
     $this->widgetSchema['user_ref'] = new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Users'), 'add_empty' => true, 'table_method' => 'getTrackingUsers'));
     $this->widgetSchema['from_date'] = new widgetFormJQueryFuzzyDate(array('culture' => $this->getCurrentCulture(), 'image' => '/images/calendar.gif', 'format' => '%day%/%month%/%year%', 'years' => $years, 'empty_values' => array('year' => 'yyyy', 'month' => 'mm', 'day' => 'dd')), array('class' => 'from_date'));
     $this->widgetSchema['to_date'] = new widgetFormJQueryFuzzyDate(array('culture' => $this->getCurrentCulture(), 'image' => '/images/calendar.gif', 'format' => '%day%/%month%/%year%', 'years' => $years, 'empty_values' => array('year' => 'yyyy', 'month' => 'mm', 'day' => 'dd')), array('class' => 'to_date'));
     $this->widgetSchema->setLabels(array('from_date' => 'Between', 'to_date' => 'and'));
     $this->validatorSchema['from_date'] = new fuzzyDateValidator(array('required' => false, 'from_date' => true, 'min' => $minDate, 'max' => $maxDate, 'empty_value' => $dateLowerBound), array('invalid' => 'Date provided is not valid'));
     $this->validatorSchema['to_date'] = new fuzzyDateValidator(array('required' => false, 'from_date' => false, 'min' => $minDate, 'max' => $maxDate, 'empty_value' => $dateUpperBound), array('invalid' => 'Date provided is not valid'));
     $this->validatorSchema->setPostValidator(new sfValidatorSchemaCompare('from_date', '<=', 'to_date', array('throw_global_error' => true), array('invalid' => 'The "begin" date cannot be above the "end" date.')));
 }
 /**
  * Configure the form with its widgets and validators
  */
 public function configure()
 {
     $this->useFields(array('name', 'expedition_from_date', 'expedition_to_date'));
     $yearsKeyVal = range(intval(sfConfig::get('dw_yearRangeMin')), intval(sfConfig::get('dw_yearRangeMax')));
     $years = array_combine($yearsKeyVal, $yearsKeyVal);
     $dateText = array('year' => 'yyyy', 'month' => 'mm', 'day' => 'dd');
     $minDate = new FuzzyDateTime(strval(min($yearsKeyVal) . '/01/01'));
     $maxDate = new FuzzyDateTime(strval(max($yearsKeyVal) . '/12/31'));
     $dateLowerBound = new FuzzyDateTime(sfConfig::get('dw_dateLowerBound'));
     $dateUpperBound = new FuzzyDateTime(sfConfig::get('dw_dateUpperBound'));
     $maxDate->setStart(false);
     $this->widgetSchema['name'] = new sfWidgetFormInputText();
     $this->widgetSchema['expedition_from_date'] = new widgetFormJQueryFuzzyDate(array('culture' => $this->getCurrentCulture(), 'image' => '/images/calendar.gif', 'format' => '%day%/%month%/%year%', 'years' => $years, 'empty_values' => $dateText), array('class' => 'from_date'));
     $this->widgetSchema['expedition_to_date'] = new widgetFormJQueryFuzzyDate(array('culture' => $this->getCurrentCulture(), 'image' => '/images/calendar.gif', 'format' => '%day%/%month%/%year%', 'years' => $years, 'empty_values' => $dateText), array('class' => 'to_date'));
     $this->widgetSchema['name']->setAttributes(array('class' => 'medium_size'));
     $this->validatorSchema['name'] = new sfValidatorString(array('required' => true, 'trim' => true));
     $this->validatorSchema['expedition_from_date'] = new fuzzyDateValidator(array('required' => false, 'from_date' => true, 'min' => $minDate, 'max' => $maxDate, 'empty_value' => $dateLowerBound), array('invalid' => 'Date provided is not valid'));
     $this->validatorSchema['expedition_to_date'] = new fuzzyDateValidator(array('required' => false, 'from_date' => false, 'min' => $minDate, 'max' => $maxDate, 'empty_value' => $dateUpperBound), array('invalid' => 'Date provided is not valid'));
     $this->validatorSchema->setPostValidator(new sfValidatorSchemaCompare('expedition_from_date', '<=', 'expedition_to_date', array('throw_global_error' => true), array('invalid' => 'The "begin" date cannot be above the "end" date.')));
     $this->validatorSchema['Members_holder'] = new sfValidatorPass();
     $this->widgetSchema['Members_holder'] = new sfWidgetFormInputHidden(array('default' => 1));
     $this->loadEmbed('Members');
     //force load of member
 }
Esempio n. 16
0
$testArray['minute'] = '';
$testDateTime2 = '1975/02/24 13:59:59';
$t->is(FuzzyDateTime::getDateTimeStringFromArray($testArray, false, $fdt->getWithTime()), $testDateTime2, 'Date without minutes - start flag set at false: Extraction of date from array succeeded !');
$testArray['hour'] = '';
$testDateTime2 = '1975/02/24 23:59:59';
$t->is(FuzzyDateTime::getDateTimeStringFromArray($testArray, false, $fdt->getWithTime()), $testDateTime2, 'Date without hours - start flag set at false: Extraction of date from array succeeded !');
$testArray['day'] = '';
$testDateTime2 = '1975/02/28 23:59:59';
$t->is(FuzzyDateTime::getDateTimeStringFromArray($testArray, false, $fdt->getWithTime()), $testDateTime2, 'Date without days - start flag set at false: Extraction of date from array succeeded !');
$testArray['month'] = '';
$testDateTime2 = '1975/12/31 23:59:59';
$t->is(FuzzyDateTime::getDateTimeStringFromArray($testArray, false, $fdt->getWithTime()), $testDateTime2, 'Date without months - start flag set at false: Extraction of date from array succeeded !');
$testArray['year'] = '';
$testDateTime2 = '2038/12/31 23:59:59';
$t->is(FuzzyDateTime::getDateTimeStringFromArray($testArray, false, $fdt->getWithTime()), $testDateTime2, 'Date without years - start flag set at false: Extraction of date from array succeeded !');
$fdt->setStart(true);
$testArray['year'] = '1975';
$testDateTime2 = '1975/01/01 00:00:00';
$t->is(FuzzyDateTime::getDateTimeStringFromArray($testArray, $fdt->getStart(), $fdt->getWithTime()), $testDateTime2, 'Date without month - start flag set at true: Extraction of date from array succeeded !');
$testArray['month'] = '02';
$testDateTime2 = '1975/02/01 00:00:00';
$t->is(FuzzyDateTime::getDateTimeStringFromArray($testArray, $fdt->getStart(), $fdt->getWithTime()), $testDateTime2, 'Date without days - start flag set at false: Extraction of date from array succeeded !');
$testArray['day'] = '24';
$testDateTime2 = '1975/02/24 00:00:00';
$t->is(FuzzyDateTime::getDateTimeStringFromArray($testArray, $fdt->getStart(), $fdt->getWithTime()), $testDateTime2, 'Date without hours - start flag set at false: Extraction of date from array succeeded !');
$testArray['hour'] = '13';
$testDateTime2 = '1975/02/24 13:00:00';
$t->is(FuzzyDateTime::getDateTimeStringFromArray($testArray, $fdt->getStart(), $fdt->getWithTime()), $testDateTime2, 'Date without minutes - start flag set at false: Extraction of date from array succeeded !');
$testArray['minute'] = '12';
$testDateTime2 = '1975/02/24 13:12:00';
$t->is(FuzzyDateTime::getDateTimeStringFromArray($testArray, $fdt->getStart(), $fdt->getWithTime()), $testDateTime2, 'Date without seconds - start flag set at false: Extraction of date from array succeeded !');
Esempio n. 17
0
 public function configure()
 {
     $default_vals = $this->getOption('default_vals');
     $format = Reports::getFormatFor($this->options['name']);
     $widgets_options = Reports::getFieldsOptions($this->options['name']);
     $this->widgetSchema['name'] = new sfWidgetFormInputHidden();
     $this->validatorSchema['name'] = new sfValidatorPass();
     $this->setDefault('name', $this->options['name']);
     $this->widgetSchema['comment'] = new sfWidgetFormInputText(array(), array('maxlength' => 255));
     $this->validatorSchema['comment'] = new sfValidatorPass();
     $this->widgetSchema['format'] = new sfWidgetFormChoice(array('choices' => $format));
     $this->validatorSchema['format'] = new sfValidatorChoice(array('choices' => $format));
     /*##########################################################################
      *  Annual reports fields
      *##########################################################################
      */
     /*
      * Date fields
      */
     $yearsKeyVal = range(intval(sfConfig::get('dw_yearRangeMin')), intval(sfConfig::get('dw_yearRangeMax')));
     $years = array_combine($yearsKeyVal, $yearsKeyVal);
     $dateText = array('year' => 'yyyy', 'month' => 'mm', 'day' => 'dd');
     $minDate = new FuzzyDateTime(strval(min($yearsKeyVal) . '/01/01'));
     $maxDate = new FuzzyDateTime(strval(max($yearsKeyVal) . '/12/31'));
     $dateLowerBound = new FuzzyDateTime(sfConfig::get('dw_dateLowerBound'));
     $dateUpperBound = new FuzzyDateTime(sfConfig::get('dw_dateUpperBound'));
     $maxDate->setStart(false);
     /*
      *  Collections selection
      */
     $this->widgetSchema['collection_ref'] = new widgetFormCompleteButtonRef(array('model' => 'Collections', 'link_url' => 'collection/choose', 'method' => 'getName', 'box_title' => $this->getI18N()->__('Choose Collection'), 'button_class' => 'check_right', 'complete_url' => 'catalogue/completeName?table=collections'));
     $this->widgetSchema->setLabels(array('collection_ref' => 'Collection'));
     $this->validatorSchema['collection_ref'] = new sfValidatorInteger(array('required' => true));
     /*
      * Fuzzy date from
      */
     $this->widgetSchema['date_from'] = new widgetFormJQueryFuzzyDate(array('culture' => $this->getCurrentCulture(), 'image' => '/images/calendar.gif', 'format' => '%day%/%month%/%year%', 'years' => $years, 'empty_values' => $dateText), array('class' => 'to_date'));
     $this->validatorSchema['date_from'] = new fuzzyDateValidator(array('required' => true, 'from_date' => true, 'min' => $minDate, 'max' => $maxDate, 'empty_value' => $dateLowerBound), array('invalid' => 'Date provided is not valid'));
     /*
      * Fuzzy date to
      */
     $this->widgetSchema['date_to'] = new widgetFormJQueryFuzzyDate(array('culture' => $this->getCurrentCulture(), 'image' => '/images/calendar.gif', 'format' => '%day%/%month%/%year%', 'years' => $years, 'empty_values' => $dateText), array('class' => 'to_date'));
     $this->validatorSchema['date_to'] = new fuzzyDateValidator(array('required' => true, 'from_date' => false, 'min' => $minDate, 'max' => $maxDate, 'empty_value' => $dateUpperBound), array('invalid' => 'Date provided is not valid'));
     /*##########################################################################
      * Catalogues listing fields
      *##########################################################################
      */
     /*
      * Type of catalogue targeted
      */
     if (isset($widgets_options['catalogue_type'])) {
         $this->widgetSchema['catalogue_type'] = new sfWidgetFormChoice(array('choices' => $widgets_options['catalogue_type']['values'], 'default' => $widgets_options['catalogue_type']['default_value']));
         $this->validatorSchema['catalogue_type'] = new sfValidatorChoice(array('choices' => array_keys($widgets_options['catalogue_type']['values'])));
         $form_name = $this->getName();
         $attached_to_id = $form_name . '_catalogue_type';
     }
     /*
      * Number of Records to get from the report
      */
     if (isset($widgets_options['nbr_records'])) {
         $this->widgetSchema['nbr_records'] = new sfWidgetFormChoice(array('choices' => $widgets_options['nbr_records']['values'], 'default' => $widgets_options['nbr_records']['default_value']));
         $this->validatorSchema['nbr_records'] = new sfValidatorChoice(array('choices' => array_keys($widgets_options['nbr_records']['values'])));
     }
     /*
      * Catalogue unit ref
      */
     if (isset($widgets_options['catalogue_unit_ref'])) {
         $model = strtolower($this->getOption('model_name', 'taxonomy'));
         if ($model == 'zoology' || $model == 'botany') {
             $model = 'taxonomy';
         }
         $modelUC = ucfirst($model);
         $this->widgetSchema['catalogue_unit_ref'] = new widgetFormButtonRefMultiple(array('model' => $modelUC, 'method' => 'getFormatedName', 'link_url' => $model . '/choose?with_js=1', 'box_title' => $this->getI18N()->__('Choose Yourself'), 'label' => $this->getI18N()->__('Catalogue unit'), 'partial_url' => 'catalogue/renderTableRowForButtonRefMultiple', 'partial_controler' => 'catalogue', 'partial_action' => 'renderTableRowForButtonRefMultiple', 'on_change_attached_to_id' => isset($attached_to_id) ? $attached_to_id : NULL, 'on_change_url_for_widget_renew' => 'report/getReport', 'on_change_url_for_widget_renew_params' => $this->getOption('name')), array('class' => 'ref_multiple_ids'));
         $this->validatorSchema['catalogue_unit_ref'] = new sfValidatorString(array('required' => TRUE));
         $this->validatorSchema['catalogue_unit_ref']->setMessage('required', 'You need to provide at least one catalogue unit');
         $this->mergePostValidator(new buttonRefMultipleValidatorSchema());
     }
     /*##########################################################################
      * Loan forms fields
      *##########################################################################
      */
     /*
      * Loan ID
      */
     if (($this->getOption('with_js', false) === true || $this->getOption('with_js', false) === '1') && !empty($default_vals['loan_id'])) {
         $this->widgetSchema['loan_id'] = new sfWidgetFormInputHidden(array('default' => $default_vals['loan_id']));
     } else {
         $this->widgetSchema['loan_id'] = new widgetFormCompleteButtonRef(array('model' => 'Loans', 'link_url' => 'loan/choose', 'method' => 'getName', 'box_title' => $this->getI18N()->__('Choose Loan'), 'button_class' => 'check_right', 'complete_url' => 'catalogue/completeName?table=loans'));
     }
     $this->validatorSchema['loan_id'] = new sfValidatorInteger(array('required' => TRUE));
     /*
      * Loan Target Selected
      */
     if (isset($widgets_options['loan_target_selected'])) {
         $this->widgetSchema['loan_target_selected'] = new sfWidgetFormChoice(array('choices' => $widgets_options['loan_target_selected']['values'], 'default' => $widgets_options['loan_target_selected']['default_value'], 'multiple' => true, 'expanded' => false));
         $this->validatorSchema['loan_target_selected'] = new sfValidatorChoice(array('choices' => array_keys($widgets_options['loan_target_selected']['values']), 'multiple' => true));
     }
     /*
      * Loan Target Catalogues
      */
     if (isset($widgets_options['loan_target_catalogues'])) {
         $this->widgetSchema['loan_target_catalogues'] = new sfWidgetFormChoice(array('choices' => $widgets_options['loan_target_catalogues']['values'], 'default' => $widgets_options['loan_target_catalogues']['default_value'], 'multiple' => true, 'expanded' => false));
         $this->validatorSchema['loan_target_catalogues'] = new sfValidatorChoice(array('choices' => array_keys($widgets_options['loan_target_catalogues']['values']), 'multiple' => true));
     }
     /*##########################################################################
      * Encoders statistics forms fields
      *##########################################################################
      */
     if (isset($widgets_options['users_array']) && $this->getOption('current_user', null) !== null) {
         $this->widgetSchema['users_array'] = new sfWidgetFormDarwinDoctrineChoice(array('model' => 'Users', 'table_method' => array('method' => 'getRestrictedEncodersList', 'parameters' => array($this->getOption('current_user'))), 'multiple' => true, 'default' => 0));
         $choices = $this->widgetSchema['users_array']->getChoices();
         $this->validatorSchema['users_array'] = new sfValidatorChoice(array('choices' => array_keys($choices), 'multiple' => true));
     }
     /*##########################################################################
      * Multiple use cases forms fields
      *##########################################################################
      */
     /*
      * Language
      */
     if (isset($widgets_options['lang'])) {
         $this->widgetSchema['lang'] = new sfWidgetFormChoice(array('choices' => $widgets_options['lang']['values'], 'default' => $widgets_options['lang']['default_value']));
         $this->validatorSchema['lang'] = new sfValidatorChoice(array('choices' => array_keys($widgets_options['lang']['values'])));
     }
     /*##########################################################################
      * Definition of list of fields to be used
      *##########################################################################
      */
     $this->useFields(array_merge(array('name', 'format', 'comment'), array_keys($this->options['fields'])));
 }
 public function configure()
 {
     $this->with_group = false;
     $this->useFields(array('gtu_code', 'gtu_from_date', 'gtu_to_date', 'taxon_level_ref', 'litho_name', 'litho_level_ref', 'litho_level_name', 'chrono_name', 'chrono_level_ref', 'chrono_level_name', 'lithology_name', 'lithology_level_ref', 'lithology_level_name', 'mineral_name', 'mineral_level_ref', 'mineral_level_name', 'ig_num', 'acquisition_category', 'acquisition_date'));
     $this->addPagerItems();
     $this->widgetSchema['gtu_code'] = new sfWidgetFormInputText();
     $this->widgetSchema['expedition_name'] = new sfWidgetFormInputText(array(), array('class' => 'medium_size'));
     $this->widgetSchema['taxon_name'] = new sfWidgetFormInputText(array(), array('class' => 'medium_size taxon_name'));
     $this->widgetSchema['taxon_level_ref'] = new sfWidgetFormDarwinDoctrineChoice(array('model' => 'CatalogueLevels', 'table_method' => array('method' => 'getLevelsByTypes', 'parameters' => array(array('table' => 'taxonomy'))), 'add_empty' => $this->getI18N()->__('All')), array('class' => 'taxon_name'));
     $rel = array('child' => 'Is a Child Of', 'direct_child' => 'Is a Direct Child', 'synonym' => 'Is a Synonym Of', 'equal' => 'Is strictly equal to');
     $this->widgetSchema['taxon_relation'] = new sfWidgetFormChoice(array('choices' => $rel, 'expanded' => true));
     $this->widgetSchema['taxon_relation']->setDefault('child');
     $this->widgetSchema['taxon_item_ref'] = new widgetFormCompleteButtonRef(array('model' => 'Taxonomy', 'method' => 'getName', 'link_url' => 'taxonomy/choose', 'box_title' => $this->getI18N()->__('Choose Taxon'), 'button_is_hidden' => true, 'complete_url' => 'catalogue/completeName?table=taxonomy&level=1', 'nullable' => true, 'field_to_clean_class' => 'taxon_name'), array('class' => 'taxon_autocomplete'));
     $this->widgetSchema['taxon_child_syn_included'] = new WidgetFormInputCheckboxDarwin();
     $this->widgetSchema['taxon_child_syn_included']->setOption('label', 'Syn. included ?');
     $this->validatorSchema['taxon_item_ref'] = new sfValidatorInteger(array('required' => false));
     $this->validatorSchema['taxon_relation'] = new sfValidatorChoice(array('required' => false, 'choices' => array_keys($rel)));
     $this->validatorSchema['taxon_child_syn_included'] = new sfValidatorBoolean();
     $this->widgetSchema['lithology_relation'] = new sfWidgetFormChoice(array('choices' => $rel, 'expanded' => true));
     $this->widgetSchema['lithology_relation']->setDefault('child');
     $this->widgetSchema['lithology_item_ref'] = new widgetFormCompleteButtonRef(array('model' => 'Lithology', 'link_url' => 'lithology/choose', 'method' => 'getName', 'box_title' => $this->getI18N()->__('Choose Lithologic unit'), 'button_is_hidden' => true, 'complete_url' => 'catalogue/completeName?table=lithology', 'nullable' => true, 'field_to_clean_class' => 'lithology_name'), array('class' => 'lithology_autocomplete'));
     $this->widgetSchema['lithology_child_syn_included'] = new WidgetFormInputCheckboxDarwin();
     $this->widgetSchema['lithology_child_syn_included']->setOption('label', 'Syn. included ?');
     $this->validatorSchema['lithology_item_ref'] = new sfValidatorInteger(array('required' => false));
     $this->validatorSchema['lithology_relation'] = new sfValidatorChoice(array('required' => false, 'choices' => array_keys($rel)));
     $this->validatorSchema['lithology_child_syn_included'] = new sfValidatorBoolean();
     $this->widgetSchema['lithology_name'] = new sfWidgetFormInputText(array(), array('class' => 'medium_size lithology_name'));
     $this->widgetSchema['lithology_level_ref'] = new sfWidgetFormDarwinDoctrineChoice(array('model' => 'CatalogueLevels', 'table_method' => array('method' => 'getLevelsByTypes', 'parameters' => array(array('table' => 'lithology'))), 'add_empty' => $this->getI18N()->__('All')), array('class' => 'lithology_name'));
     $this->widgetSchema['litho_name'] = new sfWidgetFormInputText(array(), array('class' => 'medium_size litho_name'));
     $this->widgetSchema['litho_level_ref'] = new sfWidgetFormDarwinDoctrineChoice(array('model' => 'CatalogueLevels', 'table_method' => array('method' => 'getLevelsByTypes', 'parameters' => array(array('table' => 'lithostratigraphy'))), 'add_empty' => $this->getI18N()->__('All')), array('class' => 'litho_name'));
     $this->widgetSchema['litho_relation'] = new sfWidgetFormChoice(array('choices' => $rel, 'expanded' => true));
     $this->widgetSchema['litho_relation']->setDefault('child');
     $this->widgetSchema['litho_item_ref'] = new widgetFormCompleteButtonRef(array('model' => 'Lithostratigraphy', 'link_url' => 'lithostratigraphy/choose', 'method' => 'getName', 'box_title' => $this->getI18N()->__('Choose Lithostratigraphic unit'), 'button_is_hidden' => true, 'complete_url' => 'catalogue/completeName?table=lithostratigraphy', 'nullable' => true, 'field_to_clean_class' => 'litho_name'), array('class' => 'litho_autocomplete'));
     $this->widgetSchema['litho_child_syn_included'] = new WidgetFormInputCheckboxDarwin();
     $this->widgetSchema['litho_child_syn_included']->setOption('label', 'Syn. included ?');
     $this->validatorSchema['litho_item_ref'] = new sfValidatorInteger(array('required' => false));
     $this->validatorSchema['litho_relation'] = new sfValidatorChoice(array('required' => false, 'choices' => array_keys($rel)));
     $this->validatorSchema['litho_child_syn_included'] = new sfValidatorBoolean();
     $this->widgetSchema['chrono_name'] = new sfWidgetFormInputText(array(), array('class' => 'medium_size chrono_name'));
     $this->widgetSchema['chrono_level_ref'] = new sfWidgetFormDarwinDoctrineChoice(array('model' => 'CatalogueLevels', 'table_method' => array('method' => 'getLevelsByTypes', 'parameters' => array(array('table' => 'chronostratigraphy'))), 'add_empty' => $this->getI18N()->__('All')), array('class' => 'chrono_name'));
     $this->widgetSchema['chrono_relation'] = new sfWidgetFormChoice(array('choices' => $rel, 'expanded' => true));
     $this->widgetSchema['chrono_relation']->setDefault('child');
     $this->widgetSchema['chrono_item_ref'] = new widgetFormCompleteButtonRef(array('model' => 'Chronostratigraphy', 'link_url' => 'chronostratigraphy/choose', 'method' => 'getName', 'box_title' => $this->getI18N()->__('Choose Chronostratigraphic unit'), 'nullable' => true, 'button_is_hidden' => true, 'complete_url' => 'catalogue/completeName?table=chronostratigraphy', 'button_class' => '', 'field_to_clean_class' => 'chrono_name'), array('class' => 'chrono_autocomplete'));
     $this->widgetSchema['chrono_child_syn_included'] = new WidgetFormInputCheckboxDarwin();
     $this->widgetSchema['chrono_child_syn_included']->setOption('label', 'Syn. included ?');
     $this->validatorSchema['chrono_item_ref'] = new sfValidatorInteger(array('required' => false));
     $this->validatorSchema['chrono_relation'] = new sfValidatorChoice(array('required' => false, 'choices' => array_keys($rel)));
     $this->validatorSchema['chrono_child_syn_included'] = new sfValidatorBoolean();
     $this->widgetSchema['mineral_name'] = new sfWidgetFormInputText(array(), array('class' => 'medium_size mineral_name'));
     $this->widgetSchema['mineral_level_ref'] = new sfWidgetFormDarwinDoctrineChoice(array('model' => 'CatalogueLevels', 'table_method' => array('method' => 'getLevelsByTypes', 'parameters' => array(array('table' => 'mineralogy'))), 'add_empty' => $this->getI18N()->__('All')), array('class' => 'mineral_name'));
     $this->widgetSchema['mineral_item_ref'] = new widgetFormCompleteButtonRef(array('model' => 'Mineralogy', 'link_url' => 'mineralogy/choose', 'method' => 'getName', 'box_title' => $this->getI18N()->__('Choose Mineralogic unit'), 'nullable' => true, 'button_is_hidden' => true, 'complete_url' => 'catalogue/completeName?table=mineralogy', 'button_class' => '', 'field_to_clean_class' => 'mineral_name'), array('class' => 'mineral_autocomplete'));
     $this->widgetSchema['mineral_child_syn_included'] = new WidgetFormInputCheckboxDarwin();
     $this->widgetSchema['mineral_child_syn_included']->setOption('label', 'Syn. included ?');
     $this->widgetSchema['mineral_relation'] = new sfWidgetFormChoice(array('choices' => $rel, 'expanded' => true));
     $this->widgetSchema['mineral_relation']->setDefault('child');
     $this->validatorSchema['mineral_item_ref'] = new sfValidatorInteger(array('required' => false));
     $this->validatorSchema['mineral_relation'] = new sfValidatorChoice(array('required' => false, 'choices' => array_keys($rel)));
     $this->validatorSchema['mineral_child_syn_included'] = new sfValidatorBoolean();
     $minDate = new FuzzyDateTime(strval(min(range(intval(sfConfig::get('dw_yearRangeMin')), intval(sfConfig::get('dw_yearRangeMax')))) . '/01/01'));
     $maxDate = new FuzzyDateTime(strval(max(range(intval(sfConfig::get('dw_yearRangeMin')), intval(sfConfig::get('dw_yearRangeMax')))) . '/12/31'));
     $maxDate->setStart(false);
     $dateLowerBound = new FuzzyDateTime(sfConfig::get('dw_dateLowerBound'));
     $dateUpperBound = new FuzzyDateTime(sfConfig::get('dw_dateUpperBound'));
     $this->widgetSchema['ig_num'] = new sfWidgetFormInputText();
     $this->widgetSchema['ig_from_date'] = new widgetFormJQueryFuzzyDate($this->getDateItemOptions(), array('class' => 'from_date'));
     $this->widgetSchema['ig_to_date'] = new widgetFormJQueryFuzzyDate($this->getDateItemOptions(), array('class' => 'to_date'));
     $this->widgetSchema['ig_num']->setAttributes(array('class' => 'small_size'));
     $this->validatorSchema['ig_num'] = new sfValidatorString(array('required' => false, 'trim' => true));
     $this->validatorSchema['ig_from_date'] = new fuzzyDateValidator(array('required' => false, 'from_date' => true, 'min' => $minDate, 'max' => $maxDate, 'empty_value' => $dateLowerBound), array('invalid' => 'Date provided is not valid'));
     $this->validatorSchema['ig_to_date'] = new fuzzyDateValidator(array('required' => false, 'from_date' => false, 'min' => $minDate, 'max' => $maxDate, 'empty_value' => $dateUpperBound), array('invalid' => 'Date provided is not valid'));
     $this->validatorSchema->setPostValidator(new sfValidatorSchemaCompare('ig_from_date', '<=', 'ig_to_date', array('throw_global_error' => true), array('invalid' => 'The "begin" date cannot be above the "end" date.')));
     $this->widgetSchema['col_fields'] = new sfWidgetFormInputHidden();
     $this->widgetSchema['collection_ref'] = new sfWidgetCollectionList(array('choices' => array()));
     $this->widgetSchema['collection_ref']->addOption('public_only', false);
     $this->validatorSchema['collection_ref'] = new sfValidatorPass();
     //Avoid duplicate the query
     $this->widgetSchema['spec_ids'] = new sfWidgetFormTextarea(array('label' => "#ID list separated by ',' "));
     $this->validatorSchema['spec_ids'] = new sfValidatorString(array('required' => false, 'trim' => true));
     $this->validatorSchema['col_fields'] = new sfValidatorString(array('required' => false, 'trim' => true));
     $this->validatorSchema['gtu_code'] = new sfValidatorString(array('required' => false, 'trim' => true));
     $this->validatorSchema['expedition_name'] = new sfValidatorString(array('required' => false, 'trim' => true));
     $this->validatorSchema['taxon_name'] = new sfValidatorString(array('required' => false, 'trim' => true));
     $this->validatorSchema['taxon_level_ref'] = new sfValidatorInteger(array('required' => false));
     $this->validatorSchema['chrono_name'] = new sfValidatorString(array('required' => false, 'trim' => true));
     $this->validatorSchema['chrono_level_ref'] = new sfValidatorInteger(array('required' => false));
     $this->validatorSchema['litho_name'] = new sfValidatorString(array('required' => false, 'trim' => true));
     $this->validatorSchema['litho_level_ref'] = new sfValidatorInteger(array('required' => false));
     $this->validatorSchema['lithology_name'] = new sfValidatorString(array('required' => false, 'trim' => true));
     $this->validatorSchema['lithology_level_ref'] = new sfValidatorInteger(array('required' => false));
     $this->validatorSchema['mineral_name'] = new sfValidatorString(array('required' => false, 'trim' => true));
     $this->validatorSchema['mineral_level_ref'] = new sfValidatorInteger(array('required' => false));
     $minDate = new FuzzyDateTime(strval(min(range(intval(sfConfig::get('dw_yearRangeMin')), intval(sfConfig::get('dw_yearRangeMax')))) . '/01/01'));
     $maxDate = new FuzzyDateTime(strval(max(range(intval(sfConfig::get('dw_yearRangeMin')), intval(sfConfig::get('dw_yearRangeMax')))) . '/12/31'));
     $maxDate->setStart(false);
     $dateLowerBound = new FuzzyDateTime(sfConfig::get('dw_dateLowerBound'));
     $dateUpperBound = new FuzzyDateTime(sfConfig::get('dw_dateUpperBound'));
     $this->widgetSchema['tags'] = new sfWidgetFormInputText();
     $this->widgetSchema['gtu_from_date'] = new widgetFormJQueryFuzzyDate($this->getDateItemOptions(), array('class' => 'from_date'));
     $this->widgetSchema['gtu_to_date'] = new widgetFormJQueryFuzzyDate($this->getDateItemOptions(), array('class' => 'to_date'));
     $this->validatorSchema['tags'] = new sfValidatorString(array('required' => false, 'trim' => true));
     $this->validatorSchema['gtu_from_date'] = new fuzzyDateValidator(array('required' => false, 'from_date' => true, 'min' => $minDate, 'max' => $maxDate, 'empty_value' => $dateLowerBound), array('invalid' => 'Date provided is not valid'));
     $this->validatorSchema['gtu_to_date'] = new fuzzyDateValidator(array('required' => false, 'from_date' => false, 'min' => $minDate, 'max' => $maxDate, 'empty_value' => $dateUpperBound), array('invalid' => 'Date provided is not valid'));
     $subForm = new sfForm();
     $this->embedForm('Tags', $subForm);
     $this->widgetSchema['tools'] = new widgetFormSelectDoubleListFilterable(array('choices' => new sfCallable(array(Doctrine::getTable('CollectingTools'), 'fetchTools')), 'label_associated' => $this->getI18N()->__('Selected'), 'label_unassociated' => $this->getI18N()->__('Available')));
     $this->widgetSchema['methods'] = new widgetFormSelectDoubleListFilterable(array('choices' => new sfCallable(array(Doctrine::getTable('CollectingMethods'), 'fetchMethods')), 'label_associated' => $this->getI18N()->__('Selected'), 'label_unassociated' => $this->getI18N()->__('Available')));
     $this->validatorSchema['methods'] = new sfValidatorPass();
     $this->validatorSchema['tools'] = new sfValidatorPass();
     $this->widgetSchema['with_multimedia'] = new sfWidgetFormInputCheckbox();
     $this->validatorSchema['with_multimedia'] = new sfValidatorPass();
     //people widget
     $this->widgetSchema['people_ref'] = new widgetFormButtonRef(array('model' => 'People', 'link_url' => 'people/searchBoth', 'box_title' => $this->getI18N()->__('Choose people role'), 'nullable' => true, 'button_class' => ''), array('class' => 'inline'));
     $fields_to_search = array('spec_coll_ids' => $this->getI18N()->__('Collector'), 'spec_don_sel_ids' => $this->getI18N()->__('Donator or seller'), 'ident_ids' => $this->getI18N()->__('Identifier'));
     $this->widgetSchema['role_ref'] = new sfWidgetFormChoice(array('choices' => $fields_to_search, 'multiple' => true, 'expanded' => true));
     $this->validatorSchema['people_ref'] = new sfValidatorInteger(array('required' => false));
     $this->validatorSchema['role_ref'] = new sfValidatorChoice(array('choices' => array_keys($fields_to_search), 'required' => false));
     $this->validatorSchema['role_ref'] = new sfValidatorPass();
     /* Acquisition categories */
     $this->widgetSchema['acquisition_category'] = new sfWidgetFormChoice(array('choices' => array_merge(array('' => ''), SpecimensTable::getDistinctCategories())));
     $this->widgetSchema['acquisition_from_date'] = new widgetFormJQueryFuzzyDate($this->getDateItemOptions(), array('class' => 'from_date'));
     $this->widgetSchema['acquisition_to_date'] = new widgetFormJQueryFuzzyDate($this->getDateItemOptions(), array('class' => 'to_date'));
     $this->validatorSchema['acquisition_from_date'] = new fuzzyDateValidator(array('required' => false, 'from_date' => true, 'min' => $minDate, 'max' => $maxDate, 'empty_value' => $dateLowerBound), array('invalid' => 'Date provided is not valid'));
     $this->validatorSchema['acquisition_to_date'] = new fuzzyDateValidator(array('required' => false, 'min' => $minDate, 'from_date' => false, 'max' => $maxDate, 'empty_value' => $dateUpperBound), array('invalid' => 'Date provided is not valid'));
     /**
      * Individuals Fields
      */
     $this->widgetSchema['type'] = new sfWidgetFormDarwinDoctrineChoice(array('model' => 'Specimens', 'table_method' => 'getDistinctTypeGroups', 'multiple' => true, 'expanded' => true, 'add_empty' => false));
     $this->validatorSchema['type'] = new sfValidatorPass();
     $this->widgetSchema['sex'] = new sfWidgetFormDarwinDoctrineChoice(array('model' => 'Specimens', 'table_method' => 'getDistinctSexes', 'multiple' => true, 'expanded' => true, 'add_empty' => false));
     $this->validatorSchema['sex'] = new sfValidatorPass();
     $this->widgetSchema['stage'] = new widgetFormSelectDoubleListFilterable(array('choices' => new sfCallable(array(Doctrine::getTable('Specimens'), 'getDistinctStages')), 'label_associated' => $this->getI18N()->__('Selected'), 'label_unassociated' => $this->getI18N()->__('Available')));
     $this->validatorSchema['stage'] = new sfValidatorPass();
     $this->widgetSchema['status'] = new sfWidgetFormDarwinDoctrineChoice(array('model' => 'Specimens', 'table_method' => 'getDistinctStates', 'multiple' => true, 'expanded' => true, 'add_empty' => false));
     $this->validatorSchema['status'] = new sfValidatorPass();
     $this->widgetSchema['specimen_status'] = new sfWidgetFormDarwinDoctrineChoice(array('model' => 'Specimens', 'table_method' => 'getDistinctSpecimenStatus', 'multiple' => false, 'expanded' => false, 'add_empty' => true));
     $this->validatorSchema['specimen_status'] = new sfValidatorPass();
     $this->widgetSchema['social'] = new sfWidgetFormDarwinDoctrineChoice(array('model' => 'Specimens', 'table_method' => 'getDistinctSocialStatuses', 'multiple' => true, 'expanded' => true, 'add_empty' => false));
     $this->validatorSchema['social'] = new sfValidatorPass();
     $this->widgetSchema['rockform'] = new sfWidgetFormDarwinDoctrineChoice(array('model' => 'Specimens', 'table_method' => 'getDistinctRockForms', 'multiple' => true, 'expanded' => true, 'add_empty' => false));
     $this->validatorSchema['rockform'] = new sfValidatorPass();
     $this->widgetSchema['count'] = new sfWidgetFormInput();
     $this->widgetSchema['count']->setAttributes(array('class' => 'vsmall_size'));
     $this->validatorSchema['count'] = new sfValidatorString(array('required' => false));
     $operators = array('' => '', 'e' => '=', 'l' => '<=', 'g' => '>=');
     $this->widgetSchema['count_operator'] = new sfWidgetFormChoice(array('choices' => $operators));
     $this->validatorSchema['count_operator'] = new sfValidatorChoice(array('required' => false, 'choices' => array_keys($operators)));
     $this->widgetSchema['container'] = new sfWidgetFormInput();
     $this->validatorSchema['container'] = new sfValidatorString(array('required' => false));
     $this->widgetSchema['sub_container'] = new sfWidgetFormInput();
     $this->validatorSchema['sub_container'] = new sfValidatorString(array('required' => false));
     $this->validatorSchema['part'] = new sfValidatorString(array('required' => false));
     $this->widgetSchema['part'] = new sfWidgetFormDarwinDoctrineChoice(array('model' => 'Specimens', 'table_method' => 'getDistinctParts', 'add_empty' => true));
     $this->widgetSchema['object_name'] = new sfWidgetFormInput();
     $this->validatorSchema['object_name'] = new sfValidatorString(array('required' => false));
     $this->validatorSchema['floor'] = new sfValidatorString(array('required' => false));
     $this->widgetSchema['institution_ref'] = new widgetFormButtonRef(array('model' => 'Institutions', 'link_url' => 'institution/choose?with_js=1', 'method' => 'getFamilyName', 'box_title' => $this->getI18N()->__('Choose Institution'), 'nullable' => true));
     $this->widgetSchema['institution_ref']->setLabel('Institution');
     $this->validatorSchema['institution_ref'] = new sfValidatorInteger(array('required' => false));
     $this->widgetSchema['building'] = new sfWidgetFormDarwinDoctrineChoice(array('model' => 'Specimens', 'table_method' => 'getDistinctBuildings', 'add_empty' => true));
     $this->validatorSchema['building'] = new sfValidatorString(array('required' => false));
     $this->widgetSchema['floor'] = new sfWidgetFormDarwinDoctrineChoice(array('model' => 'Specimens', 'table_method' => 'getDistinctFloors', 'add_empty' => true));
     $this->validatorSchema['floor'] = new sfValidatorString(array('required' => false));
     $this->widgetSchema['row'] = new sfWidgetFormDarwinDoctrineChoice(array('model' => 'Specimens', 'table_method' => 'getDistinctRows', 'add_empty' => true));
     $this->validatorSchema['row'] = new sfValidatorString(array('required' => false));
     $this->widgetSchema['col'] = new sfWidgetFormDarwinDoctrineChoice(array('model' => 'Specimens', 'table_method' => 'getDistinctCols', 'add_empty' => true));
     $this->validatorSchema['col'] = new sfValidatorString(array('required' => false));
     $this->widgetSchema['room'] = new sfWidgetFormDarwinDoctrineChoice(array('model' => 'Specimens', 'table_method' => 'getDistinctRooms', 'add_empty' => true));
     $this->validatorSchema['room'] = new sfValidatorString(array('required' => false));
     $this->widgetSchema['shelf'] = new sfWidgetFormDarwinDoctrineChoice(array('model' => 'Specimens', 'table_method' => 'getDistinctShelfs', 'add_empty' => true));
     $this->validatorSchema['shelf'] = new sfValidatorString(array('required' => false));
     $this->widgetSchema['property_type'] = new sfWidgetFormDarwinDoctrineChoice(array('model' => 'Properties', 'table_method' => array('method' => 'getDistinctType', 'parameters' => array('specimens')), 'add_empty' => $this->getI18N()->__('All')));
     $this->validatorSchema['property_type'] = new sfValidatorString(array('required' => false));
     $this->widgetSchema['property_applies_to'] = new sfWidgetFormDarwinDoctrineChoice(array('model' => 'Properties', 'table_method' => array('method' => 'getDistinctApplies', 'parameters' => array()), 'add_empty' => $this->getI18N()->__('All')));
     $this->validatorSchema['property_applies_to'] = new sfValidatorString(array('required' => false));
     $this->widgetSchema['property_value_from'] = new sfWidgetFormInput();
     $this->validatorSchema['property_value_from'] = new sfValidatorString(array('required' => false));
     $this->widgetSchema['property_value_to'] = new sfWidgetFormInput();
     $this->validatorSchema['property_value_to'] = new sfValidatorString(array('required' => false));
     $this->widgetSchema['property_units'] = new sfWidgetFormDarwinDoctrineChoice(array('model' => 'Properties', 'table_method' => array('method' => 'getDistinctUnit', 'parameters' => array()), 'add_empty' => true));
     $this->validatorSchema['property_units'] = new sfValidatorString(array('required' => false));
     $this->widgetSchema['comment'] = new sfWidgetFormInput();
     $this->validatorSchema['comment'] = new sfValidatorString(array('required' => false));
     $comment_choices = array('' => '');
     $comment_choices = $comment_choices + CommentsTable::getNotionsFor('specimens');
     $this->widgetSchema['comment_notion_concerned'] = new sfWidgetFormChoice(array('choices' => $comment_choices));
     $this->validatorSchema['comment_notion_concerned'] = new sfValidatorChoice(array('required' => false, 'choices' => array_keys($comment_choices)));
     $subForm = new sfForm();
     $this->embedForm('Codes', $subForm);
     // LAT LON
     $this->widgetSchema['lat_from'] = new sfWidgetForminput();
     $this->widgetSchema['lat_from']->setLabel('Latitude');
     $this->widgetSchema['lat_from']->setAttributes(array('class' => 'medium_small_size'));
     $this->widgetSchema['lat_to'] = new sfWidgetForminput();
     $this->widgetSchema['lat_to']->setAttributes(array('class' => 'medium_small_size'));
     $this->widgetSchema['lon_from'] = new sfWidgetForminput();
     $this->widgetSchema['lon_from']->setLabel('Longitude');
     $this->widgetSchema['lon_from']->setAttributes(array('class' => 'medium_small_size'));
     $this->widgetSchema['lon_to'] = new sfWidgetForminput();
     $this->widgetSchema['lon_to']->setAttributes(array('class' => 'medium_small_size'));
     $this->validatorSchema['lat_from'] = new sfValidatorNumber(array('required' => false, 'min' => '-180', 'max' => '180'));
     $this->validatorSchema['lon_from'] = new sfValidatorNumber(array('required' => false, 'min' => '-360', 'max' => '360'));
     $this->validatorSchema['lat_to'] = new sfValidatorNumber(array('required' => false, 'min' => '-180', 'max' => '180'));
     $this->validatorSchema['lon_to'] = new sfValidatorNumber(array('required' => false, 'min' => '-360', 'max' => '360'));
     sfWidgetFormSchema::setDefaultFormFormatterName('list');
     $this->widgetSchema->setNameFormat('specimen_search_filters[%s]');
     /* Labels */
     $this->widgetSchema->setLabels(array('rockform' => 'Rock form', 'gtu_code' => 'Sampling Location code', 'taxon_name' => 'Taxon text search', 'litho_name' => 'Litho text search', 'lithology_name' => 'Lithology text search', 'chrono_name' => 'Chrono text search', 'mineral_name' => 'Mineralo text search', 'taxon_level_ref' => 'Level', 'code_ref_relation' => 'Code of', 'people_ref' => 'Whom are you looking for', 'role_ref' => 'Which role', 'with_multimedia' => 'Search Only objects with multimedia files', 'gtu_from_date' => 'Between', 'gtu_to_date' => 'and', 'acquisition_from_date' => 'Between', 'acquisition_to_date' => 'and', 'ig_from_date' => 'Between', 'ig_to_date' => 'and', 'ig_num' => 'I.G. unit', 'property_type' => 'Type', 'property_applies_to' => 'Applies to', 'property_value_from' => 'From', 'property_value_to' => 'To', 'property_units' => 'Unit', 'comment_notion_concerned' => 'Notion concerned'));
     // For compat only with old saved search
     // might be removed with a migration
     $this->validatorSchema['what_searched'] = new sfValidatorPass();
 }