/**
  * Add: vdot/intensity
  */
 protected function addCalculations()
 {
     if ($this->Context->dataview()->vdot()->value() > 0 || $this->Context->activity()->jdIntensity() > 0) {
         $this->BoxedValues[] = new BoxedValue(Helper::Unknown($this->Context->dataview()->vdot()->value(), '-'), '', __('VDOT'), $this->Context->dataview()->vdotIcon());
         $this->BoxedValues[] = new BoxedValue(Helper::Unknown($this->Context->activity()->jdIntensity(), '-'), '', __('Training points'));
     }
 }
 /**
  * Add running dynamics
  */
 protected function addRunningDynamics()
 {
     if ($this->Context->activity()->groundcontact() > 0 || $this->Context->activity()->verticalOscillation() > 0) {
         $Contact = new BoxedValue(Helper::Unknown($this->Context->activity()->groundcontact(), '-'), 'ms', __('Ground contact'));
         $Contact->defineAsFloatingBlock('w50');
         $Oscillation = new BoxedValue(Helper::Unknown(round($this->Context->activity()->verticalOscillation() / 10, 1), '-'), 'cm', __('Vertical oscillation'));
         $Oscillation->defineAsFloatingBlock('w50');
         $this->BoxedValues[] = $Contact;
         $this->BoxedValues[] = $Oscillation;
     }
 }
 /**
  * Show values
  */
 protected function showValues()
 {
     $ModelQuery = new Performance\ModelQuery();
     $ModelQuery->execute(DB::getInstance());
     $TSBmodel = new Performance\TSB($ModelQuery->data(), Configuration::Trimp()->daysForCTL(), Configuration::Trimp()->daysForATL());
     $TSBmodel->calculate();
     $MonotonyQuery = new Performance\ModelQuery();
     $MonotonyQuery->setRange(time() - (Monotony::DAYS - 1) * DAY_IN_S, time());
     $MonotonyQuery->execute(DB::getInstance());
     $Monotony = new Monotony($MonotonyQuery->data());
     $Monotony->calculate();
     $VDOT = Configuration::Data()->vdot();
     $ATLmax = Configuration::Data()->maxATL();
     $CTLmax = Configuration::Data()->maxCTL();
     $ModelATLmax = $TSBmodel->maxFatigue();
     $ModelCTLmax = $TSBmodel->maxFitness();
     if ($ModelATLmax > $ATLmax) {
         Configuration::Data()->updateMaxATL($ModelATLmax);
         $ATLmax = $ModelATLmax;
     }
     if ($ModelCTLmax > $CTLmax) {
         Configuration::Data()->updateMaxCTL($ModelCTLmax);
         $CTLmax = $ModelCTLmax;
     }
     $ATLabsolute = $TSBmodel->fatigueAt(0);
     $CTLabsolute = $TSBmodel->fitnessAt(0);
     $TSBabsolute = $TSBmodel->performanceAt(0);
     $TrimpValues = array('ATL' => round(100 * $ATLabsolute / $ATLmax), 'ATLstring' => Configuration::Trimp()->showInPercent() ? round(100 * $ATLabsolute / $ATLmax) . ' %' : $ATLabsolute, 'CTL' => round(100 * $CTLabsolute / $CTLmax), 'CTLstring' => Configuration::Trimp()->showInPercent() ? round(100 * $CTLabsolute / $CTLmax) . ' %' : $CTLabsolute, 'TSB' => round(100 * $TSBabsolute / max($ATLabsolute, $CTLabsolute, 1)), 'TSBstring' => Configuration::Trimp()->showTSBinPercent() ? sprintf("%+d", round(100 * $TSBabsolute / max($ATLabsolute, $CTLabsolute))) . ' %' : sprintf("%+d", $TSBabsolute));
     $TSBisPositive = $TrimpValues['TSB'] > 0;
     $maxTrimpToBalanced = ceil($TSBmodel->maxTrimpToBalanced($CTLabsolute, $ATLabsolute));
     $restDays = ceil($TSBmodel->restDays($CTLabsolute, $ATLabsolute));
     $JDQuery = Cache::get(self::CACHE_KEY_JD_POINTS);
     if (is_null($JDQuery)) {
         $JDQueryLastWeek = DB::getInstance()->query('SELECT SUM(`jd_intensity`) FROM `' . PREFIX . 'training` WHERE `time`>=' . Time::Weekstart(time() - 7 * DAY_IN_S) . ' AND `time`<' . Time::Weekend(time() - 7 * DAY_IN_S) . ' AND accountid = ' . SessionAccountHandler::getId());
         $JDQueryThisWeek = DB::getInstance()->query('SELECT SUM(`jd_intensity`) FROM `' . PREFIX . 'training` WHERE `time`>=' . Time::Weekstart(time()) . ' AND `time`<' . Time::Weekend(time()) . ' AND accountid = ' . SessionAccountHandler::getId());
         $JDQuery['LastWeek'] = Helper::Unknown($JDQueryLastWeek->fetchColumn(), 0);
         $JDQuery['ThisWeek'] = Helper::Unknown($JDQueryThisWeek->fetchColumn(), 0);
         Cache::set(self::CACHE_KEY_JD_POINTS, $JDQuery, '600');
     }
     $JDPointsLastWeek = $JDQuery['LastWeek'];
     $JDPointsThisWeek = $JDQuery['ThisWeek'];
     $JDPointsPrognosis = round($JDPointsThisWeek / (7 - (Time::Weekend(time()) - time()) / DAY_IN_S) * 7);
     $Values = array(array('show' => $this->Configuration()->value('show_vdot'), 'bars' => array(new ProgressBarSingle(2 * round($VDOT - 30), ProgressBarSingle::$COLOR_BLUE)), 'bar-tooltip' => '', 'value' => number_format($VDOT, 2), 'title' => __('VDOT'), 'small' => '', 'tooltip' => __('Current average VDOT')), array('show' => $this->Configuration()->value('show_basicendurance'), 'bars' => array(new ProgressBarSingle(BasicEndurance::getConst(), ProgressBarSingle::$COLOR_BLUE)), 'bar-tooltip' => '', 'value' => BasicEndurance::getConst() . '&nbsp;&#37;', 'title' => __('Basic&nbsp;endurance'), 'small' => '', 'tooltip' => __('<em>Experimental value!</em><br>100 &#37; means: you had enough long runs and kilometers per week to run a good marathon, based on your current VDOT.')), array('show' => $this->Configuration()->value('show_trimpvalues'), 'bars' => array(new ProgressBarSingle($TrimpValues['ATL'], ProgressBarSingle::$COLOR_BLUE)), 'bar-tooltip' => sprintf(__('Current value: %s<br>Maximal value: %s<br>as percentage: %s &#37;'), $ATLabsolute, $ATLmax, $TrimpValues['ATL']), 'value' => $TrimpValues['ATLstring'], 'title' => __('Fatigue'), 'small' => '(ATL)', 'tooltip' => __('Actual Training Load<br><small>Average training impulse of the last weeks in relation to your maximal value.</small>')), array('show' => $this->Configuration()->value('show_trimpvalues'), 'bars' => array(new ProgressBarSingle($TrimpValues['CTL'], ProgressBarSingle::$COLOR_BLUE)), 'bar-tooltip' => sprintf(__('Current value: %s<br>Maximal value: %s<br>as percentage: %s &#37;'), $CTLabsolute, $CTLmax, $TrimpValues['CTL']), 'value' => $TrimpValues['CTLstring'], 'title' => __('Fitness&nbsp;level'), 'small' => '(CTL)', 'tooltip' => __('Chronical Training Load<br><small>Average training impulse of the last months in relation to your maximal value.</small>')), array('show' => $this->Configuration()->value('show_trimpvalues'), 'bars' => array(new ProgressBarSingle(abs($TrimpValues['TSB']) / 2, $TSBisPositive ? ProgressBarSingle::$COLOR_GREEN : ProgressBarSingle::$COLOR_RED, $TSBisPositive ? 'right' : 'left')), 'bar-tooltip' => 'TSB = CTL - ATL<br>' . sprintf(__('absolute: %s<br>as percentage: %s &#37;'), $CTLabsolute . ' - ' . $ATLabsolute . ' = ' . sprintf("%+d", $TSBabsolute), $TrimpValues['TSB']), 'value' => $TrimpValues['TSBstring'], 'title' => __('Stress&nbsp;Balance'), 'small' => '(TSB)', 'tooltip' => __('Training Stress Balance (= CTL - ATL)<br>&gt; 0: You are relaxing.<br>' . '&lt; 0: You are training hard.')), array('show' => $this->Configuration()->value('show_trimpvalues') && !$TSBisPositive, 'bars' => array(new ProgressBarSingle(100 * $restDays / 7, ProgressBarSingle::$COLOR_BLUE)), 'bar-tooltip' => '', 'value' => $restDays, 'title' => __('Rest&nbsp;days'), 'small' => '', 'tooltip' => __('Rest days needed to reach TSB = 0')), array('show' => $this->Configuration()->value('show_trimpvalues') && $TSBisPositive, 'bars' => array(new ProgressBarSingle(100 * $maxTrimpToBalanced / 1000, ProgressBarSingle::$COLOR_BLUE)), 'bar-tooltip' => '', 'value' => $maxTrimpToBalanced, 'title' => __('Easy&nbsp;TRIMP'), 'small' => '', 'tooltip' => __('Max TRIMP that will still keep you at TSB = 0')), array('show' => $this->Configuration()->value('show_trimpvalues_extra'), 'bars' => array(new ProgressBarSingle($Monotony->valueAsPercentage(), $Monotony->value() > Monotony::CRITICAL ? ProgressBarSingle::$COLOR_RED : $Monotony->value() > Monotony::WARNING ? ProgressBarSingle::$COLOR_ORANGE : ProgressBarSingle::$COLOR_GREEN)), 'bar-tooltip' => 'Monotony = avg(Trimp)/stddev(Trimp)', 'value' => number_format($Monotony->value(), 2), 'title' => __('Monotony'), 'small' => '', 'tooltip' => __('Monotony<br><small>Monotony of your last seven days.<br>Values below 1.5 are preferable.</small>')), array('show' => $this->Configuration()->value('show_trimpvalues_extra'), 'bars' => array(new ProgressBarSingle($Monotony->trainingStrainAsPercentage(), $Monotony->trainingStrainAsPercentage() >= 75 ? ProgressBarSingle::$COLOR_RED : ($Monotony->trainingStrainAsPercentage() >= 50 ? ProgressBarSingle::$COLOR_ORANGE : ProgressBarSingle::$COLOR_GREEN))), 'bar-tooltip' => 'Training strain = sum(Trimp)*Monotony', 'value' => round($Monotony->trainingStrain()), 'title' => __('Training&nbsp;strain'), 'small' => '', 'tooltip' => __('Training strain<br><small>of your last seven days</small>')), array('show' => $this->Configuration()->value('show_jd_intensity'), 'bars' => array(new ProgressBarSingle($JDPointsPrognosis / 2, ProgressBarSingle::$COLOR_LIGHT), new ProgressBarSingle($JDPointsThisWeek / 2, ProgressBarSingle::$COLOR_RED)), 'bar-goal' => $JDPointsLastWeek / 2, 'bar-tooltip' => sprintf(__('This week: %s training points<br>Prognosis: ca. %s training points<br>Last week: %s training points'), $JDPointsThisWeek, $JDPointsPrognosis, $JDPointsLastWeek), 'value' => $JDPointsThisWeek, 'title' => __('Training&nbsp;points'), 'small' => '', 'tooltip' => __('Training intensity by Jack Daniels.<br>' . 'Jack Daniels considers the following levels:<br>' . '50 points: Beginner<br>' . '100 points: Advanced Runner<br>' . '200 points: Pro Runner')));
     $this->showTableForValues($Values);
 }
Esempio n. 4
0
 /**
  * Constructor
  * @param \Runalyze\View\Activity\Context $Context
  */
 public function __construct(\Runalyze\View\Activity\Context $Context)
 {
     $WindDirection = $Context->activity()->weather()->windDegree();
     $CardinalDirection = CardinalDirection::getDirection($WindDirection->value());
     parent::__construct(\Helper::Unknown($CardinalDirection . ' / ' . $WindDirection->string(false), '-'), $WindDirection->unit(), $WindDirection->label());
 }
    /**
     * Display table-row for a competition
     * @param array $data
     */
    private function displayWKTr(array $data)
    {
        $Activity = new Activity\Entity($data);
        $Linker = new Linker($Activity);
        $Dataview = new Dataview($Activity);
        echo '<tr class="r">
				<td>' . $this->getIconForCompetition($data['id']) . '</td>
				<td class="c small">' . $Linker->weekLink() . '</a></td>
				<td class="l"><strong>' . $Linker->linkWithComment() . '</strong></td>
				<td>' . $Dataview->distance(1) . '</td>
				<td>' . $Dataview->duration()->string(Duration::FORMAT_COMPETITION) . '</td>
				<td class="small">' . $Dataview->pace()->value() . '</td>
				<td class="small">' . Helper::Unknown($Activity->hrAvg()) . ' / ' . Helper::Unknown($Activity->hrMax()) . ' bpm</td>
				<td class="small">' . ($Activity->weather()->isEmpty() ? '' : $Activity->weather()->fullString($Activity->isNight())) . '</td>
			</tr>';
    }
Esempio n. 6
0
 /**
  * Constructor
  * @param \Runalyze\View\Activity\Context $Context
  */
 public function __construct(\Runalyze\View\Activity\Context $Context)
 {
     $humidity = $Context->activity()->weather()->humidity();
     parent::__construct(\Helper::Unknown($humidity->string(false), '-'), $humidity->unit(), $humidity->label());
 }
Esempio n. 7
0
 /**
  * Constructor
  * @param \Runalyze\View\Activity\Context $Context
  */
 public function __construct(\Runalyze\View\Activity\Context $Context)
 {
     $Distance = new \Runalyze\Activity\Distance($Context->activity()->distance());
     parent::__construct(\Helper::Unknown(round($Distance->valueInPreferredUnit(), 2), '-'), $Distance->unit(), $Distance->label());
 }
Esempio n. 8
0
 /**
  * Constructor
  * @param \Runalyze\View\Activity\Context $Context
  */
 public function __construct(\Runalyze\View\Activity\Context $Context)
 {
     parent::__construct(\Helper::Unknown(\Runalyze\Activity\VerticalRatio::format($Context->activity()->verticalRatio(), false), '-'), '%', __('Vertical Ratio'));
 }
 /**
  * Set boxed values
  */
 protected function setBoxedValues()
 {
     $Distance = new Distance($this->Context->activity()->distance());
     $this->BoxedValues = array(new BoxedValue(Helper::Unknown($Distance->string(false, false), '-.--'), $Distance->unit(), __('Distance')), new BoxedValue($this->Context->dataview()->duration()->string(), '', __('Time')), new BoxedValue($this->Context->dataview()->elapsedTime(), '', __('Elapsed time')), new BoxedValue($this->Context->dataview()->pace()->value(), $this->Context->dataview()->pace()->appendix(), __('Pace')), new BoxedValue(Helper::Unknown($this->Context->activity()->hrAvg(), '-'), 'bpm', __('&oslash; Heartrate')), new BoxedValue(Helper::Unknown($this->Context->activity()->hrMax(), '-'), 'bpm', __('max. Heartrate')), new BoxedValue($this->Context->activity()->calories(), 'kcal', __('Calories')), new BoxedValue(Helper::Unknown($this->Context->dataview()->vdot()->value(), '-'), '', __('VDOT'), $this->Context->dataview()->vdotIcon()), new BoxedValue($this->Context->activity()->trimp(), '', __('TRIMP')), new Box\Elevation($this->Context));
 }
    /**
     * Display the content (old design)
     */
    protected function displayContentInOldDesign()
    {
        $Weight = '';
        $Pulse = '';
        $Analyse = '';
        $UserData = new UserData(DataObject::$LAST_OBJECT);
        if ($this->Configuration()->value('use_weight')) {
            $Weight = __('Weight') . ': <strong>' . Helper::Unknown($UserData->getWeight(), '-') . ' kg</strong><br>';
        }
        if ($this->Configuration()->value('use_pulse')) {
            $Pulse = Helper::Unknown($UserData->getPulseRest(), '-') . ' bpm / ' . Helper::Unknown($UserData->getPulseMax()) . ' bpm';
        } else {
            $Pulse = Helper::Unknown($UserData->getPulseMax(), '-') . ' bpm';
        }
        if ($this->Configuration()->value('use_body_fat')) {
            $Analyse = __('Fat') . ': ' . Helper::Unknown($UserData->getBodyFat(), '-') . ' &#37;, ' . __('Water') . ': ' . Helper::Unknown($UserData->getWater(), '-') . ' &#37;, ' . __('Muscles') . ': ' . Helper::Unknown($UserData->getMuscles(), '-') . ' &#37;';
        }
        $AnalyseIsHidden = $this->Configuration()->value('use_weight') || $this->Configuration()->value('use_pulse');
        if (!$AnalyseIsHidden && !$this->Configuration()->value('use_body_fat')) {
            return;
        }
        echo '
			<div id="sportler-content">
				<span class="right">' . $Pulse . '</span>
				' . Ajax::flotChange($Weight, 'sportler_flots', 'sportler_weights') . '
				' . Ajax::flotChange($Analyse, 'sportler_flots', 'sportler_analyse', !$AnalyseIsHidden) . '

				<div id="sportler_flots" class="flot-changeable" style="position:relative;width:320px;height:150px;margin:0 auto;">
					<div class="flot ' . Ajax::$IMG_WAIT . '" id="sportler_weights" style="width:320px;height:150px;position:absolute;"></div>
					<div class="flot ' . Ajax::$IMG_WAIT . ($AnalyseIsHidden ? ' flot-hide' : '') . '" id="sportler_analyse" style="width:320px;height:150px;position:absolute;"></div>
				</div>
			</div>';
        include FRONTEND_PATH . '../plugin/' . $this->key() . '/Plot.gewicht.php';
        include FRONTEND_PATH . '../plugin/' . $this->key() . '/Plot.analyse.php';
    }
 /**
  * Show data in table view
  * @param array $data
  * @param array $timeset
  */
 private function showDataInTableView($data, $timeset)
 {
     $Factory = new Factory(SessionAccountHandler::getId());
     if (empty($data)) {
         echo '<p><em>' . __('No data available.') . '</em></p>';
     } else {
         foreach ($data as $dat) {
             $Sport = $Factory->sport($dat['sportid']);
             $result = $dat['count_distance'] >= $dat['count'] / 2 ? Distance::format($dat['distance']) : Duration::format($dat['time_in_s']);
             echo '<p><span class="right"><small><small>(' . sprintf(__('%u-times'), Helper::Unknown($dat['count'], '0')) . ')</small></small> ' . $result . '</span> ';
             echo $Sport->icon()->code() . ' <strong>' . $Sport->name() . '</strong></p>';
         }
     }
     echo '<small class="right">' . __('since') . ' ' . date("d.m.Y", $timeset['start']) . '</small>';
     echo HTML::clearBreak();
 }
Esempio n. 12
0
 /**
  * Constructor
  * @param \Runalyze\View\Activity\Context $Context
  */
 public function __construct(\Runalyze\View\Activity\Context $Context)
 {
     $StrideLength = $Context->dataview()->strideLength();
     parent::__construct(\Helper::Unknown($StrideLength->valueInPreferredUnit(), '-'), $StrideLength->unit(), $StrideLength->label());
 }
Esempio n. 13
0
 /**
  * Constructor
  * @param \Runalyze\View\Activity\Context $Context
  */
 public function __construct(\Runalyze\View\Activity\Context $Context)
 {
     $Elevation = $Context->dataview()->elevation();
     parent::__construct(\Helper::Unknown($Elevation->valueInPreferredUnit(), '-'), $Elevation->unit(), $Elevation->label());
 }
Esempio n. 14
0
 /**
  * @covers Helper::Unknown
  */
 public function testUnknown()
 {
     $this->assertEquals('?', Helper::Unknown(null));
     $this->assertEquals('-', Helper::Unknown(0, '-'));
     $this->assertEquals(1, Helper::Unknown(1, '-'));
     $this->assertEquals('test', Helper::Unknown('test', '-'));
 }
Esempio n. 15
0
 /**
  * Constructor
  * @param \Runalyze\View\Activity\Context $Context
  */
 public function __construct(\Runalyze\View\Activity\Context $Context)
 {
     $PoolLength = new Activity\PoolLength($Context->swimdata()->poollength());
     parent::__construct(\Helper::Unknown($PoolLength->valueInPreferredUnit(), '-'), $PoolLength->unit(), $PoolLength->label());
 }
Esempio n. 16
0
    {
        return $text;
    }
}
if (!function_exists('_e')) {
    function _e($text, $domain = 'runalyze')
    {
        echo $text;
    }
}
if (!function_exists('_n')) {
    function _n($msg1, $msg2, $n, $domain = 'runalyze')
    {
        if ($n == 1) {
            return $msg1;
        }
        return $msg2;
    }
}
if (!function_exists('_ne')) {
    function _ne($msg1, $msg2, $n, $domain = 'runalyze')
    {
        if ($n == 1) {
            echo $msg1;
        }
        echo $msg2;
    }
}
// Load helper class
Helper::Unknown('');
Esempio n. 17
0
 /**
  * Constructor
  * @param \Runalyze\View\Activity\Context $Context
  */
 public function __construct(\Runalyze\View\Activity\Context $Context)
 {
     parent::__construct(\Helper::Unknown(substr($Context->dataview()->gradientInPercent(), 0, -11), '-'), '&#37;', __('&oslash; Gradient'));
 }