本文整理汇总了PHP中Preferences::getSplitRides方法的典型用法代码示例。如果您正苦于以下问题:PHP Preferences::getSplitRides方法的具体用法?PHP Preferences::getSplitRides怎么用?PHP Preferences::getSplitRides使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Preferences
的用法示例。
在下文中一共展示了Preferences::getSplitRides方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: calculate
private function calculate($state)
{
global $scratchDirectory, $maxKmFileUploads;
$source = "we should never see this value!";
$str = "";
set_time_limit(300);
$this->output("<H3>Calculating....</H3>");
date_default_timezone_set($this->preferences->getTimezone());
$start_text = "the beginning";
$end_text = "today";
$activities = [];
$timestamp = time();
if (isset($_POST["start_date"]) && $_POST["start_date"] != "") {
$start_text = $_POST["start_date"];
}
if (isset($_POST["end_date"]) && $_POST["end_date"] != "") {
$end_text = $_POST["end_date"];
}
if ($state == "calculate_from_strava") {
$this->processUploadedGpxFiles($this->strava->getUserId(), $scratchDirectory);
$source = "Strava";
$activities = $this->strava->getRides($this->start_date, $this->end_date);
if ($this->strava->getError()) {
return "<br><span style=\"color:red;\">There was a problem getting data from {$source}.</span><br><em>" . $this->strava->getError() . "</em>";
}
$overnight_rides = $this->strava->getOvernightActivities();
if ($this->preferences->getSplitRides() && $overnight_rides) {
$str .= $this->askForStravaGpx($overnight_rides, $maxKmFileUploads, "calculate_from_strava", "recalculate your E-Number");
}
} else {
if ($state == "calculate_from_mcl") {
$source = "MyCyclingLog";
$activities = $this->myCyclingLog->getRides($this->start_date, $this->end_date);
} else {
if ($state == "calculate_from_endo") {
$source = "Endomondo";
$activities = $this->endomondo->getRides($this->start_date, $this->end_date);
$error = $this->endomondo->getError();
if ($error) {
return "There was a problem getting data from {$source}:<br>" . $error;
}
} else {
if ($state == "calculate_from_rwgps") {
$source = "RideWithGPS";
$activities = $this->rideWithGps->getRides($this->start_date, $this->end_date);
$error = $this->rideWithGps->getError();
if ($error) {
$str .= "<br>There was a problem getting data from {$source}:<br>" . $error . "<br>";
}
}
}
}
}
if (!$this->start_date) {
if (sizeof($activities) == 0) {
$this->start_date = time();
} else {
$days = array_keys($activities);
sort($days);
$this->start_date = strtotime($days[0]);
}
}
if (!$this->end_date) {
$this->end_date = time();
}
$days = $this->sumActivities($activities);
$str .= "<p>According to {$source}, for the period from {$start_text} to {$end_text}, " . round(($this->end_date - $this->start_date) / self::TWENTY_FOUR_HOURS) . " elapsed days</p>\n";
uasort($days, function ($a, $b) {
if ($a == $b) {
return 0;
} else {
return $a > $b ? -1 : 1;
}
});
$eddington_imperial = $this->calculateEddington($days, $result, self::METRE_TO_MILE);
$table_imperial = '<table id="imperial" class="w3-table-all w3-right-align" style="width:60%"><tr><th>Count</th><th>Date </th><th class="w3-right-align">Distance</th></tr>';
for ($i = 1; $i <= $eddington_imperial; $i++) {
$day = array_keys($result)[$i - 1];
$actual_distance = $result[$day];
$table_imperial .= "<tr><td> {$i} </td><td> {$day}</td><td class=\"w3-right-align\">{$actual_distance} miles</td></tr>";
}
$table_imperial .= "</table>";
$str .= "<br><a href=\"#imperial\">Your imperial Eddington Number</a> is <strong>{$eddington_imperial}</strong>.<br>\n";
if ($end_text == "today") {
$goals = $this->nextGoals($eddington_imperial);
foreach ($goals as $goal) {
$num = $this->numberOfDaysToGoal($goal, $days, self::METRE_TO_MILE);
$str .= "You need to do {$num} ride(s) of at least {$goal} to increase it to {$goal}.<br>\n";
}
}
$eddington_metric = $this->calculateEddington($days, $result, self::METRE_TO_KM);
$table_metric = '<table id="metric" class="w3-table-all w3-right-align" style="width:60%"><tr><th>Count</th><th>Date </th><th class="w3-right-align">Distance</th></tr>';
for ($i = 1; $i <= $eddington_metric; $i++) {
$date = array_keys($result)[$i - 1];
$distance = $result[$date];
$table_metric .= "<tr><td> {$i} </td><td>{$date}</td><td class=\"w3-right-align\">{$distance} km</td></tr>";
}
$table_metric .= "</table>";
$str .= "<br><a href=\"#metric\">Your metric Eddington Number</a> is <strong>{$eddington_metric}</strong><br>\n";
if ($end_text == "today") {
//.........这里部分代码省略.........