<?php

include dirname(__FILE__) . '/../../bootstrap/Doctrine.php';
$t = new lime_test(13, new lime_output_color());
$t->info('getDistinctCategories');
$cat = SpecimensTable::getDistinctCategories();
$t->is(count($cat), 13, 'Number of differents categories: "13"');
$t->is($cat['undefined'], 'Undefined', 'get the first category: "Undefined"');
$t->is($cat['collect'], 'Collect', 'get the last category: "Collect"');
/* Prepare data for the test of findConservatories method */
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// User creation/extraction
$userEvil = Doctrine::getTable('Users')->findOneByFamilyName('Evil');
$brol_user = new Users();
$brol_user->setFamilyName('Brolus');
$brol_user->setGivenName('Brolus');
$brol_user->setDbUserType(Users::REGISTERED_USER);
$brol_user->save();
$conn = Doctrine_Manager::connection();
// Collection Rights association for the "brol" user - rights on Molusca, Amphibia  and Aves collections
$conn->exec("INSERT INTO collections_rights (collection_ref, user_ref, db_user_type)\n              (\n                SELECT id, ? , ?\n                FROM collections\n                WHERE name_indexed IN ('molusca', 'amphibia', 'aves')\n              )", array($brol_user->getId(), $brol_user->getDbUserType()));
// Building and Floor creation for specimens under Molusca and Amphibia collections
$conn->exec("UPDATE specimens\n              SET building = CASE WHEN id = 1 THEN 'De Vestel' ElSE 'Geology' END,\n                  floor = CASE WHEN id = 1 THEN '14' ElSE '-1' END\n              WHERE collection_ref IN (\n                                        SELECT id\n                                        FROM collections\n                                        WHERE name_indexed IN ('molusca', 'amphibia')\n                                      )\n            ");
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$t->info('Test of "findConservatories" - part 1 - registered user - building list searched');
$conservatories_counts = Doctrine::getTable("Specimens")->findConservatories($brol_user, 'building', array());
$t->is('', $conservatories_counts[0]['item'], '"1" specimen in "empty" building (in aves collection)');
$t->is(1, $conservatories_counts[0]['ctn'], '"1" specimen in "empty" building in (aves collection)');
$t->is('De Vestel', $conservatories_counts[1]['item'], '"1" specimen in building "De Vestel"');
$t->is(1, $conservatories_counts[1]['ctn'], '"1" specimen in building "De Vestel"');
$t->is('Geology', $conservatories_counts[2]['item'], '"2" specimen in building "Geology"');
 public function configure()
 {
     $this->widgetSchema['acquisition_category'] = new sfWidgetFormChoice(array('choices' => SpecimensTable::getDistinctCategories()));
     $this->validatorSchema['acquisition_category'] = new sfValidatorChoice(array('choices' => array_keys(SpecimensTable::getDistinctCategories()), 'required' => false));
 }
 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();
 }