/** * Get code * @return string */ private function getCode() { $Code = ' <table class="fullwidth zebra-style c"> <thead> <tr class="b"> <th>' . __('Icon') . '</th> <th>' . Ajax::tooltip(__('Name'), __('Name of the sport')) . '</th> <th>' . Ajax::tooltip(__('kcal/h'), __('Average energy turnover in kilocalories per hour')) . '</th> <th>' . Ajax::tooltip('Ø ' . __('HR'), __('Average heart rate (used for calculation of TRIMP)')) . '</th> <th>' . Ajax::tooltip(__('km'), __('Has a distance')) . '</th> <th>' . Ajax::tooltip(__('Unit'), __('Unit for speed')) . '</th> <th>' . Ajax::tooltip(__('Power'), __('Power is recorded or calculated.')) . '</th> <th>' . Ajax::tooltip(__('Outside'), __('Sport is performed outdoor: activate route, weather, ...')) . '</th> <th>' . Ajax::tooltip(__('Main equipment'), __('Objects of main equipment type can be shown in the activity overview.')) . '</th> <th>' . Ajax::tooltip(__('Calendar view'), __('Mode for displaying activities in calendar')) . '</th> <th>' . Ajax::tooltip(Icon::$CROSS_SMALL, __('A sport can only be deleted if no references exist.')) . '</th> </tr> </thead> <tbody>'; $Sports = SportFactory::AllSports(); $SportCount = SportFactory::CountArray(); foreach ($SportCount as $is => $SC) { if (isset($Sports[$is])) { $Sports[$is]['counts'] = $SC; } } usort($Sports, function ($a, $b) { return !isset($b['counts']) || isset($a['counts']) && (int) $a['counts'] > (int) $b['counts'] ? -1 : 1; }); $Sports[] = array('id' => -1, 'new' => true, 'name' => '', 'img' => 'unknown.gif', 'short' => 0, 'kcal' => '', 'HFavg' => '', 'distances' => 0, 'speed' => Pace::STANDARD, 'power' => 0, 'outside' => '', 'main_equipmenttypeid' => 0); $IconOptions = SportFactory::getIconOptions(); $PaceOptions = Pace::options(); $ShortOptions = array(0 => __('complete row'), 1 => __('only icon')); foreach ($Sports as $Data) { $id = $Data['id']; $isRunning = $id == Runalyze\Configuration::General()->runningSport(); $iconSelect = HTML::selectBox('sport[img][' . $id . ']', $IconOptions, $Data['img'], '', 'fip-select'); $EquipmentTypeOptions = $this->getEquipmentTypeOptions($id); if ($id == -1) { $delete = ''; } elseif (!isset($SportCount[$id]) || $SportCount[$id] == 0) { $delete = '<input type="checkbox" name="sport[delete][' . $id . ']">'; } else { $delete = SearchLink::to('sportid', $id, '<small>(' . $SportCount[$id] . ')</small>'); } $Code .= ' <tr class="' . (isset($Data['new']) ? ' unimportant' : '') . '"> <td>' . $iconSelect . '</td> <td>' . ($isRunning ? '<input type="hidden" name="sport[name][' . $id . ']" value="' . $Data['name'] . '">' . $Data['name'] : '<input type="text" name="sport[name][' . $id . ']" value="' . $Data['name'] . '">') . '</td> <td><input type="text" size="3" name="sport[kcal][' . $id . ']" value="' . $Data['kcal'] . '"></td> <td><input type="text" size="3" name="sport[HFavg][' . $id . ']" value="' . $Data['HFavg'] . '"></td> <td><input type="checkbox" name="sport[distances][' . $id . ']"' . ($Data['distances'] == 1 ? ' checked' : '') . '></td> <td>' . HTML::selectBox('sport[speed][' . $id . ']', $PaceOptions, $Data['speed']) . '</td> <td><input type="checkbox" name="sport[power][' . $id . ']"' . ($Data['power'] == 1 ? ' checked' : '') . '></td> <td><input type="checkbox" name="sport[outside][' . $id . ']"' . ($Data['outside'] == 1 ? ' checked' : '') . '></td> <td>' . HTML::selectBox('sport[main_equipmenttypeid][' . $id . ']', $EquipmentTypeOptions, $Data['main_equipmenttypeid']) . '</td> <td>' . ($isRunning ? '<input type="hidden" name="sport[short][' . $id . ']" value="0">-' : HTML::selectBox('sport[short][' . $id . ']', $ShortOptions, $Data['short'])) . '</td> <td>' . ($isRunning ? '-' : $delete) . '</td> </tr>'; } $Code .= ' </tbody> </table>'; return $Code; }
/** * Get code * @return string */ private function getCode() { $Code = ' <table class="fullwidth zebra-style c"> <thead> <tr class="b"> <th>' . __('Name') . '</th> <th>' . __('Abbreviation') . '</th> <th>' . Ajax::tooltip(__('Sport'), __('A type can only belong to one sport.')) . '</th> <th>' . Ajax::tooltip('Ø ' . __('HR'), __('Average heart rate (used for calculation of TRIMP)')) . '</th> <th>' . Ajax::tooltip(__('Quality?'), __('Quality sessions will be emphasized in your calendar.')) . '</th> <th>' . Ajax::tooltip(__('Race'), __('You need to set one type for running as race type.')) . '</th> <th>' . Ajax::tooltip(__('Calendar view'), __('Mode for displaying activities in calendar')) . '</th> <th>' . Ajax::tooltip(Icon::$CROSS_SMALL, __('A type can only be deleted if no references exist.')) . '</th> </tr> </thead> <tbody>'; $Types = DB::getInstance()->query(' SELECT ty.id, ty.name, ty.abbr, ty.sportid, ty.short, ty.hr_avg, ty.quality_session, ty.accountid, ( SELECT COUNT(*) FROM `' . PREFIX . 'training` tr WHERE tr.typeid = ty.id AND `accountid`="' . SessionAccountHandler::getId() . '" ) AS tcount FROM `' . PREFIX . 'type` ty WHERE `accountid`="' . SessionAccountHandler::getId() . '" ORDER BY `sportid` ASC, `tcount` DESC ')->fetchAll(); //TODO Change all locations where Typeid is used $Types[] = array('id' => -1, 'sportid' => -1, 'name' => '', 'abbr' => '', 'short' => 0, 'hr_avg' => 120, 'quality_session' => 0); $raceID = Configuration::General()->competitionType(); $sportid = false; foreach ($Types as $Data) { $id = $Data['id']; if ($id == -1) { $delete = ''; } elseif ($Data['tcount'] == 0) { $delete = '<input type="checkbox" name="type[delete][' . $id . ']">'; } else { $delete = SearchLink::to('typeid', $id, '<small>(' . $Data['tcount'] . ')</small>'); } $Sports = SportFactory::AllSports(); $ShortOptions = array(0 => __('complete row'), 1 => __('only icon')); $Code .= ' <tr class="' . ($sportid !== false && $sportid != $Data['sportid'] ? 'top-separated-light' : '') . ($id == -1 ? ' unimportant' : '') . '"> <td><input type="text" size="20" name="type[name][' . $id . ']" value="' . $Data['name'] . '"></td> <td><input type="text" size="3" name="type[abbr][' . $id . ']" value="' . $Data['abbr'] . '"></td> <td><select name="type[sportid][' . $id . ']">'; foreach ($Sports as $SData) { $Code .= '<option value="' . $SData['id'] . '"' . HTML::Selected($SData['id'] == $Data['sportid']) . '>' . $SData['name'] . '</option>'; } $Code .= '</select></td> <td> <span class="input-with-unit"> <input type="text" name="type[hr_avg][' . $id . ']" value="' . $Data['hr_avg'] . '" id="type_hr_avg_' . $id . '" class="small-size"> <label for="type_hr_avg_' . $id . '" class="input-unit">bpm</label> </span> </td> <td><input type="checkbox" name="type[quality_session][' . $id . ']"' . ($Data['quality_session'] ? ' checked' : '') . '></td> <td>' . ($id == -1 ? '' : '<input type="radio" name="racetype" value="' . $id . '"' . ($id == $raceID ? ' checked' : '') . '>') . '</td> <td>' . HTML::selectBox('type[short][' . $id . ']', $ShortOptions, $Data['short']) . '</td> <td>' . $delete . '</td> </tr>'; $sportid = $Data['sportid']; } $Code .= ' </tbody> </table>'; return $Code; }
/** * Display less visited cities */ private function displayLonelyCities() { echo '<table class="margin-5 fullwidth zebra-style">'; echo '<thead><tr><th colspan="2">' . __('Rare places') . '</th></tr></thead>'; echo '<tbody>'; $num_x = 0; $LonelyCities = array_reverse($this->Cities); foreach ($LonelyCities as $city => $num) { if ($num_x <= 4) { if ($num_x != $num) { if ($num != 1) { echo '</td></tr>'; } $num_x = $num; echo '<tr><td class="b">' . $num . 'x</td><td>'; } else { echo ', '; } echo SearchLink::to('route', $city, $city, 'like'); } else { echo '</td></tr>'; break; } } echo ' <tr class="no-zebra"> <td colspan="2" class="c"> ' . sprintf(__('You have visited %s different places.'), count($this->Cities)) . ' </td> </tr> </tbody> </table> <p class="c"><em>' . __('Everything seperated by a \' - \' is considered as an individual place.') . '</em></p>'; }
/** * Display table */ public function displayTable() { if (is_null($this->Equipment)) { $this->initTableData(); } echo '<table id="list-of-all-equipment" class="fullwidth zebra-style"> <thead> <tr> <th class="{sorter: \'x\'} small">' . __('x-times') . '</th> <th>' . __('Name') . '</th> <th class="{sorter: \'germandate\'} small">' . __('since') . '</th> <th class="{sorter: \'distance\'}">Ø ' . Runalyze\Configuration::General()->distanceUnitSystem()->distanceUnit() . '</th> <th>Ø ' . __('Pace') . '</th> <th class="{sorter: \'distance\'} small"><small>' . __('max.') . '</small> ' . Runalyze\Configuration::General()->distanceUnitSystem()->distanceUnit() . '</th> <th class="small"><small>' . __('min.') . '</small> ' . __('Pace') . '</th> <th class="{sorter: \'resulttime\'}">' . __('Time') . '</th> <th class="{sorter: \'distance\'}">' . __('Distance') . '</th> <th>' . __('Notes') . '</th> </tr> </thead> <tbody>'; if (!empty($this->Equipment)) { foreach ($this->Equipment as $data) { $Object = new Model\Equipment\Object($data); $in_use = $Object->isInUse() ? '' : ' unimportant'; $Pace = new Pace($Object->duration(), $Object->distance()); $MaxPace = new Pace($data['pace_in_s'], 1); echo '<tr class="' . $in_use . ' r" style="position: relative"> <td class="small">' . $data['num'] . 'x</td> <td class="b l">' . SearchLink::to('equipmentid', $Object->id(), $Object->name()) . '</td> <td class="small">' . $this->formatData($Object->startDate()) . '</td> <td>' . ($data['num'] != 0 ? Distance::format($Object->distance() / $data['num']) : '-') . '</td> <td>' . ($Object->duration() > 0 ? $Pace->asMinPerKm() . '/km' : '-') . '</td> <td class="small">' . Distance::format($data['dist']) . '</td> <td class="small">' . $MaxPace->asMinPerKm() . '/km' . '</td> <td>' . Duration::format($Object->duration()) . '</td> <td>' . Distance::format($Object->totalDistance()) . '</td> <td class="small">' . $Object->notes() . '</td> </tr>'; } } else { echo '<tr><td colspan="9">' . __('You don\'t have any shoes') . '</td></tr>'; } echo '</tbody>'; echo '</table>'; Ajax::createTablesorterFor("#list-of-all-equipment", true); }
/** * Add equipment */ protected function addEquipment() { $Types = array(); $Factory = new \Runalyze\Model\Factory(SessionAccountHandler::getId()); $Equipment = $Factory->equipmentForActivity($this->Context->activity()->id()); foreach ($Equipment as $Object) { $Link = SearchLink::to('equipmentid', $Object->id(), $Object->name()); if (isset($Types[$Object->typeid()])) { $Types[$Object->typeid()][] = $Link; } else { $Types[$Object->typeid()] = array($Link); } } foreach ($Types as $typeid => $links) { $Type = $Factory->equipmentType($typeid); $Value = new BoxedValue(implode(', ', $links), '', $Type->name()); $Value->defineAsFloatingBlock('w100 flexible-height'); $this->BoxedValues[] = $Value; } }
/** * Add tags */ protected function addTags() { $Links = array(); $Factory = new \Runalyze\Model\Factory(SessionAccountHandler::getId()); $SelectedTags = $Factory->tagForActivity($this->Context->activity()->id()); foreach ($SelectedTags as $Object) { $Links[] = SearchLink::to('tagid', $Object->id(), '#' . $Object->tag()); } if (!empty($Links)) { $Value = new BoxedValue(implode(', ', $Links), '', __('Tags')); $Value->defineAsFloatingBlock('w100 flexible-height'); $this->BoxedValues[] = $Value; } }
/** * Display the content * @see PluginStat::displayContent() */ protected function displayContent() { echo '<table class="fullwidth zebra-style">'; echo '<thead><tr><th colspan="2">' . __('All training partners') . '</th></tr></thead>'; echo '<tbody>'; if (empty($this->Partner)) { echo ' <tr> <td class="b">0x</td> <td><em>' . __('You have only trained on your own.') . '</em></td> </tr>'; } else { $row_num = INFINITY; $i = 0; foreach ($this->Partner as $name => $name_num) { if ($row_num == $name_num) { echo ', '; } else { if ($name_num != 1 && $row_num != INFINITY) { echo '</td></tr>'; } $row_num = $name_num; $i++; echo '<tr><td class="b">' . $row_num . 'x</td><td>'; } echo SearchLink::to('partner', $name, $name, 'like'); } echo '</td></tr>'; } echo '</tobdy>'; echo '</table>'; echo '<p class="text">'; echo sprintf(__('You have trained <strong>%sx</strong> in total and out of that <strong>%sx</strong> with a training partner, '), $this->TrainingsTotal, $this->TrainingsWithPartner); echo sprintf(__('that are <strong>%s</strong> %.'), $this->TrainingsTotal == 0 ? 0 : round(100 * $this->TrainingsWithPartner / $this->TrainingsTotal)); echo '</p>'; }
/** * Get search link for given shoe id * @param int $id * @return string */ public static function getSearchLink($id) { $shoes = self::AllShoes(); if (!isset($shoes[$id])) { return '?'; } return SearchLink::to('shoeid', $id, $shoes[$id]['name']); }
/** * Get search-link for one ID * @param int $id * @return string */ public static function getSearchLinkForSingleClothes($id) { return SearchLink::to('clothes', $id, self::NameFor($id)); }