/** * Set content right */ protected function setRightContent() { if ($this->Context->trackdata()->has(Trackdata\Object::CADENCE)) { if ($this->Context->activity()->sportid() == Runalyze\Configuration::General()->runningSport()) { $Cadence = new Cadence\Running(); } else { $Cadence = new Cadence\General(); } $Plot = new Activity\Plot\Cadence($this->Context); $this->addRightContent('cadence', $Cadence->label(), $Plot); } if ($this->Context->activity()->sportid() == Runalyze\Configuration::General()->runningSport() && $this->Context->trackdata()->has(Trackdata\Object::TIME) && $this->Context->trackdata()->has(Trackdata\Object::DISTANCE) && $this->Context->trackdata()->has(Trackdata\Object::CADENCE)) { $Plot = new Activity\Plot\StrideLength($this->Context); $this->addRightContent('stridelength', __('Stride length plot'), $Plot); } if ($this->Context->trackdata()->has(Trackdata\Object::VERTICAL_OSCILLATION)) { $Plot = new Activity\Plot\VerticalOscillation($this->Context); $this->addRightContent('verticaloscillation', __('Oscillation plot'), $Plot); } if ($this->Context->trackdata()->has(Trackdata\Object::VERTICAL_RATIO)) { $Plot = new Activity\Plot\VerticalRatio($this->Context); $this->addRightContent('verticalratio', __('Vertical ratio'), $Plot); } if ($this->Context->trackdata()->has(Trackdata\Object::GROUNDCONTACT)) { $Plot = new Activity\Plot\GroundContact($this->Context); $this->addRightContent('groundcontact', __('Ground contact plot'), $Plot); } }
/** * Create from array * @param array $array */ private function createFromArray($array) { $this->asArray = array(); $factor = $this->transformDistanceUnit ? Runalyze\Configuration::General()->distanceUnitSystem()->distanceToKmFactor() : 1; // TODO escaping if (isset($array['km']) && isset($array['time'])) { foreach ($array['km'] as $i => $km) { $this->asArray[] = array('km' => $km * $factor, 'time' => $array['time'][$i], 'active' => !isset($array['active']) || isset($array['active']) && isset($array['active'][$i]) && $array['active'][$i]); } } }
/** * @return string */ protected function getEquipmentTypeCode() { $Code = ' <table class="fullwidth zebra-style c"> <thead> <tr> <th>' . __('Name') . '</th> <th>' . __('Type') . '</th> <th>' . __('max.') . Runalyze\Configuration::General()->distanceUnitSystem()->distanceUnit() . '</th> <th>' . __('max. Time') . '</th> <th>' . __('Sports') . '</th> <th>' . __('delete') . ' ' . $this->getDeleteIcon() . '</th> </tr> </thead> <tbody>'; $Sports = $this->Model->allSports(); $Types = $this->Model->allEquipmentTypes(); $Types[] = new EquipmentType\Entity(); foreach ($Types as $Type) { $isNew = !$Type->hasID(); $id = $isNew ? -1 : $Type->id(); $delete = $isNew ? '' : '<input type="checkbox" class="delete-checkbox" name="equipmenttype[delete][' . $id . ']">'; $sportIDs = $isNew ? array() : $this->Model->sportForEquipmentType($id, true); $MaxDistance = new Distance($Type->maxDistance()); $Code .= ' <tr class="' . ($isNew ? ' unimportant' : '') . '"> <td><input type="text" class="middle-size" name="equipmenttype[name][' . $id . ']" value="' . $Type->name() . '"></td> <td><select name="equipmenttype[input][' . $id . ']""> <option value="' . EquipmentType\Entity::CHOICE_SINGLE . '" ' . HTML::Selected(!$Type->allowsMultipleValues()) . '>' . __('Single choice') . '</option> <option value="' . EquipmentType\Entity::CHOICE_MULTIPLE . '" ' . HTML::Selected($Type->allowsMultipleValues()) . '>' . __('Multiple choice') . '</option> </select></td> <td><span class="input-with-unit"><input type="text" class="small-size" name="equipmenttype[max_km][' . $id . ']" value="' . round($MaxDistance->valueInPreferredUnit()) . '"><label class="input-unit">' . $MaxDistance->unit() . '</label></span></td> <td><input type="text" class="small-size" name="equipmenttype[max_time][' . $id . ']" value="' . ($Type->maxDuration() > 0 ? Duration::format($Type->maxDuration()) : '') . '" placeholder="d hh:mm:ss"></td> <td><input name="equipmenttype[sportid_old][' . $id . ']" type="hidden" value="' . implode(',', $sportIDs) . '"> <select name="equipmenttype[sportid][' . $id . '][]" class="middle-size" multiple>'; foreach ($Sports as $Sport) { $Code .= '<option value="' . $Sport->id() . '"' . HTML::Selected(in_array($Sport->id(), $sportIDs)) . '>' . $Sport->name() . '</option>'; } $Code .= '</select></td> <td>' . $delete . '</td> </tr>'; } $Code .= ' </tbody> </table>'; return $Code; }
/** * Constructor */ public function __construct() { $this->timerStart = 1; $this->WeekStart = Runalyze\Configuration::General()->weekStart(); if (Request::param('y') == self::LAST_6_MONTHS) { $this->timerEnd = 26; } else { if (Request::param('y') == self::LAST_12_MONTHS) { $yearEnd = date('Y') - 1; } else { $yearEnd = (int) Request::param('y'); } $this->timerEnd = date("W", mktime(0, 0, 0, 12, 28, $yearEnd)); // http://de.php.net/manual/en/function.date.php#49457 } parent::__construct(); }
/** * Parse all post values */ public function parsePostData() { $Sports = SportFactory::AllSports(); $Sports[] = array('id' => -1); foreach ($Sports as $Data) { $id = $Data['id']; $columns = array('name', 'img', 'short', 'kcal', 'HFavg', 'distances', 'speed', 'power', 'outside', 'main_equipmenttypeid'); $values = array($_POST['sport']['name'][$id], $_POST['sport']['img'][$id], $_POST['sport']['short'][$id], $_POST['sport']['kcal'][$id], $_POST['sport']['HFavg'][$id], isset($_POST['sport']['distances'][$id]), $_POST['sport']['speed'][$id], isset($_POST['sport']['power'][$id]), isset($_POST['sport']['outside'][$id]), $_POST['sport']['main_equipmenttypeid'][$id]); if (isset($_POST['sport']['delete'][$id]) && $id != Runalyze\Configuration::General()->runningSport()) { DB::getInstance()->deleteByID('sport', (int) $id); } elseif ($Data['id'] != -1) { DB::getInstance()->update('sport', $id, $columns, $values); } elseif (strlen($_POST['sport']['name'][$id]) > 2) { Db::getInstance()->insert('sport', $columns, $values); } } SportFactory::reInitAllSports(); Ajax::setReloadFlag(Ajax::$RELOAD_DATABROWSER); }
/** * 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); }