+ '$more' => L10n::t('show more'),
+ '$items' => $entries
+ ]);
+ }
+
+ /**
+ * Insert a tag cloud widget for the present profile.
+ *
+ * @brief Insert a tag cloud widget for the present profile.
+ * @param int $limit Max number of displayed tags.
+ * @return string HTML formatted output.
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
+ */
+ public static function tagCloud($limit = 50)
+ {
+ $a = \get_app();
+
+ if (!$a->profile['profile_uid'] || !$a->profile['url']) {
+ return '';
+ }
+
+ if (Feature::isEnabled($a->profile['profile_uid'], 'tagadelic')) {
+ $owner_id = Contact::getIdForURL($a->profile['url'], 0, true);
+
+ if (!$owner_id) {
+ return '';
+ }
+ return Widget\TagCloud::getHTML($a->profile['profile_uid'], $limit, $owner_id, 'wall');
+ }
+
+ return '';
+ }
+
+ /**
+ * @param string $url Base page URL
+ * @param int $uid User ID consulting/publishing posts
+ * @param bool $wall True: Posted by User; False: Posted to User (network timeline)
+ * @return string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ */
+ public static function postedByYear(string $url, int $uid, bool $wall)
+ {
+ $o = '';
+
+ if (!Feature::isEnabled($uid, 'archives')) {
+ return $o;
+ }
+
+ $visible_years = PConfig::get($uid, 'system', 'archive_visible_years', 5);
+
+ /* arrange the list in years */
+ $dnow = DateTimeFormat::localNow('Y-m-d');
+
+ $ret = [];
+
+ $dthen = Item::firstPostDate($uid, $wall);
+ if ($dthen) {
+ // Set the start and end date to the beginning of the month
+ $dnow = substr($dnow, 0, 8) . '01';
+ $dthen = substr($dthen, 0, 8) . '01';
+
+ /*
+ * Starting with the current month, get the first and last days of every
+ * month down to and including the month of the first post
+ */
+ while (substr($dnow, 0, 7) >= substr($dthen, 0, 7)) {
+ $dyear = intval(substr($dnow, 0, 4));
+ $dstart = substr($dnow, 0, 8) . '01';
+ $dend = substr($dnow, 0, 8) . Temporal::getDaysInMonth(intval($dnow), intval(substr($dnow, 5)));
+ $start_month = DateTimeFormat::utc($dstart, 'Y-m-d');
+ $end_month = DateTimeFormat::utc($dend, 'Y-m-d');
+ $str = L10n::getDay(DateTimeFormat::utc($dnow, 'F'));
+
+ if (empty($ret[$dyear])) {
+ $ret[$dyear] = [];
+ }
+
+ $ret[$dyear][] = [$str, $end_month, $start_month];
+ $dnow = DateTimeFormat::utc($dnow . ' -1 month', 'Y-m-d');
+ }
+ }
+
+ if (!DBA::isResult($ret)) {
+ return $o;
+ }
+
+
+ $cutoff_year = intval(DateTimeFormat::localNow('Y')) - $visible_years;
+ $cutoff = array_key_exists($cutoff_year, $ret);
+
+ $o = Renderer::replaceMacros(Renderer::getMarkupTemplate('widget/posted_date.tpl'),[
+ '$title' => L10n::t('Archives'),
+ '$size' => $visible_years,
+ '$cutoff_year' => $cutoff_year,
+ '$cutoff' => $cutoff,
+ '$url' => $url,
+ '$dates' => $ret,
+ '$showmore' => L10n::t('show more')
+ ]);
+
+ return $o;