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'
|
||||
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.
|
||||
|
@ -185,11 +188,6 @@ function run_submit($url)
|
|||
$t = substr($t, 0, 254);
|
||||
|
||||
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') ",
|
||||
dbesc($t),
|
||||
dbesc($nurl)
|
||||
|
@ -197,7 +195,6 @@ function run_submit($url)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$submit_photo_start = microtime(true);
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
function tags_widget()
|
||||
use Friendica\Directory\App;
|
||||
|
||||
function tags_widget(App $a)
|
||||
{
|
||||
$o = '';
|
||||
|
||||
|
@ -10,29 +12,30 @@ function tags_widget()
|
|||
$o .= '<h3>' . t('Trending Interests') . '</h3>';
|
||||
$o .= '<ul>';
|
||||
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>';
|
||||
}
|
||||
return $o;
|
||||
}
|
||||
|
||||
function country_widget()
|
||||
function country_widget(App $a)
|
||||
{
|
||||
$o = '';
|
||||
|
||||
$r = q("SELECT `country-name`, COUNT(`country-name`) AS `total`"
|
||||
. " FROM `profile`"
|
||||
. " WHERE `country-name` != ''"
|
||||
. " GROUP BY `country-name`"
|
||||
. " ORDER BY COUNT(`country-name`) DESC"
|
||||
. " LIMIT 20");
|
||||
$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");
|
||||
if (count($r)) {
|
||||
$o .= '<div class="widget">';
|
||||
$o .= '<h3>' . t('Locations') . '</h3>';
|
||||
$o .= '<ul>';
|
||||
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>';
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ $db = new dba($db_host, $db_user, $db_pass, $db_data);
|
|||
unset($db_host, $db_user, $db_pass, $db_data);
|
||||
|
||||
$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();
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@ function directory_init(App $a)
|
|||
{
|
||||
$a->set_pager_itemspage(30);
|
||||
|
||||
$a->page['aside'] .= tags_widget();
|
||||
$a->page['aside'] .= country_widget();
|
||||
$a->page['aside'] .= tags_widget($a);
|
||||
$a->page['aside'] .= country_widget($a);
|
||||
}
|
||||
|
||||
function directory_content(App $a)
|
||||
|
@ -82,6 +82,7 @@ function directory_content(App $a)
|
|||
$view->addHelper('filterForumsUrl', SearchHelper::get('filterForumsUrl'));
|
||||
|
||||
$view->output(array(
|
||||
'aside' => $a->page['aside'],
|
||||
'total' => number_format($total),
|
||||
'results' => $r,
|
||||
'filter' => $filter,
|
||||
|
|
|
@ -5,6 +5,16 @@ use Friendica\Directory\Rendering\View;
|
|||
use Friendica\Directory\Helper\Search as SearchHelper;
|
||||
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)
|
||||
{
|
||||
//Filters
|
||||
|
@ -89,6 +99,7 @@ function search_content(App $a)
|
|||
$view->addHelper('filterForumsUrl', SearchHelper::get('filterForumsUrl'));
|
||||
|
||||
$view->output(array(
|
||||
'aside' => $a->page['aside'],
|
||||
'total' => number_format($total),
|
||||
'results' => $r,
|
||||
'filter' => $filter,
|
||||
|
|
|
@ -8,8 +8,7 @@
|
|||
|
||||
<div class="directory-results">
|
||||
<aside>
|
||||
<?php echo tags_widget() ?>
|
||||
<?php echo country_widget() ?>
|
||||
<?php echo $aside ?>
|
||||
</aside>
|
||||
<section>
|
||||
<div class="profiles">
|
||||
|
@ -17,7 +16,7 @@
|
|||
|
||||
<?php
|
||||
foreach ($results as $profile) {
|
||||
echo $this->view('_profile', array('profile' => $profile));
|
||||
echo $this->view('_profile', ['profile' => $profile]);
|
||||
}
|
||||
?>
|
||||
|
||||
|
|
|
@ -6,19 +6,21 @@
|
|||
</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>
|
||||
<div class="profiles">
|
||||
<?php if (count($results)): ?>
|
||||
|
||||
<?php
|
||||
|
||||
foreach ($results as $profile) {
|
||||
echo $this->view('_profile', array('profile' => $profile));
|
||||
echo $this->view('_profile', ['profile' => $profile]);
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
<?php else: ?>
|
||||
|
||||
<h3>There were no results</h3>
|
||||
|
@ -26,4 +28,5 @@
|
|||
<?php endif ?>
|
||||
</div>
|
||||
<?php echo $this->paginate(); ?>
|
||||
</section>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Reference in a new issue