X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FContent%2FWidget.php;h=139fd8ebb6131b9566d62c33fbd9bcac2b4ba253;hb=3d64c3031bd79ed9162774f945ffe169954c4785;hp=3e5af2251f1cfc88db5dbe03b4de9e5edaf3a972;hpb=860a25eb38614c839dca8cc0b7b0dfb5e4738e71;p=friendica.git diff --git a/src/Content/Widget.php b/src/Content/Widget.php index 3e5af2251f..139fd8ebb6 100644 --- a/src/Content/Widget.php +++ b/src/Content/Widget.php @@ -1,6 +1,6 @@ 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,6 +509,7 @@ class Widget '$cutoff' => $cutoff, '$url' => $url, '$dates' => $ret, + '$showless' => DI::l10n()->t('show less'), '$showmore' => DI::l10n()->t('show more') ]); @@ -527,23 +517,23 @@ class Widget } /** - * Display the accounts sidebar - * + * Display the account types sidebar + * The account type value is added as a parameter to the url + * * @param string $base Basepath - * @param string $accounttype Acount type (person, organisation, news, community) + * @param int $accounttype Acount type * @return string */ - public static function accounts(string $base, string $accounttype) + public static function accounttypes(string $base, $accounttype) { - return Renderer::replaceMacros(Renderer::getMarkupTemplate('widget/accounts.tpl'), [ - '$title' => DI::l10n()->t('Accounts'), - '$content' => $base, - '$accounttype' => ($accounttype ?? ''), - '$all' => DI::l10n()->t('All'), - '$person' => DI::l10n()->t('Persons'), - '$organisation' => DI::l10n()->t('Organisations'), - '$news' => DI::l10n()->t('News'), - '$community' => DI::l10n()->t('Forums'), - ]); + $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); } }