2019-10-07 14:13:31 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Friendica\Content\Widget;
|
|
|
|
|
|
|
|
use Friendica\Core\Renderer;
|
|
|
|
use Friendica\Database\DBA;
|
2020-01-18 16:07:07 -05:00
|
|
|
use Friendica\DI;
|
2019-10-07 14:13:31 -04:00
|
|
|
|
|
|
|
class SavedSearches
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @param string $return_url
|
|
|
|
* @param string $search
|
|
|
|
* @return string
|
|
|
|
* @throws \Exception
|
|
|
|
*/
|
|
|
|
public static function getHTML($return_url, $search = '')
|
|
|
|
{
|
|
|
|
$o = '';
|
|
|
|
|
|
|
|
$saved_searches = DBA::select('search', ['id', 'term'], ['uid' => local_user()]);
|
|
|
|
if (DBA::isResult($saved_searches)) {
|
|
|
|
$saved = [];
|
|
|
|
foreach ($saved_searches as $saved_search) {
|
|
|
|
$saved[] = [
|
|
|
|
'id' => $saved_search['id'],
|
|
|
|
'term' => $saved_search['term'],
|
|
|
|
'encodedterm' => urlencode($saved_search['term']),
|
2020-01-18 14:52:34 -05:00
|
|
|
'delete' => DI::l10n()->t('Remove term'),
|
2019-10-07 14:13:31 -04:00
|
|
|
'selected' => $search == $saved_search['term'],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
$tpl = Renderer::getMarkupTemplate('widget/saved_searches.tpl');
|
|
|
|
|
|
|
|
$o = Renderer::replaceMacros($tpl, [
|
2020-01-18 14:52:34 -05:00
|
|
|
'$title' => DI::l10n()->t('Saved Searches'),
|
2019-10-07 14:13:31 -04:00
|
|
|
'$add' => '',
|
|
|
|
'$searchbox' => '',
|
|
|
|
'$saved' => $saved,
|
|
|
|
'$return_url' => urlencode($return_url),
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $o;
|
|
|
|
}
|
|
|
|
}
|