Merge remote-tracking branch 'upstream/develop' into reduce-update-contacts
This commit is contained in:
commit
088a3b6bc4
10 changed files with 160 additions and 121 deletions
|
@ -243,6 +243,14 @@ abstract class BaseModule implements ICanHandleRequests
|
|||
$this->response->addContent($arr['content']);
|
||||
$this->response->addContent($this->content($request));
|
||||
} catch (HTTPException $e) {
|
||||
// In case of System::externalRedirects(), we don't want to prettyprint the exception
|
||||
// just redirect to the new location
|
||||
if (($e instanceof HTTPException\FoundException) ||
|
||||
($e instanceof HTTPException\MovedPermanentlyException) ||
|
||||
($e instanceof HTTPException\TemporaryRedirectException)) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
$this->response->addContent($httpException->content($e));
|
||||
} finally {
|
||||
$this->profiler->set(microtime(true) - $timestamp, 'content');
|
||||
|
|
|
@ -234,32 +234,32 @@ class Conversation
|
|||
$likers .= ' ' . $this->l10n->t('and %d other people', $total - $this->config->get('system', 'max_likers'));
|
||||
}
|
||||
|
||||
$spanatts = "class=\"fakelink\" onclick=\"openClose('{$verb}list-$id');\"";
|
||||
$spanatts = "class=\"btn btn-link fakelink\" onclick=\"openClose('{$verb}list-$id');\"";
|
||||
|
||||
$explikers = '';
|
||||
switch ($verb) {
|
||||
case 'like':
|
||||
$phrase = $this->l10n->t('<span %1$s>%2$d people</span> like this', $spanatts, $total);
|
||||
$phrase = $this->l10n->t('<button type="button" %1$s>%2$d people</button> like this', $spanatts, $total);
|
||||
$explikers = $this->l10n->t('%s like this.', $likers);
|
||||
break;
|
||||
case 'dislike':
|
||||
$phrase = $this->l10n->t('<span %1$s>%2$d people</span> don\'t like this', $spanatts, $total);
|
||||
$phrase = $this->l10n->t('<button type="button" %1$s>%2$d people</button> don\'t like this', $spanatts, $total);
|
||||
$explikers = $this->l10n->t('%s don\'t like this.', $likers);
|
||||
break;
|
||||
case 'attendyes':
|
||||
$phrase = $this->l10n->t('<span %1$s>%2$d people</span> attend', $spanatts, $total);
|
||||
$phrase = $this->l10n->t('<button type="button" %1$s>%2$d people</button> attend', $spanatts, $total);
|
||||
$explikers = $this->l10n->t('%s attend.', $likers);
|
||||
break;
|
||||
case 'attendno':
|
||||
$phrase = $this->l10n->t('<span %1$s>%2$d people</span> don\'t attend', $spanatts, $total);
|
||||
$phrase = $this->l10n->t('<button type="button" %1$s>%2$d people</button> don\'t attend', $spanatts, $total);
|
||||
$explikers = $this->l10n->t('%s don\'t attend.', $likers);
|
||||
break;
|
||||
case 'attendmaybe':
|
||||
$phrase = $this->l10n->t('<span %1$s>%2$d people</span> attend maybe', $spanatts, $total);
|
||||
$phrase = $this->l10n->t('<button type="button" %1$s>%2$d people</button> attend maybe', $spanatts, $total);
|
||||
$explikers = $this->l10n->t('%s attend maybe.', $likers);
|
||||
break;
|
||||
case 'announce':
|
||||
$phrase = $this->l10n->t('<span %1$s>%2$d people</span> reshared this', $spanatts, $total);
|
||||
$phrase = $this->l10n->t('<button type="button" %1$s>%2$d people</button> reshared this', $spanatts, $total);
|
||||
$explikers = $this->l10n->t('%s reshared this.', $likers);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -137,7 +137,7 @@ abstract class BaseUsers extends BaseModeration
|
|||
$user['account_type'] = ($user['page_flags_raw'] == 0) ? $account_types[$user['account-type']] : '';
|
||||
|
||||
$user['register_date'] = Temporal::getRelativeDate($user['register_date']);
|
||||
$user['login_date'] = Temporal::getRelativeDate($user['last-activity'], null, false);
|
||||
$user['login_date'] = Temporal::getRelativeDate($user['last-activity'], false);
|
||||
$user['lastitem_date'] = Temporal::getRelativeDate($user['last-item']);
|
||||
$user['is_admin'] = in_array($user['email'], $adminlist);
|
||||
$user['is_deletable'] = !$user['account_removed'] && intval($user['uid']) != $this->session->getLocalUserId();
|
||||
|
|
|
@ -26,6 +26,8 @@ use DateTimeZone;
|
|||
use Friendica\Core\Renderer;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Util\Clock\SystemClock;
|
||||
use Psr\Clock\ClockInterface;
|
||||
|
||||
/**
|
||||
* Temporal class
|
||||
|
@ -305,19 +307,21 @@ class Temporal
|
|||
* Results relative to current timezone.
|
||||
* Limited to range of timestamps.
|
||||
*
|
||||
* @param string $posted_date MySQL-formatted date string (YYYY-MM-DD HH:MM:SS)
|
||||
* @param string $format (optional) Parsed with sprintf()
|
||||
* @param bool $compare_time Compare date (false) or date and time (true). "true" is default.
|
||||
* <tt>%1$d %2$s ago</tt>, e.g. 22 hours ago, 1 minute ago
|
||||
* @param string|null $posted_date MySQL-formatted date string (YYYY-MM-DD HH:MM:SS)
|
||||
* @param bool $compare_time Compare date (false) or date and time (true). "true" is default.
|
||||
* @param ClockInterface|null $clock
|
||||
* <tt>%1$d %2$s ago</tt>, e.g. 22 hours ago, 1 minute ago
|
||||
*
|
||||
* @return string with relative date
|
||||
*/
|
||||
public static function getRelativeDate(string $posted_date = null, string $format = null, bool $compare_time = true): string
|
||||
public static function getRelativeDate(string $posted_date = null, bool $compare_time = true, ClockInterface $clock = null): string
|
||||
{
|
||||
if (empty($posted_date) || $posted_date <= DBA::NULL_DATETIME) {
|
||||
return DI::l10n()->t('never');
|
||||
}
|
||||
|
||||
$clock = $clock ?? new SystemClock();
|
||||
|
||||
$localtime = $posted_date . ' UTC';
|
||||
$abs = strtotime($localtime);
|
||||
|
||||
|
@ -325,8 +329,8 @@ class Temporal
|
|||
return DI::l10n()->t('never');
|
||||
}
|
||||
|
||||
$now = time();
|
||||
|
||||
$now = $clock->now()->getTimestamp();
|
||||
|
||||
if (!$compare_time) {
|
||||
$now = mktime(0, 0, 0, date('m', $now), date('d', $now), date('Y', $now));
|
||||
$abs = mktime(0, 0, 0, date('m', $abs), date('d', $abs), date('Y', $abs));
|
||||
|
@ -335,7 +339,7 @@ class Temporal
|
|||
$isfuture = false;
|
||||
$etime = $now - $abs;
|
||||
|
||||
if ($etime < 1 && $etime >= 0) {
|
||||
if ($etime >= 0 && $etime < 1) {
|
||||
return $compare_time ? DI::l10n()->t('less than a second ago') : DI::l10n()->t('today');
|
||||
}
|
||||
|
||||
|
@ -357,15 +361,13 @@ class Temporal
|
|||
foreach ($a as $secs => $str) {
|
||||
$d = $etime / $secs;
|
||||
if ($d >= 1) {
|
||||
$r = round($d);
|
||||
$r = floor($d);
|
||||
// translators - e.g. 22 hours ago, 1 minute ago
|
||||
if (!$format) {
|
||||
if($isfuture){
|
||||
$format = DI::l10n()->t('in %1$d %2$s');
|
||||
}
|
||||
else {
|
||||
$format = DI::l10n()->t('%1$d %2$s ago');
|
||||
}
|
||||
if($isfuture){
|
||||
$format = DI::l10n()->t('in %1$d %2$s');
|
||||
}
|
||||
else {
|
||||
$format = DI::l10n()->t('%1$d %2$s ago');
|
||||
}
|
||||
|
||||
return sprintf($format, $r, (($r == 1) ? $str[0] : $str[1]));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue