Exemplo n.º 1
0
 /**
  * function_description
  *
  * @return return_description
  */
 public static function navigation()
 {
     $user = JFactory::getUser();
     $juser = new JUser($user->id);
     $uri = JFactory::getApplication()->input->get('layout');
     $navi = '';
     $navi .= '<div class="gps-navi">';
     $navi .= '<div class="navi-part"><a href="' . JRoute::_("index.php?option=com_htraininglogs") . '">' . JText::_('COM_HTRAININGLOGS_OVERVIEW') . '</a></div>';
     $navi .= '<div class="navi-part"><a href="' . JRoute::_("index.php?option=com_htraininglogs&view=cats&layout=default") . '">' . JText::_('COM_HTRAININGLOGS_CATS') . '</a></div>';
     $navi .= '<div class="navi-part"><a href="' . JRoute::_("index.php?option=com_htraininglogs&view=files&layout=list") . '">' . JText::_('COM_HTRAININGLOGS_TRACKS') . '</a></div>';
     $cfg = HTraininglogsHelper::getConfig();
     if ($user->get('id')) {
         // Erscheint nur, wenn User kein Gast
         if (HTraininglogsHelper::userHasFrontendRights()) {
             $navi .= '<div class="navi-part"><a href="' . JRoute::_("index.php?option=com_htraininglogs&view=files&layout=form") . '">' . JText::_('COM_HTRAININGLOGS_ADD_FILE') . '</a></div>';
         }
         // Erscheint bei jedem Registrierten
         $navi .= '<div class="navi-part"><a href="' . JRoute::_("index.php?option=com_htraininglogs&view=files&layout=user") . '">' . JText::_('COM_HTRAININGLOGS_MY_FILES') . '</a></div>';
         if ($uri != null and $uri == 'file') {
             $gpsfile = new JtgModelFiles();
             $track = JFactory::getApplication()->input->get('id');
             $track = $gpsfile->getFile($track);
             if ($track !== null and $user->get('id') == $track->uid) {
                 // User can delete or, update its own tracks
                 $navi .= '<div class="navi-part"><a href="' . JRoute::_("index.php?option=com_htraininglogs&view=files&layout=form&id=" . JFactory::getApplication()->input->get('id')) . '">' . JText::_('COM_HTRAININGLOGS_UPDATE_GPS_FILE') . '</a></div>';
                 $navi .= '<div class="navi-part"><a href="' . JRoute::_("index.php?option=com_htraininglogs&controller=files&task=delete&id=" . JFactory::getApplication()->input->get('id')) . '">' . JText::_('COM_HTRAININGLOGS_DELETE_FILE') . '</a></div>';
             }
         }
     }
     $navi .= '<div class="no-float"></div>';
     $navi .= '</div>';
     return $navi;
 }
Exemplo n.º 2
0
 public static function makedaygraphdata($sessiondetails)
 {
     //Chart type
     $maxp = 900;
     $graphdata = "['Type','Alt','HR','Speed','Cad']";
     $mod = intval(count($sessiondetails) / $maxp) + 1;
     $i = 0;
     $max = intval(count($sessiondetails) / $mod) * $mod;
     while ($i < $max) {
         $time1 = 0;
         $alt = 0;
         $hr = 0;
         $speed = 0;
         $cad = 0;
         for ($j = 0; $j < $mod; $j++) {
             $time1 = $time1 + $sessiondetails[$i + $j]->time1;
             $hr = $hr + $sessiondetails[$i + $j]->hr;
             $alt = $alt + $sessiondetails[$i + $j]->alt;
             $speed = $speed + $sessiondetails[$i + $j]->speed;
             $cad = $cad + $sessiondetails[$i + $j]->cad;
         }
         $i = $i + $mod;
         $time1 = $time1 / $mod;
         $hr = $hr / $mod;
         $alt = $alt / $mod;
         $speed = $speed / $mod;
         $cad = $cad / $mod;
         $graphdata = $graphdata . ",['" . HTraininglogsHelper::makehmmss($time1) . "'," . $alt . "," . $hr . "," . number_format($speed * 3.6, 2, ".", ".") . ',' . number_format($cad, 2, ".", ".") . ']';
     }
     return $graphdata;
 }
Exemplo n.º 3
0
 public static function postprocess($sessions, $groupparams, $user, $yachs, $sport, $period)
 {
     foreach ($sessions as $tsession) {
         $maxp = 900;
         $graphdata = "['Type','" . $groupparams['CLMB']->abbr . "','" . $groupparams['HR']->abbr . "','" . $groupparams['SPEED']->abbr . "'" . "]";
         $mod = intval(count($tsession->sessiondetails) / $maxp) + 1;
         $i = 0;
         $max = intval(count($tsession->sessiondetails) / $mod) * $mod;
         while ($i < $max) {
             $time1 = 0;
             $alt = 0;
             $hr = 0;
             $speed = 0;
             $cad = 0;
             for ($j = 0; $j < $mod; $j++) {
                 $time1 = $time1 + $tsession->sessiondetails[$i + $j]->time1;
                 $hr = $hr + $tsession->sessiondetails[$i + $j]->hr;
                 $alt = $alt + $tsession->sessiondetails[$i + $j]->alt0;
                 $speed = $speed + $tsession->sessiondetails[$i + $j]->speed100;
                 //$cad=$cad+$tsession->sessiondetails[$i+$j]->cad;
             }
             $i = $i + $mod;
             $time1 = $time1 / $mod;
             $hr = $hr / $mod;
             $alt = $alt / $mod;
             $speed = $speed / $mod;
             //		$cad=$cad/$mod;
             $graphdata = $graphdata . ",['" . HTraininglogsHelper::makehmmss($time1) . "'," . $alt . "," . $hr . "," . number_format($speed, 2, ".", ".") . ']';
         }
         //	print_r($graphdata);exit;
         $tsession->graphdata = $graphdata;
     }
     return $sessions;
 }
Exemplo n.º 4
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);
 }
Exemplo n.º 5
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $model = $this->getModel('plansessions');
     $user = JFactory::getUser();
     $this->state = $this->get('State');
     $trainingbook = $app->getUserState("com_htraininglogs.filter.trainingbook", NULL);
     $this->trainingbook = $trainingbook;
     $params = $app->getParams();
     $doma_installed = $params->get('doma_installed');
     $date1 = $this->state->get('filter.date1');
     $yachs = $this->state->get('filter.yachs');
     $currentpage = $this->state->get('filter.currentpage');
     $period = HTraininglogsHelper::getPeriod($date1, $currentpage, $trainingbook->user_id);
     $groupparams = HTraininglogsHelper::getGroupparams();
     $portlets = $model->getpageviewportlets($currentpage, $trainingbook);
     $this->currentpage = $currentpage;
     $this->groupparams = $groupparams;
     $this->period = $period;
     $this->yachs = $yachs;
     $this->tdate = $this->period->enddat->format('Y-m-d');
     $this->portlets = $portlets;
     $portletarray = array();
     $itemarray = array();
     $this->results = array();
     foreach ($portlets as $i => $portlet) {
         $portletexists = array_search($portlet->view_data, $portletarray);
         if (!$portletexists) {
             $plansessionshelper = $portlet->view_data . 'HTraininglogsHelper';
             JLoader::register($plansessionshelper, JPATH_COMPONENT . '/sessionshelpers/' . $portlet->view_data . 'helper.php');
             $this->items[$i] = $plansessionshelper::getItems($period, $user, $yachs, $sport, $currentpage);
             $itemarray[$i] = $this->items[$i];
         } else {
             $this->items[$i] = $itemarray[$portletexists];
         }
         $this->results[$i] = count($this->items[$i]);
         if (file_exists(JPATH_COMPONENT . '/plansessionshelpers/' . $portlet->title . 'posthelper.php')) {
             $plansessionsposthelper = $portlet->title . 'post' . 'HTraininglogsHelper';
             JLoader::register($plansessionsposthelper, JPATH_COMPONENT . '/plansessionshelpers/' . $portlet->title . 'posthelper.php');
             $this->items[$i] = $plansessionsposthelper::postprocess($this->items[$i], $groupparams, $user, $yachs, $sport, $period);
         }
         array_push($portletarray, $portlet->view_data);
     }
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     $this->_preparePageheader($currentpage);
     $this->_prepareDocument();
     parent::display($tpl);
 }
Exemplo n.º 6
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);
 }
Exemplo n.º 7
0
 public function prepare_fileupload($map_id, $mapimage)
 {
     $app = JFactory::getApplication();
     $model = $this->getModel();
     $user = JFactory::getUser();
     $dir = JPATH_SITE . DS . 'images' . DS . 'htraininglogs' . DS . $user->id . DS . 'maps' . DS;
     $file = JRequest::getVar('file_upload2', null, 'files', 'array');
     if ($file['name'] != '') {
         $filename = HTraininglogsHelper::uploadmediafile($file, $mapimage, $dir, 1, 100);
         if (!$filename) {
             return false;
             $this->setRedirect(JRoute::_('index.php?option=com_htraininglogs&view=session&layout=edit&sub_id=' . $sub_id, false));
         } else {
             $model->storeimage($filename, $map_id);
             return true;
         }
     }
 }
Exemplo n.º 8
0
echo sprintf('%1.1f', $this->items[$this->i]->sum->TT * $perweek);
?>
		</td>
		 <td class="item-ntime hidden-phone">
				<?php 
echo HTraininglogsHelper::makehmm($ntime);
?>
		</td>
		<td class="item-ntime">
			<?php 
echo date("H:i", mktime(0, 0, $ntime * $perweek));
?>
		</td>
		<td class="item-etime hidden-phone">
				<?php 
echo HTraininglogsHelper::makehmm($etime);
?>
		</td>
		<td class="item-etime">
				<?php 
echo date("H:i", mktime(0, 0, $etime * $perweek));
?>
		</td>
		<td class="item-km hidden-phone">
				<?php 
echo sprintf('%01.1f', $km);
?>
		</td>
		<td class="item-km">
				<?php 
echo sprintf('%01.1f', $km * $perweek);
Exemplo n.º 9
0
 public static function getItems($period, $user, $yachs = 'ntime', $sport = '*', $currentpage = 'weekpage')
 {
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('YEARWEEK(a.tdate ,1) AS weeknr, count( DISTINCT (date( a.tdate ))) AS TT, count(DISTINCT(a.id)) AS TE,' . 'sum( i.km * sc.multiplier) AS km, sum( i.climb ) AS climb, sum( i.etime ) AS ntime, sum( i.ntime ) AS ntime,' . 'sum(i.' . $yachs . '*(c.group=1)) as RECOM,sum(i.' . $yachs . '*(c.group=2)) as GA1,sum(i.' . $yachs . '*(c.group=3)) as KA1,' . 'sum(i.' . $yachs . '*(c.group=4)) as GA2,sum(i.' . $yachs . '*(c.group=5)) as KA2,sum(i.' . $yachs . '*(c.group=6)) as WSA,' . 'sum(i.' . $yachs . '*(c.group=0)) as Alt');
     $query->from($db->quoteName('#__htraininglogs_tr_sessions') . ' AS a,' . $db->quoteName('#__htraininglogs_tr_splittimes') . ' AS s,' . $db->quoteName('#__htraininglogs_tr_intensitylevels') . 'as i,' . $db->quoteName('#__htraininglogs_cfg_sport') . 'AS sc,' . $db->quoteName('#__htraininglogs_cfg_intensity') . ' AS c');
     if ($sport != '*') {
         $query->where('a.sport_id in (' . $sport . ')');
     }
     $query->where('a.id = s.tr_id');
     $query->where('s.id = i.split_id');
     $query->where('a.sport_id = sc.id');
     $query->where('a.user_id = ' . $user->id);
     $query->where('a.state = 1');
     $query->where('i.state = 1');
     $query->where('i.int_id = c.id');
     $query->where('a.tdate BETWEEN "' . $period->anfdat->format('Y-m-d') . ' 0:00:00" AND "' . $period->enddat->format('Y-m-d') . ' 23:59:59"');
     $query->group('weeknr');
     $query->order('a.tdate DESC');
     $db->setQuery($query);
     $items = $db->loadObjectlist();
     $yearwkanf = $period->enddat->format('oW');
     $yearwkend = $period->anfdat->format('oW');
     $yearanf = $yearwkanf[0] . $yearwkanf[1] . $yearwkanf[2] . $yearwkanf[3];
     $kwanf = $yearwkanf[4] . $yearwkanf[5];
     $yearend = $yearwkend[0] . $yearwkend[1] . $yearwkend[2] . $yearwkend[3];
     $kwend = $yearwkend[4] . $yearwkend[5];
     $i = 0;
     $itemsfull = array();
     $itemnew = new stdClass();
     $itemnew->week = 0;
     while ($yearanf > $yearend or $kwanf > $kwend) {
         $item = $items[$i];
         $year = $item->weeknr[0] . $item->weeknr[1] . $item->weeknr[2] . $item->weeknr[3];
         $kw = $item->weeknr[4] . $item->weeknr[5];
         if ($yearanf == $year and $kwanf == $kw) {
             $i++;
             $item->weekstart = HTraininglogsHelper::get_monday_of_week($kw, $year);
             $datum = new DateTime($item->weekstart);
             $datum = date_modify($datum, '+6 day');
             $item->weekend = $datum->format('Y-m-d');
             $item->weeknr = $kw . '/' . $year;
             array_push($itemsfull, $item);
         } else {
             $j = array_push($itemsfull, new $itemnew());
             $itemsfull[$j - 1]->TT = 0;
             $itemsfull[$j - 1]->TE = 0;
             $itemsfull[$j - 1]->km = 0;
             $itemsfull[$j - 1]->climb = 0;
             $itemsfull[$j - 1]->ntime = 0;
             $itemsfull[$j - 1]->ntime = 0;
             $itemsfull[$j - 1]->RECOM = 0;
             $itemsfull[$j - 1]->GA1 = 0;
             $itemsfull[$j - 1]->KA1 = 0;
             $itemsfull[$j - 1]->GA2 = 0;
             $itemsfull[$j - 1]->KA2 = 0;
             $itemsfull[$j - 1]->WSA = 0;
             $itemsfull[$j - 1]->Alt = 0;
             $itemsfull[$j - 1]->weekstart = HTraininglogsHelper::get_monday_of_week($kwanf, $yearanf);
             $datum = new DateTime($itemsfull[$j - 1]->weekstart);
             $datum = date_modify($datum, '+6 day');
             $itemsfull[$j - 1]->weekend = $datum->format('Y-m-d');
             $itemsfull[$j - 1]->weeknr = $kwanf . '/' . $yearanf;
         }
         $kwanf--;
         if ($kwanf == 0) {
             $kwanf = date("W", mktime(0, 0, 0, 12, 28, --$yearanf));
         }
     }
     return $itemsfull;
 }
Exemplo n.º 10
0
 public function add_competitionmedia()
 {
     $model = $this->getModel();
     $sub_id = JRequest::getVar('sub_id');
     $newmedia = JRequest::getVar('newmedia');
     $mtitle = JRequest::getVar('mtitle');
     $file = JRequest::getVar('media_upload', null, 'files', 'array');
     $filename = JFile::makeSafe($file['name']);
     $user = JFactory::getUser();
     $dir = JPATH_SITE . '/images/htraininglogs/' . $user->id . '/' . 'media/';
     if ($newmedia) {
         $model->savemedialink(0, $sub_id, $newmedia);
     }
     if ($file['name'] != '') {
         $filename = HTraininglogsHelper::uploadmediafile($file, $mediafile, $dir, 0, 150);
         if (!$filename) {
             return false;
             $this->setRedirect(JRoute::_('index.php?option=com_htraininglogs&view=session&layout=edit&sub_id=' . $sub_id, false));
         } else {
             $upload_id = $model->storemedia($filename, $mtitle);
             $model->savemedialink(0, $sub_id, $upload_id);
             return true;
         }
     }
     $i = 0;
     while ($link_id = JRequest::getVar('mlink_id' . $i)) {
         $media_id = JRequest::getVar('media' . $i);
         $model->savemedialink($link_id, $sub_id, $media_id);
         $i++;
     }
 }
Exemplo n.º 11
0
						<small><?php 
        echo $this->escape($item->comment);
        ?>
</small>
					</td>
					<?php 
        if (!$this->state->get('filter.iscomp')) {
            ?>
						<td class="hidden-phone">
							<?php 
            echo HTraininglogsHelper::makehmm($item->ntime);
            ?>
						</td>
						<td class="hidden-phone">
							<?php 
            echo HTraininglogsHelper::makehmm($item->etime);
            ?>
						</td>
						<td class="hidden-phone">
							<?php 
            echo sprintf('%01.1f', $item->km);
            ?>
						</td>
						<td class="hidden-phone">
							<?php 
            echo sprintf('%01.0f', $item->climb);
            ?>
						</td>
					<?php 
        } else {
            ?>
Exemplo n.º 12
0
 public function dfgsdfguploadmapfile($file, $map_id, $mapimage)
 {
     $app = JFactory::getApplication();
     $model = $this->getModel();
     $user = JFactory::getUser();
     $filename = HTraininglogsHelper::sanitize($file['name']);
     //JFile::makeSafe($file['name']);
     $src = $file['tmp_name'];
     $dir = JPATH_SITE . DS . 'images' . DS . 'htraininglogs' . DS . $user->id . DS . 'maps' . DS;
     $dir_thumb = $dir . 'thumbs' . DS;
     $dest = $dir . $filename;
     if (!file_exists($dest) || $filename == $mapimage) {
         if (JFile::upload($src, $dest)) {
             $file_ext = strtolower(JFile::getExt($filename));
             $thumbnail = $dir_thumb . $filename;
             list($width, $height) = getimagesize($dir . $filename);
             $ratio = $width / $height;
             $thumb_height = 100;
             $thumb_width = 300;
             //intval($thumb_height*$ratio);
             $thumb_create = imagecreatetruecolor($thumb_width, $thumb_height);
             //echo $thumbnail.$dir.$filename;exit;
             switch ($file_ext) {
                 case 'jpg':
                     $source = imagecreatefromjpeg($dir . $filename);
                     break;
                 case 'jpeg':
                     $source = imagecreatefromjpeg($dir . $filename);
                     break;
                 case 'png':
                     $source = imagecreatefrompng($dir . $filename);
                     break;
                 case 'gif':
                     $source = imagecreatefromgif($dir . $filename);
                     break;
                 default:
                     $source = imagecreatefromjpeg($dir . $filename);
             }
             //imagecopyresized($thumb_create,$source,0,0,0,0,$thumb_width,$thumb_height,$width,$height);
             imagecopyresized($thumb_create, $source, 0, 0, (int) $width / 2 - $thumb_width, (int) $height / 2 - $thumb_height, $thumb_width, $thumb_height, 2 * $thumb_width, 2 * $thumb_height);
             switch ($file_ext) {
                 case 'jpg':
                 case 'jpeg':
                     imagejpeg($thumb_create, $thumbnail, 100);
                     break;
                 case 'png':
                     imagepng($thumb_create, $thumbnail, 100);
                     break;
                 case 'gif':
                     imagegif($thumb_create, $thumbnail, 100);
                     break;
                 default:
                     imagejpeg($thumb_create, $thumbnail, 100);
             }
             if ($model->storeimage($filename, $map_id)) {
                 return true;
             }
         }
     } else {
         $app->enqueueMessage(JText::sprintf('COM_HTRAININGLOGS_FILEEXISTS', $filename), 'error');
         return false;
     }
 }
Exemplo n.º 13
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);
 }
Exemplo n.º 14
0
 public static function uploadmediafile($file, $currentfilename, $destdir, $center, $thumb_height)
 {
     $app = JFactory::getApplication();
     $filename = HTraininglogsHelper::sanitize($file['name']);
     //JFile::makeSafe($file['name']);HTraininglogsHelper::
     $src = $file['tmp_name'];
     $dest = $destdir . $filename;
     $dir_thumb = $destdir . 'thumbs/';
     if (!file_exists($dest) || $filename == $currentfilename) {
         if (JFile::upload($src, $dest)) {
             HTraininglogsHelper::create_thumb($destdir, $filename, $center, $dir_thumb, $thumb_height, NULL);
             if (!$center) {
                 $dir_thumb = $destdir . 'bigthumbs/';
                 HTraininglogsHelper::create_thumb($destdir, $filename, $center, $dir_thumb, NULL, 750);
             }
             return $filename;
         } else {
             $app->enqueueMessage(JText::sprintf('COM_HTRAININGLOGS_FILEUPLOADFAILED', $filename), 'error');
             return false;
         }
     } else {
         $app->enqueueMessage(JText::sprintf('COM_HTRAININGLOGS_FILEEXISTS', $filename), 'error');
         return false;
     }
 }
Exemplo n.º 15
0
 /**
  * function_description
  *
  * @return array
  */
 private function parseXMLlinesOL()
 {
     // 	global $jtg_microtime;
     $cfg = HTraininglogsHelper::getConfig();
     $iconpath = JUri::base() . "/media/com_htraininglogs/assets/template/" . $cfg->template . "/images/";
     $link = JUri::current();
     $string_se = "";
     $center = "";
     // TODO if (AnimatedCursorLayer)
     if (true) {
         /* AnimatedCursorLayer
          * This MUST be added after olmap.zoomToExtent
          */
         $document = JFactory::getDocument();
         $document->addScript(JUri::base(true) . '/media/com_htraininglogs/assets/js/animatedCursor.js');
         $center .= "\n// <!-- parseOLMapAnimatedCursorLayer BEGIN -->\n";
         $center .= "longitudeData = {$this->longitudeData};\n";
         $center .= "latitudeData = {$this->latitudeData};\n";
         $center .= "var points = [];\n";
         $center .= "var style ={strokeOpacity: 0.7, strokeColor: \"#ff00ff\", strokeWidth: 5, graphicZIndex: 5}\n";
         $center .= "for (var i = 0; i < longitudeData.length; i++) {\n";
         $center .= "\tvar point = new OpenLayers.Geometry.Point(longitudeData[i], latitudeData[i]). transform(new OpenLayers.Projection(\"EPSG:4326\"), olmap.getProjectionObject());\n";
         $center .= "\tpoints.push(point);\n";
         $center .= "}\n";
         $center .= "var line = new OpenLayers.Geometry.LineString(points);\n";
         $center .= "var linefeature  = new OpenLayers.Feature.Vector(line, null, style);\n";
         $track_name = htmlentities($this->trackname, ENT_QUOTES, 'UTF-8');
         $center .= "animatedCursorLayer = new OpenLayers.Layer.Vector(\"{$track_name}\");\n";
         $center .= "animatedCursorLayer.addFeatures([linefeature]);\n";
         $center .= "animatedCursorLayer.gpxfeature = animatedCursorLayer.features[0];\n";
         $center .= "olmap.addLayer(animatedCursorLayer);\n";
         $center .= "\n// <!-- parseOLMapAnimatedCursorIcon BEGIN -->\n";
         $center .= "animatedCursorIcon = new OpenLayers.Layer.Markers(\"Animated Cursor\", {\n";
         $center .= "displayInLayerSwitcher: false });\n";
         $center .= "olmap.addLayer(animatedCursorIcon);\n";
         $center .= "animatedCursorIcon.setVisibility(false);\n";
         $center .= "var size = new OpenLayers.Size(32,32);\n";
         $center .= "var offset = new OpenLayers.Pixel(-16,-32);\n";
         $center .= "var cursorIcon = new OpenLayers.Icon(\"" . JUri::base() . "/media/com_htraininglogs/assets/images/orange-dot.png\",size,offset);\n";
         $center .= "var lonLatStart = new OpenLayers.LonLat(" . $this->track[1]->start . ") . ";
         $center .= "transform(new OpenLayers.Projection(\"EPSG:4326\"), olmap.getProjectionObject());\n";
         $center .= "animatedCursorIcon.addMarker(new OpenLayers.Marker(lonLatStart,cursorIcon));\n";
         $center .= "// <!-- parseOLMapAnimatedCursorIcon END -->\n";
     } else {
         $center .= "<!-- AnimatedCursorLayer not activated -->\n";
     }
     $center .= "// <!-- parseOLMapAnimatedCursorLayer END -->\n";
     $string = "// <!-- parseXMLlines BEGIN -->\n";
     if ($this->trackCount == 0) {
         return;
     }
     $tracksColors = $this->calculateAllColors($this->trackCount);
     for ($i = 1; $i <= $this->trackCount; $i++) {
         $m = microtime(true);
         $coords = $this->track[$i]->coords;
         $subid = $link . "&amp;subid=" . $i;
         $color = "#" . $tracksColors[$i - 1];
         $string_se .= "var lonLatStart" . $i . " = new OpenLayers.LonLat(" . $this->track[$i]->start . ") . ";
         $string_se .= "transform(new OpenLayers.Projection(\"EPSG:4326\"), olmap.getProjectionObject());\n";
         $string_se .= "var lonLatStop" . $i . " = new OpenLayers.LonLat(" . $this->track[$i]->stop . ") . ";
         $string_se .= "transform(new OpenLayers.Projection(\"EPSG:4326\"), olmap.getProjectionObject());\n";
         $string_se .= "var sizeStart" . $i . " = new OpenLayers.Size(24,24);\n";
         $string_se .= "var sizeStop" . $i . " = new OpenLayers.Size(24,24);\n";
         $string_se .= "var offsetStart" . $i . " = new OpenLayers.Pixel(-3,-22);\n";
         $string_se .= "var offsetStop" . $i . " = new OpenLayers.Pixel(-19,-22);\n";
         $string_se .= "var iconStart" . $i . " = ";
         $string_se .= "new OpenLayers.Icon(\"" . $iconpath . "trackStart.png\",";
         $string_se .= "sizeStart" . $i . ",offsetStart" . $i . ");\n";
         $string_se .= "var iconStop" . $i . " = new OpenLayers.Icon(\"" . $iconpath . "trackDest.png\",";
         $string_se .= "sizeStop" . $i . ",offsetStop" . $i . ");\n";
         $string_se .= "layer_startstop.addMarker(new OpenLayers.Marker(lonLatStop" . $i . ",iconStop" . $i . "));\n";
         $string_se .= "popupClassStart = AutoSizeFramedCloud;\n";
         $string_se .= "popupContentHTMLStart = '";
         $string_se .= "<font style=\"font-weight: bold;\" color=\"" . $color . "\">";
         $string_se .= $this->track[$i]->trackname ? htmlentities($this->track[$i]->trackname, ENT_QUOTES, 'UTF-8') : JText::_('COM_HTRAININGLOGS_TRACK') . $i;
         $string_se .= "</font>";
         $string_se .= "';\n";
         $string_se .= "addlayer_startstop(lonLatStart" . $i . ", popupClassStart, popupContentHTMLStart, true, false, iconStart" . $i . ", olmap);\n";
     }
     $string .= "layer_startstop = new OpenLayers.Layer.Markers(";
     $string .= "\"" . $i . ": " . $track_name . "\"";
     $string .= ", { displayInLayerSwitcher: false }";
     $string .= ");";
     $string .= "olmap.addLayer(layer_startstop);";
     $string .= "layer_startstop.setVisibility(true);";
     $string .= $string_se;
     $string .= "// <!-- parseXMLlines END -->\n";
     $center .= "// <!-- parseOLMapCenterSingleTrack BEGIN -->\n";
     $center .= "var min = lonLatToMercator(new OpenLayers.LonLat";
     $center .= "(" . $this->bbox_lon_min . "," . $this->bbox_lat_min . "));\n";
     $center .= "var max = lonLatToMercator(new OpenLayers.LonLat";
     $center .= "(" . $this->bbox_lon_max . "," . $this->bbox_lat_max . "));\n";
     $center .= "olmap.zoomToExtent(new OpenLayers.Bounds(min.lon, min.lat, max.lon, max.lat));\n";
     $center .= "// <!-- parseOLMapCenterSingleTrack END -->\n";
     return array("coords" => $string, "center" => $center);
 }
Exemplo n.º 16
0
 function createintensity()
 {
     //$this->save();
     $form = JRequest::getVar('jform', array(), 'post', 'array');
     $sportid = $form['id'];
     $ka_percent = $form['ka_percent'];
     $max_hr = $form['max_hr'];
     $max_speed = $form['max_speed'];
     $p1 = 75;
     //% of max intensity defines intensiti factor = 1
     $p0 = 50;
     //% of speed is lowes speed that counts as training
     $reality_factor = 0.9;
     //% of speed used as real speed to calculate distance when no GPS
     $kakactor = 0.75;
     // speed reduced due to uphill
     $pow = 1.25;
     // to emphasis factor in high intensity areas
     $lhrs = array(60, 70, 72, 80, 84, 90);
     $dlhrs = array(10, 10, 12, 10, 6, 10);
     $ka_groups = array(3, 5);
     $groupparams = HTraininglogsHelper::getIntgroupparams();
     $model = $this->getModel();
     for ($i = 1; $i <= 6; $i++) {
         $color = $groupparams[$i]->color;
         $items = $model->getIntensities($sportid, $i);
         if (!$items->cfg) {
             $f = ($lhrs[$i - 1] / ($p1 - $p0) - $p0 / ($p1 - $p0)) * $lhrs[$i - 1] / $p1;
             if ($f >= 1) {
                 $f = pow($f, $pow);
             }
             if (in_array($i, $ka_groups)) {
                 $ka_factor = $kakactor;
             } else {
                 $ka_factor = 1;
             }
             $v = $max_speed * $lhrs[$i - 1] / 100 * $reality_factor * $ka_factor;
             $title = JText::_($groupparams[$i]->title);
             if (!($result = $model->updateIntensity(0, $title, $i, $color, $v, $max_hr * $lhrs[$i - 1] / 100, $f, 1, $sportid))) {
                 $this->setMessage($model->getError(), 'error');
                 return false;
             }
         } else {
             $n = count($items->cfg);
             foreach ($items->cfg as $j => $item) {
                 $dhr = round($dlhrs[$i - 1] / $n);
                 $f = (($lhrs[$i - 1] + $dhr * $j) / ($p1 - $p0) - $p0 / ($p1 - $p0)) * ($lhrs[$i - 1] + $dhr * $j) / $p1;
                 if ($f >= 1) {
                     $f = pow($f, $pow);
                 }
                 if (in_array($i, $ka_groups)) {
                     $ka_factor = $kakactor;
                 } else {
                     $ka_factor = 1;
                 }
                 $v = $max_speed * $lhrs[$i - 1] / 100 * $reality_factor * $ka_factor;
                 if (!$item->color || $item->color == '#000000' || $item->color == 0) {
                     $item->color = $color;
                 }
                 if (!($result = $model->updateIntensity($item->id, $item->intensity, $i, $item->color, $v, $max_hr * ($lhrs[$i - 1] + $dhr * $j) / 100, $f, $item->state, $sportid))) {
                     $this->setMessage($model->getError(), 'error');
                     return false;
                 }
             }
         }
     }
     $items = $model->getIntensities($sportid, 6);
     $n = count($items->cfg);
     $f = pow((100 / ($p1 - $p0) - $p0 / ($p1 - $p0)) * 100 / $p1, $pow);
     $v = $max_speed;
     if ($n == 1) {
         $id = 0;
     } else {
         $id = $items->cfg[$n - 1]->id;
     }
     if (!($result = $model->updateIntensity($id, 'max', 6, $color, $v, $max_hr, $f, 1, $sportid))) {
         $this->setMessage($model->getError(), 'error');
         return false;
     }
     $this->setRedirect(JRoute::_('index.php?option=com_htraininglogs&view=cfgsport&layout=edit&id=' . $sportid, false));
 }