示例#1
0
 /**
  * Constructor
  * @param int $id
  */
 public function __construct($id = false)
 {
     if ($id === false) {
         $id = Configuration::General()->mainSport();
     }
     $this->id = $id;
     $this->data = SportFactory::DataFor($id);
 }
 /**
  * Init some class variables
  */
 private function initVariables()
 {
     $this->Sport = SportFactory::DataFor($this->sportid);
     $this->Dataset = new Dataset(SessionAccountHandler::getId());
     require_once 'class.SummaryTable.php';
     require_once 'class.SummaryTable10Weeks.php';
     require_once 'class.SummaryTableAllWeeks.php';
     require_once 'class.SummaryTableAllYears.php';
     require_once 'class.SummaryTableMonths.php';
 }
 /**
  * Init some class variables
  */
 private function initVariables()
 {
     $this->Sport = SportFactory::DataFor($this->sportid);
     $this->DatasetConfig = new \Runalyze\Dataset\Configuration(DB::getInstance(), SessionAccountHandler::getId());
     require_once 'class.SummaryTable.php';
     require_once 'class.SummaryTable10Weeks.php';
     require_once 'class.SummaryTableAllWeeks.php';
     require_once 'class.SummaryTableAllYears.php';
     require_once 'class.SummaryTableMonths.php';
 }
示例#4
0
 /**
  * Get the sport-specific icon
  * @param int $id
  * @param string $title
  */
 public static function getSportIcon($id, $title = '', $tooltip = '')
 {
     $data = SportFactory::DataFor($id);
     if ($data === false) {
         return '';
     }
     if ($title == '') {
         $title = $data['name'];
     }
     if ($tooltip == '') {
         $tooltip = $title;
     }
     return Ajax::tooltip('<i class="' . $data['img'] . '"></i>', $tooltip);
 }
示例#5
0
<?php

/**
 * Draw total time of training for each day of a week for the user
 * Include:   inc/draw/Plot.Weekday.php
 * @package Runalyze\Plugins\Stats
 */
$titleCenter = __('Activity [in h] by weekday');
$yAxis = array();
$xAxis = array();
for ($w = 1; $w <= 7; $w++) {
    $xAxis[] = array($w - 1, Time::Weekday($w, true));
}
if ($this->sportid > 0) {
    $Sports = array(SportFactory::DataFor((int) $this->sportid));
} else {
    $Sports = SportFactory::AllSports();
}
$Query = DB::getInstance()->prepare('SELECT
		SUM(`s`) as `value`,
		(DAYOFWEEK(FROM_UNIXTIME(`time`))-1) as `day`
	FROM `' . PREFIX . 'training`
	WHERE
		`sportid`=:id
		' . $this->getYearDependenceForQuery() . '
	GROUP BY `day`
	ORDER BY ((`day`+6)%7) ASC');
// TODO: Should be possible with one query?
foreach ($Sports as $sport) {
    $id = $sport['name'];
    $yAxis[$id] = array(0, 0, 0, 0, 0, 0, 0);
 /**
  * Initialize internal data
  */
 private function initData()
 {
     $this->sport = SportFactory::DataFor($this->sportid);
     if ($this->year != -1) {
         $this->num = 12;
         $this->num_start = 1;
         $this->num_end = 12;
     } else {
         $this->num = date("Y") - START_YEAR + 1;
         $this->num_start = START_YEAR;
         $this->num_end = date("Y");
     }
     $this->colspan = $this->num + 1;
 }
示例#7
0
 /**
  * Sport
  * @param int $sportid
  * @return \Runalyze\Model\Sport\Object
  */
 public function sport($sportid)
 {
     return new Sport\Object(\SportFactory::DataFor($sportid));
 }