Пример #1
0
 /**
  * Called after fields are validated.
  * @param PICTURE $obj
  * @access private
  */
 protected function _post_validate($obj)
 {
     parent::_post_validate($obj);
     $file_name = $this->_selected_file_name();
     if (!$this->value_for('use_upload')) {
         $old_file_name = $obj->file_name;
         $obj->file_name = $file_name;
         $file_name = url_to_file_name($obj->full_file_name());
         $obj->file_name = $old_file_name;
     }
     if ($this->value_for('read_exif')) {
         $url_is_empty = $this->value_is_empty('file_name');
         $use_upload = $this->value_for('use_upload');
         if ($use_upload && !$this->num_errors('upload_file', Form_first_control_for_field) || !$url_is_empty) {
             $class_name = $this->context->final_class_name('IMAGE', 'webcore/util/image.php');
             /** @var IMAGE $img */
             $img = new $class_name();
             $img->set_file($file_name, true);
             if ($img->properties->exists() && $img->properties->time_created->is_valid()) {
                 $this->_exif_date = $img->properties->time_created;
             } else {
                 $this->record_error('day', 'Could not extract date information from the picture.');
             }
         }
     }
     if (!$this->value_for('read_exif') && $this->value_is_empty('day')) {
         $this->record_error('day', 'Please set a date.');
     }
 }
Пример #2
0
 /**
  * Does this form hold valid data for this journal entry?
  * @param JOURNAL $obj
  * @access private
  */
 protected function _post_validate($obj)
 {
     parent::_post_validate($obj);
     if ($this->value_for('lo_temp') > $this->value_for('hi_temp')) {
         $this->record_error('temps', "Please make sure that low temperature is less than the high temperature.");
     }
 }