/** * @return string */ protected function tableFooter() { $Code = '<tbody>'; $Code .= '<tr class="no-zebra"><td colspan="4" class="r">' . __('Average') . ':</td>'; $Code .= '<td class="c">' . ($this->AverageTime != null ? $this->AverageTime->string() : '') . '</td>'; $Code .= '<td></td>'; $Code .= '<td class="c">' . ($this->AveragePace != null ? $this->AveragePace->valueWithAppendix() : '') . '</td>'; $Code .= '<td colspan="4"></td>'; $Code .= '</tr>'; $Code .= '</tbody>'; $Code .= '</table>'; return $Code; }
/** * @return string */ protected function tableFooter() { $Code = '<tbody>'; $Code .= '<tr class="no-zebra"><td colspan="4" class="r">' . __('Average') . ':</td>'; $Code .= '<td class="c">' . ($this->AverageTime != null ? $this->AverageTime->string() : '') . '</td>'; $Code .= $this->DemandedTime->isZero() ? '' : '<td></td>'; $Code .= '<td class="c">' . ($this->AveragePace != null ? $this->AveragePace->valueWithAppendix() : '') . '</td>'; $Code .= $this->DemandedPace->isEmpty() ? '' : '<td></td>'; $Code .= '<td colspan="' . (3 + count($this->AdditionalKeys)) . '"></td>'; $Code .= '</tr>'; $Code .= '</tbody>'; $Code .= '</table>'; $Code .= $this->checkboxToToggleInactiveSplits(); return $Code; }
/** * Parse: time in seconds => time-string * @param mixed $value */ protected static function parseTimeMinutes(&$value) { if ($value == 0) { $value = '0:00'; } else { $duration = new Duration($value * 60); $value = $duration->string('G:i'); } }
/** * Show prognosis for a given distance * @param double $distance */ protected function showPrognosis($distance) { $PB = new PersonalBest($distance); $PBTime = $PB->exists() ? Duration::format($PB->seconds()) : '-'; $Prognosis = new Duration($this->Prognosis->inSeconds($distance)); $Distance = new Distance($distance); $Pace = new Pace($Prognosis->seconds(), $distance, Pace::MIN_PER_KM); echo '<p> <span class="right"> ' . sprintf(__('<small>from</small> %s <small>to</small> <strong>%s</strong>'), $PBTime, $Prognosis->string(Duration::FORMAT_AUTO, 0)) . ' <small>(' . $Pace->valueWithAppendix() . ')</small> </span> <strong>' . $Distance->string(Distance::FORMAT_AUTO, 1) . '</strong> </p>'; }
/** * Get link with icon as text * @return string HTML-link to this training */ public function linkWithSportIcon() { $Sport = new Sport($this->Activity->sportid()); $Time = new Duration($this->Activity->duration()); $tooltip = $Sport->name() . ': ' . $Time->string(); return $this->link($Sport->Icon($tooltip)); }
/** * Compare * @param \Runalyze\Activity\Duration $other * @param boolean $invert [optional] by default, larger is 'better'; set to true to invert that * @param boolean $raw [optional] * @throws \InvalidArgumentException * @return string */ public function compareTo(Duration $other, $invert = false, $raw = false) { if ($this->seconds() == 0 || $other->seconds() == 0) { return ''; } $CompareTime = new Duration(round(abs($this->seconds() - $other->seconds()))); $isPositive = !$invert ? $this->seconds() > $other->seconds() : $this->seconds() <= $other->seconds(); return $this->formatComparison($CompareTime->string(), $isPositive, $raw); }
?> </th> <?php } ?> </tr> </thead> <tbody> <?php foreach ($this->Range as $sPer400m) { ?> <tr> <?php foreach ($this->Configuration()->value('pace_distances') as $km) { ?> <?php $Duration->fromSeconds($km * $sPer400m / 0.4); ?> <td><?php echo $Duration->string('auto', $km >= 0.4 ? 0 : 1); ?> </td> <?php } ?> </tr> <?php } ?> </tbody> </table>
/** * @param \Runalyze\Model\EquipmentType\Object $EquipmentType * @param boolean $inuse */ protected function showListFor(Model\EquipmentType\Object $EquipmentType, &$inuse) { $max = 0; $showDistance = $EquipmentType->hasMaxDistance(); $hasMaxDuration = $showDistance || $EquipmentType->hasMaxDuration(); $allEquipment = DB::getInstance()->query('SELECT * FROM `' . PREFIX . 'equipment` WHERE `typeid`="' . $EquipmentType->id() . '" AND `accountid`="' . SessionAccountHandler::getId() . '" ORDER BY ISNULL(`date_end`) DESC, `distance` DESC')->fetchAll(); foreach ($allEquipment as $data) { $Object = new Model\Equipment\Object($data); $Distance = new Distance($Object->totalDistance()); $Duration = new Duration($Object->duration()); if ($inuse && !$Object->isInUse()) { echo '<div id="hiddenequipment" style="display:none;">'; $inuse = false; } if ($max == 0) { $max = $Object->duration(); } echo '<p style="position:relative;"> <span class="right">' . ($showDistance ? $Distance->string() : $Duration->string()) . '</span> <strong>' . SearchLink::to('equipmentid', $Object->id(), $Object->name()) . '</strong> ' . $this->getUsageImage($showDistance ? $Object->totalDistance() / $EquipmentType->maxDistance() : $Object->duration() / ($hasMaxDuration ? $EquipmentType->maxDuration() : $max)) . ' </p>'; } if (empty($allEquipment)) { echo HTML::em(__('You don\'t have any equipment')); } if (!$inuse) { echo '</div>'; } }
/** * Initialize line-data-array for 'Stunden' * @param array $dat */ private function initStundenData($dat) { if ($dat['s'] > 0) { $duration = new Duration($dat['s']); $text = $duration->string(Duration::FORMAT_WITH_HOURS); } else { $text = NBSP; } $this->StundenData[] = array('i' => $dat['i'], 'text' => $text); }
/** * Show prognosis for a given distance * @param double $distance */ protected function showPrognosis($distance) { $PB = new PersonalBest($distance); $PB->lookupWithDetails(); $PBTime = $PB->exists() ? Duration::format($PB->seconds()) : '-'; $PBString = $PB->exists() ? Ajax::trainingLink($PB->activityId(), $PBTime, true) : $PBTime; $Prognosis = new Duration($this->Prognosis->inSeconds($distance)); $Distance = new Distance($distance); $Pace = new Pace($Prognosis->seconds(), $distance, SportFactory::getSpeedUnitFor(Configuration::General()->runningSport())); echo '<p> <span class="right"> ' . sprintf(__('<small>from</small> %s <small>to</small> <strong>%s</strong>'), $PBString, $Prognosis->string(Duration::FORMAT_AUTO, 0)) . ' <small>(' . $Pace->valueWithAppendix() . ')</small> </span> <strong>' . $Distance->stringAuto(true, 1) . '</strong> </p>'; }
/** * Format time for output * @param int $seconds * @return string */ protected function formatTime($seconds) { $Duration = new Duration($seconds); return $Duration->string(Duration::FORMAT_WITH_HOURS); }
/** * Get link with icon as text * @param string $tooltipCssClass optional, e.g. 'atRight' * @return string HTML-link to this training */ public function linkWithSportIcon($tooltipCssClass = '') { $Time = new Duration($this->Activity->duration()); $Factory = new \Runalyze\Model\Factory(\SessionAccountHandler::getId()); $Sport = $Factory->sport($this->Activity->sportid()); $code = $Sport->icon()->code(); $Tooltip = new \Runalyze\View\Tooltip($Sport->name() . ': ' . $Time->string()); $Tooltip->setPosition($tooltipCssClass); $Tooltip->wrapAround($code); return $this->link($code); }
/** * Show boxed values * @param array $data */ private function showDataAsBoxedValues($data) { $Factory = new Factory(SessionAccountHandler::getId()); foreach ($data as $dat) { // TODO: Define the decision (distance or time) somehow in the configuration $Sport = $Factory->sport($dat['sportid']); $Value = new BoxedValue(); $Value->setIcon($Sport->icon()->code()); $Value->setInfo($Sport->name()); $Value->defineAsFloatingBlock('w50'); if ($dat['count_distance'] >= $dat['count'] / 2) { $Distance = new Distance($dat['distance']); $Value->setValue($Distance->string(false, false, false)); $Value->setUnit($Distance->unit()); } else { $Duration = new Duration($dat['time_in_s']); $Value->setValue($Duration->string(Duration::FORMAT_WITH_HOURS)); } $Value->display(); } }