Fix country widget + search + tags #38
7 changed files with 72 additions and 58 deletions
|
@ -39,6 +39,9 @@ function run_submit($url)
|
||||||
`updated` = '%s'
|
`updated` = '%s'
|
||||||
WHERE `id` = %d LIMIT 1", dbesc(datetime_convert()), intval($profile_id)
|
WHERE `id` = %d LIMIT 1", dbesc(datetime_convert()), intval($profile_id)
|
||||||
);
|
);
|
||||||
|
$r = q("DELETE FROM `tag` WHERE `nurl` = '%s'",
|
||||||
|
dbesc($r[0]['nurl'])
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Remove duplicates.
|
//Remove duplicates.
|
||||||
|
@ -185,11 +188,6 @@ function run_submit($url)
|
||||||
$t = substr($t, 0, 254);
|
$t = substr($t, 0, 254);
|
||||||
|
|
||||||
if (strlen($t)) {
|
if (strlen($t)) {
|
||||||
$r = q("SELECT `id` FROM `tag` WHERE `term` = '%s' and `nurl` = '%s' LIMIT 1",
|
|
||||||
dbesc($t),
|
|
||||||
dbesc($nurl)
|
|
||||||
);
|
|
||||||
if (!count($r)) {
|
|
||||||
$r = q("INSERT INTO `tag` (`term`, `nurl`) VALUES ('%s', '%s') ",
|
$r = q("INSERT INTO `tag` (`term`, `nurl`) VALUES ('%s', '%s') ",
|
||||||
dbesc($t),
|
dbesc($t),
|
||||||
dbesc($nurl)
|
dbesc($nurl)
|
||||||
|
@ -197,7 +195,6 @@ function run_submit($url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$submit_photo_start = microtime(true);
|
$submit_photo_start = microtime(true);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function tags_widget()
|
use Friendica\Directory\App;
|
||||||
|
|
||||||
|
function tags_widget(App $a)
|
||||||
{
|
{
|
||||||
$o = '';
|
$o = '';
|
||||||
|
|
||||||
|
@ -10,29 +12,30 @@ function tags_widget()
|
||||||
$o .= '<h3>' . t('Trending Interests') . '</h3>';
|
$o .= '<h3>' . t('Trending Interests') . '</h3>';
|
||||||
$o .= '<ul>';
|
$o .= '<ul>';
|
||||||
foreach ($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
$o .= '<li><a href="search?query=' . $rr['term'] . '" >' . $rr['term'] . '</a> (' . $rr['total'] . ')</li>';
|
$o .= '<li><a href="' . $a->get_baseurl() . '/search?query=' . $rr['term'] . '" >' . $rr['term'] . '</a> (' . $rr['total'] . ')</li>';
|
||||||
}
|
}
|
||||||
$o .= '</ul></div>';
|
$o .= '</ul></div>';
|
||||||
}
|
}
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
||||||
function country_widget()
|
function country_widget(App $a)
|
||||||
{
|
{
|
||||||
$o = '';
|
$o = '';
|
||||||
|
|
||||||
$r = q("SELECT `country-name`, COUNT(`country-name`) AS `total`"
|
$r = q("SELECT `country-name`, COUNT(`country-name`) AS `total`
|
||||||
. " FROM `profile`"
|
FROM `profile`
|
||||||
. " WHERE `country-name` != ''"
|
WHERE `country-name` != ''
|
||||||
. " GROUP BY `country-name`"
|
AND `available`
|
||||||
. " ORDER BY COUNT(`country-name`) DESC"
|
GROUP BY `country-name`
|
||||||
. " LIMIT 20");
|
ORDER BY COUNT(`country-name`) DESC
|
||||||
|
LIMIT 20");
|
||||||
if (count($r)) {
|
if (count($r)) {
|
||||||
$o .= '<div class="widget">';
|
$o .= '<div class="widget">';
|
||||||
$o .= '<h3>' . t('Locations') . '</h3>';
|
$o .= '<h3>' . t('Locations') . '</h3>';
|
||||||
$o .= '<ul>';
|
$o .= '<ul>';
|
||||||
foreach ($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
$o .= '<li><a href="search?query=' . $rr['country-name'] . '" >' . $rr['country-name'] . '</a> (' . $rr['total'] . ')</li>';
|
$o .= '<li><a href="' . $a->get_baseurl() . '/search?query=' . $rr['country-name'] . '" >' . $rr['country-name'] . '</a> (' . $rr['total'] . ')</li>';
|
||||||
}
|
}
|
||||||
$o .= '</ul></div>';
|
$o .= '</ul></div>';
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ $db = new dba($db_host, $db_user, $db_pass, $db_data);
|
||||||
unset($db_host, $db_user, $db_pass, $db_data);
|
unset($db_host, $db_user, $db_pass, $db_data);
|
||||||
|
|
||||||
$a->init_pagehead();
|
$a->init_pagehead();
|
||||||
$a->page['aside'] = '<div id="logo"><img src="images/friendica-32.png" alt="friendica logo" /> <a href="http://friendica.com">Friendica</a></div><div id="slogan">Your friends. Your web.</div>';
|
$a->page['aside'] = '';
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,8 @@ function directory_init(App $a)
|
||||||
{
|
{
|
||||||
$a->set_pager_itemspage(30);
|
$a->set_pager_itemspage(30);
|
||||||
|
|
||||||
$a->page['aside'] .= tags_widget();
|
$a->page['aside'] .= tags_widget($a);
|
||||||
$a->page['aside'] .= country_widget();
|
$a->page['aside'] .= country_widget($a);
|
||||||
}
|
}
|
||||||
|
|
||||||
function directory_content(App $a)
|
function directory_content(App $a)
|
||||||
|
@ -82,6 +82,7 @@ function directory_content(App $a)
|
||||||
$view->addHelper('filterForumsUrl', SearchHelper::get('filterForumsUrl'));
|
$view->addHelper('filterForumsUrl', SearchHelper::get('filterForumsUrl'));
|
||||||
|
|
||||||
$view->output(array(
|
$view->output(array(
|
||||||
|
'aside' => $a->page['aside'],
|
||||||
'total' => number_format($total),
|
'total' => number_format($total),
|
||||||
'results' => $r,
|
'results' => $r,
|
||||||
'filter' => $filter,
|
'filter' => $filter,
|
||||||
|
|
|
@ -5,6 +5,16 @@ use Friendica\Directory\Rendering\View;
|
||||||
use Friendica\Directory\Helper\Search as SearchHelper;
|
use Friendica\Directory\Helper\Search as SearchHelper;
|
||||||
use Friendica\Directory\Helper\Profile as ProfileHelper;
|
use Friendica\Directory\Helper\Profile as ProfileHelper;
|
||||||
|
|
||||||
|
require_once 'include/widget.php';
|
||||||
|
|
||||||
|
function search_init(App $a)
|
||||||
|
{
|
||||||
|
$a->set_pager_itemspage(30);
|
||||||
|
|
||||||
|
$a->page['aside'] .= tags_widget($a);
|
||||||
|
$a->page['aside'] .= country_widget($a);
|
||||||
|
}
|
||||||
|
|
||||||
function search_content(App $a)
|
function search_content(App $a)
|
||||||
{
|
{
|
||||||
//Filters
|
//Filters
|
||||||
|
@ -89,6 +99,7 @@ function search_content(App $a)
|
||||||
$view->addHelper('filterForumsUrl', SearchHelper::get('filterForumsUrl'));
|
$view->addHelper('filterForumsUrl', SearchHelper::get('filterForumsUrl'));
|
||||||
|
|
||||||
$view->output(array(
|
$view->output(array(
|
||||||
|
'aside' => $a->page['aside'],
|
||||||
'total' => number_format($total),
|
'total' => number_format($total),
|
||||||
'results' => $r,
|
'results' => $r,
|
||||||
'filter' => $filter,
|
'filter' => $filter,
|
||||||
|
|
|
@ -8,8 +8,7 @@
|
||||||
|
|
||||||
<div class="directory-results">
|
<div class="directory-results">
|
||||||
<aside>
|
<aside>
|
||||||
<?php echo tags_widget() ?>
|
<?php echo $aside ?>
|
||||||
<?php echo country_widget() ?>
|
|
||||||
</aside>
|
</aside>
|
||||||
<section>
|
<section>
|
||||||
<div class="profiles">
|
<div class="profiles">
|
||||||
|
@ -17,7 +16,7 @@
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
foreach ($results as $profile) {
|
foreach ($results as $profile) {
|
||||||
echo $this->view('_profile', array('profile' => $profile));
|
echo $this->view('_profile', ['profile' => $profile]);
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
|
@ -6,19 +6,21 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="search-results">
|
<div class="directory-results">
|
||||||
|
<aside>
|
||||||
|
<?php echo $aside ?>
|
||||||
|
</aside>
|
||||||
|
<section>
|
||||||
<h3>Results for "<?php echo $query; ?>" (<?php echo $total; ?>)</h3>
|
<h3>Results for "<?php echo $query; ?>" (<?php echo $total; ?>)</h3>
|
||||||
<div class="profiles">
|
<div class="profiles">
|
||||||
<?php if (count($results)): ?>
|
<?php if (count($results)): ?>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
foreach ($results as $profile) {
|
foreach ($results as $profile) {
|
||||||
echo $this->view('_profile', array('profile' => $profile));
|
echo $this->view('_profile', ['profile' => $profile]);
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
|
|
||||||
<h3>There were no results</h3>
|
<h3>There were no results</h3>
|
||||||
|
@ -26,4 +28,5 @@
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
</div>
|
</div>
|
||||||
<?php echo $this->paginate(); ?>
|
<?php echo $this->paginate(); ?>
|
||||||
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue