Merge pull request #1572 from basteyy/patch-1
Fix 2 deprecated messages
This commit is contained in:
commit
16c70204dc
2 changed files with 39 additions and 32 deletions
|
@ -632,7 +632,7 @@ class Pages extends dbJSON
|
||||||
|
|
||||||
private function sortByPositionLowToHigh($a, $b)
|
private function sortByPositionLowToHigh($a, $b)
|
||||||
{
|
{
|
||||||
return $a['position'] > $b['position'];
|
return $a['position'] <=> $b['position'];
|
||||||
}
|
}
|
||||||
private function sortByPositionHighToLow($a, $b)
|
private function sortByPositionHighToLow($a, $b)
|
||||||
{
|
{
|
||||||
|
|
|
@ -543,38 +543,45 @@ class Page
|
||||||
// $complete = false : short version
|
// $complete = false : short version
|
||||||
// $complete = true : full version
|
// $complete = true : full version
|
||||||
public function relativeTime($complete = false)
|
public function relativeTime($complete = false)
|
||||||
{
|
{
|
||||||
$current = new DateTime;
|
$current = new DateTime;
|
||||||
$past = new DateTime($this->getValue('dateRaw'));
|
$past = new DateTime($this->getValue('dateRaw'));
|
||||||
$elapsed = $current->diff($past);
|
$elapsed = $current->diff($past);
|
||||||
|
|
||||||
|
// Calculate weeks separately
|
||||||
|
$weeks = floor($elapsed->d / 7);
|
||||||
|
$elapsed->d -= $weeks * 7;
|
||||||
|
|
||||||
|
$string = array(
|
||||||
|
'y' => 'year',
|
||||||
|
'm' => 'month',
|
||||||
|
'w' => $weeks,
|
||||||
|
'd' => 'day',
|
||||||
|
'h' => 'hour',
|
||||||
|
'i' => 'minute',
|
||||||
|
's' => 'second',
|
||||||
|
);
|
||||||
|
|
||||||
$elapsed->w = floor($elapsed->d / 7);
|
foreach ($string as $key => &$value) {
|
||||||
$elapsed->d -= $elapsed->w * 7;
|
if ($key == 'w') {
|
||||||
|
if ($weeks > 0) {
|
||||||
$string = array(
|
$value = $weeks . ' week' . ($weeks > 1 ? 's' : '');
|
||||||
'y' => 'year',
|
} else {
|
||||||
'm' => 'month',
|
unset($string[$key]);
|
||||||
'w' => 'week',
|
}
|
||||||
'd' => 'day',
|
} elseif ($elapsed->$key) {
|
||||||
'h' => 'hour',
|
$value = $elapsed->$key . ' ' . $value . ($elapsed->$key > 1 ? 's' : '');
|
||||||
'i' => 'minute',
|
} else {
|
||||||
's' => 'second',
|
unset($string[$key]);
|
||||||
);
|
}
|
||||||
|
}
|
||||||
foreach ($string as $key => &$value) {
|
|
||||||
if ($elapsed->$key) {
|
if (!$complete) {
|
||||||
$value = $elapsed->$key . ' ' . $value . ($elapsed->$key > 1 ? 's' : ' ');
|
$string = array_slice($string, 0, 1);
|
||||||
} else {
|
}
|
||||||
unset($string[$key]);
|
|
||||||
}
|
return $string ? implode(', ', $string) . ' ago' : 'Just now';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$complete) {
|
|
||||||
$string = array_slice($string, 0, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $string ? implode(', ', $string) . ' ago' : 'Just now';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns the value from the field, false if the fields doesn't exists
|
// Returns the value from the field, false if the fields doesn't exists
|
||||||
// If you set the $option as TRUE, the function returns an array with all the values of the field
|
// If you set the $option as TRUE, the function returns an array with all the values of the field
|
||||||
|
|
Loading…
Reference in a new issue