function restoreState()
 {
     //  must call super
     parent::restoreState();
     // look for the things in the form I need to restore state...
     if (isset($_REQUEST[$this->id])) {
         $inputVal = trim($_REQUEST[$this->id]);
         if (empty($inputVal)) {
             $this->value = NULL;
         } else {
             try {
                 $value = new WFDateTime($inputVal);
                 $value->setTime(0, 0, 0);
                 $this->value = $value;
             } catch (Exception $e) {
                 $this->addError(new WFError($e->getMessage()));
             }
         }
     }
 }
 function restoreState()
 {
     //  must call super
     parent::restoreState();
     try {
         $this->datePicker->restoreState();
         $this->timePicker->restoreState();
         $this->timezonePicker->restoreState();
         if ($this->datePicker->hasErrors() or $this->timePicker->hasErrors() or $this->timezonePicker->hasErrors()) {
             return;
         }
     } catch (Exception $e) {
         die('should not happen. someone is mis-behaving.');
     }
     $datePartEntered = $this->datePicker->value() !== NULL;
     $timePartEntered = trim($this->timePicker->value()) != '';
     if (!$datePartEntered and !$timePartEntered) {
         $this->value = NULL;
         return;
     }
     // parse & validate date
     $datePart = date_parse($this->datePicker->value());
     if ($datePart === false) {
         $this->addError(new WFError("Invalid date."));
     } else {
         if ($datePart['error_count']) {
             foreach ($datePart['errors'] as $err) {
                 $this->addError(new WFError("The date you entered is invalid"));
             }
         }
     }
     // parse & validate time
     if (!$timePartEntered) {
         $this->addError(new WFError("Please enter a time."));
     } else {
         $timePart = date_parse($this->timePicker->value());
         if ($timePart === false) {
             $this->addError(new WFError("Invalid time."));
         } else {
             if ($timePart['error_count']) {
                 foreach ($timePart['errors'] as $err) {
                     $this->addError(new WFError("The time you entered is invalid"));
                 }
             }
         }
     }
     try {
         // calculate timezone
         $tz = $this->timezonePicker->value();
         if ($tz == NULL or $tz === self::SELECT_TIMEZONE_LABEL) {
             if ($this->requireTimezone) {
                 $this->addError(new WFError("Please select a timezone."));
             } else {
                 $tz = new DateTimeZone(date_default_timezone_get());
             }
         } else {
             $tz = new DateTimeZone($tz);
         }
         // assemble datetime+timezone
         if (count($this->errors()) === 0) {
             try {
                 $this->setValue(new WFDateTime("{$datePart['year']}-{$datePart['month']}-{$datePart['day']} {$timePart['hour']}:{$timePart['minute']}:{$timePart['second']}", $tz));
             } catch (Exception $e) {
                 $this->addError(new WFError("Couldn't create datetime: " . $e->getMessage()));
             }
         }
     } catch (Exception $e) {
         $this->addError(new WFError("The timezone you entered is invalid"));
     }
 }
 function restoreState()
 {
     //  must call super
     parent::restoreState();
     if (isset($_REQUEST[$this->getInternalTextFieldId()])) {
         $this->value = $_REQUEST[$this->getInternalTextFieldId()];
     }
 }
 function restoreState()
 {
     //  must call super
     parent::restoreState();
     if (isset($_FILES[$this->name])) {
         if (is_array($_FILES[$this->name]['name'])) {
             throw new Exception("WFYAHOO_widget_Uploader expected a single upload files but multiple found.");
         }
         if ($_FILES[$this->name]['error'] == UPLOAD_ERR_OK) {
             if (is_uploaded_file($_FILES[$this->name]['tmp_name'])) {
                 $this->hasUpload = true;
                 $this->tmpFileName = $_FILES[$this->name]['tmp_name'];
                 $this->originalFileName = $_FILES[$this->name]['name'];
                 $this->mimeType = $_FILES[$this->name]['type'];
             } else {
                 throw new WFException("File: '{$_FILES[$this->name]['name']}' is not a legitimate PHP upload. This is a hack attempt.");
             }
         } else {
             if ($_FILES[$this->name]['error'] != UPLOAD_ERR_NO_FILE) {
                 // send back error+noretry
                 print "UPLOAD ERROR: NO FILE SENT";
                 exit;
             }
         }
     }
 }
 function restoreState()
 {
     //  must call super
     parent::restoreState();
     // look for the things in the form I need to restore state...
     if (isset($_REQUEST[$this->name]) and $this->nullPlaceholder !== $_REQUEST[$this->name]) {
         $this->value = $_REQUEST[$this->name];
     }
 }