/** * Method for getting the right symbol(s) * @see PluginPanel::getRightSymbol() */ protected function getRightSymbol() { $Links = ''; $Links .= '<li>' . Ajax::window('<a href="plugin/' . $this->key() . '/window.sportler.php" ' . Ajax::tooltip('', __('Add data'), true, true) . '>' . Icon::$ADD . '</a>') . '</li>'; $Links .= '<li>' . Ajax::window('<a href="plugin/' . $this->key() . '/window.sportler.table.php" ' . Ajax::tooltip('', __('Show table'), true, true) . '>' . Icon::$TABLE . '</a>') . '</li>'; return '<ul>' . $Links . '</ul>'; }
/** * Get own links for toolbar navigation * @return array */ protected function getToolbarNavigationLinks() { $LinkList = array(); if ($this->Configuration()->value('for_weather')) { $LinkList[] = '<li>' . Ajax::window('<a href="plugin/' . $this->key() . '/window.php">' . Ajax::tooltip(Icon::$LINE_CHART, __('Show temperature plots')) . '</a>') . '</li>'; } return $LinkList; }
/** * Add field * @param \Runalyze\Configuration\Handle $Handle * @param array $options * @return \FormularField */ public function FieldFor(Handle $Handle, array $options = array()) { $options = array_merge(array('label' => $Handle->key(), 'tooltip' => '', 'unit' => '', 'size' => '', 'css' => '', 'layout' => ''), $options); $label = !empty($options['tooltip']) ? \Ajax::tooltip($options['label'], $options['tooltip']) : $options['label']; $Field = $this->createFieldFor($Handle, $label); $this->setAttributesToField($Field, $options); return $Field; }
/** * Init toolbar links */ private function initToolbarLinks() { $Linker = new Linker($this->Context->activity()); if (!Request::isOnSharedPage()) { $this->initShareLinks($Linker); $this->initExportLinks(); $this->initEditLinks($Linker); } $this->ToolbarLinks[] = Ajax::tooltip($Linker->weekLink(), '<em>' . __('Show week') . '</em><br>' . $this->Context->dataview()->weekday() . ', ' . $this->Context->dataview()->dateAndDaytime()); }
/** * Get link to shared list for current user * @param string $text [optional] * @return string */ public static function getListLinkForCurrentUser($text = null) { if (!Configuration::Privacy()->listIsPublic()) { return ''; } if (is_null($text)) { $text = Icon::$ATTACH; } return '<a href="shared/' . SessionAccountHandler::getUsername() . '/" target="_blank" ' . Ajax::tooltip('', __('Public list'), false, true) . '>' . $text . '</a>'; }
/** * Get own links for toolbar navigation * @return array */ protected function getToolbarNavigationLinks() { $LinkList = array(); $LinkList[] = '<li>' . Ajax::window('<a href="plugin/' . $this->key() . '/window.php">' . Ajax::tooltip(Icon::$LINE_CHART, __('Show temperature plots')) . '</a>') . '</li>'; $LinkList[] = '<li class="with-submenu"><span class="link">' . __('Equipment types') . '</span><ul class="submenu">'; foreach ($this->EquipmentTypes as $EqType) { $LinkList[] = '<li>' . $this->getInnerLink($EqType->name(), false, false, $EqType->id()) . '</li>'; } $LinkList[] = '</ul></li>'; return $LinkList; }
/** * Init toolbar links */ private function initToolbarLinks() { $Linker = new Linker($this->Context->activity()); if ($this->Context->activity()->isPublic()) { $this->ToolbarLinks[] = '<a href="' . $Linker->publicUrl() . '" target="_blank">' . Icon::$ATTACH . ' ' . __('Public link') . '</a>'; } if (!Request::isOnSharedPage()) { $this->ToolbarLinks[] = Ajax::window('<a href="' . ExporterWindow::$URL . '?id=' . $this->Context->activity()->id() . '">' . Icon::$DOWNLOAD . ' ' . __('Export') . '</a> ', 'small'); $this->ToolbarLinks[] = Ajax::window('<a href="' . $Linker->editUrl() . '">' . Icon::$EDIT . ' ' . __('Edit') . '</a> ', 'small'); } $this->ToolbarLinks[] = Ajax::tooltip($Linker->weekLink(), '<em>' . __('Show week') . '</em><br>' . $this->Context->dataview()->weekday() . ', ' . $this->Context->dataview()->dateAndDaytime()); }
/** * Method for getting the right symbol(s) */ protected function getRightSymbol() { $Links = ''; $Links .= '<li class="with-submenu">' . Ajax::link(__('Type'), 'panel-' . $this->id(), Plugin::$DISPLAY_URL . '?id=' . $this->id()); $Links .= '<ul class="submenu">'; foreach ($this->AllTypes as $Type) { $active = $Type['id'] == (int) $this->Configuration()->value('type'); $Links .= '<li' . ($active ? ' class="active"' : '') . '>' . Ajax::link($Type['name'], 'panel-' . $this->id(), Plugin::$DISPLAY_URL . '?id=' . $this->id() . '&type=' . $Type['id']) . '</li>'; } $Links .= '</ul>'; $Links .= '</li>'; $Links .= '<li>' . Ajax::window('<a href="' . ConfigTabs::$CONFIG_URL . '?key=config_tab_equipment" ' . Ajax::tooltip('', __('Add/Edit equipment'), true, true) . '>' . Icon::$ADD . '</a>') . '</li>'; $Links .= '<li>' . Ajax::window('<a href="plugin/' . $this->key() . '/window.equipment.table.php" ' . Ajax::tooltip('', __('Show all equipment'), true, true) . '>' . Icon::$TABLE . '</a>') . '</li>'; return '<ul>' . $Links . '</ul>'; }
/** * Get code * @return string */ private function getCode() { $Code = ' <table class="c fullwidth zebra-style" id="conf-tab-dataset"> <thead> <tr> <th> </th> <th>' . Ajax::tooltip(__('Display'), __('The information will be shown directly in the row.')) . '</th> <th colspan="2">' . Ajax::tooltip(__('Summary'), __('The value will be summarized for the sport.')) . '</th> <th>' . Ajax::tooltip(__('Order'), __('Indicates the order of appearance.')) . '</th> <th>' . Ajax::tooltip(__('CSS-Class'), __('\'c\': centered<br>\'l\': left-aligned<br>\'small\': small<br>\'b\': bold')) . '</th> <th>' . Ajax::tooltip(__('CSS-Style'), __('any CSS-Code')) . '</th> <th>' . __('Example') . '</th> </tr> </thead> <tbody>'; $Labels = new DatasetLabels(); $DatasetObject = new Dataset(); $DatasetObject->setActivityData($this->getExampleTraining()); $Dataset = DB::getInstance()->query('SELECT *, (`position` = 0) as `hidden` FROM `' . PREFIX . 'dataset` WHERE accountid = ' . SessionAccountHandler::getId() . ' ORDER BY (`position` > 0) DESC, `position` ASC')->fetchAll(); foreach ($Dataset as $pos => $Data) { $disabled = $Data['modus'] == 3 ? ' disabled' : ''; $checked_2 = $Data['modus'] >= 2 ? ' checked' : ''; $checked = $Data['summary'] == 1 ? ' checked' : ''; $SummarySign = ''; switch ($Data['summary_mode']) { case 'YES': case 'NO': $checked .= ' disabled'; break; case 'AVG': $SummarySign = 'Ø'; break; case 'SUM': $SummarySign = '∑'; break; case 'MAX': $SummarySign = 'max'; break; } $Example = $DatasetObject->getDataset($Data['name']); $Code .= ' <tr class="r" id="' . $Data['id'] . '_tr"> <td class="l b">' . $Labels->get($Data['name']) . '</td> <td class="c"> <input type="hidden" name="' . $Data['id'] . '_modus_3" value="' . $Data['modus'] . '"> <input type="checkbox" name="' . $Data['id'] . '_modus"' . $checked_2 . $disabled . '> </td> <td class="c"><input type="checkbox" name="' . $Data['id'] . '_summary"' . $checked . '></td> <td class="c small">' . $SummarySign . '</td> <td class="c"> <input class="dataset-position" type="text" name="' . $Data['id'] . '_position" value="' . ($pos + 1) . '" size="2"> <span class="link" onclick="datasetMove(' . $Data['id'] . ', \'up\')">' . Icon::$UP . '</span> <span class="link" onclick="datasetMove(' . $Data['id'] . ', \'down\')">' . Icon::$DOWN . '</span> </td> <td class="c"><input type="text" name="' . $Data['id'] . '_class" value="' . $Data['class'] . '" size="7"></td> <td class="c"><input type="text" name="' . $Data['id'] . '_style" value="' . $Data['style'] . '" size="15"></td> <td class="' . $Data['class'] . '" style="' . $Data['style'] . '">' . $Example . '</td> </tr>'; } $Code .= ' </tbody> </table>'; $Code .= Ajax::wrapJS(' function datasetMove(id, way) { var pos = parseInt($("input[name=\'"+id+"_position\']").val()), tr = $("#"+id+"_tr"); if (way == "up" && pos > 1) { $("#"+id+"_tr .dataset-position").val(pos-1); tr.prev().find(".dataset-position").val(pos); tr.prev().toggleClass("swapped"); tr.prev().before(tr); } else if (way == "down" && tr.next().find(".dataset-position").val() > 0) { $("#"+id+"_tr .dataset-position").val(pos+1); tr.next().find(".dataset-position").val(pos); tr.next().toggleClass("swapped"); tr.next().after(tr); } tr.toggleClass("swapped"); } '); return $Code; }
/** * @return string */ protected function getTableHeader() { return '<table class="c fullwidth zebra-style" id="conf-tab-dataset"> <thead> <tr> <th> </th> <th> </th> <th>' . Ajax::tooltip(__('Display'), __('The information will be shown directly in the row.')) . '</th> <th>' . Ajax::tooltip(__('Order'), __('Indicates the order of appearance.')) . '</th> <th>' . Ajax::tooltip(__('CSS-Style'), __('any CSS-Code')) . '</th> <th>' . __('Example') . '</th> </tr> </thead> <tbody>'; }
/** * Get link for editing a shoe * @param int $id * @return string */ private function editLinkFor($id) { return Ajax::window('<a href="plugin/' . $this->key() . '/window.schuhe.php?id=' . $id . '">' . Ajax::tooltip(Icon::$EDIT, __('Edit')) . '</a>'); }
/** * Get ajax-link for searching * @return string */ protected function getNaviSearchLink() { return Ajax::window('<a href="' . SearchLink::$WINDOW_URL . '" ' . Ajax::tooltip('', __('Search for an activity'), false, true) . '>' . Icon::$SEARCH . '</a>', 'big'); }
/** * Show paces */ protected function showPaces() { echo '</div>'; echo '<div class="panel-content panel-sub-content">'; echo '<table class="fullwidth nomargin">'; $Paces = $this->getArrayForPaces(); $VDOT = new VDOT(Configuration::Data()->vdot()); foreach ($Paces as $Pace) { $DisplayedString = '<strong>' . $Pace['short'] . '</strong>'; echo '<tr>'; echo '<td>' . Ajax::tooltip($DisplayedString, $Pace['description']) . '</td>'; echo '<td class="r"><em>' . Duration::format($VDOT->paceAt($Pace['limit-high'] / 100)) . '</em> - <em>' . Duration::format($VDOT->paceAt($Pace['limit-low'] / 100)) . '</em>/km</td>'; echo '</tr>'; } echo '</table>'; }
/** * 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 standard values */ protected function displayStandardValues() { if ($this->manualElevation != $this->calculatedElevation) { $Linker = new Runalyze\View\Activity\Linker($this->Context->activity()); $useCalculatedValueLink = Ajax::window('<a class="small as-input" href="' . $Linker->urlToElevationInfo('use-calculated-value=true') . '">» ' . __('apply data') . '</a>', 'small'); } else { $useCalculatedValueLink = ''; } $Fieldset = new FormularFieldset(__('General data')); $Fieldset->setHtmlCode(' <div class="w50"> <label>' . Ajax::tooltip(__('manual value'), __('If you did not insert a value by hand, this value has been calculated.')) . '</label> <span class="as-input">' . $this->manualElevation . ' m</span> </div> <div class="w50"> <label>' . __('Lowest point') . '</label> <span class="as-input">' . $this->lowestPoint . ' m</span> </div> <div class="w50"> <label>' . Ajax::tooltip(__('calculated value'), __('This value is calculated with your current configuration. The saved value may be outdated.')) . '</label> <span class="as-input">' . $this->calculatedElevation . ' m</span> ' . $useCalculatedValueLink . ' </div> <div class="w50"> <label>' . __('Highest point') . '</label> <span class="as-input">' . $this->highestPoint . ' m</span> </div> <div class="w50"> <label>ø ' . __('Gradient') . '</label> <span class="as-input">' . $this->Context->dataview()->gradientInPercent() . '</span> </div> <div class="w50"> <label>' . __('Up/Down') . '</label> <span class="as-input">+' . $this->Context->route()->elevationUp() . 'm / -' . $this->Context->route()->elevationDown() . 'm</span> </div> '); $Fieldset->display(); }
/** * Get link for create window */ public static function link() { return Ajax::window('<a href="' . self::$URL . '" ' . Ajax::tooltip('', __('Add workout'), false, true) . '>' . Icon::$ADD . '</a>', 'small'); }
/** * Get fieldset for settings * @return \FormularFieldset */ private function getSettingsFieldset() { FormularInput::setStandardSize(FormularInput::$SIZE_MIDDLE); $Fieldset = new FormularFieldset(__('Settings')); $Fieldset->addField(new FormularCheckbox('RUNALYZE_DEBUG', __('Debug mode'))); $Fieldset->addField(new FormularCheckbox('USER_CANT_LOGIN', __('Maintenance mode'))); $Fieldset->addField(new FormularCheckbox('USER_CAN_REGISTER', __('Users can register'))); $Fieldset->addField(new FormularInput('GARMIN_API_KEY', Ajax::tooltip(__('Garmin API-key'), __('Needed for any online-version of the Garmin Communicator<br>see http://developer.garmin.com/web-device/garmin-communicator-plugin/get-your-site-key/')))); $Fieldset->addField(new FormularInput('PERL_PATH', __('Perl Path'))); $Fieldset->addField(new FormularInput('TTBIN_PATH', __('TTBIN Converter Path'))); $Fieldset->addField(new FormularInput('MAIL_SENDER', __('Sender e-mail'))); $Fieldset->addField(new FormularInput('MAIL_NAME', __('Sender e-mail name'))); $Fieldset->addField(new FormularInput('SMTP_HOST', __('SMTP: host'))); $Fieldset->addField(new FormularInput('SMTP_PORT', __('SMTP: port'))); $Fieldset->addField(new FormularInput('SMTP_SECURITY', __('SMTP: encryption'))); $Fieldset->addField(new FormularInput('SMTP_USERNAME', __('SMTP: username'))); $Fieldset->addField(new FormularInputPassword('SMTP_PASSWORD', __('SMTP: password'))); $Fieldset->addField(new FormularInput('OPENWEATHERMAP_API_KEY', Ajax::tooltip(__('OpenWeatherMap API-Key'), __('Loading weather data requires an api key, see openweathermap.org/appid')))); $Fieldset->addField(new FormularInput('NOKIA_HERE_APPID', Ajax::tooltip(__('Nokia/Here App-ID'), __('Nokia maps require an app-id/-token, see developer.here.com')))); $Fieldset->addField(new FormularInput('NOKIA_HERE_TOKEN', Ajax::tooltip(__('Nokia/Here Token'), __('Nokia maps require an app-id/-token, see developer.here.com')))); $Fieldset->addField(new FormularSubmit(__('Save'), '')); $Fieldset->setLayoutForFields(FormularFieldset::$LAYOUT_FIELD_W100); if (!is_writable(FRONTEND_PATH . '../data/config.php')) { $Fieldset->addError(__('<strong>data/config.php</strong> is not writable') . ', <em>(chmod = ' . substr(decoct(fileperms(FRONTEND_PATH . '../data/config.php')), 1) . ')</em> ' . __('Changes can\'t be saved.')); } return $Fieldset; }
/** * Cut a string if it is longer than $cut (default CUT_LENGTH) * @param string $text * @param int $cut [optional] */ public static function Cut($text, $cut = 0) { if ($cut == 0) { $cut = CUT_LENGTH; } if (mb_strlen($text) >= $cut) { return Ajax::tooltip(mb_substr($text, 0, $cut - 3) . '...', $text); } return $text; }
/** * Display a single dataset * @param array $set */ private function displayDataset($set) { if ($this->isSummary && $set['summary'] == 0) { echo HTML::emptyTD(); } else { $Labels = new DatasetLabels(); echo HTML::td('<span ' . Ajax::tooltip('', $Labels->get($set['name']), false, true) . '>' . $this->getDataset($set['name']) . '</span>', $set['class'], $set['style']); } }
/** * Show paces */ protected function showPaces() { echo '</div>'; echo '<div class="panel-content panel-sub-content">'; echo '<table class="fullwidth nomargin">'; $Paces = $this->getArrayForPaces(); $VDOT = new VDOT(Configuration::Data()->vdot()); $PaceObject = new Runalyze\Activity\Pace(0, 1, SportFactory::getSpeedUnitFor(Configuration::General()->runningSport())); foreach ($Paces as $Pace) { $DisplayedString = '<strong>' . $Pace['short'] . '</strong>'; echo '<tr>'; echo '<td>' . Ajax::tooltip($DisplayedString, $Pace['description']) . '</td>'; echo '<td class="r"><em>' . $PaceObject->setTime($VDOT->paceAt($Pace['limit-high'] / 100))->value() . '</em> - <em>' . $PaceObject->setTime($VDOT->paceAt($Pace['limit-low'] / 100))->value() . '</em>' . $PaceObject->appendix() . '</td>'; echo '</tr>'; } echo '</table>'; }
/** * Display labels */ public function displayTableLabels() { if (Configuration::DataBrowser()->showEditLink()) { echo HTML::emptyTD(); } $Labels = new DatasetLabels(); foreach ($this->data as $set) { echo '<td><span ' . Ajax::tooltip('', $Labels->get($set['name']), false, true) . '>' . $Labels->get($set['name']) . '</span></td>'; } }
/** * As icon with tooltip * @return string */ public function asIconWithTooltip() { if (!$this->areEmpty()) { return Ajax::tooltip(Icon::$CLOCK, $this->asReadableString()); } return ''; }
/** * Method for getting the right symbol(s) * @see PluginPanel::getRightSymbol() */ protected function getRightSymbol() { $Links = ''; $Links .= '<li>' . Ajax::window('<a href="plugin/' . $this->key() . '/window.plot.php" ' . Ajax::tooltip('', __('Show prognosis trend'), true, true) . '>' . Icon::$LINE_CHART . '</a>') . '</li>'; $Links .= '<li>' . Ajax::window('<a href="plugin/' . $this->key() . '/window.php" ' . Ajax::tooltip('', __('Prognosis calculator'), true, true) . '>' . Icon::$CALCULATOR . '</a>') . '</li>'; return '<ul>' . $Links . '</ul>'; }
/** * Get uninstall link * @param string $name [optional] default: delete-icon * @return string */ public static function uninstallLink($key, $name = '') { if ($name == '') { $name = Icon::$DELETE; } return Ajax::window('<a href="' . self::UNINSTALL_URL . '?key=' . $key . '">' . Ajax::tooltip($name, __('Uninstall plugin')) . '</a>'); }
/** * Add field: send to multi editor */ private function addFieldSendToMultiEditor() { $Label = Ajax::tooltip(__('Send to multi editor'), sprintf(__('Our multi editor is limited to a maximum of %d activities.'), SearchResults::MAX_LIMIT_FOR_MULTI_EDITOR), 'atRight'); $Field = new FormularCheckbox('send-to-multi-editor', $Label); $Field->setLayout(FormularFieldset::$LAYOUT_FIELD_W33); $this->Fieldset->addField($Field); }
/** * 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; }
/** * As string with tooltip * @return string */ public final function unitAsStringWithTooltip() { return Ajax::tooltip($this->unitAsString(), $this->unitExplanation()); }
/** * Get sport icon * @param string $gif filename.gif * @param string tooltip * @return string */ public static function getSportIconForGif($gif, $tooltip = '') { return Ajax::tooltip('<i class="' . $gif . '""></i>', $tooltip); }
/** * Get ajax-link for showing week-kilometer * @return string */ protected function getWeekKmLink() { return Ajax::window('<a href="' . self::getUrlForWeekKm() . '">' . Ajax::tooltip(Icon::$BARS_SMALL, __('Activity per week')) . '</a>'); }
/** * Get additional stuff for tooltip * @return string */ protected function getTooltip() { if (!empty($this->Tooltip)) { return ' ' . Ajax::tooltip('', $this->Tooltip, false, true); } return ''; }