コード例 #1
0
 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);
 }
コード例 #2
0
 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());
 }
コード例 #3
0
 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));
 }
コード例 #4
0
 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.')));
 }
コード例 #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');
 }
コード例 #6
0
 public function configure()
 {
     $this->useFields(array('ig_ref', 'from_date', 'to_date', 'specimen_ref', 'details'));
     $this->widgetSchema['details'] = new sfWidgetFormTextarea(array(), array('rows' => 3));
     $yearsKeyVal = range(1970, 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'));
     $this->widgetSchema['loan_item_ind'] = new sfWidgetFormInputHidden();
     // Indicator of line presence
     $this->setDefault('loan_item_ind', 1);
     $this->validatorSchema['loan_item_ind'] = new sfValidatorPass();
     $this->widgetSchema['loan_ref'] = new sfWidgetFormInputHidden();
     $this->validatorSchema['loan_ref'] = new sfValidatorPass();
     $this->widgetSchema['item_visible'] = new sfWidgetFormInputHidden();
     $this->validatorSchema['item_visible'] = new sfValidatorPass();
     $this->setDefault('item_visible', 'true');
     $this->widgetSchema['from_date'] = 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['from_date'] = new sfValidatorDate(array('required' => false, 'min' => $minDate->getDateTime(), 'date_format' => 'd/M/Y'), array('invalid' => 'Invalid date "from"'));
     $this->widgetSchema['to_date'] = 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['to_date'] = new sfValidatorDate(array('required' => false, 'min' => $minDate->getDateTime(), 'date_format' => 'd/M/Y'), array('invalid' => 'Invalid date "return"'));
     $this->widgetSchema['ig_ref'] = new widgetFormInputChecked(array('model' => 'Igs', 'method' => 'getIgNum', 'nullable' => true, 'link_url' => 'igs/searchFor', 'notExistingAddTitle' => $this->getI18N()->__('This I.G. number does not exist. Would you like to automatically insert it ?'), 'notExistingAddValues' => array($this->getI18N()->__('No'), $this->getI18N()->__('Yes'))));
     $this->widgetSchema['specimen_ref'] = new widgetFormButtonRef(array('model' => 'Specimens', 'link_url' => 'specimen/choosePinned', 'method' => 'getId', 'box_title' => $this->getI18N()->__('Choose Darwin item'), 'button_class' => '', 'nullable' => true, 'edit_route' => 'specimen/edit', 'edit_route_params' => array('id')), array('class' => 'inline'));
     $this->widgetSchema->setLabels(array('from_date' => 'Expedition date', 'to_date' => 'Return date'));
     $this->validatorSchema['specimen_ref'] = new sfValidatorInteger(array('required' => false));
     $this->mergePostValidator(new LoanOverviewLineValidatorSchema());
 }
コード例 #7
0
 public function setExpeditionToDate($fd)
 {
     if ($fd instanceof FuzzyDateTime) {
         $this->_set('expedition_to_date', $fd->format('Y/m/d'));
         $this->_set('expedition_to_date_mask', $fd->getMask());
     } else {
         $dateTime = new FuzzyDateTime($fd, 56, false);
         $this->_set('expedition_to_date', $dateTime->format('Y/m/d'));
         $this->_set('expedition_to_date_mask', $dateTime->getMask());
     }
 }
コード例 #8
0
ファイル: Igs.class.php プロジェクト: naturalsciences/Darwin
 public function setIgDate($fd)
 {
     if ($fd instanceof FuzzyDateTime) {
         $this->_set('ig_date', $fd->format('Y/m/d'));
         $this->_set('ig_date_mask', $fd->getMask());
     } else {
         $dateTime = new FuzzyDateTime($fd, 56, true);
         $this->_set('ig_date', $dateTime->format('Y/m/d'));
         $this->_set('ig_date_mask', $dateTime->getMask());
     }
 }
コード例 #9
0
 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'));
 }
コード例 #10
0
ファイル: Gtu.class.php プロジェクト: naturalsciences/Darwin
 public function setGtuToDate($fd)
 {
     if ($fd instanceof FuzzyDateTime) {
         $this->_set('gtu_to_date', $fd->format('Y/m/d H:i:s'));
         $this->_set('gtu_to_date_mask', $fd->getMask());
     } else {
         $dateTime = new FuzzyDateTime($fd, 56, false, true);
         if (is_array($fd)) {
             $dateTime->setMask(FuzzyDateTime::getMaskFromDate($fd));
         }
         $this->_set('gtu_to_date', $dateTime->format('Y/m/d H:i:s'));
         $this->_set('gtu_to_date_mask', $dateTime->getMask());
     }
 }
コード例 #11
0
 public function setNotionDate($fd)
 {
     if ($fd instanceof FuzzyDateTime) {
         if ($this->getNotionDate() != $fd->getDateTimeMaskedAsArray()) {
             $this->_set('notion_date', $fd->format('Y/m/d'));
             $this->_set('notion_date_mask', $fd->getMask());
         }
     } else {
         $dateTime = new FuzzyDateTime($fd, 56, true);
         if ($this->getNotionDate() != $dateTime->getDateTimeMaskedAsArray()) {
             $this->_set('notion_date', $dateTime->format('Y/m/d'));
             $this->_set('notion_date_mask', $dateTime->getMask());
         }
     }
 }
コード例 #12
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'));
 }
コード例 #13
0
 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.'));
 }
コード例 #14
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'));
 }
コード例 #15
0
 public function getToDate()
 {
     $time = null;
     if ($this->GTUdate['time']) {
         $time = $this->GTUdate['time'];
     }
     return $this->GTUdate['to'] ? FuzzyDateTime::getValidDate($this->GTUdate['to']) : $time;
 }
コード例 #16
0
 public function setParameters($data)
 {
     $param = '';
     $widget = self::getRequiredFieldForReport($data['name']);
     foreach ($widget as $field => $name) {
         if ($field == 'date_from' || $field == 'date_to') {
             $dateTime = new FuzzyDateTime($data[$field], 56, true);
             $param .= '"' . $field . '"=>"' . $dateTime->format('Y-m-d') . '",';
         } else {
             if (is_array($data[$field])) {
                 $param .= '"' . $field . '"=>"[' . implode(", ", $data[$field]) . ']",';
             } else {
                 $param .= '"' . $field . '"=>"' . $data[$field] . '",';
             }
         }
     }
     $this->_set('parameters', $param);
 }
コード例 #17
0
 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.')));
 }
コード例 #18
0
 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());
 }
コード例 #19
0
 public function configure()
 {
     unset($this['search_indexed']);
     $yearsKeyVal = range(1970, 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'));
     $dateText = array('year' => 'yyyy', 'month' => 'mm', 'day' => 'dd');
     $this->widgetSchema['name'] = new sfWidgetFormInput();
     $this->widgetSchema['from_date'] = new widgetFormJQueryFuzzyDate(array('culture' => $this->getCurrentCulture(), 'image' => '/images/calendar.gif', 'format' => '%day%/%month%/%year%', 'years' => $years, 'with_time' => false, 'empty_values' => $dateText), array('class' => 'from_date'));
     $this->widgetSchema['to_date'] = new widgetFormJQueryFuzzyDate(array('culture' => $this->getCurrentCulture(), 'image' => '/images/calendar.gif', 'format' => '%day%/%month%/%year%', 'years' => $years, 'with_time' => false, 'empty_values' => $dateText), array('class' => 'from_date'));
     $this->widgetSchema['extended_to_date'] = new widgetFormJQueryFuzzyDate(array('culture' => $this->getCurrentCulture(), 'image' => '/images/calendar.gif', 'format' => '%day%/%month%/%year%', 'years' => $years, 'with_time' => false, 'empty_values' => $dateText), array('class' => 'to_date'));
     $this->widgetSchema['sender'] = new sfWidgetFormInputHidden(array('default' => 1));
     $this->widgetSchema['receiver'] = new sfWidgetFormInputHidden(array('default' => 1));
     $this->widgetSchema['users'] = new sfWidgetFormInputHidden(array('default' => 1));
     /* Input file for related files */
     $this->widgetSchema['filenames'] = new sfWidgetFormInputFile();
     $this->widgetSchema['filenames']->setAttributes(array('class' => 'Add_related_file'));
     /*Validators*/
     $this->validatorSchema['name'] = new sfValidatorString(array('required' => true));
     $this->validatorSchema['from_date'] = new sfValidatorDate(array('required' => false, 'min' => $minDate->getDateTime(), 'date_format' => 'd/M/Y'), array('invalid' => 'Invalid date "from"'));
     $this->validatorSchema['to_date'] = new sfValidatorDate(array('required' => false, 'min' => $minDate->getDateTime(), 'date_format' => 'd/M/Y'), array('invalid' => 'Invalid date "to"'));
     $this->validatorSchema['extended_to_date'] = new sfValidatorDate(array('required' => false, 'min' => $minDate->getDateTime(), 'date_format' => 'd/M/Y'), array('invalid' => 'Invalid date "Extended"'));
     $this->validatorSchema['sender'] = new sfValidatorPass();
     $this->validatorSchema['receiver'] = new sfValidatorPass();
     $this->validatorSchema['users'] = new sfValidatorPass();
     //Loan form is submited to upload file, when called like that we don't want some fields to be required
     $this->validatorSchema['filenames'] = new sfValidatorPass();
     $this->mergePostValidator(new LoanValidatorDates());
     /*Labels*/
     $this->widgetSchema->setLabels(array('from_date' => 'Starts on', 'to_date' => 'Ends on', 'filenames' => 'Add File'));
     $this->validatorSchema['Comments_holder'] = new sfValidatorPass();
     $this->widgetSchema['Comments_holder'] = new sfWidgetFormInputHidden(array('default' => 1));
     $this->validatorSchema['RelatedFiles_holder'] = new sfValidatorPass();
     $this->widgetSchema['RelatedFiles_holder'] = new sfWidgetFormInputHidden(array('default' => 1));
     $this->validatorSchema['Insurances_holder'] = new sfValidatorPass();
     $this->widgetSchema['Insurances_holder'] = new sfWidgetFormInputHidden(array('default' => 1));
 }
コード例 #20
0
 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.')));
 }
コード例 #21
0
 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');
 }
コード例 #22
0
 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.')));
 }
コード例 #23
0
 /**
  * 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
 }
コード例 #24
0
 /**
  * @param  array|string  $value      Date/Time passed as an array or a string
  * @var    string        $checkDateStructure: Get an empty string if the date structure is correct, otherwise get the error
  * @var    FuzzyDateTime $clean: A FuzzyDateTime object containing the date/time corrected and the associated mask
  * @return FuzzyDateTime $clean
  * @see    sfValidatorBase
  */
 protected function doClean($value)
 {
     if (is_array($value)) {
         try {
             // Check date time structure
             $checkDateStructure = FuzzyDateTime::checkDateTimeStructure($value);
         } catch (Exception $e) {
             throw new sfValidatorError($this, 'invalid', array('value' => $value));
         }
         if (!empty($checkDateStructure)) {
             throw new sfValidatorError($this, $checkDateStructure, array('value' => $value));
         }
         try {
             $clean = new FuzzyDateTime($value, FuzzyDateTime::getMaskFromDate($value), $this->getOption('from_date'), $this->getOption('with_time'));
         } catch (Exception $e) {
             throw new sfValidatorError($this, 'invalid', array('value' => $value));
         }
     } else {
         if ($regex = $this->getOption('date_format')) {
             // ...and that it can be extracted from string
             if (!preg_match($regex, $value, $match)) {
                 throw new sfValidatorError($this, 'bad_format', array('value' => $value, 'date_format' => $this->getOption('date_format_error') ? $this->getOption('date_format_error') : $this->getOption('date_format')));
             }
             $clean = new FuzzyDateTime($match);
         } else {
             try {
                 $clean = new FuzzyDateTime($value);
             } catch (Exception $e) {
                 throw new sfValidatorError($this, 'invalid', array('value' => $value));
             }
         }
     }
     // Check date is between min and max values given
     if ($this->hasOption('max') && $clean > $this->getOption('max')) {
         throw new sfValidatorError($this, 'max', array('value' => $value, 'max' => $this->getOption('max')));
     }
     if ($this->hasOption('min') && $clean < $this->getOption('min')) {
         throw new sfValidatorError($this, 'min', array('value' => $value, 'min' => $this->getOption('min')));
     }
     return $clean;
 }
コード例 #25
0
 private function endElement($parser, $name)
 {
     $this->cdata = trim($this->cdata);
     $this->inside_data = false;
     if (in_array($this->getPreviousTag(), array('Bacterial', 'Zoological', 'Botanical', 'Viral'))) {
         $this->object->handleKeyword($this->tag, $this->cdata, $this->staging);
     } elseif ($this->getPreviousTag() == "efg:LithostratigraphicAttribution" && $name != "efg:InformalLithostratigraphicName") {
         $this->object->handleParent($name, strtolower($this->cdata), $this->staging);
     } else {
         switch ($name) {
             case "AccessionCatalogue":
                 $this->object->addAccession($this->cdata);
                 break;
             case "AccessionDate":
                 if (date('Y-m-d H:i:s', strtotime($this->cdata)) == $this->cdata) {
                     $this->object->InitAccessionVar($this->cdata);
                 }
                 break;
             case "AccessionNumber":
                 $this->object->accession_num = $this->cdata;
                 $this->object->HandleAccession($this->staging, $this->object_to_save);
                 break;
             case "Accuracy":
                 $this->getPreviousTag() == 'Altitude' ? $this->staging['gtu_elevation_accuracy'] = $this->cdata : ($this->property->property->property_accuracy = $this->cdata);
                 break;
             case "AcquisitionDate":
                 $dt = FuzzyDateTime::getValidDate($this->cdata);
                 if (!is_null($dt)) {
                     $this->staging['acquisition_date'] = $dt->getDateTime();
                     $this->staging['acquisition_date_mask'] = $dt->getMask();
                 }
                 break;
             case "AcquisitionType":
                 $this->staging['acquisition_category'] = in_array($this->cdata, SpecimensTable::$acquisition_category) ? array_search($this->cdata, SpecimensTable::$acquisition_category) : 'undefined';
                 break;
             case "AppliesTo":
                 $this->property->setAppliesTo($this->cdata);
                 break;
             case "AreaClass":
                 $this->object->tag_group_name = $this->cdata;
                 break;
             case "AreaName":
                 $this->object->tag_value = $this->cdata;
                 break;
             case "AssociatedUnitID":
                 if (in_array($this->cdata, array_keys($this->unit_id_ref))) {
                     $this->object->setStagingRelatedRef($this->unit_id_ref[$this->cdata]);
                 } else {
                     $this->object->setSourceId($this->cdata);
                     $this->object->setUnitType('external');
                 }
                 break;
             case "AssociatedUnitSourceInstitutionCode":
                 $this->object->setInstitutionName($this->cdata);
                 break;
             case "AssociatedUnitSourceName":
                 $this->object->setSourceName($this->cdata);
                 break;
             case "AssociationType":
                 $this->object->setRelationshipType($this->cdata);
                 break;
             case "efg:ChronostratigraphicAttribution":
                 $this->cdata = $this->object->setChronoParent();
                 if ($this->cdata) {
                     $this->property = new ParsingProperties("Local stage", "chronostratigraphy");
                     $this->property->property->setLowerValue($this->cdata['name']);
                     $this->addProperty(true);
                 }
                 break;
             case "efg:ChronoStratigraphicDivision":
                 $this->object->getChronoLevel(strtolower($this->cdata));
                 break;
             case "efg:ChronostratigraphicAttributions":
                 $this->object->saveChrono($this->staging);
                 break;
             case "efg:ChronostratigraphicName":
                 $this->object->name = $this->cdata;
                 break;
             case "Code":
                 $this->staging['gtu_code'] = (string) $this->cdata;
                 break;
             case "CoordinateErrorDistanceInMeters":
                 $this->staging['gtu_lat_long_accuracy'] = $this->cdata;
                 break;
             case "Context":
                 $this->object->multimedia_data['sub_type'] = $this->cdata;
                 break;
             case "CreatedDate":
                 $this->object->multimedia_data['creation_date'] = $this->cdata;
                 break;
             case "Country":
                 $this->staging_tags[] = $this->object->addTagGroups();
                 break;
             case "Database":
                 $this->object->desc .= "Database ref :" . $this->cdata . ";";
                 break;
             case "DateText":
                 $this->object->getDateText($this->cdata);
                 break;
             case "DateTime":
                 if ($this->getPreviousTag() == "Gathering") {
                     if ($this->object->getFromDate()) {
                         $this->staging["gtu_from_date"] = $this->object->getFromDate()->getDateTime();
                     }
                     if ($this->object->getToDate()) {
                         $this->staging["gtu_to_date"] = $this->object->getToDate()->getDateTime();
                     }
                     if ($this->object->getFromDate()) {
                         $this->staging["gtu_from_date_mask"] = $this->object->getFromDate()->getMask();
                     }
                     if ($this->object->getToDate()) {
                         $this->staging["gtu_to_date_mask"] = $this->object->getToDate()->getMask();
                     }
                 }
                 break;
             case "TimeOfDayBegin":
                 if ($this->getPreviousTag() == "DateTime") {
                     $this->object->GTUdate['from'] .= " " . $this->cdata;
                 }
                 break;
             case "TimeOfDayEnd":
                 if ($this->getPreviousTag() == "DateTime") {
                     $this->object->GTUdate['to'] .= " " . $this->cdata;
                 }
                 break;
             case "dna:Concentration":
                 $this->property = new ParsingProperties("Concentration", "DNA");
                 $this->property->property->setLowerValue($this->cdata);
                 $this->property->property->setPropertyUnit("ng/µl");
                 $this->addProperty(true);
                 break;
             case "dna:DNASample":
                 $this->object->addMaintenance($this->staging);
                 break;
             case "dna:ExtractionDate":
                 $dt = FuzzyDateTime::getValidDate($this->cdata);
                 if (!is_null($dt)) {
                     $this->object->maintenance->setModificationDateTime($dt->getDateTime());
                     $this->object->maintenance->setModificationDateMask($dt->getMask());
                 }
                 break;
             case "dna:ExtractionMethod":
                 $this->object->maintenance->setDescription($this->cdata);
                 break;
             case "dna:ExtractionStaff":
                 $this->handlePeople($this->object->people_type, $this->cdata);
                 break;
             case "dna:GenBankNumber":
                 $this->handleGenbankNumber($this->cdata);
                 break;
             case "dna:RatioOfAbsorbance260_280":
                 $this->property = new ParsingProperties("Ratio of absorbance 260/280", "DNA");
                 $this->property->property->setLowerValue($this->cdata);
                 $this->addProperty(true);
                 break;
             case "dna:Tissue":
                 $this->property = new ParsingProperties("Tissue", "DNA");
                 $this->property->property->setLowerValue($this->cdata);
                 $this->addProperty(true);
                 break;
             case "dna:Preservation":
                 $this->addComment(false, "conservation_mean");
                 break;
             case "Duration":
                 $this->property->setDateTo($this->cdata);
                 break;
             case "FileURI":
                 $this->handleFileURI($this->cdata);
                 break;
             case "Format":
                 $this->object->multimedia_data['type'] = $this->cdata;
                 break;
             case "FullName":
                 $this->people_name = $this->cdata;
                 break;
             case "efg:ScientificNameString":
                 $this->object->fullname = $this->cdata;
                 break;
             case "FullScientificNameString":
                 $this->object->fullname = $this->cdata;
                 break;
             case "InformalNameString":
                 $this->object->fullname = $this->cdata;
                 $this->object->setInformal(true);
                 $this->staging["taxon_name"] = $this->object->getLastParentName();
                 $this->staging["taxon_level_name"] = $this->object->getLastParentLevel();
                 break;
             case "MarkText":
                 $this->staging->setObjectName($this->cdata);
                 break;
             case "efg:InformalLithostratigraphicName":
                 $this->addComment(true, "lithostratigraphy");
                 break;
             case "Gathering":
                 if ($this->object->staging_info !== null) {
                     $this->object_to_save[] = $this->object->staging_info;
                 }
                 break;
             case "HigherTaxa":
                 $this->object->getCatalogueParent($this->staging);
                 break;
             case "HigherTaxon":
                 $this->object->handleParent();
                 break;
             case "HigherTaxonName":
                 $this->object->higher_name = $this->cdata;
                 break;
             case "HigherTaxonRank":
                 $this->object->higher_level = strtolower($this->cdata);
                 break;
             case "TaxonIdentified":
                 $this->object->checkNoSelfInParents($this->staging);
                 break;
             case "efg:LithostratigraphicAttribution":
                 $this->staging["litho_parents"] = $this->object->getParent();
                 break;
             case "Identification":
                 $this->object->save($this->staging);
                 break;
             case "IdentificationHistory":
                 $this->addComment(true, 'taxonomy');
                 break;
             case "ID-in-Database":
                 $this->object->desc .= "id in database :" . $this->cdata . " ;";
                 break;
             case "ISODateTimeBegin":
                 if ($this->getPreviousTag() == "DateTime") {
                     $this->object->GTUdate['from'] = $this->cdata;
                 } elseif ($this->getPreviousTag() == "Date") {
                     $this->object->identification->setNotionDate(FuzzyDateTime::getValidDate($this->cdata));
                 }
                 break;
             case "ISODateTimeEnd":
                 if ($this->getPreviousTag() == "DateTime") {
                     $this->object->GTUdate['to'] = $this->cdata;
                 }
                 break;
             case "IsQuantitative":
                 $this->property->property->setIsQuantitative($this->cdata);
                 break;
             case "KindOfUnit":
                 $this->staging['part'] = $this->cdata;
                 break;
             case "RecordBasis":
                 if ($this->cdata == "PreservedSpecimen") {
                     $this->staging->setCategory('specimen');
                 } else {
                     $this->staging->setCategory('observation');
                 }
                 break;
             case "LatitudeDecimal":
                 $this->staging['gtu_latitude'] = $this->cdata;
                 break;
             case "Length":
                 $this->object->desc .= "Length : " . $this->cdata . " ;";
                 break;
             case "efg:LithostratigraphicAttributions":
                 $this->object->setAttribution($this->staging);
                 break;
             case "LocalityText":
                 (string) $this->addComment(false, "exact_site");
                 break;
             case "LongitudeDecimal":
                 $this->staging['gtu_longitude'] = $this->cdata;
                 break;
             case "LowerValue":
                 $this->property->property->setLowerValue($this->cdata);
                 break;
             case "MeasurementDateTime":
                 $this->property->getDateFrom($this->cdata, $this->getPreviousTag(), $this->staging);
                 break;
             case "Method":
                 if ($this->getPreviousTag() == "Identification") {
                     $this->addComment(false, "identifications");
                 } else {
                     $this->object_to_save[] = $this->object->addMethod($this->cdata, $this->staging->getId());
                 }
                 break;
             case "efg:Petrology":
                 break;
             case "MeasurementsOrFacts":
                 if ($this->object && property_exists($this->object, 'staging_info') && $this->getPreviousTag() != "Unit" && $this->object->staging_info) {
                     $this->object_to_save[] = $this->object->staging_info;
                 }
                 break;
             case "MeasurementOrFactAtomised":
                 if ($this->getPreviousTag() == "Altitude") {
                     //Set Altitude in meters in GTU
                     $altitude = str_replace('.', ',', $this->property->property->getLowerValue());
                     $comma_count = mb_substr_count($altitude, ',');
                     if ($comma_count > 1) {
                         $altitude = preg_replace('/\\,/', '', $altitude, $comma_count - 1);
                     }
                     $altitude = str_replace(',', '.', $altitude);
                     $this->staging['gtu_elevation'] = $altitude;
                 } else {
                     $this->addProperty();
                 }
                 break;
             case "MeasurementOrFactText":
                 $this->addComment();
                 break;
             case "MineralColour":
                 $this->staging->setMineralColour($this->cdata);
                 break;
             case "efg:MineralRockClassification":
                 if ($this->getPreviousTag() == "efg:MineralRockGroup") {
                     $this->object->higher_level = strtolower($this->cdata);
                 } elseif ($this->getPreviousTag() == "efg:MineralRockNameAtomised") {
                     $this->object->classification = strtolower($this->cdata);
                 }
                 break;
             case "efg:MineralRockGroup":
                 $this->object->handleRockParent();
                 break;
             case "efg:MineralRockGroupName":
                 $this->object->higher_name = $this->cdata;
                 break;
             case "efg:MineralRockIdentified":
                 $this->object->getCatalogueParent($this->staging);
                 if ($this->object->notion !== 'mineralogy') {
                     $this->object->checkNoSelfInParents($this->staging);
                 }
                 break;
             case "Name":
                 if ($this->getPreviousTag() == "Country") {
                     $this->object->tag_value = $this->cdata;
                 }
                 break;
             case "efg:NameComments":
                 $this->object->setNotion(strtolower($this->cdata));
                 break;
             case "NameAddendum":
                 if (stripos($this->cdata, 'Variety') !== false) {
                     $this->object->level_name = 'variety';
                     $this->object->catalogue_parent['variety'] = $this->object->getCatalogueName();
                 }
                 break;
             case "NamedArea":
                 $this->staging_tags[] = $this->object->addTagGroups();
                 break;
             case "Notes":
                 if ($this->getPreviousTag() == "Identification") {
                     $this->addComment(true, "identifications");
                 } else {
                     $this->addComment();
                 }
                 break;
             case "Parameter":
                 $this->property->property->setPropertyType($this->cdata);
                 if ($this->cdata == 'DNA size') {
                     $this->property->property->setAppliesTo('DNA');
                 }
                 break;
             case "PersonName":
                 $this->handlePeople($this->object->people_type, $this->people_name);
                 break;
             case "Person":
                 $this->handlePeople($this->object->people_type, $this->people_name);
                 break;
             case "efg:MineralDescriptionText":
                 $this->addComment(true, 'mineralogy');
                 break;
             case "PetrologyDescriptiveText":
                 //SAME AS BELOW
             //SAME AS BELOW
             case "efg:PetrologyDescriptiveText":
                 $this->addComment(true, 'description');
                 break;
             case "PhaseOrStage":
                 $this->staging->setIndividualStage($this->cdata);
                 break;
             case "Preparation":
                 $this->addPreparation();
                 break;
             case "PreparationType":
                 $this->preparation_type = $this->cdata;
                 break;
             case "PreparationMaterials":
                 $this->preparation_mat = $this->cdata;
                 break;
             case "ProjectTitle":
                 $this->staging['expedition_name'] = $this->cdata;
                 break;
             case "RecordURI":
                 $this->addExternalLink($this->cdata);
                 break;
             case "ScientificName":
                 $this->staging["taxon_name"] = $this->object->getCatalogueName();
                 $this->staging["taxon_level_name"] = strtolower($this->object->level_name);
                 break;
             case "Sequence":
                 $this->object->addMaintenance($this->staging, true);
                 break;
             case "Sex":
                 if (strtolower($this->cdata) == 'm') {
                     $this->staging->setIndividualSex('male');
                 } elseif (strtolower($this->cdata) == 'f') {
                     $this->staging->setIndividualSex('female');
                 } elseif (strtolower($this->cdata) == 'u') {
                     $this->staging->setIndividualSex('unknown');
                 } elseif (strtolower($this->cdata) == 'n') {
                     $this->staging->setIndividualSex('not applicable');
                 } elseif (strtolower($this->cdata) == 'x') {
                     $this->staging->setIndividualSex('mixed');
                 }
                 break;
             case "storage:Barcode":
                 $this->addCode("barcode");
                 break;
                 // c'est un code avec "2dbarcode" dans le main
             // c'est un code avec "2dbarcode" dans le main
             case "storage:Institution":
                 $this->staging->setInstitutionName($this->cdata);
                 break;
             case "storage:Building":
                 $this->staging->setBuilding($this->cdata);
                 break;
             case "storage:Floor":
                 $this->staging->setFloor($this->cdata);
                 break;
             case "storage:Room":
                 $this->staging->setRoom($this->cdata);
                 break;
             case "storage:Column":
                 $this->staging->setCol($this->cdata);
                 break;
             case "storage:Row":
                 $this->staging->setRow($this->cdata);
                 break;
             case "storage:Shelf":
                 $this->staging->setShelf($this->cdata);
                 break;
             case "storage:Rack":
                 $this->staging->setShelf($this->cdata);
                 break;
             case "storage:Box":
                 $this->staging->setContainerType('box');
                 $this->staging->setContainer($this->cdata);
                 break;
             case "storage:Tube":
                 $this->staging->setSubContainerType('tube');
                 $this->staging->setSubContainer($this->cdata);
                 break;
             case "storage:ContainerName":
                 $this->staging->setContainer($this->cdata);
                 break;
             case "storage:ContainerType":
                 $this->staging->setContainerType($this->cdata);
                 break;
             case "storage:ContainerStorage":
                 $this->staging->setContainerStorage($this->cdata);
                 break;
             case "storage:SubcontainerName":
                 $this->staging->setSubContainer($this->cdata);
                 break;
             case "storage:SubcontainerType":
                 $this->staging->setSubContainerType($this->cdata);
                 break;
             case "storage:SubcontainerStorage":
                 $this->staging->setSubContainerStorage($this->cdata);
                 break;
             case "storage:Position":
                 $this->staging->setSubContainerType('position');
                 $this->staging->setSubContainer($this->cdata);
                 break;
             case "Text":
                 if ($this->getPreviousTag() == "Biotope") {
                     $this->object->tag_group_name = 'ecology';
                     $this->object->tag_value = $this->cdata;
                     $this->staging_tags[] = $this->object->addTagGroups();
                 }
                 break;
             case "TitleCitation":
                 if (substr($this->cdata, 0, 7) == 'http://') {
                     $this->addExternalLink($this->cdata);
                 }
                 if ($this->getPreviousTag() == "UnitReference") {
                     $this->addComment(true, 'publication');
                 } else {
                     $this->addComment(true, "identifications");
                 }
                 break;
             case "TypeStatus":
                 $this->staging->setIndividualType($this->cdata);
                 break;
             case "Unit":
                 $this->saveUnit();
                 break;
             case "UnitAssociation":
                 $this->staging->addRelated($this->object);
                 $this->object = null;
                 break;
             case "UnitID":
                 $this->addCode();
                 $this->name = $this->cdata;
                 break;
             case "SourceID":
                 if ($this->cdata != 'Not defined') {
                     $this->addCode('secondary');
                 }
                 break;
             case "UnitOfMeasurement":
                 $this->property->property->setPropertyUnit($this->cdata);
                 break;
             case "Accuracy":
                 $this->property->property->setPropertyAccuracy($this->cdata);
                 break;
             case "UpperValue":
                 $this->property->property->setUpperValue($this->cdata);
                 break;
             case "efg:InformalNameString":
                 $this->addComment(true, "identifications");
                 break;
             case "VerificationLevel":
                 $this->object->determination_status = $this->cdata;
                 break;
             case "storage:Type":
                 $this->code_type = $this->cdata;
                 break;
             case "storage:Value":
                 $this->addCode($this->code_type);
                 break;
             case "Major":
                 $this->version = $this->cdata;
                 break;
             case "Minor":
                 $this->version .= !empty($this->cdata) ? '.' . $this->cdata : '';
                 break;
             case "Version":
                 $this->version_defined = true;
                 $authorized = sfConfig::get('tpl_authorizedversion');
                 Doctrine::getTable('Imports')->find($this->import_id)->setTemplateVersion(trim($this->version))->save();
                 if (!isset($authorized['specimens']) || empty($authorized['specimens']) || isset($authorized['specimens']) && !empty($authorized['specimens']) && !in_array(trim($this->version), $authorized['specimens'])) {
                     $this->errors_reported .= $this->version_error_msg;
                 }
                 break;
         }
     }
     $this->tag = "";
     $this->path = substr($this->path, 0, strrpos($this->path, "/{$name}"));
 }
コード例 #26
0
          <?php 
}
?>
          
        </td>
  </tr> 
  <tr>
  	<th><?php 
echo __('Activity date to');
?>
</th>
        <td>
          <?php 
if (FuzzyDateTime::getDateTimeStringFromArray($people->getActivityDateTo()->getRawValue()) != '0001/01/01') {
    ?>
        
          <?php 
    echo FuzzyDateTime::getDateTimeStringFromArray($people->getActivityDateTo()->getRawValue());
    ?>
          <?php 
} else {
    ?>
          -
          <?php 
}
?>
          
        </td>
  </tr> 
</table>
コード例 #27
0
$t->is(FuzzyDateTime::checkDateTimeStructure($testArray), 'month_missing', 'Date structure test ok');
$testArray['year'] = '';
$t->is(FuzzyDateTime::checkDateTimeStructure($testArray), 'year_missing', 'Date structure test ok');
$testArray['year'] = '1975';
$testArray['month'] = '02';
$testArray['day'] = '';
$testArray['hour'] = '02';
$t->is(FuzzyDateTime::checkDateTimeStructure($testArray), 'day_missing', 'Date structure test ok');
$testArray['year'] = '0001';
$testArray['month'] = '01';
$testArray['day'] = '01';
$fdt = new FuzzyDateTime($testArray);
$t->is($fdt->format('d/m/Y'), '01/01/0001', 'Date lower bound format ok');
$testArray = array('year' => '', 'month' => '', 'day' => '', 'hour' => '', 'minute' => '', 'second' => '');
$fdt = new FuzzyDateTime('2009/12/05');
$t->is_deeply($fdt->getDateTimeMaskedAsArray(), $testArray, 'array is the same');
$testArray = array('year' => 2009, 'month' => 12, 'day' => '', 'hour' => '', 'minute' => '', 'second' => '');
$fdt->setMask(48);
$t->is_deeply($fdt->getDateTimeMaskedAsArray(), $testArray, 'array is the same');
$testArray = array('year' => 2009, 'month' => 12, 'day' => 05, 'hour' => '', 'minute' => '', 'second' => '');
$fdt->setMask(56);
$t->is_deeply($fdt->getDateTimeMaskedAsArray(), $testArray, 'array is the same');
$testArray = array('year' => 2009, 'month' => 2);
$t->is('2009/02/28', FuzzyDateTime::getDateTimeStringFromArray($testArray, false), 'Date are nicelly completed with missing day in fev');
$testArray = array('year' => 2009, 'month' => 12);
$t->is('2009/12/31', FuzzyDateTime::getDateTimeStringFromArray($testArray, false), 'Date are nicelly completed  with missing day in decembre');
$testArray = array('year' => 2009, 'month' => 100);
$t->is('2038/12/31', FuzzyDateTime::getDateTimeStringFromArray($testArray, false), 'Default date is set from wrong dates');
$fdt = new FuzzyDateTime(array('year' => '2005', 'month' => '02', 'day' => '02', 'hour' => '01', 'minute' => 0, 'second' => 0), 63, false, true);
$fdt->setDateFormat('Y/m/d');
$t->is($fdt->getDateMasked(), '2005/02/02 01:00:00', 'Default date is set from wrong dates');
コード例 #28
0
?>
</th>
        <td>
          <?php 
echo FuzzyDateTime::getDateTimeStringFromArray($expedition->getExpeditionFromDate()->getRawValue());
?>
        </td>
      </tr>      
      <tr>
        <th><?php 
echo $form['expedition_to_date']->renderLabel();
?>
</th>
        <td>
          <?php 
echo FuzzyDateTime::getDateTimeStringFromArray($expedition->getExpeditionToDate()->getRawValue());
?>
        </td>
      </tr>
      <tr>
        <td colspan="2" class="search_form">
        <fieldset>
        <legend><?php 
echo __('Members');
?>
</legend>
          <ul>
           <?php 
foreach ($form['Members'] as $form_value) {
    ?>
       
コード例 #29
0
 /** 
  * Get Modification Date as array with masked values
  * @return array an array of masked elements with key year,month,day,hour,minute,second
  * @see FuzzyDateTime::getDateTimeMaskedAsArray
  */
 public function getModificationDateTime()
 {
     $date = new FuzzyDateTime($this->_get('modification_date_time'), $this->_get('modification_date_mask'), true, true);
     return $date->getDateTimeMaskedAsArray();
 }
コード例 #30
0
 /** 
  * Get date From as array with masked values
  * @return array an array of masked elements with key year,month,day,hour,minute,second
  * @see FuzzyDateTime::getDateTimeMaskedAsArray
  */
 public function getDateFrom()
 {
     $date = new FuzzyDateTime($this->_get('date_from'), $this->_get('date_from_mask'), false, true);
     return $date->getDateTimeMaskedAsArray();
 }