2012-05-16 07:31:36 +02:00
|
|
|
<?php
|
|
|
|
|
2018-01-15 04:22:37 +01:00
|
|
|
use Friendica\Directory\App;
|
|
|
|
|
|
|
|
function tags_widget(App $a)
|
2017-05-05 03:35:43 +02:00
|
|
|
{
|
2012-05-16 07:31:36 +02:00
|
|
|
$o = '';
|
|
|
|
|
2017-05-05 03:35:43 +02:00
|
|
|
$r = q("SELECT `term`, COUNT(`term`) AS `total` FROM `tag` GROUP BY `term` ORDER BY COUNT(`term`) DESC LIMIT 20");
|
|
|
|
if (count($r)) {
|
2012-05-16 07:31:36 +02:00
|
|
|
$o .= '<div class="widget">';
|
|
|
|
$o .= '<h3>' . t('Trending Interests') . '</h3>';
|
|
|
|
$o .= '<ul>';
|
2017-05-05 03:35:43 +02:00
|
|
|
foreach ($r as $rr) {
|
2018-01-15 04:22:37 +01:00
|
|
|
$o .= '<li><a href="' . $a->get_baseurl() . '/search?query=' . $rr['term'] . '" >' . $rr['term'] . '</a> (' . $rr['total'] . ')</li>';
|
2012-05-16 07:31:36 +02:00
|
|
|
}
|
|
|
|
$o .= '</ul></div>';
|
|
|
|
}
|
|
|
|
return $o;
|
|
|
|
}
|
|
|
|
|
2018-01-15 04:22:37 +01:00
|
|
|
function country_widget(App $a)
|
2017-05-05 03:35:43 +02:00
|
|
|
{
|
2012-05-16 07:31:36 +02:00
|
|
|
$o = '';
|
|
|
|
|
2018-01-15 04:22:37 +01:00
|
|
|
$r = q("SELECT `country-name`, COUNT(`country-name`) AS `total`
|
|
|
|
FROM `profile`
|
|
|
|
WHERE `country-name` != ''
|
|
|
|
AND `available`
|
|
|
|
GROUP BY `country-name`
|
|
|
|
ORDER BY COUNT(`country-name`) DESC
|
|
|
|
LIMIT 20");
|
2017-05-05 03:35:43 +02:00
|
|
|
if (count($r)) {
|
2012-05-16 07:31:36 +02:00
|
|
|
$o .= '<div class="widget">';
|
|
|
|
$o .= '<h3>' . t('Locations') . '</h3>';
|
|
|
|
$o .= '<ul>';
|
2017-05-05 03:35:43 +02:00
|
|
|
foreach ($r as $rr) {
|
2018-01-15 04:22:37 +01:00
|
|
|
$o .= '<li><a href="' . $a->get_baseurl() . '/search?query=' . $rr['country-name'] . '" >' . $rr['country-name'] . '</a> (' . $rr['total'] . ')</li>';
|
2012-05-16 07:31:36 +02:00
|
|
|
}
|
|
|
|
$o .= '</ul></div>';
|
|
|
|
}
|
|
|
|
return $o;
|
|
|
|
}
|
2012-07-06 07:06:42 +02:00
|
|
|
|
2017-05-05 03:35:43 +02:00
|
|
|
function get_taglist($limit = 50)
|
|
|
|
{
|
|
|
|
$r = q("SELECT DISTINCT(`term`), COUNT(`term`) AS `total` FROM `tag` GROUP BY `term` ORDER BY COUNT(`term`) DESC LIMIT %d",
|
2012-07-06 07:06:42 +02:00
|
|
|
intval($limit)
|
|
|
|
);
|
|
|
|
|
|
|
|
return $r;
|
|
|
|
}
|