/** * Set values like distance, duration, etc. from gps data if they are empty */ private function setValuesFromArraysIfEmpty() { if (!$this->TrainingObject->hasDistance()) { if ($this->TrainingObject->hasArrayDistance()) { $this->TrainingObject->setDistance($this->TrainingObject->getArrayDistanceLastPoint()); } elseif (!$this->TrainingObject->Splits()->areEmpty()) { $this->TrainingObject->setDistance($this->TrainingObject->Splits()->totalDistance()); } } if ($this->TrainingObject->getTimeInSeconds() == 0) { if ($this->TrainingObject->hasArrayTime()) { $this->TrainingObject->setTimeInSeconds($this->TrainingObject->getArrayTimeLastPoint()); } elseif (!$this->TrainingObject->Splits()->areEmpty()) { $this->TrainingObject->setTimeInSeconds($this->TrainingObject->Splits()->totalTime()); } } if ($this->TrainingObject->getPulseAvg() == 0 && $this->TrainingObject->getPulseMax() == 0) { $this->setAvgAndMaxHeartrateFromArray(); } $this->setAvgCadenceFromArray(); $this->setAvgPowerFromArray(); $this->setTemperatureFromArray(); $this->setRunningDynamicsFromArray(); $this->setDistanceFromGPSdata(); }
/** * Get table row for training * @param TrainingObject $TrainingObject * @param int $i */ private function getTableRowFor(TrainingObject &$TrainingObject, $i) { $TrainingObject->updateAfterParsing(); $Data = urlencode(serialize($TrainingObject->getArray())); $Inputs = HTML::checkBox('training-import[' . $i . ']', true); $Inputs .= HTML::hiddenInput('training-data[' . $i . ']', $Data); $Preview = new Preview(new Activity\Entity(array(Activity\Entity::TIMESTAMP => $TrainingObject->getTimestamp(), Activity\Entity::SPORTID => $TrainingObject->get('sportid'), Activity\Entity::TIME_IN_SECONDS => $TrainingObject->getTimeInSeconds(), Activity\Entity::DISTANCE => $TrainingObject->getDistance(), Activity\Entity::IS_TRACK => $TrainingObject->isTrack(), Activity\Entity::HR_AVG => $TrainingObject->getPulseAvg(), Activity\Entity::SPLITS => $TrainingObject->get('splits'), Activity\Entity::ROUTEID => $TrainingObject->hasPositionData()))); $Row = '<td>' . $Inputs . '</td>'; $Row .= '<td>' . $Preview->dateAndTime() . '</td>'; $Row .= '<td>' . $Preview->duration() . '</td>'; $Row .= '<td>' . $Preview->distance() . '</td>'; $Row .= '<td>' . $Preview->sportIcon() . '</td>'; $Row .= '<td>' . $Preview->hrIcon() . '</td>'; $Row .= '<td>' . $Preview->splitsIcon() . '</td>'; $Row .= '<td>' . $Preview->mapIcon() . '</td>'; return $Row; }