<?php
/**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
namespace Friendica\Content;
use Friendica\Core\Addon;
+use Friendica\Core\Cache\Duration;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
-use Friendica\Model\FileTag;
use Friendica\Model\Group;
use Friendica\Model\Item;
+use Friendica\Model\Post;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Temporal;
$extra_sql = self::unavailableNetworks();
- $r = DBA::p("SELECT DISTINCT(`network`) FROM `contact` WHERE `uid` = ? AND NOT `deleted` AND `network` != '' $extra_sql ORDER BY `network`",
+ $r = DBA::p("SELECT `network` FROM `contact` WHERE `uid` = ? AND NOT `deleted` AND `network` != '' $extra_sql GROUP BY `network` ORDER BY `network`",
local_user()
);
return '';
}
- $saved = DI::pConfig()->get(local_user(), 'system', 'filetags');
- if (!strlen($saved)) {
- return;
- }
-
$terms = [];
- foreach (FileTag::fileToArray($saved) as $savedFolderName) {
+ foreach (Post\Category::getArray(local_user(), Post\Category::FILE) as $savedFolderName) {
$terms[] = ['ref' => $savedFolderName, 'name' => $savedFolderName];
}
-
- usort($terms, function ($a, $b) {
- return strcmp($a['name'], $b['name']);
- });
return self::filter(
'file',
return '';
}
- $saved = DI::pConfig()->get($uid, 'system', 'filetags');
- if (!strlen($saved)) {
- return;
- }
-
$terms = array();
- foreach (FileTag::fileToArray($saved, 'category') as $savedFolderName) {
+ foreach (Post\Category::getArray(local_user(), Post\Category::CATEGORY) as $savedFolderName) {
$terms[] = ['ref' => $savedFolderName, 'name' => $savedFolderName];
}
$entries = [];
foreach ($commonContacts as $contact) {
$entries[] = [
- 'url' => Contact::magicLink($contact['url']),
+ 'url' => Contact::magicLinkByContact($contact),
'name' => $contact['name'],
'photo' => Contact::getThumb($contact),
];
$ret = [];
- $dthen = Item::firstPostDate($uid, $wall);
+ $cachekey = 'Widget::postedByYear' . $uid . '-' . (int)$wall;
+ $dthen = DI::cache()->get($cachekey);
+ if (empty($dthen)) {
+ $dthen = Item::firstPostDate($uid, $wall);
+ DI::cache()->set($cachekey, $dthen, Duration::HOUR);
+ }
+
if ($dthen) {
// Set the start and end date to the beginning of the month
$dnow = substr($dnow, 0, 8) . '01';
'$cutoff' => $cutoff,
'$url' => $url,
'$dates' => $ret,
- '$showless' => DI::l10n()->t('show less'),
+ '$showless' => DI::l10n()->t('show less'),
'$showmore' => DI::l10n()->t('show more')
]);