Ejemplo n.º 1
0
 function display($tpl = null)
 {
     $user = JFactory::getUser();
     $app = JFactory::getApplication();
     $params = $app->getParams();
     $navbar = $params->get('navbar');
     $doma = $params->get('doma_installed');
     $item = $this->get('Item');
     $this->item = $item;
     $this->form = $this->get('Form');
     if ($doma) {
         $maplist = $this->get('Maplist');
         $maps = $this->get('Maps');
     }
     $competition = $this->get('Competition');
     $complists = ListHTraininglogsHelper::getcomplists($user->id);
     $medialist = $this->get('Medialist');
     $media = $this->get('Media');
     $istemphr = $this->get('Ishr');
     // are there HR data in temp table
     $splittimes = $this->get('Splittimes');
     $groupparams = HTraininglogsHelper::getGroupparams();
     $startpoint = $this->get('Startpoint');
     if ($istemphr) {
         $hrdata = $this->get('Hrdata');
     } else {
         $intensities = $this->get('Intensities');
         $technics = $this->get('Technics');
         $tools = $this->get('Tools');
         $this->intensity = $intensities;
         $this->technic = $technics;
         $this->tool = $tools;
         $this->groupparams = $groupparams;
     }
     $this->form->bind($item);
     if (count($errors = $this->get('Errors'))) {
         JError::raiseWarning(500, implode("\n", $errors));
         return false;
     }
     $this->item = $item;
     $this->competition = $competition;
     $this->istemphr = $istemphr;
     $this->navbar = $navbar;
     $this->maplist = $maplist;
     $this->medialist = $medialist;
     $this->complists = $complists;
     $this->maps = $maps;
     $this->media = $media;
     $this->split = $splittimes;
     $this->startpoint = $startpoint;
     $this->_prepareDocument();
     if ($istemphr) {
         graphHTraininglogsHelper::prepare_daygraph($hrdata, $groupparams);
         gpsHTraininglogsHelper::prepare_gps_track($hrdata, $groupparams, $hrdata[0]->gpsdetails);
     }
     parent::display($tpl);
 }
Ejemplo n.º 2
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $params = $app->getParams();
     $Itemid = JRequest::getVar('Itemid');
     $state = $this->get('State');
     $items = $this->get('Items');
     $search = $this->get('Searchfilter');
     $filterlists = $this->get('Filterlists');
     $this->groupparams = HTraininglogsHelper::getGroupparams();
     $yachs = JRequest::getVar('yachs', 'ttime');
     $sport = JRequest::getVar('sport', '*');
     if (count($items) > 0) {
         $sumitems = $this->get('Sumitems');
         $graphdata = $this->get('Graphdata');
         $gps = $this->get('Gps');
         $this->graphdata = $graphdata;
         $this->gps = $gps;
     }
     //   	JLoader::register('HTraininglogsHelper', JPATH_COMPONENT.'/helpers/helper.php');
     //       $sumitems= HTraininglogsHelper::getSum($period);
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     // Check whether SearchPage access level allows access.
     $user = JFactory::getUser();
     $this->state = $state;
     $this->items = $items;
     $this->search = $search;
     $this->sumitems = $sumitems;
     //		$this->period = $period;
     $this->Itemid = $Itemid;
     $this->filterlists = $filterlists;
     //print_r($this->filterlists->oparr.'KLLLKKK');
     //Escape strings for HTML output
     $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
     $this->_prepareDocument();
     if (count($items) > 0) {
         graphHTraininglogsHelper::prepare_weekgraph($tems, $groupparams, $yachs, $sport);
         $start_points = $model->GetStartpoints($period, $user, $sport);
         gpsHTraininglogsHelper::prepare_startpointmap($start_points);
     }
     parent::display($tpl);
 }
Ejemplo n.º 3
0
 function loadgpx($xmlfile, $sub_id)
 {
     $model = $this->getModel();
     if (@file_exists($xmlfile) == false) {
         echo 'Die CSV Datei: ' . $xmlfile . ' gibt es nicht!';
     } else {
         $startzeitoffset = $model->loadexistingtrainingtime($sub_id);
         //if hr data exists (to combien two sessions into one)
         $sport_id = $model->getssportart($sub_id);
         $startzeit = 0;
         $file = file_get_contents($xmlfile);
         $file = str_replace(':hr', 'hr', $file);
         $file = str_replace(':TrackPointExtension', 'TrackPointExtension', $file);
         $file = str_replace(':atemp', 'atemp', $file);
         file_put_contents($xmlfile, $file);
         var_dump($file);
         $xml = simplexml_load_file($xmlfile);
         $t0 = 0;
         $told = 0;
         $latold = 0;
         $lonold = 0;
         $altold = -1000;
         foreach ($xml->trk->trkseg->trkpt as $trkpt) {
             foreach ($trkpt->attributes() as $a => $b) {
                 if ($a == 'lon') {
                     $lon = $b;
                 }
                 if ($a == 'lat') {
                     $lat = $b;
                 }
             }
             if ($latold == 0) {
                 $latold = $lat;
             }
             if ($lonold == 0) {
                 $lonold = $lon;
             }
             $t1 = substr($trkpt->{'time'}, 11, 8);
             if ($told == 0) {
                 $told = $t1;
             }
             if ($t0 == 0) {
                 $t0 = strtotime($t1);
                 $model->updatesessionstarttime($sub_id, DATE("Y-m-d H:i:s", $t0));
             }
             $time1 = strtotime($t1) - $t0;
             if ($told == 0) {
                 $told = $time1;
             }
             $alt = $trkpt->ele;
             if ($altold == -1000) {
                 $altold = $alt;
             }
             $hr = $trkpt->extensions->gpxtpxTrackPointExtension->{'gpxtpxhr'};
             $dist = $trkpt->extensions->{'gpxdatadistance'};
             if (!$dist) {
                 $dist = gpsHTraininglogsHelper::distance_slc($latold, $lonold, $lat, $lon);
             }
             $dist = sqrt(pow($dist, 2) + pow($alt - $altold, 2));
             $speed = $dist / ($time1 - $told);
             $latold = $lat;
             $lonold = $lon;
             $altold = $alt;
             $told = $time1;
             $model->addsessiondetails($sub_id, $time1 + $startzeitoffset, $lat, $lon, $alt, $speed, $hr, 0);
         }
         $split_id = $model->addlaptime($sub_id, $sport_id, $time1 + $startzeitoffset);
     }
     return $split_id;
 }
Ejemplo n.º 4
0
 public function calibratemap()
 {
     //print_r($_POST);exit;
     $app = JFactory::getApplication();
     $model = $this->getModel();
     $form = JRequest::getVar('jform');
     $map_id = $form['id'];
     $mapimage = $form['mapimage'];
     $user = JFactory::getUser();
     $mapurl = JPATH_SITE . DS . 'images' . DS . 'htraininglogs' . DS . $user->id . DS . 'maps' . DS;
     $map = $mapurl . $mapimage;
     list($width, $height, $type, $attr) = getimagesize($map);
     $x1 = (int) JRequest::getVar('elon');
     $y1 = (int) JRequest::getVar('slat');
     $x2 = (int) JRequest::getVar('wlon');
     $y2 = (int) JRequest::getVar('nlat');
     $lon1 = JRequest::getVar('elon2');
     $lat1 = JRequest::getVar('slat2');
     $lon2 = JRequest::getVar('wlon2');
     $lat2 = JRequest::getVar('nlat2');
     $distlat = gpsHTraininglogsHelper::distance_slc($lat1, $lon1, $lat2, $lon1);
     $distlon = gpsHTraininglogsHelper::distance_slc($lat1, $lon1, $lat1, $lon2);
     $dalpha = rad2deg(atan($this->sign($y2 - $y1) * $distlat / ($this->sign($x2 - $x1) * $distlon))) - rad2deg(atan(($y2 - $y1) / ($x2 - $x1)));
     /*echo '.$x1: '.$x1.'<br>';
     echo '.$y1: '.$y1.'<br>';
     echo '.$x2: '.$x2.'<br>';
     echo '.$y2: '.$y2.'<br>';
     echo '.$lon1: '.$lon1.'<br>';
     echo '.$lat1: '.$lat1.'<br>';
     echo '.$lon2: '.$lon2.'<br>';
     echo '.$lat2: '.$lat2.'<br>';
     echo '$x2-$x1: '.($x2-$x1).'<br>';
     echo 'y2-$y1: '.($y2-$y1).'<br>';
     echo '$distlat: '.$distlat.'<br>';
     echo '$distlon: '.$distlon.'<br>';
     echo '$dalpha: '.$dalpha.'<br>'; exit;*/
     if (abs($dalpha) > 0.5) {
         if (abs($dalpha) <= 7) {
             $this->rotate_map($mapimage, $mapurl, $dalpha);
             $app->enqueueMessage(JText::sprintf('COM_HTRAININGLOGS_MAPFILEROTATED', $dalpha), 'warning');
         } else {
             $app->enqueueMessage(JText::sprintf('COM_HTRAININGLOGS_MAPFILEROTATIONREQUIRED', $dalpha), 'warning');
         }
     }
     $gppx = ($lon2 - $lon1) / ($x2 - $x1);
     $gppy = ($lat2 - $lat1) / ($y2 - $y1);
     $elon = $lon1 - $x1 * $gppx;
     $slat = $lat1 - $y1 * $gppy;
     $wlon = $lon2 + ($width - $x2) * $gppx;
     $nlat = $lat2 + ($height - $y2) * $gppy;
     $model->storeextent($elon, $slat, $wlon, $nlat, $map_id);
     $this->setRedirect(JRoute::_('index.php?option=com_htraininglogs&view=omap&layout=edit&id=' . $map_id, false));
 }
Ejemplo n.º 5
0
 function display($tpl = null)
 {
     $user = JFactory::getUser();
     $model = $this->getModel('sessions');
     $app = JFactory::getApplication();
     $params = $app->getParams();
     $this->navbar = $params->get('navbar');
     $doma_installed = $params->get('doma_installed');
     $Itemid = JRequest::getVar('Itemid');
     $date1 = JRequest::getVar('date');
     $yachs = JRequest::getVar('yachs', 'ntime');
     $sport = JRequest::getVar('sport', '*');
     $this->yachsarr = array(JHTML::_('select.option', 'ntime', JText::_('COM_HTRAININGLOGS_TIME')), JHTML::_('select.option', 'etime', JText::_('COM_HTRAININGLOGS_ETIME')), JHTML::_('select.option', 'km', JText::_('COM_HTRAININGLOGS_KM')));
     $this->sportarray = $model->getsportartarray($user);
     $currentpage = JRequest::getVar('page', 'weekpage');
     $period = $this->_getPeriod($date1, $currentpage, $user);
     $groupparams = HTraininglogsHelper::getGroupparams();
     $page = $model->getpageviewportlets($currentpage);
     $this->Itemid = $Itemid;
     $this->currentpage = $currentpage;
     $this->groupparams = $groupparams;
     $this->period = $period;
     $this->tdate = $this->period->enddat->format('Y-m-d');
     $this->page = $page;
     $this->yachs = $yachs;
     $this->sport = $sport;
     $summaryitems = $model->getSummeryItems($period, $yachs, $sport);
     $this->summaryitems = $summaryitems;
     //	print_r($page);exit;
     if ($page->sum_table) {
     }
     //end:summary view
     if ($page->hr_graph || $page->gpstrack_map || $page->gpstrack_olmap || $page->day_table) {
         $sessions = $model->getSessions($period, $user, $sport);
         if ($page->hr_graph || $page->gpstrack_map || $page->gpstrack_olmap) {
             $sessions = $model->getSessiondetails($sessions);
             if ($page->hr_graph) {
                 graphHTraininglogsHelper::prepare_daygraph($sessions, $groupparams);
             }
             if ($page->gpstrack_map) {
                 $sessions_gps = $model->getGPSdetails($period);
                 $this->sessions_gps = $sessions_gps;
                 gpsHTraininglogsHelper::prepare_gps_track($sessions, $groupparams, $sessions_gps);
             }
             if ($page->gpstrack_olmap) {
                 $sessions_gpsextent = $model->getGPSExtent($period);
                 if ($doma_installed) {
                     $this->sessions_omaps = $model->getOMaps($period);
                 }
                 $this->olmapdetails = gpsHTraininglogsHelper::prepare_gps_oltrack($sessions, $groupparams, $sessions_gpsextent);
             }
         }
         if ($page->day_table) {
             $sessions = $model->getSessionIntensities($sessions);
         }
         $this->sessions = $sessions;
     }
     if ($page->week_table || $page->week_graph) {
         $weekitems = $model->GetWeekItems($period, $user, $yachs, $sport);
         if ($page->week_table) {
             $this->weekitems = $weekitems;
         }
         if ($page->week_graph) {
             graphHTraininglogsHelper::prepare_weekgraph($weekitems, $groupparams, $yachs, $sport, $page->week_graph);
         }
     }
     if ($page->month_table || $page->month_graph) {
         $monthitems = $model->GetMonthItems($period, $user, $yachs, $sport);
         if ($page->month_table) {
             $this->monthitems = $monthitems;
         }
         if ($page->month_graph) {
             $graphitems = $model->GetMonthGraphItems($monthitems->itemsfull, $monthitems->itemsback, $period);
             graphHTraininglogsHelper::prepare_monthgraph($graphitems, $groupparams, $yachs, $sport, $page->month_graph);
         }
     }
     if ($page->year_table || $page->year_graph) {
         $yearitems = $model->GetYearItems($period, $user, $yachs, $sport);
         if ($page->year_graph) {
             //$yeargraphdata	= $model->GetYearGraphdata($period,$user);
             graphHTraininglogsHelper::prepare_yeargraph($yearitems, $groupparams, $yachs, $sport, $page->year_graph);
         }
         if ($page->year_table) {
             $this->yearitems = $yearitems;
         }
     }
     if ($page->life_table || $page->life_graph) {
         $lifeitems = $model->GetLifeItems($period, $user, $yachs, $sport);
         if ($page->life_graph) {
             graphHTraininglogsHelper::prepare_lifegraph($lifeitems, $groupparams, $yachs, $sport, $page->life_graph);
         }
         if ($page->life_table) {
             $this->lifeitems = $lifeitems;
         }
     }
     if ($page->startpoint_map) {
         $start_points = $model->GetStartpoints($period, $user, $sport);
         gpsHTraininglogsHelper::prepare_startpointmap($start_points);
     }
     if ($page->fitness_data || $page->fitness_graphs) {
         $fitnessdataitembased = $model->getFitnessdataitembased($period, $user);
         $fitnessdatavaluebased = $model->getFitnessdatavaluebased($period, $user);
         if ($page->fitness_data) {
             $this->fitnessdataitembased = $fitnessdataitembased;
             $this->fitnessdatavaluebased = $fitnessdatavaluebased;
             $this->fitnessblog = $model->getfitnessblog($period, $page, $user);
         }
         if ($page->fitness_graphs) {
             $fitnessgraphitembased = $model->getfitnessgraphitembased($fitnessdataitembased, $period, $user);
             $fitnessgraphvaluebased = $model->getfitnessgraphvaluebased($fitnessdatavaluebased, $period, $user, $currentpage);
             graphHTraininglogsHelper::prepare_fitnessitembasedgraph($fitnessdataitembased, $fitnessgraphitembased);
             graphHTraininglogsHelper::prepare_fitnessvaluebasedgraph($fitnessdatavaluebased, $fitnessgraphvaluebased);
         }
     }
     if ($currentpage == 'daypage') {
         $this->heading = JText::_('COM_HTRAININGLOGS_DAYPAGEVIEW');
         $this->datetext = $this->period->enddat->format('d. m. Y');
     } else {
         if ($currentpage == 'weekpage') {
             $this->heading = JText::_('COM_HTRAININGLOGS_WEEKPAGE');
             $this->datetext = $this->period->anfdat->format('d. m.') . ' - ' . $this->period->enddat->format('d. m. Y');
         } else {
             if ($currentpage == 'monthpage') {
                 $this->heading = JText::_('COM_HTRAININGLOGS_MONTHPAGE');
                 $this->datetext = $this->period->anfdat->format('d. m.') . ' - ' . $this->period->enddat->format('d. m. Y');
             } else {
                 if ($currentpage == 'yearpage') {
                     $this->heading = JText::_('COM_HTRAININGLOGS_YEARPAGE');
                     $this->datetext = $this->period->anfdat->format('d. m. Y') . ' - ' . $this->period->enddat->format('d. m. Y');
                 } else {
                     if ($currentpage == 'lifepage') {
                         $this->heading = JText::_('COM_HTRAININGLOGS_LIFEPAGEVIEW');
                         $this->datetext = $this->period->anfdat->format('d. m. Y') . ' - ' . $this->period->enddat->format('d. m. Y');
                     }
                 }
             }
         }
     }
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     $this->_prepareDocument();
     parent::display($tpl);
 }