streams/Zotlabs/Widget/Appcategories.php

56 lines
1.6 KiB
PHP
Raw Normal View History

2017-03-16 03:11:28 +00:00
<?php
namespace Zotlabs\Widget;
2021-12-02 23:02:31 +00:00
class Appcategories
{
2017-03-16 03:11:28 +00:00
2021-12-02 23:02:31 +00:00
public function widget($arr)
{
2017-03-16 03:11:28 +00:00
2021-12-02 23:02:31 +00:00
if (!local_channel())
return '';
2017-03-16 03:11:28 +00:00
2021-12-02 23:02:31 +00:00
$selected = ((x($_REQUEST, 'cat')) ? htmlspecialchars($_REQUEST['cat'], ENT_COMPAT, 'UTF-8') : '');
2017-03-16 03:11:28 +00:00
2021-12-02 23:02:31 +00:00
// @FIXME ??? $srchurl undefined here - commented out until is reviewed
//$srchurl = rtrim(preg_replace('/cat\=[^\&].*?(\&|$)/is','',$srchurl),'&');
//$srchurl = str_replace(array('?f=','&f='),array('',''),$srchurl);
2017-03-16 03:11:28 +00:00
2021-12-02 23:02:31 +00:00
// Leaving this line which negates the effect of the two invalid lines prior
$srchurl = z_root() . '/apps';
if (argc() > 1 && argv(1) === 'available')
$srchurl .= '/available';
2018-07-05 05:56:43 +00:00
2017-03-16 03:11:28 +00:00
2021-12-02 23:02:31 +00:00
$terms = [];
2017-03-16 03:11:28 +00:00
2021-12-02 23:02:31 +00:00
$r = q("select distinct(term.term)
2017-03-16 03:11:28 +00:00
from term join app on term.oid = app.id
where app_channel = %d
and term.uid = app_channel
and term.otype = %d
and term.term != 'nav_featured_app'
and term.term != 'nav_pinned_app'
2017-03-16 03:11:28 +00:00
order by term.term asc",
2021-12-02 23:02:31 +00:00
intval(local_channel()),
intval(TERM_OBJ_APP)
);
if ($r) {
foreach ($r as $rr)
$terms[] = array('name' => $rr['term'], 'selected' => (($selected == $rr['term']) ? 'selected' : ''));
return replace_macros(get_markup_template('categories_widget.tpl'), array(
'$title' => t('Categories'),
'$desc' => '',
'$sel_all' => (($selected == '') ? 'selected' : ''),
'$all' => t('Everything'),
'$terms' => $terms,
'$base' => $srchurl,
));
}
}
2017-03-16 03:11:28 +00:00
}