X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FContent%2FWidget.php;h=032b9e7534d3f8a3e05a12ab1c1b067697a5b463;hb=1b90686fcd6ce2a58c8d606c34a2dc0e430eda7d;hp=a7ce52cc466107f8ecaa1cbf1b9eb7c3ad799d24;hpb=fb7f7435c080e15bdafbbcbb5a3dfd94ef8dd952;p=friendica.git diff --git a/src/Content/Widget.php b/src/Content/Widget.php index a7ce52cc46..032b9e7534 100644 --- a/src/Content/Widget.php +++ b/src/Content/Widget.php @@ -22,19 +22,16 @@ namespace Friendica\Content; use Friendica\Core\Addon; +use Friendica\Core\Cache\Duration; use Friendica\Core\Protocol; use Friendica\Core\Renderer; -use Friendica\Core\Session; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Contact; -use Friendica\Model\FileTag; -use Friendica\Model\GContact; use Friendica\Model\Group; use Friendica\Model\Item; -use Friendica\Model\Profile; +use Friendica\Model\Post; use Friendica\Util\DateTimeFormat; -use Friendica\Util\Strings; use Friendica\Util\Temporal; class Widget @@ -270,7 +267,7 @@ class Widget $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() ); @@ -309,19 +306,10 @@ class Widget 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', @@ -352,13 +340,8 @@ class Widget 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]; } @@ -413,7 +396,7 @@ class Widget $entries = []; foreach ($commonContacts as $contact) { $entries[] = [ - 'url' => Contact::magicLink($contact['url']), + 'url' => Contact::magicLinkByContact($contact), 'name' => $contact['name'], 'photo' => Contact::getThumb($contact), ]; @@ -478,7 +461,13 @@ class Widget $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'; @@ -520,9 +509,31 @@ class Widget '$cutoff' => $cutoff, '$url' => $url, '$dates' => $ret, + '$showless' => DI::l10n()->t('show less'), '$showmore' => DI::l10n()->t('show more') ]); return $o; } + + /** + * Display the account types sidebar + * The account type value is added as a parameter to the url + * + * @param string $base Basepath + * @param int $accounttype Acount type + * @return string + */ + public static function accounttypes(string $base, $accounttype) + { + $accounts = [ + ['ref' => 'person', 'name' => DI::l10n()->t('Persons')], + ['ref' => 'organisation', 'name' => DI::l10n()->t('Organisations')], + ['ref' => 'news', 'name' => DI::l10n()->t('News')], + ['ref' => 'community', 'name' => DI::l10n()->t('Forums')], + ]; + + return self::filter('accounttype', DI::l10n()->t('Account Types'), '', + DI::l10n()->t('All'), $base, $accounts, $accounttype); + } }